-
Notifications
You must be signed in to change notification settings - Fork 44
feat: Pectra upgrade + EIP7702 support #239
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
13 commits
Select commit
Hold shift + click to select a range
d861311
feat: hooked
djm07073 241463c
feat: add hooked statedb
djm07073 fa31ec1
fix(statedb): return previous balance in self-destructing
djm07073 af24fa4
chore: duplicated import
djm07073 cabbacf
fix: revert statedb interface
djm07073 92ec4b4
fix(precompile): refactor test code
djm07073 1dd476b
Merge branch 'main' into bump/v1.15.11
beer-1 03718e9
wip
beer-1 7ae77b9
support EIP7702
beer-1 8fcad63
use real dep
beer-1 aefed67
apply comments
beer-1 df89ee1
fix lint
beer-1 d41b795
add upgrade handler
beer-1 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 |
|---|---|---|
|
|
@@ -38,3 +38,4 @@ ignore: | |
| - "x/evm/contracts" | ||
| - "**/*.sol" | ||
| - "tests/" | ||
| - "**/mock.go" | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| package v1_2_0 | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| upgradetypes "cosmossdk.io/x/upgrade/types" | ||
| "github.com/cosmos/cosmos-sdk/types/module" | ||
| "github.com/ethereum/go-ethereum/common/hexutil" | ||
|
|
||
| "github.com/initia-labs/minievm/app/upgrades" | ||
| "github.com/initia-labs/minievm/app/upgrades/contracts/erc20_factory" | ||
| "github.com/initia-labs/minievm/app/upgrades/contracts/erc20_wrapper" | ||
| ) | ||
|
|
||
| const upgradeName = "v1.2.0" | ||
|
|
||
| // RegisterUpgradeHandlers registers the upgrade handlers for the app. | ||
| func RegisterUpgradeHandlers(app upgrades.MinitiaApp) { | ||
| app.GetUpgradeKeeper().SetUpgradeHandler( | ||
| upgradeName, | ||
| func(ctx context.Context, _ upgradetypes.Plan, versionMap module.VersionMap) (module.VersionMap, error) { | ||
|
|
||
| // 0. update params with normalized address | ||
| params, err := app.GetEVMKeeper().Params.Get(ctx) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| err = params.NormalizeAddresses(app.GetAccountKeeper().AddressCodec()) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| err = app.GetEVMKeeper().Params.Set(ctx, params) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // 1. update erc20 wrapper contract | ||
| wrapperAddr, err := app.GetEVMKeeper().GetERC20WrapperAddr(ctx) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| wrapperRuntimeCode, err := hexutil.Decode(erc20_wrapper.Erc20WrapperBin) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| wrapperCodeHash := upgrades.CodeHash(wrapperRuntimeCode) | ||
| if err := upgrades.ReplaceCodeAndCodeHash(ctx, app, wrapperAddr.Bytes(), wrapperRuntimeCode, wrapperCodeHash); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // 2. update erc20 factory contract | ||
| factoryAddr, err := app.GetEVMKeeper().GetERC20FactoryAddr(ctx) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| factoryRuntimeCode, err := hexutil.Decode(erc20_factory.Erc20FactoryBin) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| factoryCodeHash := upgrades.CodeHash(factoryRuntimeCode) | ||
| if err := upgrades.ReplaceCodeAndCodeHash(ctx, app, factoryAddr.Bytes(), factoryRuntimeCode, factoryCodeHash); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // 3. run migrations | ||
| return app.GetModuleManager().RunMigrations(ctx, app.GetConfigurator(), versionMap) | ||
| }, | ||
| ) | ||
| } | ||
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.
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.