sei-protocol / sei-chain

Apache License 2.0
2.7k stars 805 forks source link

Reuse existing EVM instance in interop calls #1731

Closed codchen closed 2 months ago

codchen commented 3 months ago

Describe your changes and provide context

Using new EVM instance for interop calls can cause discrepancies in behavior against ethereum. This PR changes the behavior to be reusing existing EVM instance, with an additional tweak which returns the latest sdk.Context from the evm instance to the wasmd message handler, so that there will never be a scenario where messages dispatched by a wasm call operate on different sdk.Context.

Testing performed to validate your change

existing integration test should still work

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 69.23077% with 20 lines in your changes missing coverage. Please review.

Project coverage is 61.39%. Comparing base (bdf72f2) to head (01677c5).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/sei-protocol/sei-chain/pull/1731/graphs/tree.svg?width=650&height=150&src=pr&token=DG7ZZJ3PVV&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sei-protocol)](https://app.codecov.io/gh/sei-protocol/sei-chain/pull/1731?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sei-protocol) ```diff @@ Coverage Diff @@ ## main #1731 +/- ## ========================================== - Coverage 61.52% 61.39% -0.14% ========================================== Files 255 256 +1 Lines 22122 22162 +40 ========================================== - Hits 13611 13606 -5 - Misses 7556 7603 +47 + Partials 955 953 -2 ``` | [Files](https://app.codecov.io/gh/sei-protocol/sei-chain/pull/1731?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sei-protocol) | Coverage Δ | | |---|---|---| | [evmrpc/simulate.go](https://app.codecov.io/gh/sei-protocol/sei-chain/pull/1731?src=pr&el=tree&filepath=evmrpc%2Fsimulate.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sei-protocol#diff-ZXZtcnBjL3NpbXVsYXRlLmdv) | `65.23% <100.00%> (+0.50%)` | :arrow_up: | | [x/evm/ante/fee.go](https://app.codecov.io/gh/sei-protocol/sei-chain/pull/1731?src=pr&el=tree&filepath=x%2Fevm%2Fante%2Ffee.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sei-protocol#diff-eC9ldm0vYW50ZS9mZWUuZ28=) | `64.47% <100.00%> (+0.47%)` | :arrow_up: | | [x/evm/keeper/msg\_server.go](https://app.codecov.io/gh/sei-protocol/sei-chain/pull/1731?src=pr&el=tree&filepath=x%2Fevm%2Fkeeper%2Fmsg_server.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sei-protocol#diff-eC9ldm0va2VlcGVyL21zZ19zZXJ2ZXIuZ28=) | `76.05% <100.00%> (+0.10%)` | :arrow_up: | | [x/evm/state/statedb.go](https://app.codecov.io/gh/sei-protocol/sei-chain/pull/1731?src=pr&el=tree&filepath=x%2Fevm%2Fstate%2Fstatedb.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sei-protocol#diff-eC9ldm0vc3RhdGUvc3RhdGVkYi5nbw==) | `52.33% <100.00%> (+3.31%)` | :arrow_up: | | [x/evm/types/context.go](https://app.codecov.io/gh/sei-protocol/sei-chain/pull/1731?src=pr&el=tree&filepath=x%2Fevm%2Ftypes%2Fcontext.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sei-protocol#diff-eC9ldm0vdHlwZXMvY29udGV4dC5nbw==) | `100.00% <100.00%> (ø)` | | | [x/evm/keeper/evm.go](https://app.codecov.io/gh/sei-protocol/sei-chain/pull/1731?src=pr&el=tree&filepath=x%2Fevm%2Fkeeper%2Fevm.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sei-protocol#diff-eC9ldm0va2VlcGVyL2V2bS5nbw==) | `66.45% <51.21%> (-0.22%)` | :arrow_down: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/sei-protocol/sei-chain/pull/1731/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sei-protocol)