Port messages API for new Virtual Machine#5122
Merged
mpapierski merged 20 commits intocasper-network:devfrom Mar 11, 2025
Merged
Port messages API for new Virtual Machine#5122mpapierski merged 20 commits intocasper-network:devfrom
mpapierski merged 20 commits intocasper-network:devfrom
Conversation
All host function interactions are contained within `casper_sdk::casper` module now, and also, there are improvements to the prelude module: macros are re-exported so smart contract developers can just add the SDK as dependency.
igor-casper
approved these changes
Mar 3, 2025
| ExecutionKind::SessionBytes(_wasm_bytes) => Key::Account(initiator), | ||
| }; | ||
|
|
||
| // Here we don't carry the cost from callee. Each execution g |
Conflicts: executor/wasm-host/src/host.rs executor/wasm/src/lib.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces the ability for new VM smart contracts to emit events as according to the specification described in CEP88 casper-network/ceps#88
The only difference between the implementation in 2.0 in VM1 runtime and the implementation in 2.0 is that under VM2 runtime, the topic is registered lazily in the global state upon first emitting of given message. This is a quality-of-life improvement that also simplifies the code and has potential gas savings (i.e., you don't need to register a topic upfront that may never be emitted). Another difference is that VM2 runtime only allows "Bytes" variant of a payload (compared to String/Bytes option in VM1 runtime).
Usage
Contract code:
The schema obtained from the contract code contains details regarding the decoding of given message:
{ ..., "definitions": { "vm2_cep18::messages::Transfer": { "type": "Struct", "items": [ { "name": "from", "decl": "Option<Entity>" }, { "name": "to", "decl": "Entity" }, { "name": "amount", "decl": "U64" } ] }, "messages": [ { "name": "Transfer", "decl": "vm2_cep18::messages::Transfer" }, { "name": "Approve", "decl": "vm2_cep18::messages::Approve" } ]Closes #4993