Skip to content

Commit

Permalink
Chore(standalone): reuse contract_methods logic (#830)
Browse files Browse the repository at this point in the history
## Description

This is a follow-up PR from #827 . In this PR we make the standalone
engine reuse the logic that was isolated from the contract in that PR.
One key thing to notice about this change is the raw bytes that would be
passed to the on-chain contract as input are now also passed to the
standalone engine. This will help enable the hashchain to work
identically both on-chain and off-chain. Additionally, the output from
all methods is captured in the IO instance. We do not yet make use of
this, but in a follow-up PR this will also be a necessary feature to
ensure the hashchain works properly.

## Performance / NEAR gas cost considerations

N/A standalone engine changes only

## Testing

Existing tests.

## Additional information

Note: the `TransactionKind::raw_bytes` method is only used in tests and
for backwards compatibility. After a full re-index of the Borealis state
(which will be needed to compute the hashchain history anyway) this
method will not be used in production (i.e. we are not de-serializing +
re-serializing the input on every transaction, that would be very
inefficient).
  • Loading branch information
birchmd authored Aug 28, 2023
1 parent eafc2c3 commit 2d3a4d8
Show file tree
Hide file tree
Showing 12 changed files with 381 additions and 308 deletions.
4 changes: 3 additions & 1 deletion engine-standalone-storage/src/relayer_db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ where
env.random_seed = block_metadata.random_seed;

let args = SubmitArgs {
tx_data: transaction_bytes,
tx_data: transaction_bytes.clone(),
..Default::default()
};
let result = storage.with_engine_access(block_height, transaction_position, &[], |io| {
Expand Down Expand Up @@ -154,6 +154,7 @@ where
attached_near: 0,
transaction: crate::sync::types::TransactionKind::Submit(tx),
promise_data: Vec::new(),
raw_input: transaction_bytes,
};
storage.set_transaction_included(tx_hash, &tx_msg, &diff)?;
}
Expand Down Expand Up @@ -265,6 +266,7 @@ mod test {
attached_near: 0,
transaction: TransactionKind::Unknown,
promise_data: Vec::new(),
raw_input: Vec::new(),
},
&diff,
)
Expand Down
Loading

0 comments on commit 2d3a4d8

Please sign in to comment.