Skip to content

wip: state migration msg #169

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,019 changes: 990 additions & 29 deletions api/cosmos/evm/vm/v1/tx.pulsar.go

Large diffs are not rendered by default.

43 changes: 41 additions & 2 deletions api/cosmos/evm/vm/v1/tx_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions evmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,11 @@ func NewExampleApp(
app.AccountKeeper,
app.PreciseBankKeeper,
app.StakingKeeper,
app.FeeGrantKeeper,
app.AuthzKeeper,
app.FeeMarketKeeper,
&app.Erc20Keeper,
baseapp.NewMsgServiceRouter(),
tracer,
)

Expand Down
17 changes: 17 additions & 0 deletions proto/cosmos/evm/vm/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ service Msg {
// parameters. The authority is hard-coded to the Cosmos SDK x/gov module
// account
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);

//todo: comments
rpc MigrateAccount(MsgMigrateAccount) returns (MsgMigrateAccountResponse);
}

// MsgEthereumTx encapsulates an Ethereum transaction as an SDK message.
Expand Down Expand Up @@ -208,3 +211,17 @@ message MsgUpdateParams {
// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
message MsgUpdateParamsResponse {}

// todo: comments
message MsgMigrateAccount {
option (amino.name) = "cosmos/evm/x/vm/MsgMigrateAccount";
option (cosmos.msg.v1.signer) = "original_address";

// original_address is the address of the account that is migrating to a new state
string original_address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// new_address is the address of the account that is being migrated to from the old account
string new_address = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

message MsgMigrateAccountResponse {}
22 changes: 22 additions & 0 deletions testutil/integration/common/grpc/feegrant.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package grpc

import (
"context"

Check failure on line 4 in testutil/integration/common/grpc/feegrant.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

File is not properly formatted (gci)
"cosmossdk.io/x/feegrant"
)

// GetGrants returns the grants for the given grantee and granter combination.
//
// NOTE: To extract the concrete authorizations, use the GetAuthorizations method.
func (gqh *IntegrationHandler) Allowance(grantee, granter string) (*feegrant.QueryAllowanceResponse, error) {
feegrantClient := gqh.network.GetFeeGrantClient()
res, err := feegrantClient.Allowance(context.Background(), &feegrant.QueryAllowanceRequest{
Grantee: grantee,
Granter: granter,
})
if err != nil {
return nil, err
}

return res, nil
}
4 changes: 4 additions & 0 deletions testutil/integration/common/grpc/grpc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package grpc

import (
"cosmossdk.io/x/feegrant"

Check failure on line 4 in testutil/integration/common/grpc/grpc.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

File is not properly formatted (gci)
"github.com/cosmos/evm/testutil/integration/common/network"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -46,6 +47,9 @@
GetValidatorOutstandingRewards(validatorAddress string) (*distrtypes.QueryValidatorOutstandingRewardsResponse, error)
GetCommunityPool() (*distrtypes.QueryCommunityPoolResponse, error)
GetBondedValidators() (*stakingtypes.QueryValidatorsResponse, error)

// Feegrant methods
Allowance(granter, grantee string) (*feegrant.QueryAllowanceResponse, error)
}

var _ Handler = (*IntegrationHandler)(nil)
Expand Down
2 changes: 2 additions & 0 deletions testutil/integration/common/network/network.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package network

import (
"cosmossdk.io/x/feegrant"

Check failure on line 4 in testutil/integration/common/network/network.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

File is not properly formatted (gci)
"testing"
"time"

Expand Down Expand Up @@ -39,6 +40,7 @@
GetBankClient() banktypes.QueryClient
GetStakingClient() stakingtypes.QueryClient
GetDistrClient() distrtypes.QueryClient
GetFeeGrantClient() feegrant.QueryClient

BroadcastTxSync(txBytes []byte) (abcitypes.ExecTxResult, error)
Simulate(txBytes []byte) (*txtypes.SimulateResponse, error)
Expand Down
7 changes: 7 additions & 0 deletions testutil/integration/os/network/clients.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package network

import (
"cosmossdk.io/x/feegrant"
erc20types "github.com/cosmos/evm/x/erc20/types"
feemarkettypes "github.com/cosmos/evm/x/feemarket/types"
precisebankkeeper "github.com/cosmos/evm/x/precisebank/keeper"
Expand Down Expand Up @@ -74,6 +75,12 @@ func (n *IntegrationNetwork) GetAuthzClient() authz.QueryClient {
return authz.NewQueryClient(queryHelper)
}

func (n *IntegrationNetwork) GetFeeGrantClient() feegrant.QueryClient {
queryHelper := getQueryHelper(n.GetContext(), n.GetEncodingConfig())
feegrant.RegisterQueryServer(queryHelper, n.app.FeeGrantKeeper)
return feegrant.NewQueryClient(queryHelper)
}

func (n *IntegrationNetwork) GetStakingClient() stakingtypes.QueryClient {
queryHelper := getQueryHelper(n.GetContext(), n.GetEncodingConfig())
stakingtypes.RegisterQueryServer(queryHelper, stakingkeeper.Querier{Keeper: n.app.StakingKeeper})
Expand Down
13 changes: 13 additions & 0 deletions x/precisebank/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import (
"context"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

Check failure on line 5 in x/precisebank/keeper/keeper.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

File is not properly formatted (gci)

"github.com/cosmos/evm/x/precisebank/types"
evmtypes "github.com/cosmos/evm/x/vm/types"
Expand All @@ -24,6 +25,18 @@
ak types.AccountKeeper
}

func (k Keeper) GetAllBalances(ctx context.Context, addr sdk.AccAddress) sdk.Coins {
return k.bk.GetAllBalances(ctx, addr)
}

func (k Keeper) SpendableBalances(ctx context.Context, req *banktypes.QuerySpendableBalancesRequest) (*banktypes.QuerySpendableBalancesResponse, error) {
return k.bk.SpendableBalances(ctx, req)
}

func (k Keeper) BlockedAddr(addr sdk.AccAddress) bool {
return k.bk.BlockedAddr(addr)
}

// NewKeeper creates a new keeper
func NewKeeper(
cdc codec.BinaryCodec,
Expand Down
2 changes: 2 additions & 0 deletions x/precisebank/types/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import (
"context"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

Check failure on line 5 in x/precisebank/types/interfaces.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

File is not properly formatted (gci)

sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand All @@ -20,6 +21,7 @@
GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin
GetSupply(ctx context.Context, denom string) sdk.Coin
SpendableCoin(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin
SpendableBalances(ctx context.Context, req *banktypes.QuerySpendableBalancesRequest) (*banktypes.QuerySpendableBalancesResponse, error)

BlockedAddr(addr sdk.AccAddress) bool

Expand Down
5 changes: 5 additions & 0 deletions x/precisebank/types/mocks/MockBankKeeper.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading