Skip to content
22 changes: 21 additions & 1 deletion Stellar-contract-config-setting.x
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@ struct ContractCostParamEntry {
ExtensionPoint ext;
};

struct StateExpirationSettings {
uint32 maxEntryLifetime;
uint32 minTempEntryLifetime;
uint32 minRestorableEntryLifetime;
uint32 autoBumpLedgers;

// rent_fee = wfee_rate_average / rent_rate_denominator_for_type
int64 restorableRentRateDenominator;
int64 tempRentRateDenominator;

union switch (int v)
{
case 0:
void;
} ext;
};

// limits the ContractCostParams size to 20kB
const CONTRACT_COST_COUNT_LIMIT = 1024;

Expand All @@ -152,7 +169,8 @@ enum ConfigSettingID
CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS = 6,
CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES = 7,
CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES = 8,
CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES = 9
CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES = 9,
CONFIG_SETTING_STATE_EXPIRATION = 10
};

union ConfigSettingEntry switch (ConfigSettingID configSettingID)
Expand All @@ -177,5 +195,7 @@ case CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES:
uint32 contractDataKeySizeBytes;
case CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES:
uint32 contractDataEntrySizeBytes;
case CONFIG_SETTING_STATE_EXPIRATION:
StateExpirationSettings stateExpirationSettings;
};
}
14 changes: 13 additions & 1 deletion Stellar-contract.x
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ enum SCValType
// symbolic SCVals used as the key for ledger entries for a contract's code
// and an address' nonce, respectively.
SCV_LEDGER_KEY_CONTRACT_EXECUTABLE = 20,
SCV_LEDGER_KEY_NONCE = 21
SCV_LEDGER_KEY_NONCE = 21,

SCV_STORAGE_TYPE = 22
};

enum SCErrorType
Expand Down Expand Up @@ -165,6 +167,13 @@ case SC_ADDRESS_TYPE_CONTRACT:
Hash contractId;
};

// Here due to circular dependency
enum ContractDataType {
TEMPORARY = 0,
RECREATABLE = 1,
UNIQUE = 2
};

%struct SCVal;
%struct SCMapEntry;

Expand Down Expand Up @@ -240,6 +249,9 @@ case SCV_LEDGER_KEY_CONTRACT_EXECUTABLE:
void;
case SCV_LEDGER_KEY_NONCE:
SCNonceKey nonce_key;

case SCV_STORAGE_TYPE:
ContractDataType storageType;
};

struct SCMapEntry
Expand Down
42 changes: 40 additions & 2 deletions Stellar-ledger-entries.x
Original file line number Diff line number Diff line change
Expand Up @@ -493,17 +493,52 @@ struct LiquidityPoolEntry
body;
};

enum ContractLedgerEntryType {
DATA_ENTRY = 0,
LIFETIME_EXTENSION = 1
};

const MASK_CONTRACT_DATA_FLAGS_V20 = 0x1;

enum ContractDataFlags {
// When set, the given entry does not recieve automatic lifetime bumps
// on access. Note that entries can still be bumped manually via the footprint.
NO_AUTOBUMP = 0x1
};

struct ContractDataEntry {
Hash contractID;
SCVal key;
SCVal val;
ContractDataType type;

union switch (ContractLedgerEntryType leType)
{
case DATA_ENTRY:
struct
{
uint32 flags;
SCVal val;
} data;
case LIFETIME_EXTENSION:
void;
} body;

uint32 expirationLedgerSeq;
};

struct ContractCodeEntry {
ExtensionPoint ext;

Hash hash;
opaque code<>;
union switch (ContractLedgerEntryType leType)
{
case DATA_ENTRY:
opaque code<>;
case LIFETIME_EXTENSION:
void;
} body;

uint32 expirationLedgerSeq;
};


Expand Down Expand Up @@ -602,11 +637,14 @@ case CONTRACT_DATA:
{
Hash contractID;
SCVal key;
ContractDataType type;
ContractLedgerEntryType leType;
} contractData;
case CONTRACT_CODE:
struct
{
Hash hash;
ContractLedgerEntryType leType;
} contractCode;
case CONFIG_SETTING:
struct
Expand Down