aurora-is-near / aurora-engine

⚙️ Aurora Engine implements an Ethereum Virtual Machine (EVM) on the NEAR Protocol.
https://doc.aurora.dev/develop/compat/evm
325 stars 78 forks source link

Chore: factor logic out of all top-level contract methods #827

Closed birchmd closed 12 months ago

birchmd commented 12 months ago

Description

This PR is further preparation for the eventual introduction of the hashchain to Aurora Engine. This PR is only a refactor (no functional change to the code). The purpose of this refactor is to move all the logic related to state-changing contract methods from lib.rs into a public module that can be reused in the standalone engine. Making this change will ensure that the standalone engine and the Wasm contract both see the exact same input bytes and generate the exact same output bytes. This is important because the input and output both contribute to the hashchain.

This PR only refactors lib.rs. In a future PR I will change the standalone engine to use the new module introduced by this PR, replacing the logic that currently exists in fn execute_transaction.

Performance / NEAR gas cost considerations

No impact -- refactor only.

Testing

Existing tests -- refactor only.

How should this be reviewed

The logic that is removed from lib.rs should appear nearly verbatim in the new contract_methods.rs module. The main difference is being able to replace sdk_unwrap with ? since all functions now return a Result.

birchmd commented 12 months ago

I would rename contract_methods to modifying_methods or something not too common.

Thanks for the suggestion @aleksuss . I decided to keep the contract_methods top-level module name, but split the functions into logical sub-modules. Does that look good to you?

aleksuss commented 12 months ago

Yes. That sounds good.