forked from cerc-io/laconicd-deprecated
update chain-id format (#542)
* chain_id.go * rpc changes * update scripts * additional test * changelog * fix tests * update script * rpc updates * validate testnet command chain-id * validate rest server chain-id * fix lint * rpc updates * changelog * comment simulations
This commit is contained in:
@@ -180,7 +180,7 @@ func (suite *AnteTestSuite) TestEthInvalidSig() {
|
||||
tx, err := newTestEthTx(suite.ctx, ethMsg, priv1)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
ctx := suite.ctx.WithChainID("4")
|
||||
ctx := suite.ctx.WithChainID("ethermint-4")
|
||||
requireInvalidTx(suite.T(), suite.anteHandler, ctx, tx, false)
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ func (suite *AnteTestSuite) TestEthInvalidIntrinsicGas() {
|
||||
func (suite *AnteTestSuite) TestEthInvalidMempoolFees() {
|
||||
// setup app with checkTx = true
|
||||
suite.app = app.Setup(true)
|
||||
suite.ctx = suite.app.BaseApp.NewContext(true, abci.Header{Height: 1, ChainID: "3", Time: time.Now().UTC()})
|
||||
suite.ctx = suite.app.BaseApp.NewContext(true, abci.Header{Height: 1, ChainID: "ethermint-3", Time: time.Now().UTC()})
|
||||
suite.app.EvmKeeper.SetParams(suite.ctx, evmtypes.DefaultParams())
|
||||
|
||||
suite.anteHandler = ante.NewAnteHandler(suite.app.AccountKeeper, suite.app.EvmKeeper, suite.app.SupplyKeeper)
|
||||
|
||||
+5
-5
@@ -10,7 +10,7 @@ import (
|
||||
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
|
||||
emint "github.com/cosmos/ethermint/types"
|
||||
ethermint "github.com/cosmos/ethermint/types"
|
||||
evmtypes "github.com/cosmos/ethermint/x/evm/types"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
@@ -141,13 +141,13 @@ func (esvd EthSigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, s
|
||||
}
|
||||
|
||||
// parse the chainID from a string to a base-10 integer
|
||||
chainID, ok := new(big.Int).SetString(ctx.ChainID(), 10)
|
||||
if !ok {
|
||||
return ctx, sdkerrors.Wrap(emint.ErrInvalidChainID, ctx.ChainID())
|
||||
chainIDEpoch, err := ethermint.ParseChainID(ctx.ChainID())
|
||||
if err != nil {
|
||||
return ctx, err
|
||||
}
|
||||
|
||||
// validate sender/signature and cache the address
|
||||
_, err = msgEthTx.VerifySig(chainID)
|
||||
_, err = msgEthTx.VerifySig(chainIDEpoch)
|
||||
if err != nil {
|
||||
return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "signature verification failed: %s", err.Error())
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package ante_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -37,7 +36,7 @@ func (suite *AnteTestSuite) SetupTest() {
|
||||
suite.app = app.Setup(checkTx)
|
||||
suite.app.Codec().RegisterConcrete(&sdk.TestMsg{}, "test/TestMsg", nil)
|
||||
|
||||
suite.ctx = suite.app.BaseApp.NewContext(checkTx, abci.Header{Height: 1, ChainID: "3", Time: time.Now().UTC()})
|
||||
suite.ctx = suite.app.BaseApp.NewContext(checkTx, abci.Header{Height: 1, ChainID: "ethermint-3", Time: time.Now().UTC()})
|
||||
suite.app.EvmKeeper.SetParams(suite.ctx, evmtypes.DefaultParams())
|
||||
|
||||
suite.anteHandler = ante.NewAnteHandler(suite.app.AccountKeeper, suite.app.EvmKeeper, suite.app.SupplyKeeper)
|
||||
@@ -91,9 +90,9 @@ func newTestSDKTx(
|
||||
}
|
||||
|
||||
func newTestEthTx(ctx sdk.Context, msg evmtypes.MsgEthereumTx, priv tmcrypto.PrivKey) (sdk.Tx, error) {
|
||||
chainID, ok := new(big.Int).SetString(ctx.ChainID(), 10)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid chainID: %s", ctx.ChainID())
|
||||
chainIDEpoch, err := ethermint.ParseChainID(ctx.ChainID())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
privkey, ok := priv.(crypto.PrivKeySecp256k1)
|
||||
@@ -101,8 +100,7 @@ func newTestEthTx(ctx sdk.Context, msg evmtypes.MsgEthereumTx, priv tmcrypto.Pri
|
||||
return nil, fmt.Errorf("invalid private key type: %T", priv)
|
||||
}
|
||||
|
||||
err := msg.Sign(chainID, privkey.ToECDSA())
|
||||
if err != nil {
|
||||
if err := msg.Sign(chainIDEpoch, privkey.ToECDSA()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user