forked from cerc-io/laconicd-deprecated
bump Cosmos SDK version to v0.38.2 (#183)
* evm: move Keeper and Querier to /keeper package * keeper: update keeper_test.go * fix format * evm: use aliased types * bump SDK version to v0.38.1 * app: updates from new version * errors: switch sdk.Error -> error * errors: switch sdk.Error -> error. Continuation * more fixes * update app/ * update keys and client pkgs * build * fix tests * lint * minor changes * changelog * address @austinbell comments * Fix keyring usage in rpc API and CLI * fix keyring * break line * Misc cleanup (#188) * evm: move Begin and EndBlock to abci.go * evm: use expected keeper interfaces * app: use EthermintApp for integration and unit test setup * evm: remove count type; update codec * go mod verify * evm: rename msgs for consistency * evm: events * minor cleanup * lint * ante: update tests * changelog * nolint * evm: update statedb to create ethermint Account instead of BaseAccount * fix importer test * address @austinabell comments * update README * changelog * evm: update codec * fix event sender * store logs in keeper after transition (#210) * add some comments * begin log handler test * update TransitionCSDB to return ReturnData * use rlp for result data encode/decode * update tests * implement SetBlockLogs * implement GetBlockLogs * test log set/get * update keeper get/set logs to use hash as key * fix test * move logsKey to csdb * attempt to fix test * attempt to fix test * attempt to fix test * lint * lint * lint * save logs after handling msg * update k.Logs * cleanup * remove unused * fix issues * comment out handler test * address comments * lint * fix handler test * address comments * use amino * lint * address comments * merge * fix encoding bug * minor fix * rpc: error handling * rpc: simulate only returns gasConsumed * rpc: error ineffassign * go: bump version to 1.14 and SDK version to latest master * rpc: fix simulation return value * breaking changes from SDK * sdk: breaking changes; build * tests: fixes * minor fix * proto: ethermint types attempt * proto: define EthAccount proto type and extend sdk std.Codec * evm: fix panic on handler test * evm: minor state object changes * cleanup * tests: update test-importer * fix pubkey registration * lint * cleanup * more test checks for importer * minor change * codec fixes * rm init func * fix importer test build * fix marshaling for TxDecoder * use amino codec for evm * fix marshaling for SimulationResponse * use jsonpb for unmarshaling * fix method handler crashed * return err on VerifySig * switch stateObject balance to sdk.Int * fixes to codec and encoding * cleanup * set tmhash -> ethhash in state transition * add tmhash->ethereumhash to csdb.GetLogs * attempt to fix tests * update GetLogs to switch with Has * ante panic * diff changes * update SetLogs * evm/cli: use ethermint codec * use LengthPrefixed for encoding * add check for nil *big.Int * add balance to UpdateAccounts * fix previous balance * fix balance bug * prevent panic on make test-import Co-authored-by: austinabell <austinabell8@gmail.com> Co-authored-by: noot <36753753+noot@users.noreply.github.com> Co-authored-by: noot <elizabethjbinks@gmail.com>
This commit is contained in:
co-authored by
austinabell
noot
noot
parent
2693718662
commit
4d609b2a22
+3
-2
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
|
||||
"github.com/cosmos/ethermint/crypto"
|
||||
evmtypes "github.com/cosmos/ethermint/x/evm/types"
|
||||
@@ -24,7 +25,7 @@ const (
|
||||
// Ethereum or SDK transaction to an internal ante handler for performing
|
||||
// transaction-level processing (e.g. fee payment, signature verification) before
|
||||
// being passed onto it's respective handler.
|
||||
func NewAnteHandler(ak auth.AccountKeeper, sk types.SupplyKeeper) sdk.AnteHandler {
|
||||
func NewAnteHandler(ak auth.AccountKeeper, bk bank.Keeper, sk types.SupplyKeeper) sdk.AnteHandler {
|
||||
return func(
|
||||
ctx sdk.Context, tx sdk.Tx, sim bool,
|
||||
) (newCtx sdk.Context, err error) {
|
||||
@@ -50,7 +51,7 @@ func NewAnteHandler(ak auth.AccountKeeper, sk types.SupplyKeeper) sdk.AnteHandle
|
||||
NewEthSetupContextDecorator(), // outermost AnteDecorator. EthSetUpContext must be called first
|
||||
NewEthMempoolFeeDecorator(),
|
||||
NewEthSigVerificationDecorator(),
|
||||
NewAccountVerificationDecorator(ak),
|
||||
NewAccountVerificationDecorator(ak, bk),
|
||||
NewNonceVerificationDecorator(ak),
|
||||
NewEthGasConsumeDecorator(ak, sk),
|
||||
NewIncrementSenderSequenceDecorator(ak), // innermost AnteDecorator.
|
||||
|
||||
+20
-20
@@ -42,14 +42,14 @@ func (suite *AnteTestSuite) TestValidEthTx() {
|
||||
addr2, _ := newTestAddrKey()
|
||||
|
||||
acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
|
||||
err := acc1.SetCoins(newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
suite.app.AccountKeeper.SetAccount(suite.ctx, acc1)
|
||||
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc1.GetAddress(), newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
|
||||
acc2 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr2)
|
||||
err = acc2.SetCoins(newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
suite.app.AccountKeeper.SetAccount(suite.ctx, acc2)
|
||||
err = suite.app.BankKeeper.SetBalances(suite.ctx, acc2.GetAddress(), newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// require a valid Ethereum tx to pass
|
||||
to := ethcmn.BytesToAddress(addr2.Bytes())
|
||||
@@ -68,14 +68,14 @@ func (suite *AnteTestSuite) TestValidTx() {
|
||||
addr2, priv2 := newTestAddrKey()
|
||||
|
||||
acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
|
||||
err := acc1.SetCoins(newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
suite.app.AccountKeeper.SetAccount(suite.ctx, acc1)
|
||||
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc1.GetAddress(), newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
|
||||
acc2 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr2)
|
||||
err = acc2.SetCoins(newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
suite.app.AccountKeeper.SetAccount(suite.ctx, acc2)
|
||||
err = suite.app.BankKeeper.SetBalances(suite.ctx, acc2.GetAddress(), newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// require a valid SDK tx to pass
|
||||
fee := newTestStdFee()
|
||||
@@ -99,14 +99,14 @@ func (suite *AnteTestSuite) TestSDKInvalidSigs() {
|
||||
addr3, priv3 := newTestAddrKey()
|
||||
|
||||
acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
|
||||
err := acc1.SetCoins(newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
suite.app.AccountKeeper.SetAccount(suite.ctx, acc1)
|
||||
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc1.GetAddress(), newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
|
||||
acc2 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr2)
|
||||
err = acc2.SetCoins(newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
suite.app.AccountKeeper.SetAccount(suite.ctx, acc2)
|
||||
err = suite.app.BankKeeper.SetBalances(suite.ctx, acc2.GetAddress(), newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
|
||||
fee := newTestStdFee()
|
||||
msg1 := newTestMsg(addr1, addr2)
|
||||
@@ -149,9 +149,9 @@ func (suite *AnteTestSuite) TestSDKInvalidAcc() {
|
||||
addr1, priv1 := newTestAddrKey()
|
||||
|
||||
acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
|
||||
err := acc1.SetCoins(newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
suite.app.AccountKeeper.SetAccount(suite.ctx, acc1)
|
||||
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc1.GetAddress(), newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
|
||||
fee := newTestStdFee()
|
||||
msg1 := newTestMsg(addr1)
|
||||
@@ -198,7 +198,7 @@ func (suite *AnteTestSuite) TestEthInvalidNonce() {
|
||||
acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
|
||||
err := acc.SetSequence(10)
|
||||
suite.Require().NoError(err)
|
||||
err = acc.SetCoins(newTestCoins())
|
||||
err = suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
|
||||
|
||||
@@ -238,7 +238,7 @@ func (suite *AnteTestSuite) TestEthInvalidIntrinsicGas() {
|
||||
addr2, _ := newTestAddrKey()
|
||||
|
||||
acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
|
||||
err := acc.SetCoins(newTestCoins())
|
||||
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
|
||||
|
||||
@@ -257,14 +257,14 @@ 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.anteHandler = ante.NewAnteHandler(suite.app.AccountKeeper, suite.app.SupplyKeeper)
|
||||
suite.anteHandler = ante.NewAnteHandler(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.SupplyKeeper)
|
||||
|
||||
suite.ctx = suite.ctx.WithMinGasPrices(sdk.NewDecCoins(sdk.NewCoins(sdk.NewCoin(types.DenomDefault, sdk.NewInt(500000)))))
|
||||
suite.ctx = suite.ctx.WithMinGasPrices(sdk.NewDecCoins(sdk.NewDecCoin(types.DenomDefault, sdk.NewInt(500000))))
|
||||
addr1, priv1 := newTestAddrKey()
|
||||
addr2, _ := newTestAddrKey()
|
||||
|
||||
acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
|
||||
err := acc.SetCoins(newTestCoins())
|
||||
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
|
||||
|
||||
@@ -285,7 +285,7 @@ func (suite *AnteTestSuite) TestEthInvalidChainID() {
|
||||
addr2, _ := newTestAddrKey()
|
||||
|
||||
acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
|
||||
err := acc.SetCoins(newTestCoins())
|
||||
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins())
|
||||
suite.Require().NoError(err)
|
||||
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
|
||||
|
||||
|
||||
+6
-3
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
|
||||
emint "github.com/cosmos/ethermint/types"
|
||||
evmtypes "github.com/cosmos/ethermint/x/evm/types"
|
||||
@@ -146,12 +147,14 @@ func (esvd EthSigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, s
|
||||
// AccountVerificationDecorator validates an account balance checks
|
||||
type AccountVerificationDecorator struct {
|
||||
ak auth.AccountKeeper
|
||||
bk bank.Keeper
|
||||
}
|
||||
|
||||
// NewAccountVerificationDecorator creates a new AccountVerificationDecorator
|
||||
func NewAccountVerificationDecorator(ak auth.AccountKeeper) AccountVerificationDecorator {
|
||||
func NewAccountVerificationDecorator(ak auth.AccountKeeper, bk bank.Keeper) AccountVerificationDecorator {
|
||||
return AccountVerificationDecorator{
|
||||
ak: ak,
|
||||
bk: bk,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,8 +189,8 @@ func (avd AccountVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, s
|
||||
}
|
||||
|
||||
// validate sender has enough funds
|
||||
balance := acc.GetCoins().AmountOf(emint.DenomDefault)
|
||||
if balance.BigInt().Cmp(msgEthTx.Cost()) < 0 {
|
||||
balance := avd.bk.GetBalance(ctx, acc.GetAddress(), emint.DenomDefault)
|
||||
if balance.Amount.BigInt().Cmp(msgEthTx.Cost()) < 0 {
|
||||
return ctx, sdkerrors.Wrapf(
|
||||
sdkerrors.ErrInsufficientFunds,
|
||||
"%s < %s%s", balance.String(), msgEthTx.Cost().String(), emint.DenomDefault,
|
||||
|
||||
@@ -38,7 +38,7 @@ func (suite *AnteTestSuite) SetupTest() {
|
||||
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.anteHandler = ante.NewAnteHandler(suite.app.AccountKeeper, suite.app.SupplyKeeper)
|
||||
suite.anteHandler = ante.NewAnteHandler(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.SupplyKeeper)
|
||||
}
|
||||
|
||||
func TestAnteTestSuite(t *testing.T) {
|
||||
@@ -80,7 +80,7 @@ func newTestSDKTx(
|
||||
}
|
||||
|
||||
sigs[i] = auth.StdSignature{
|
||||
PubKey: priv.PubKey(),
|
||||
PubKey: priv.PubKey().Bytes(),
|
||||
Signature: sig,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user