-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add transient hostios #15
base: testnet-2
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ VM_HOOK(account_codehash) void account_codehash(const uint8_t * address, uint8_t | |
* that of the EVM. This means that, under the hood, this hostio is accessing the 32-byte | ||
* value stored in the EVM state trie at offset `key`, which will be `0` when not previously | ||
* set. The semantics, then, are equivalent to that of the EVM's [`SLOAD`] opcode. | ||
* | ||
* | ||
* [`SLOAD`]: https://www.evm.codes/#54 | ||
*/ | ||
VM_HOOK(storage_load_bytes32) void storage_load_bytes32(const uint8_t * key, uint8_t * dest); | ||
|
@@ -46,11 +46,31 @@ VM_HOOK(storage_load_bytes32) void storage_load_bytes32(const uint8_t * key, uin | |
* of the EVM. This means that, under the hood, this hostio is storing a 32-byte value into | ||
* the EVM state trie at offset `key`. Furthermore, refunds are tabulated exactly as in the | ||
* EVM. The semantics, then, are equivalent to that of the EVM's [`SSTORE`] opcode. | ||
* | ||
* | ||
* [`SSTORE`]: https://www.evm.codes/#55 | ||
*/ | ||
VM_HOOK(storage_store_bytes32) void storage_store_bytes32(const uint8_t * key, const uint8_t * value); | ||
|
||
/** | ||
* Reads a 32-byte value from transient storage. Stylus's storage format is identical to | ||
* that of the EVM. This means that, under the hood, this hostio is accessing the 32-byte | ||
* value stored in the EVM transient storage at offset `key`, which will be `0` when not previously | ||
* set. The semantics, then, are equivalent to that of the EVM's [`TLOAD`] opcode. | ||
* | ||
* [`TLOAD`]: https://www.evm.codes/#5c | ||
*/ | ||
VM_HOOK(transient_load_bytes32) void transient_load_bytes32(const uint8_t * key, uint8_t * dest); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we discussed on slack, let's rename these. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
/** | ||
* Stores a 32-byte value to permanent storage. Stylus's storage format is identical to that | ||
* of the EVM. This means that, under the hood, this hostio is storing a 32-byte value into | ||
* the EVM transient storage at offset `key`. Furthermore, refunds are tabulated exactly as in the | ||
* EVM. The semantics, then, are equivalent to that of the EVM's [`TSTORE`] opcode. | ||
* | ||
* [`TSTORE`]: https://www.evm.codes/#5d | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's link the following for now since these opcodes don't yet exist There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
*/ | ||
VM_HOOK(transient_store_bytes32) void transient_store_bytes32(const uint8_t * key, const uint8_t * value); | ||
|
||
/** | ||
* Gets the basefee of the current block. The semantics are equivalent to that of the EVM's | ||
* [`BASEFEE`] opcode. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ extern "C" { | |
|
||
/** | ||
* storage_load / store load or store a value from storage accordingly. | ||
* | ||
* | ||
* The value of the first "storage" pointer is not used. | ||
* generated headers provide: | ||
* a const storage pointer when working for a view-only function | ||
|
@@ -42,6 +42,27 @@ inline void storage_store(void *storage, const uint8_t *key, const uint8_t *valu | |
storage_store_bytes32(key, value); | ||
} | ||
|
||
/** | ||
* transient_load / store load or store a value from transient storage accordingly. | ||
* | ||
* The value of the first "storage" pointer is not used. | ||
* generated headers provide: | ||
* a const storage pointer when working for a view-only function | ||
* a non const pointer for a mutating function | ||
* no pointer (so don't call transient_load) for a pure function | ||
* | ||
*/ | ||
inline void transient_load(const void* storage, const uint8_t *key, uint8_t *dest) { | ||
transient_load_bytes32(key, dest); | ||
} | ||
|
||
/** | ||
* see documentation for transient_load | ||
*/ | ||
inline void transient_store(void *storage, const uint8_t *key, const uint8_t *value) { | ||
transient_store_bytes32(key, value); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's drop these for now, since we're not yet supporting higher-order affordances There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
/** | ||
* calculate slot for a map with base slot "storage" to put "key" | ||
* If key requires padding it must be applied before calling this function | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's re-add these, since they're the way the blocks are currently formatted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍