Skip to content

Commit

Permalink
runtime-sdk/modules/evm: Add subcall precompile
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Jul 14, 2023
1 parent 7ffa8fd commit 9829a82
Show file tree
Hide file tree
Showing 18 changed files with 1,176 additions and 374 deletions.
9 changes: 9 additions & 0 deletions runtime-sdk/modules/contracts/src/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ fn process_subcalls<Cfg: Config, C: TxContext>(
// preconfigured the amount of available gas.
<C::Runtime as Runtime>::Core::use_tx_gas(ctx, result.gas_used)?;

// Forward any emitted event tags.
ctx.emit_etags(result.state.events);

// Forward any emitted runtime messages.
for (msg, hook) in result.state.messages {
// This should never fail as child context has the right limits configured.
ctx.emit_message(msg, hook)?;
}

// Process replies based on filtering criteria.
let result = result.call_result;
match (reply, result.is_success()) {
Expand Down
9 changes: 6 additions & 3 deletions runtime-sdk/modules/contracts/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,13 @@ fn test_hello_contract_call() {
"there should only be one denomination"
);

let (etags, messages) = tx_ctx.commit();
let tags = etags.into_tags();
let state = tx_ctx.commit();
let tags = state.events.into_tags();
// Make sure no runtime messages got emitted.
assert!(messages.is_empty(), "no runtime messages should be emitted");
assert!(
state.messages.is_empty(),
"no runtime messages should be emitted"
);
// Make sure a contract event was emitted and is properly formatted.
assert_eq!(tags.len(), 2, "two events should have been emitted");
assert_eq!(tags[0].key, b"accounts\x00\x00\x00\x01"); // accounts.Transfer (code = 1) event
Expand Down
Loading

0 comments on commit 9829a82

Please sign in to comment.