-
Notifications
You must be signed in to change notification settings - Fork 124
feat: Prepare v7.4.0 #375
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
Open
AndresRamirez9912
wants to merge
35
commits into
main
Choose a base branch
from
feat/v7.4.0-fix-vulnerabilities
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: Prepare v7.4.0 #375
Changes from 19 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
619ebaf
feat: add v7.3.2 upgrade with evm fork v0.6.2-fork.1
mattkii 402521e
docs: add public release for hotfix
mattkii 393491a
fix: block vesting account creation in ante
mattkii c3b0c70
fix: test
mattkii adc90ef
fix: block vesting account creation in ante (#371)
mattkii 66b06bd
feat: create v7.4.0 upgrade handler
AndresRamirez9912 3cd9fbb
feat: add upgrade plan v7.4.0 and update preblocker
AndresRamirez9912 9fbfad9
chore: add validations for the upgrade to be done only on mainnet
AndresRamirez9912 a0b14cf
feat: add blacklist for block address
mattkii b15ce26
fix: block through BankKeeper
mattkii a4f2abc
fix: remove from ante and go through bank
mattkii 8fd143a
fix: rebase to v7.4.0
mattkii 8e52765
feat: ignore token transfer in chains different than mainnet
AndresRamirez9912 e9ea648
feat: Prepare v7.4.0 (#373)
AndresRamirez9912 c5bc65b
Merge remote-tracking branch 'origin/feat/v7.3.2-evm-hotfix' into fix…
AndresRamirez9912 49f6764
chore: centralize list of blocked address
AndresRamirez9912 f1da507
fix: remove convert blocked address list to hashmap
AndresRamirez9912 af89098
feat: add blacklist for blocked addresses (#372)
AndresRamirez9912 6338227
chore: bump evm to fork 2 (#374)
jhelison b89c5ba
fix: add required read access secret to go modules
21Chani 7544f72
fix: sort hashmap with blocked addresses
AndresRamirez9912 e6b6740
refactor: enhance sweep process on upgrade
AndresRamirez9912 ae1a591
fix: fix linter
AndresRamirez9912 c698360
fix: test.yml with right config and lint format
21Chani 85bd519
fix: Enhance upgrade sweep (#377)
AndresRamirez9912 bb5d7b2
refactor: validate upgrade plan exactly on preblocker
AndresRamirez9912 1aada21
refactor: ensure the upgrade on preblocker is executed
AndresRamirez9912 6b6700e
fix: add required read access secret to go modules (#376)
21Chani 4609b6f
chore: delete v7.3.2 and its reference
AndresRamirez9912 4ced426
fix: Enhance preblocker upgrade (#378)
AndresRamirez9912 82be126
refactor: check invariants on v7.4.0 upgrade process
AndresRamirez9912 67ff569
chore: Delete v7.3.2 and its reference (#379)
AndresRamirez9912 671898e
refactor: Add invariants checks on v7.4.0 upgrade process (#380)
AndresRamirez9912 86feca9
fix: use speandable instead of get balance on sweep attackers funds
AndresRamirez9912 fbe9a6a
fix: Use speandable on sweep attackers funds (#381)
AndresRamirez9912 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
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 ante | ||
|
|
||
| import ( | ||
| errorsmod "cosmossdk.io/errors" | ||
|
|
||
| "github.com/cosmos/cosmos-sdk/codec" | ||
| sdk "github.com/cosmos/cosmos-sdk/types" | ||
| sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" | ||
| "github.com/cosmos/cosmos-sdk/x/authz" | ||
|
|
||
| xerrors "github.com/kiichain/kiichain/v7/x/types/errors" | ||
| ) | ||
|
|
||
| // blockedVestingCreateMsgs is the set of vesting-module messages that open a | ||
| // new account with LockedCoins. Those accounts are the book the EVM locked- | ||
| // balance snapshot must stay consistent with; new creates are rejected until | ||
| // that path is safe. | ||
| var blockedVestingCreateMsgs = map[string]struct{}{ | ||
| sdk.MsgTypeURL(&sdkvesting.MsgCreateVestingAccount{}): {}, | ||
| sdk.MsgTypeURL(&sdkvesting.MsgCreatePeriodicVestingAccount{}): {}, | ||
| sdk.MsgTypeURL(&sdkvesting.MsgCreatePermanentLockedAccount{}): {}, | ||
| } | ||
|
|
||
| // VestingAccountCreationDecorator rejects messages that create vesting or | ||
| // permanently locked accounts, including when nested in authz.MsgExec. | ||
| type VestingAccountCreationDecorator struct { | ||
| cdc codec.BinaryCodec | ||
| } | ||
|
|
||
| // NewVestingAccountCreationDecorator returns a decorator that blocks new | ||
| // vesting account creation. | ||
| func NewVestingAccountCreationDecorator(cdc codec.BinaryCodec) VestingAccountCreationDecorator { | ||
| return VestingAccountCreationDecorator{cdc: cdc} | ||
| } | ||
|
|
||
| // AnteHandle rejects blocked vesting-create messages at any authz nesting depth. | ||
| func (d VestingAccountCreationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { | ||
| if err := d.validateMsgs(tx.GetMsgs()); err != nil { | ||
| return ctx, err | ||
| } | ||
| return next(ctx, tx, simulate) | ||
| } | ||
|
|
||
| func (d VestingAccountCreationDecorator) validateMsgs(msgs []sdk.Msg) error { | ||
| for _, msg := range msgs { | ||
| if execMsg, ok := msg.(*authz.MsgExec); ok { | ||
| if err := d.validateAuthzExec(execMsg); err != nil { | ||
| return err | ||
| } | ||
| continue | ||
| } | ||
|
|
||
| typeURL := sdk.MsgTypeURL(msg) | ||
| if _, blocked := blockedVestingCreateMsgs[typeURL]; blocked { | ||
| return errorsmod.Wrapf(xerrors.ErrUnauthorized, "vesting account creation is disabled: %s", typeURL) | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (d VestingAccountCreationDecorator) validateAuthzExec(execMsg *authz.MsgExec) error { | ||
| innerMsgs := make([]sdk.Msg, 0, len(execMsg.Msgs)) | ||
| for _, v := range execMsg.Msgs { | ||
| var innerMsg sdk.Msg | ||
| if err := d.cdc.UnpackAny(v, &innerMsg); err != nil { | ||
| return errorsmod.Wrapf(xerrors.ErrUnauthorized, "cannot unmarshal authz exec msg (type %s): %v", v.TypeUrl, err) | ||
| } | ||
| innerMsgs = append(innerMsgs, innerMsg) | ||
| } | ||
| return d.validateMsgs(innerMsgs) | ||
| } |
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,101 @@ | ||
| package ante | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "cosmossdk.io/math" | ||
|
|
||
| "github.com/cosmos/cosmos-sdk/codec" | ||
| codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
| sdk "github.com/cosmos/cosmos-sdk/types" | ||
| sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" | ||
| "github.com/cosmos/cosmos-sdk/x/authz" | ||
| banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
| ) | ||
|
|
||
| func TestVestingAccountCreationDecorator(t *testing.T) { | ||
| registry := codectypes.NewInterfaceRegistry() | ||
| authz.RegisterInterfaces(registry) | ||
| sdkvesting.RegisterInterfaces(registry) | ||
| banktypes.RegisterInterfaces(registry) | ||
| decorator := NewVestingAccountCreationDecorator(codec.NewProtoCodec(registry)) | ||
|
|
||
| from := sdk.AccAddress("from________________") | ||
| to := sdk.AccAddress("to__________________") | ||
| coins := sdk.NewCoins(sdk.NewCoin("akii", math.NewInt(1))) | ||
|
|
||
| exec := func(msgs ...sdk.Msg) sdk.Msg { | ||
| m := authz.NewMsgExec(from, msgs) | ||
| return &m | ||
| } | ||
|
|
||
| testCases := []struct { | ||
| name string | ||
| msgs []sdk.Msg | ||
| expectErr bool | ||
| }{ | ||
| { | ||
| name: "allow bank send", | ||
| msgs: []sdk.Msg{&banktypes.MsgSend{ | ||
| FromAddress: from.String(), | ||
| ToAddress: to.String(), | ||
| Amount: coins, | ||
| }}, | ||
| }, | ||
| { | ||
| name: "block MsgCreateVestingAccount", | ||
| msgs: []sdk.Msg{sdkvesting.NewMsgCreateVestingAccount(from, to, coins, 1, false)}, | ||
| expectErr: true, | ||
| }, | ||
| { | ||
| name: "block delayed MsgCreateVestingAccount", | ||
| msgs: []sdk.Msg{sdkvesting.NewMsgCreateVestingAccount(from, to, coins, 1, true)}, | ||
| expectErr: true, | ||
| }, | ||
| { | ||
| name: "block MsgCreatePeriodicVestingAccount", | ||
| msgs: []sdk.Msg{sdkvesting.NewMsgCreatePeriodicVestingAccount(from, to, 1, []sdkvesting.Period{{ | ||
| Length: 1, | ||
| Amount: coins, | ||
| }})}, | ||
| expectErr: true, | ||
| }, | ||
| { | ||
| name: "block MsgCreatePermanentLockedAccount", | ||
| msgs: []sdk.Msg{sdkvesting.NewMsgCreatePermanentLockedAccount(from, to, coins)}, | ||
| expectErr: true, | ||
| }, | ||
| { | ||
| name: "block MsgCreateVestingAccount inside authz.MsgExec", | ||
| msgs: []sdk.Msg{exec(sdkvesting.NewMsgCreateVestingAccount(from, to, coins, 1, false))}, | ||
| expectErr: true, | ||
| }, | ||
| { | ||
| name: "block MsgCreatePeriodicVestingAccount inside nested authz.MsgExec", | ||
| msgs: []sdk.Msg{exec(exec(sdkvesting.NewMsgCreatePeriodicVestingAccount(from, to, 1, []sdkvesting.Period{{ | ||
| Length: 1, | ||
| Amount: coins, | ||
| }})))}, | ||
| expectErr: true, | ||
| }, | ||
| { | ||
| name: "block MsgCreatePermanentLockedAccount inside authz.MsgExec", | ||
| msgs: []sdk.Msg{exec(sdkvesting.NewMsgCreatePermanentLockedAccount(from, to, coins))}, | ||
| expectErr: true, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| err := decorator.validateMsgs(tc.msgs) | ||
| if tc.expectErr { | ||
| require.Error(t, err) | ||
| require.ErrorContains(t, err, "vesting account creation is disabled") | ||
| } else { | ||
| require.NoError(t, err) | ||
| } | ||
| }) | ||
| } | ||
| } |
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.