-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Allow for "Nick's Method" Style Transactions & Contract Deployments in Revive #10476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
de2a301
Allow txs with no chain id to be executed on pallet-revive
0xOmarA bb198a9
Formatting
0xOmarA 89fb643
Update the fix implementation
0xOmarA bb01922
Add tests for Nick's method deployment
0xOmarA 5943759
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] abca514
Update the commit hash of the revive-differential-tests (#10397)
0xOmarA 8d5a721
Add an RPC flag for allowing unprotected transactions
0xOmarA 07cafdf
Merge branch 'master' into 0xOmarA/allow-no-chain-id-txs
athei ba08030
Fix compilation
athei a3d9df4
Merge branch 'master' into 0xOmarA/allow-no-chain-id-txs
athei 1473631
Remove un-needed test
0xOmarA 95e1161
Add a comment to contract_deployment_with_nick_method_works
0xOmarA 6095c96
Merge remote-tracking branch 'origin/master' into 0xOmarA/allow-no-ch…
0xOmarA 61626bb
Merge branch 'master' into 0xOmarA/allow-no-chain-id-txs
athei bb6e801
Update from github-actions[bot] running command 'fmt'
github-actions[bot] 180b343
Add missing crates to PRdoc
athei 37eb1a9
Move rpc flag to revive-eth-rpc
0xOmarA 866afcd
Update from github-actions[bot] running command 'fmt'
github-actions[bot] fa26f93
Update prdoc/pr_10476.prdoc
athei f302fea
Merge branch 'master' into 0xOmarA/allow-no-chain-id-txs
athei e58123f
Fix prdoc
athei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| title: Allow for "Nick's Method" style deployments | ||
| doc: | ||
| - audience: Runtime Dev | ||
| description: "# Description\n\nThis pull request allows for \u201C[Nick\u2019s Method](https://weka.medium.com/how-to-send-ether-to-11-440-people-187e332566b7)\u201D\ | ||
| \ style of deploying contracts which was requested in https://github.com/paritytech/contract-issues/issues/225\ | ||
| \ and was attempted to be solved in https://github.com/paritytech/contract-issues/issues/99.\n\ | ||
| \nThe \u201CNick Method\u201D style of contract deployment is a very useful concept\ | ||
| \ to use when we wish to deploy a contract on multiple chains **with the same\ | ||
| \ address**. It allows us to do that by constructing a deployment transaction\ | ||
| \ that can be executed on any chain, thus allowing us to get the same address\ | ||
| \ for the contract\u2019s deployment on any chain.\n\nAdditionally, this method\ | ||
| \ allows for the contracts to be deployed trustlessly, meaning that if any actor\ | ||
| \ (regardless of whether they\u2019re honest or not) follow the same method for\ | ||
| \ deploying the contract then they\u2019d get the same address across all chains.\ | ||
| \ This allows anyone in the Polkadot ecosystem to take existing contracts that\ | ||
| \ use this method of deployment (e.g., `Multicall3` and the ERC-1820 registry)\ | ||
| \ and deploy them on Polkadot and there\u2019s already trust that the code is\ | ||
| \ the same.\n\nIn order to be able to use the same transaction across multiple\ | ||
| \ chains transaction authors need to:\n\n- Not include a chain id.\n- Include\ | ||
| \ a high gas limit so that the transaction works on (almost) all chains.\n\nAs\ | ||
| \ mentioned in https://github.com/paritytech/contract-issues/issues/225, this\ | ||
| \ pattern is already being used in a number of contracts. Most notably, `Multicall3`\ | ||
| \ and the ERC-1820 Registry.\n\nBefore this PR this method didn\u2019t work in\ | ||
| \ revive since the chain id was an absolute must and any transaction that didn\u2019\ | ||
| t include a chain id would fail with an `Invalid Transaction` error as seen below:\n\ | ||
| \nhttps://github.com/paritytech/polkadot-sdk/blob/c688963f51c55b3c2a16a00a33c4a086792a1544/substrate/frame/revive/src/evm/call.rs#L71-L76\n\ | ||
| \nThe above implementation misses an important detail: legacy transactions are\ | ||
| \ permitted to not have the chain id set while all other non-legacy transactions\ | ||
| \ do not permit that. Therefore, this part of the code was changed to the following:\n\ | ||
| \n```rust\nmatch (tx.chain_id, tx.r#type.as_ref()) {\n\t(None, Some(super::Byte(TYPE_LEGACY)))\ | ||
| \ => {},\n\t(Some(chain_id), ..) =>\n\t\tif chain_id != <T as Config>::ChainId::get().into()\ | ||
| \ {\n\t\t\tlog::debug!(target: LOG_TARGET, \"Invalid chain_id {chain_id:?}\");\n\ | ||
| \t\t\treturn Err(InvalidTransaction::Call);\n\t\t},\n\t(None, ..) => {\n\t\tlog::debug!(target:\ | ||
| \ LOG_TARGET, \"Invalid chain_id None\");\n\t\treturn Err(InvalidTransaction::Call);\n\ | ||
| \t},\n}\n```\n\nThe above code skips the chain id check if the transaction is\ | ||
| \ of the legacy type. Otherwise, the chain id is checked. If no chain id is provided\ | ||
| \ and the transaction is not of the legacy type then we error out.\n\n## Integration\n\ | ||
| \nBe aware that we now allow for legacy transactions to not have the chain ID\ | ||
| \ set in order to allow for \u201C[Nick\u2019s Method](https://weka.medium.com/how-to-send-ether-to-11-440-people-187e332566b7)\u201D\ | ||
| \ style of contract deployment. Non-legacy transaction continue to require the\ | ||
| \ chain id to be provided.\n\n## Review Notes\n\n- The main change that this PR\ | ||
| \ makes can be found in the `substrate/frame/revive/src/evm/call.rs` file allowing\ | ||
| \ for legacy contracts to not have the chain id set.\n- Two new tests were added\ | ||
| \ with this PR:\n - `dry_run_contract_deployment_with_nick_method_works`\n -\ | ||
| \ `contract_deployment_with_nick_method_works`\n- Both of the above tests test\ | ||
| \ that \u201C[Nick\u2019s Method](https://weka.medium.com/how-to-send-ether-to-11-440-people-187e332566b7)\u201D\ | ||
| \ can be used to deploy the singleton factory contract provided in [ERC-2470](https://eips.ethereum.org/EIPS/eip-2470)\ | ||
| \ in a dry run and in an `eth_transact` call.\n- Note that the above tests needed\ | ||
| \ to modify the transaction provided in the ERC to update its gas limit (since\ | ||
| \ the provided gas limit was too low for our platform), **which breaks the whole\ | ||
| \ idea of Nick\u2019s Method where the same transaction can be submitted to the\ | ||
| \ same chain**. I suspect that https://github.com/paritytech/polkadot-sdk/pull/10393\ | ||
| \ should fix this issue with the new gas scaling." | ||
| crates: | ||
| - name: pallet-revive | ||
| bump: patch | ||
| - name: pallet-revive-eth-rpc | ||
| bump: major |
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.