diff --git a/app/test/std_sdk_test.go b/app/test/std_sdk_test.go index 9f12a077ff..a48e853765 100644 --- a/app/test/std_sdk_test.go +++ b/app/test/std_sdk_test.go @@ -1,7 +1,6 @@ package app_test import ( - "math/big" "sync" "testing" @@ -19,7 +18,6 @@ import ( oldgov "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/params/types/proposal" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -132,7 +130,6 @@ func (s *StandardSDKIntegrationTestSuite) TestStandardSDK() { account := s.unusedAccount() valopAccAddr := getAddress(account, s.cctx.Keyring) valopAddr := sdk.ValAddress(valopAccAddr) - evmAddr := common.BigToAddress(big.NewInt(420)) msg, err := stakingtypes.NewMsgCreateValidator( valopAddr, pv.PrivKey.PubKey(), @@ -140,7 +137,6 @@ func (s *StandardSDKIntegrationTestSuite) TestStandardSDK() { stakingtypes.NewDescription("taco tuesday", "my keybase", "www.celestia.org", "ping @celestiaorg on twitter", "fake validator"), stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(6, 0o2), sdk.NewDecWithPrec(12, 0o2), sdk.NewDecWithPrec(1, 0o2)), sdk.NewInt(1000000), - evmAddr, ) require.NoError(t, err) return []sdk.Msg{msg}, account diff --git a/go.mod b/go.mod index 786835a130..0ba4edec6d 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( cosmossdk.io/math v1.0.0-rc.0 github.com/celestiaorg/rsmt2d v0.10.0 github.com/cosmos/cosmos-proto v1.0.0-alpha8 - github.com/cosmos/cosmos-sdk v0.46.13 + github.com/cosmos/cosmos-sdk v0.46.14 github.com/cosmos/gogoproto v1.4.10 github.com/cosmos/ibc-go/v6 v6.2.0 github.com/rs/zerolog v1.30.0 @@ -233,7 +233,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.16.1-sdk-v0.46.13 + github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.17.0-sdk-v0.46.14 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v1.26.2-tm-v0.34.28 diff --git a/go.sum b/go.sum index ad3ae4d72a..fe309fec9c 100644 --- a/go.sum +++ b/go.sum @@ -172,8 +172,8 @@ github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOC github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/celestiaorg/celestia-core v1.26.2-tm-v0.34.28 h1:2efXQaggLFknz0wQufr4nUEz5G7pSVHS1j7NuJDsvII= github.com/celestiaorg/celestia-core v1.26.2-tm-v0.34.28/go.mod h1:++dNzzzjP9jYg+NopN9G8sg1HEZ58lv1TPtg71evZ0E= -github.com/celestiaorg/cosmos-sdk v1.16.1-sdk-v0.46.13 h1:CxEQDQEQR1ypB+VUmCISIqFVmHfb+mx8x+zh7rHbyU8= -github.com/celestiaorg/cosmos-sdk v1.16.1-sdk-v0.46.13/go.mod h1:xpBZc/OYZ736hp0IZlBGNUhEgCD9C+bKs8yNLZibyv0= +github.com/celestiaorg/cosmos-sdk v1.17.0-sdk-v0.46.14 h1:PckXGxLJjXv97VO3xS8NPHN5oO83X5nvJLbc/4s8jUM= +github.com/celestiaorg/cosmos-sdk v1.17.0-sdk-v0.46.14/go.mod h1:70Go8qNy7YAb1PUcHCChRHNX2ke7c9jgUIEklUX+Mac= github.com/celestiaorg/knuu v0.8.2 h1:x63nYTO46j293VkNP7VcRHtYHSize6dM/h7xME2Vgi0= github.com/celestiaorg/knuu v0.8.2/go.mod h1:zBrMXhFl7irCPOVJyHS8sBg7K9Hux5dLy9VChA40LTo= github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 h1:CJdIpo8n5MFP2MwK0gSRcOVlDlFdQJO1p+FqdxYzmvc= diff --git a/test/e2e/setup.go b/test/e2e/setup.go index ce9ba5173c..e883fc4080 100644 --- a/test/e2e/setup.go +++ b/test/e2e/setup.go @@ -17,9 +17,7 @@ import ( bank "github.com/cosmos/cosmos-sdk/x/bank/types" slashing "github.com/cosmos/cosmos-sdk/x/slashing/types" staking "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ethereum/go-ethereum/common" "github.com/tendermint/tendermint/config" - "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p/pex" "github.com/tendermint/tendermint/types" @@ -61,7 +59,6 @@ func MakeGenesis(nodes []*Node, accounts []*GenesisAccount) (types.GenesisDoc, e if err != nil { return types.GenesisDoc{}, err } - evmAddress := common.HexToAddress(crypto.CRandHex(common.AddressLength)) validators = append(validators, staking.Validator{ OperatorAddress: sdk.ValAddress(addr).String(), @@ -75,7 +72,6 @@ func MakeGenesis(nodes []*Node, accounts []*GenesisAccount) (types.GenesisDoc, e // 5% commission Commission: staking.NewCommission(sdk.NewDecWithPrec(5, 2), sdk.OneDec(), sdk.OneDec()), MinSelfDelegation: sdk.ZeroInt(), - EvmAddress: evmAddress.Hex(), }) totalBonded += node.SelfDelegation consensusAddr := pk.Address() diff --git a/test/tokenfilter/setup.go b/test/tokenfilter/setup.go index 316a112219..c91e70cb16 100644 --- a/test/tokenfilter/setup.go +++ b/test/tokenfilter/setup.go @@ -11,7 +11,6 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - "github.com/ethereum/go-ethereum/common" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -20,7 +19,6 @@ import ( ibctesting "github.com/cosmos/ibc-go/v6/testing" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" @@ -159,7 +157,6 @@ func SetupWithGenesisValSet(t testing.TB, valSet *tmtypes.ValidatorSet, genAccs require.NoError(t, err) pkAny, err := codectypes.NewAnyWithValue(pk) require.NoError(t, err) - evmAddress := common.HexToAddress(crypto.CRandHex(common.AddressLength)) validator := stakingtypes.Validator{ OperatorAddress: sdk.ValAddress(val.Address).String(), ConsensusPubkey: pkAny, @@ -172,7 +169,6 @@ func SetupWithGenesisValSet(t testing.TB, valSet *tmtypes.ValidatorSet, genAccs UnbondingTime: time.Unix(0, 0).UTC(), Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), MinSelfDelegation: sdk.ZeroInt(), - EvmAddress: evmAddress.Hex(), } validators = append(validators, validator) diff --git a/test/util/common.go b/test/util/common.go index 1411bfcad6..abc1a4801d 100644 --- a/test/util/common.go +++ b/test/util/common.go @@ -1,7 +1,6 @@ package util import ( - "bytes" "testing" "time" @@ -38,7 +37,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - gethcommon "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -113,9 +111,6 @@ var ( sdk.ValAddress(AccPubKeys[4].Address()), } - // EVMAddrs holds etheruem addresses - EVMAddrs = initEVMAddrs(1000000) // TODO update 1000000 with a more realistic value - // InitTokens holds the number of tokens to initialize an account with InitTokens = sdk.TokensFromConsensusPower(110, sdk.DefaultPowerReduction) @@ -126,15 +121,6 @@ var ( StakingAmount = sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction) ) -func initEVMAddrs(count int) []gethcommon.Address { - addresses := make([]gethcommon.Address, count) - for i := 0; i < count; i++ { - evmAddr := gethcommon.BytesToAddress(bytes.Repeat([]byte{byte(i + 1)}, 20)) - addresses[i] = evmAddr - } - return addresses -} - // TestInput stores the various keepers required to test the QGB type TestInput struct { QgbKeeper *keeper.Keeper @@ -364,7 +350,7 @@ func SetupFiveValChain(t *testing.T) (TestInput, sdk.Context) { // Initialize each of the validators for i := range []int{0, 1, 2, 3, 4} { - CreateValidator(t, input, AccAddrs[i], AccPubKeys[i], uint64(i), ValAddrs[i], ConsPubKeys[i], StakingAmount, EVMAddrs[i]) + CreateValidator(t, input, AccAddrs[i], AccPubKeys[i], uint64(i), ValAddrs[i], ConsPubKeys[i], StakingAmount) } // Run the staking endblocker to ensure valset is correct in state @@ -383,7 +369,6 @@ func CreateValidator( valAddr sdk.ValAddress, consPubKey ccrypto.PubKey, stakingAmount cosmosmath.Int, - evmAddr gethcommon.Address, ) { // Initialize the account for the key acc := input.AccountKeeper.NewAccount( @@ -402,7 +387,7 @@ func CreateValidator( // Create a validator for that account using some tokens in the account // and the staking handler msgServer := stakingkeeper.NewMsgServerImpl(input.StakingKeeper) - _, err = msgServer.CreateValidator(input.Context, NewTestMsgCreateValidator(valAddr, consPubKey, stakingAmount, evmAddr)) + _, err = msgServer.CreateValidator(input.Context, NewTestMsgCreateValidator(valAddr, consPubKey, stakingAmount)) require.NoError(t, err) } @@ -410,7 +395,6 @@ func NewTestMsgCreateValidator( address sdk.ValAddress, pubKey ccrypto.PubKey, amt cosmosmath.Int, - evmAddr gethcommon.Address, ) *stakingtypes.MsgCreateValidator { commission := stakingtypes.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) out, err := stakingtypes.NewMsgCreateValidator( @@ -422,7 +406,6 @@ func NewTestMsgCreateValidator( SecurityContact: "", Details: "", }, commission, sdk.OneInt(), - evmAddr, ) if err != nil { panic(err) @@ -467,7 +450,7 @@ func SetupTestChain(t *testing.T, weights []uint64) (TestInput, sdk.Context) { // and the staking handler _, err := msgServer.CreateValidator( input.Context, - NewTestMsgCreateValidator(valAddr, consPubKey, sdk.NewIntFromUint64(weight), EVMAddrs[i]), + NewTestMsgCreateValidator(valAddr, consPubKey, sdk.NewIntFromUint64(weight)), ) require.NoError(t, err) diff --git a/test/util/testnode/node_init.go b/test/util/testnode/node_init.go index 6cca3710d6..2004a46bcb 100644 --- a/test/util/testnode/node_init.go +++ b/test/util/testnode/node_init.go @@ -1,7 +1,6 @@ package testnode import ( - "crypto/ecdsa" "encoding/json" "fmt" "net/url" @@ -22,17 +21,12 @@ import ( "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/tendermint/tendermint/config" tmos "github.com/tendermint/tendermint/libs/os" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/tendermint/tendermint/types" ) -// NodeEVMPrivateKey the key used to initialize the test node validator. -// Its corresponding address is: "0x9c2B12b5a07FC6D719Ed7646e5041A7E85758329". -var NodeEVMPrivateKey, _ = crypto.HexToECDSA("64a1d6f0e760a8d62b4afdde4096f16f51b401eaaecc915740f71770ea76a8ad") - func collectGenFiles(tmCfg *config.Config, encCfg encoding.Config, pubKey cryptotypes.PubKey, nodeID, rootDir string) error { gentxsDir := filepath.Join(rootDir, "gentxs") @@ -126,8 +120,6 @@ func createValidator( if err != nil { return err } - orchEVMPublicKey := NodeEVMPrivateKey.Public().(*ecdsa.PublicKey) - evmAddr := crypto.PubkeyToAddress(*orchEVMPublicKey) createValMsg, err := stakingtypes.NewMsgCreateValidator( sdk.ValAddress(addr), @@ -136,7 +128,6 @@ func createValidator( stakingtypes.NewDescription("test", "", "", "", ""), stakingtypes.NewCommissionRates(commission, sdk.OneDec(), sdk.OneDec()), sdk.OneInt(), - evmAddr, ) if err != nil { return err diff --git a/x/qgb/abci_test.go b/x/qgb/abci_test.go index e63310426e..691e7972b9 100644 --- a/x/qgb/abci_test.go +++ b/x/qgb/abci_test.go @@ -6,7 +6,6 @@ import ( "github.com/celestiaorg/celestia-app/x/qgb/types" - "github.com/cosmos/cosmos-sdk/x/staking/teststaking" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" testutil "github.com/celestiaorg/celestia-app/test/util" @@ -83,22 +82,20 @@ func TestValsetCreationWhenEditingEVMAddr(t *testing.T) { ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) msgServer := stakingkeeper.NewMsgServerImpl(input.StakingKeeper) - newEVMAddr, err := teststaking.RandomEVMAddress() - require.NoError(t, err) editMsg := stakingtypes.NewMsgEditValidator( testutil.ValAddrs[1], stakingtypes.Description{}, nil, nil, - newEVMAddr, ) - _, err = msgServer.EditValidator(ctx, editMsg) + _, err := msgServer.EditValidator(ctx, editMsg) require.NoError(t, err) staking.EndBlocker(ctx, input.StakingKeeper) qgb.EndBlocker(ctx, *pk) ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 10) - assert.Equal(t, currentAttestationNonce+1, pk.GetLatestAttestationNonce(ctx)) + // FIXME: this needs to change to 2 once we have a proper implementation of editing the EVM address + assert.Equal(t, currentAttestationNonce, pk.GetLatestAttestationNonce(ctx)) } func TestSetValset(t *testing.T) { diff --git a/x/qgb/keeper/keeper.go b/x/qgb/keeper/keeper.go index 1b37ea331e..fd6323911b 100644 --- a/x/qgb/keeper/keeper.go +++ b/x/qgb/keeper/keeper.go @@ -11,7 +11,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/ethereum/go-ethereum/common" "github.com/tendermint/tendermint/libs/log" ) @@ -66,7 +65,6 @@ type StakingKeeper interface { GetLastValidatorPower(ctx sdk.Context, valAddr sdk.ValAddress) int64 GetParams(ctx sdk.Context) stakingtypes.Params ValidatorQueueIterator(ctx sdk.Context, endTime time.Time, endHeight int64) sdk.Iterator - GetValidatorByEVMAddress(ctx sdk.Context, addr common.Address) (validator stakingtypes.Validator, found bool) } func (k Keeper) Logger(ctx sdk.Context) log.Logger { diff --git a/x/qgb/keeper/keeper_valset.go b/x/qgb/keeper/keeper_valset.go index 19c413c211..c7dd280fce 100644 --- a/x/qgb/keeper/keeper_valset.go +++ b/x/qgb/keeper/keeper_valset.go @@ -6,8 +6,8 @@ import ( cosmosmath "cosmossdk.io/math" "github.com/celestiaorg/celestia-app/x/qgb/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + gethcommon "github.com/ethereum/go-ethereum/common" "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -94,8 +94,9 @@ func (k Keeper) GetCurrentValset(ctx sdk.Context) (types.Valset, error) { p := sdk.NewInt(k.StakingKeeper.GetLastValidatorPower(ctx, val)) - // TODO make sure this is always the case - bv := types.BridgeValidator{Power: p.Uint64(), EvmAddress: validator.EvmAddress} + // FIXME @cmwaters fix this by adding a mapping from val address to evm address + evmAddrs := gethcommon.BytesToAddress(val) + bv := types.BridgeValidator{Power: p.Uint64(), EvmAddress: evmAddrs.String()} ibv, err := types.NewInternalBridgeValidator(bv) if err != nil { return types.Valset{}, errors.Wrapf(err, types.ErrInvalidEVMAddress.Error(), val) diff --git a/x/qgb/keeper/keeper_valset_test.go b/x/qgb/keeper/keeper_valset_test.go index b452ed1a79..5d96b9741b 100644 --- a/x/qgb/keeper/keeper_valset_test.go +++ b/x/qgb/keeper/keeper_valset_test.go @@ -80,7 +80,6 @@ func TestCheckingEarliestAvailableAttestationNonceInValsets(t *testing.T) { testutil.ValAddrs[0], testutil.ConsPubKeys[0], testutil.StakingAmount, - testutil.EVMAddrs[0], ) // Run the staking endblocker to ensure valset is correct in state staking.EndBlocker(input.Context, input.StakingKeeper) @@ -131,7 +130,6 @@ func TestCheckingAttestationNonceInValsets(t *testing.T) { testutil.ValAddrs[0], testutil.ConsPubKeys[0], testutil.StakingAmount, - testutil.EVMAddrs[0], ) // Run the staking endblocker to ensure valset is correct in state staking.EndBlocker(input.Context, input.StakingKeeper) diff --git a/x/qgb/types/validator.go b/x/qgb/types/validator.go index acd337e79c..0668477cb3 100644 --- a/x/qgb/types/validator.go +++ b/x/qgb/types/validator.go @@ -2,13 +2,12 @@ package types import ( "bytes" + "fmt" math "math" "sort" "github.com/ethereum/go-ethereum/common" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "cosmossdk.io/errors" ) @@ -42,7 +41,8 @@ type InternalBridgeValidator struct { func NewInternalBridgeValidator(bridgeValidator BridgeValidator) (*InternalBridgeValidator, error) { if !common.IsHexAddress(bridgeValidator.EvmAddress) { - return nil, stakingtypes.ErrEVMAddressNotHex + // TODO @cmwaters add appropriate QGB error type for this + return nil, fmt.Errorf("bridge validator evm address (%s) is not HEX formatted", bridgeValidator.EvmAddress) } validatorEVMAddr := common.HexToAddress(bridgeValidator.EvmAddress) i := &InternalBridgeValidator{