Skip to content

Commit

Permalink
Add ContractCodeCostInputs and new cost types
Browse files Browse the repository at this point in the history
  • Loading branch information
graydon committed Mar 7, 2024
1 parent b96148c commit a7de8ac
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
25 changes: 24 additions & 1 deletion Stellar-contract-config-setting.x
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,30 @@ enum ContractCostType {
// Cost of int256 shift (`shl`, `shr`) operation
Int256Shift = 21,
// Cost of drawing random bytes using a ChaCha20 PRNG
ChaCha20DrawBytes = 22
ChaCha20DrawBytes = 22,

// Cost of instantiating unknown wasm bytecode.
VmInstantiateUnknownBytes = 23,
// Cost of instantiating wasm bytes that only encode instructions.
VmInstantiateInstructions = 24,
// Cost of instantiating a known number of wasm functions.
VmInstantiateFunctions = 25,
// Cost of instantiating a known number of wasm globals.
VmInstantiateGlobals = 26,
// Cost of instantiating a known number of wasm table entries.
VmInstantiateTableEntries = 27,
// Cost of instantiating a known number of wasm types.
VmInstantiateTypes = 28,
// Cost of instantiating a known number of wasm data segments.
VmInstantiateDataSegments = 29,
// Cost of instantiating a known number of wasm element segments.
VmInstantiateElemSegments = 30,
// Cost of instantiating a known number of wasm imports.
VmInstantiateImports = 31,
// Cost of instantiating a known number of wasm exports.
VmInstantiateExports = 32,
// Cost of instantiating a known number of memory pages.
VmInstantiateMemoryPages = 33
};

struct ContractCostParamEntry {
Expand Down
24 changes: 23 additions & 1 deletion Stellar-ledger-entries.x
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,30 @@ struct ContractDataEntry {
SCVal val;
};

struct ContractCodeCostInputs {
uint32 nFunctions;
uint32 nGlobals;
uint32 nTableEntries;
uint32 nTypes;
uint32 nDataSegments;
uint32 nElemSegments;
uint32 nImports;
uint32 nExports;
uint32 nMemoryPages;
};

struct ContractCodeEntry {
ExtensionPoint ext;
union switch (int v)
{
case 0:
void;
case 1:
struct
{
ExtensionPoint ext;
ContractCodeCostInputs costInputs;
} v1;
} ext;

Hash hash;
opaque code<>;
Expand Down

0 comments on commit a7de8ac

Please sign in to comment.