runtime-sdk/modules/evm: Add support for simulating CREATE#1669
Merged
Conversation
✅ Deploy Preview for oasisprotocol-oasis-sdk canceled.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1669 +/- ##
==========================================
- Coverage 65.34% 65.33% -0.01%
==========================================
Files 114 114
Lines 8365 8380 +15
==========================================
+ Hits 5466 5475 +9
- Misses 2899 2905 +6 ☔ View full report in Codecov by Sentry. |
fb2417a to
da8c76e
Compare
ptrus
reviewed
Mar 26, 2024
ptrus
reviewed
Mar 26, 2024
ptrus
approved these changes
Mar 26, 2024
da8c76e to
c9b9a9d
Compare
c9b9a9d to
44eaec5
Compare
CedarMist
previously requested changes
Mar 27, 2024
I need to test against updated oasis-web3-gateway
CedarMist
approved these changes
Mar 27, 2024
github-actions Bot
added a commit
that referenced
this pull request
Mar 27, 2024
…ostko/feature/evm-simulate-create runtime-sdk/modules/evm: Add support for simulating CREATE a9c70cb
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.
Story: oasisprotocol/oasis-web3-gateway#543 (comment)
Problem:
Performing an
eth_callto simulate contract creation is currently not possible.This is used by
hardhat-ignition(a deterministic deployment framework) to determine if creating the contract will be possible.In oasis web3 gateway the
EstimateGasfunction calls eitherevm.Createorevm.Calldepending on if thetofield is empty. I initially made a workaround in oasis-web3-gateway by setting thetofield to the zero address, however this will erroneously succeed (as calls to unknown addresses succeed so transfers can be made to previously unknown EOAs). So while that silences the error inhardhat-ignitionthe behavior is incorrect.For the correct behavior the
evm.SimulateCallfunction would be modified to handle contract creation with EVM semantics (notoaddress = create contract & run init code). Theevm.SimulateCallfunction would make theaddressparameter optional. This would then have to be invoked with a signed query to faithfully replicate EVM semantics.The initial workaround (setting
to=0) is broken and shouldn't be used.Example RPC call performed by
hardhat-ignition:Suggested modification to
SimulateCallQuerystruct:Suggested modification in
oasis-web3-gateway/rpc/eth/api.go:Suggested modification in
runtime-sdk/modules/evm/src/lib.rs:evm.Createtofn simulate_callevm.SimulateCreatewhich can be invoked from oasis-web3-gateway instead ofevm.CallThis PR
... solves this.