Skip to content

Commit

Permalink
chore!: bump sdk fork to v1.17.0 (#2278)
Browse files Browse the repository at this point in the history
Bumps to the latest version of the SDK. Note that this deactivates the
use of the EVM address. To fulfill that functionality we will need to
reintroduce a mapping in
#2169
  • Loading branch information
cmwaters committed Aug 17, 2023
1 parent a93dc76 commit b2cd703
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 69 deletions.
4 changes: 0 additions & 4 deletions app/test/std_sdk_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package app_test

import (
"math/big"
"sync"
"testing"

Expand All @@ -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"
Expand Down Expand Up @@ -132,15 +130,13 @@ 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(),
sdk.NewCoin(app.BondDenom, sdk.NewInt(1000000)),
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
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/celestiaorg/celestia-app
go 1.20

require (
github.com/celestiaorg/nmt v0.17.0
github.com/celestiaorg/nmt v0.18.1
github.com/celestiaorg/quantum-gravity-bridge v1.3.0
github.com/ethereum/go-ethereum v1.12.0
github.com/gogo/protobuf v1.3.3
Expand All @@ -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.29.1
Expand Down Expand Up @@ -198,7 +198,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.24.0-tm-v0.34.28
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ 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.24.0-tm-v0.34.28 h1:eXS3v26nob8Xs2+flKHVxcTzhzQW44KgTcooR3OxnK4=
github.com/celestiaorg/celestia-core v1.24.0-tm-v0.34.28/go.mod h1:J/GsBjoTZaFz71VeyrLZbG8rV+Rzi6oFEUZUipQ97hQ=
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/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 h1:CJdIpo8n5MFP2MwK0gSRcOVlDlFdQJO1p+FqdxYzmvc=
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4/go.mod h1:fzuHnhzj1pUygGz+1ZkB3uQbEUL4htqCGJ4Qs2LwMZA=
github.com/celestiaorg/nmt v0.17.0 h1:/k8YLwJvuHgT/jQ435zXKaDX811+sYEMXL4B/vYdSLU=
github.com/celestiaorg/nmt v0.17.0/go.mod h1:ZndCeAR4l9lxm7W51ouoyTo1cxhtFgK+4DpEIkxRA3A=
github.com/celestiaorg/nmt v0.18.1 h1:zU3apzW4y0fs0ilQA74XnEYW8FvRv0CUK2LXK66L3rA=
github.com/celestiaorg/nmt v0.18.1/go.mod h1:0l8q6UYRju1xNrxtvV6NwPdW3lfsN6KuZ0htRnModdc=
github.com/celestiaorg/quantum-gravity-bridge v1.3.0 h1:9zPIp7w1FWfkPnn16y3S4FpFLnQtS7rm81CUVcHEts0=
github.com/celestiaorg/quantum-gravity-bridge v1.3.0/go.mod h1:6WOajINTDEUXpSj5UZzod16UZ96ZVB/rFNKyM+Mt1gI=
github.com/celestiaorg/rsmt2d v0.10.0 h1:8dprr6CW5mCk5YPnbiLdirojw9YsJOE+XB+GORb8sT0=
Expand Down
4 changes: 0 additions & 4 deletions test/e2e/pkg/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ import (
staking "github.com/cosmos/cosmos-sdk/x/staking/types"
dockertypes "github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"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/privval"
Expand Down Expand Up @@ -140,7 +138,6 @@ func MakeGenesis(testnet *Testnet) (types.GenesisDoc, error) {
if err != nil {
return types.GenesisDoc{}, err
}
evmAddress := common.HexToAddress(crypto.CRandHex(common.AddressLength))

validators = append(validators, staking.Validator{
OperatorAddress: sdk.ValAddress(addr).String(),
Expand All @@ -154,7 +151,6 @@ func MakeGenesis(testnet *Testnet) (types.GenesisDoc, error) {
// 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()
Expand Down
4 changes: 0 additions & 4 deletions test/tokenfilter/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down
23 changes: 3 additions & 20 deletions test/util/common.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package util

import (
"bytes"
"testing"
"time"

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -402,15 +387,14 @@ 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)
}

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(
Expand All @@ -422,7 +406,6 @@ func NewTestMsgCreateValidator(
SecurityContact: "",
Details: "",
}, commission, sdk.OneInt(),
evmAddr,
)
if err != nil {
panic(err)
Expand Down Expand Up @@ -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)

Expand Down
17 changes: 3 additions & 14 deletions test/util/testnode/node_init.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package testnode

import (
"crypto/ecdsa"
"encoding/json"
"fmt"
"net/url"
Expand All @@ -21,31 +20,24 @@ 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"
tmtime "github.com/tendermint/tendermint/types/time"
)

// 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, chainID, rootDir string) error {
genTime := tmtime.Now()

gentxsDir := filepath.Join(rootDir, "gentxs")

initCfg := genutiltypes.NewInitConfig(chainID, gentxsDir, nodeID, pubKey)

genFile := tmCfg.GenesisFile()
genDoc, err := types.GenesisDocFromFile(genFile)
if err != nil {
return err
}

initCfg := genutiltypes.NewInitConfig(chainID, gentxsDir, nodeID, pubKey)

appState, err := genutil.GenAppStateFromConfig(
encCfg.Codec,
encCfg.TxConfig,
Expand All @@ -59,7 +51,7 @@ func collectGenFiles(tmCfg *config.Config, encCfg encoding.Config, pubKey crypto
}

genDoc = &types.GenesisDoc{
GenesisTime: genTime,
GenesisTime: tmtime.Now(),
ChainID: chainID,
Validators: nil,
AppState: appState,
Expand Down Expand Up @@ -124,8 +116,6 @@ func createValidator(
if err != nil {
return err
}
orchEVMPublicKey := NodeEVMPrivateKey.Public().(*ecdsa.PublicKey)
evmAddr := crypto.PubkeyToAddress(*orchEVMPublicKey)

createValMsg, err := stakingtypes.NewMsgCreateValidator(
sdk.ValAddress(addr),
Expand All @@ -134,7 +124,6 @@ func createValidator(
stakingtypes.NewDescription("test", "", "", "", ""),
stakingtypes.NewCommissionRates(commission, sdk.OneDec(), sdk.OneDec()),
sdk.OneInt(),
evmAddr,
)
if err != nil {
return err
Expand Down
9 changes: 3 additions & 6 deletions x/qgb/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions x/qgb/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions x/qgb/keeper/keeper_valset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions x/qgb/keeper/keeper_valset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit b2cd703

Please sign in to comment.