bump SDK to v0.39.1 (#386)

* bump sdk version to v0.39.0 candidate

* updates

* update evm

* bump commit

* more changes

* build

* genesis

* fix tests

* fix tests

* bump commit

* bump commit

* bump commit

* add keygen func

* bump version to 0.39.0-rc0

* update AnteHandler

* fix TxDecoder

* lint

* fix test

* update statedb

* changelog

* fixes

* remove extra files

* update make test-import

* rename test

* bump SDK version to final release

* update to 0.39.1-rc1

* fix evm tests

* update RPC

* minor fixes

* update to rc2

* bump to v0.39.1

* fix personal API

* fix string type cast ambiguity (#449)

* init

* fix estimate gas test

* minor genesis change

* remove comments from unstable commit (stargate release)

Co-authored-by: Alessio Treglia <quadrispro@ubuntu.com>
This commit is contained in:
Federico Kunze 2020-08-23 23:41:54 +02:00 committed by GitHub
parent 6fa5fafb12
commit 261f86fdf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
65 changed files with 688 additions and 2696 deletions

View File

@ -39,20 +39,18 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Improvements
* (sdk) [\#171](https://github.com/ChainSafe/ethermint/issues/177) Bump Cosmos SDK version to [v0.38.1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.38.1) [@fedekunze](https://github.com/fedekunze):
* Add `x/evidence` module to ethermint app
* Bump Go requirement to 1.14+
* (`x/evm`) [\#181](https://github.com/ChainSafe/ethermint/issues/181) Updated EVM module to the recommended module structure. [@fedekunze](https://github.com/fedekunze)
* (app) [\#188](https://github.com/ChainSafe/ethermint/issues/186) Misc cleanup [@fedekunze](https://github.com/fedekunze):
* (sdk) [\#386](https://github.com/ChainSafe/ethermint/pull/386) Bump Cosmos SDK version to [v0.39.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.39.0)
* (`x/evm`) [\#181](https://github.com/ChainSafe/ethermint/issues/181) Updated EVM module to the recommended module structure.
* (app) [\#188](https://github.com/ChainSafe/ethermint/issues/186) Misc cleanup:
* (`x/evm`) Rename `EthereumTxMsg` --> `MsgEthereumTx` and `EmintMsg` --> `MsgEthermint` for consistency with SDK standards
* Updated integration and unit tests to use `EthermintApp` as testing suite
* Use expected keeper interface for `AccountKeeper`
* Replaced `count` type in keeper with `int`
* Add SDK events for transactions
* [\#236](https://github.com/ChainSafe/ethermint/pull/236) Changes from upgrade [@fedekunze](https://github.com/fedekunze)
* [\#236](https://github.com/ChainSafe/ethermint/pull/236) Changes from upgrade:
* (`app/ante`) Moved `AnteHandler` implementation to `app/ante`
* (keys) Marked `ExportEthKeyCommand` as **UNSAFE**
* (x/evm) Moved `BeginBlock` and `EndBlock` to `x/evm/abci.go`
* (`x/evm`) Moved `BeginBlock` and `EndBlock` to `x/evm/abci.go`
* (`x/evm`) [\#255](https://github.com/ChainSafe/ethermint/pull/255) Add missing `GenesisState` fields and support `ExportGenesis` functionality.
* [\#272](https://github.com/ChainSafe/ethermint/pull/272) Add `Logger` for evm module.
* [\#317](https://github.com/ChainSafe/ethermint/pull/317) `GenesisAccount` validation.
@ -81,7 +79,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes
* (rpc) [\#305](https://github.com/ChainSafe/ethermint/issues/305) Update eth_getTransactionCount to check for account existence before getting sequence and return 0 as the nonce if it doesn't exist.
* (rpc) [\#305](https://github.com/ChainSafe/ethermint/issues/305) Update `eth_getTransactionCount` to check for account existence before getting sequence and return 0 as the nonce if it doesn't exist.
* (`x/evm`) [\#319](https://github.com/ChainSafe/ethermint/pull/319) Fix `SetBlockHash` that was setting the incorrect height during `BeginBlock`.
* (x/evm) [\#176](https://github.com/ChainSafe/ethermint/issues/176) Updated Web3 transaction hash from using RLP hash. Now all transaction hashes exposed are amino hashes.
* (`x/evm`) [\#176](https://github.com/ChainSafe/ethermint/issues/176) Updated Web3 transaction hash from using RLP hash. Now all transaction hashes exposed are amino hashes:
* Removes `Hash()` (RLP) function from `MsgEthereumTx` to avoid confusion or misuse in future.

View File

@ -14,6 +14,10 @@ import (
tmcrypto "github.com/tendermint/tendermint/crypto"
)
func init() {
crypto.RegisterCodec(types.ModuleCdc)
}
const (
// TODO: Use this cost per byte through parameter or overriding NewConsumeGasForTxSizeDecorator
// which currently defaults at 10, if intended
@ -43,9 +47,7 @@ func NewAnteHandler(ak auth.AccountKeeper, bk bank.Keeper, sk types.SupplyKeeper
authante.NewDeductFeeDecorator(ak, sk),
authante.NewSigGasConsumeDecorator(ak, sigGasConsumer),
authante.NewSigVerificationDecorator(ak),
// TODO: remove once SDK is updated to v0.39.
// This fixes an issue that account sequence wasn't being updated on CheckTx.
NewIncrementSequenceDecorator(ak), // innermost AnteDecorator
authante.NewIncrementSequenceDecorator(ak), // innermost AnteDecorator
)
case evmtypes.MsgEthereumTx:

View File

@ -42,14 +42,12 @@ func (suite *AnteTestSuite) TestValidEthTx() {
addr2, _ := newTestAddrKey()
acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
_ = acc1.SetCoins(newTestCoins())
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)
_ = acc2.SetCoins(newTestCoins())
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())
@ -69,14 +67,12 @@ func (suite *AnteTestSuite) TestValidTx() {
addr2, priv2 := newTestAddrKey()
acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
_ = acc1.SetCoins(newTestCoins())
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)
_ = acc2.SetCoins(newTestCoins())
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()
@ -100,14 +96,12 @@ func (suite *AnteTestSuite) TestSDKInvalidSigs() {
addr3, priv3 := newTestAddrKey()
acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
_ = acc1.SetCoins(newTestCoins())
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)
_ = acc2.SetCoins(newTestCoins())
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)
@ -150,9 +144,8 @@ func (suite *AnteTestSuite) TestSDKInvalidAcc() {
addr1, priv1 := newTestAddrKey()
acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
_ = acc1.SetCoins(newTestCoins())
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)
@ -201,8 +194,7 @@ func (suite *AnteTestSuite) TestEthInvalidNonce() {
acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
err := acc.SetSequence(10)
suite.Require().NoError(err)
err = suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins())
suite.Require().NoError(err)
_ = acc.SetCoins(newTestCoins())
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
// require a valid Ethereum tx to pass
@ -243,8 +235,7 @@ func (suite *AnteTestSuite) TestEthInvalidIntrinsicGas() {
addr2, _ := newTestAddrKey()
acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins())
suite.Require().NoError(err)
_ = acc.SetCoins(newTestCoins())
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
// require a valid Ethereum tx to pass
@ -270,8 +261,7 @@ func (suite *AnteTestSuite) TestEthInvalidMempoolFees() {
addr2, _ := newTestAddrKey()
acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins())
suite.Require().NoError(err)
_ = acc.SetCoins(newTestCoins())
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
// require a valid Ethereum tx to pass
@ -292,8 +282,7 @@ func (suite *AnteTestSuite) TestEthInvalidChainID() {
addr2, _ := newTestAddrKey()
acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins())
suite.Require().NoError(err)
_ = acc.SetCoins(newTestCoins())
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
// require a valid Ethereum tx to pass

View File

@ -193,7 +193,7 @@ func (avd AccountVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, s
}
// validate sender has enough funds to pay for gas cost
balance := avd.bk.GetBalance(ctx, acc.GetAddress(), emint.DenomDefault)
balance := sdk.Coin{Denom: emint.DenomDefault, Amount: acc.GetCoins().AmountOf(emint.DenomDefault)}
if balance.Amount.BigInt().Cmp(msgEthTx.Cost()) < 0 {
return ctx, sdkerrors.Wrapf(
sdkerrors.ErrInsufficientFunds,
@ -345,12 +345,6 @@ func (issd IncrementSenderSequenceDecorator) AnteHandle(ctx sdk.Context, tx sdk.
gasMeter := ctx.GasMeter()
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
// no need to increment sequence on RecheckTx mode
if ctx.IsReCheckTx() && !simulate {
ctx = ctx.WithGasMeter(gasMeter)
return next(ctx, tx, simulate)
}
msgEthTx, ok := tx.(evmtypes.MsgEthereumTx)
if !ok {
ctx = ctx.WithGasMeter(gasMeter)

View File

@ -80,7 +80,7 @@ func newTestSDKTx(
}
sigs[i] = auth.StdSignature{
PubKey: priv.PubKey().Bytes(),
PubKey: priv.PubKey(),
Signature: sig,
}
}

View File

@ -20,7 +20,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/mint"
"github.com/cosmos/cosmos-sdk/x/params"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/supply"
@ -143,7 +142,6 @@ func NewEthermintApp(
) *EthermintApp {
cdc := ethermintcodec.MakeCodec(ModuleBasics)
appCodec := ethermintcodec.NewAppCodec(cdc)
// use custom Ethermint transaction decoder
bApp := bam.NewBaseApp(appName, logger, db, evm.TxDecoder(cdc), baseAppOptions...)
@ -151,7 +149,7 @@ func NewEthermintApp(
bApp.SetAppVersion(version.Version)
keys := sdk.NewKVStoreKeys(
bam.MainStoreKey, auth.StoreKey, bank.StoreKey, staking.StoreKey,
bam.MainStoreKey, auth.StoreKey, staking.StoreKey,
supply.StoreKey, mint.StoreKey, distr.StoreKey, slashing.StoreKey,
gov.StoreKey, params.StoreKey, evidence.StoreKey, evm.StoreKey,
faucet.StoreKey,
@ -169,7 +167,7 @@ func NewEthermintApp(
}
// init params keeper and subspaces
app.ParamsKeeper = params.NewKeeper(appCodec, keys[params.StoreKey], tkeys[params.TStoreKey])
app.ParamsKeeper = params.NewKeeper(cdc, keys[params.StoreKey], tkeys[params.TStoreKey])
app.subspaces[auth.ModuleName] = app.ParamsKeeper.Subspace(auth.DefaultParamspace)
app.subspaces[bank.ModuleName] = app.ParamsKeeper.Subspace(bank.DefaultParamspace)
app.subspaces[staking.ModuleName] = app.ParamsKeeper.Subspace(staking.DefaultParamspace)
@ -182,43 +180,41 @@ func NewEthermintApp(
// use custom Ethermint account for contracts
app.AccountKeeper = auth.NewAccountKeeper(
appCodec, keys[auth.StoreKey], app.subspaces[auth.ModuleName], ethermint.ProtoAccount,
cdc, keys[auth.StoreKey], app.subspaces[auth.ModuleName], ethermint.ProtoAccount,
)
app.BankKeeper = bank.NewBaseKeeper(
appCodec, keys[bank.StoreKey], app.AccountKeeper, app.subspaces[bank.ModuleName], app.BlacklistedAccAddrs(),
app.AccountKeeper, app.subspaces[bank.ModuleName], app.BlacklistedAccAddrs(),
)
app.SupplyKeeper = supply.NewKeeper(
appCodec, keys[supply.StoreKey], app.AccountKeeper, app.BankKeeper, maccPerms,
cdc, keys[supply.StoreKey], app.AccountKeeper, app.BankKeeper, maccPerms,
)
stakingKeeper := staking.NewKeeper(
appCodec, keys[staking.StoreKey], app.BankKeeper, app.SupplyKeeper, app.subspaces[staking.ModuleName],
cdc, keys[staking.StoreKey], app.SupplyKeeper, app.subspaces[staking.ModuleName],
)
app.MintKeeper = mint.NewKeeper(
appCodec, keys[mint.StoreKey], app.subspaces[mint.ModuleName], &stakingKeeper,
cdc, keys[mint.StoreKey], app.subspaces[mint.ModuleName], &stakingKeeper,
app.SupplyKeeper, auth.FeeCollectorName,
)
app.DistrKeeper = distr.NewKeeper(
appCodec, keys[distr.StoreKey], app.subspaces[distr.ModuleName], app.BankKeeper, &stakingKeeper,
cdc, keys[distr.StoreKey], app.subspaces[distr.ModuleName], &stakingKeeper,
app.SupplyKeeper, auth.FeeCollectorName, app.ModuleAccountAddrs(),
)
app.SlashingKeeper = slashing.NewKeeper(
appCodec, keys[slashing.StoreKey], &stakingKeeper, app.subspaces[slashing.ModuleName],
cdc, keys[slashing.StoreKey], &stakingKeeper, app.subspaces[slashing.ModuleName],
)
app.CrisisKeeper = crisis.NewKeeper(
app.subspaces[crisis.ModuleName], invCheckPeriod, app.SupplyKeeper, auth.FeeCollectorName,
)
app.EvmKeeper = evm.NewKeeper(
app.cdc, keys[evm.StoreKey], app.AccountKeeper,
app.BankKeeper,
)
// TODO: use protobuf
app.FaucetKeeper = faucet.NewKeeper(
app.cdc, keys[faucet.StoreKey], app.SupplyKeeper,
)
// create evidence keeper with router
evidenceKeeper := evidence.NewKeeper(
appCodec, keys[evidence.StoreKey], app.subspaces[evidence.ModuleName], &app.StakingKeeper, app.SlashingKeeper,
cdc, keys[evidence.StoreKey], app.subspaces[evidence.ModuleName], &app.StakingKeeper, app.SlashingKeeper,
)
evidenceRouter := evidence.NewRouter()
// TODO: Register evidence routes.
@ -228,10 +224,10 @@ func NewEthermintApp(
// register the proposal types
govRouter := gov.NewRouter()
govRouter.AddRoute(gov.RouterKey, gov.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(params.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distr.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper))
app.GovKeeper = gov.NewKeeper(
appCodec, keys[gov.StoreKey], app.subspaces[gov.ModuleName], app.SupplyKeeper,
cdc, keys[gov.StoreKey], app.subspaces[gov.ModuleName], app.SupplyKeeper,
&stakingKeeper, govRouter,
)
@ -245,15 +241,15 @@ func NewEthermintApp(
// must be passed by reference here.
app.mm = module.NewManager(
genutil.NewAppModule(app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx),
auth.NewAppModule(app.AccountKeeper, app.SupplyKeeper),
auth.NewAppModule(app.AccountKeeper),
bank.NewAppModule(app.BankKeeper, app.AccountKeeper),
crisis.NewAppModule(&app.CrisisKeeper),
supply.NewAppModule(app.SupplyKeeper, app.BankKeeper, app.AccountKeeper),
gov.NewAppModule(app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.SupplyKeeper),
mint.NewAppModule(app.MintKeeper, app.SupplyKeeper),
slashing.NewAppModule(app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
distr.NewAppModule(app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.SupplyKeeper, app.StakingKeeper),
staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.SupplyKeeper),
supply.NewAppModule(app.SupplyKeeper, app.AccountKeeper),
gov.NewAppModule(app.GovKeeper, app.AccountKeeper, app.SupplyKeeper),
mint.NewAppModule(app.MintKeeper),
slashing.NewAppModule(app.SlashingKeeper, app.AccountKeeper, app.StakingKeeper),
distr.NewAppModule(app.DistrKeeper, app.AccountKeeper, app.SupplyKeeper, app.StakingKeeper),
staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper),
faucet.NewAppModule(app.FaucetKeeper),
@ -287,14 +283,14 @@ func NewEthermintApp(
// NOTE: this is not required apps that don't use the simulator for fuzz testing
// transactions
app.sm = module.NewSimulationManager(
auth.NewAppModule(app.AccountKeeper, app.SupplyKeeper),
auth.NewAppModule(app.AccountKeeper),
bank.NewAppModule(app.BankKeeper, app.AccountKeeper),
supply.NewAppModule(app.SupplyKeeper, app.BankKeeper, app.AccountKeeper),
gov.NewAppModule(app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.SupplyKeeper),
mint.NewAppModule(app.MintKeeper, app.SupplyKeeper),
staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.SupplyKeeper),
distr.NewAppModule(app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.SupplyKeeper, app.StakingKeeper),
slashing.NewAppModule(app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
supply.NewAppModule(app.SupplyKeeper, app.AccountKeeper),
gov.NewAppModule(app.GovKeeper, app.AccountKeeper, app.SupplyKeeper),
mint.NewAppModule(app.MintKeeper),
staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper),
distr.NewAppModule(app.DistrKeeper, app.AccountKeeper, app.SupplyKeeper, app.StakingKeeper),
slashing.NewAppModule(app.SlashingKeeper, app.AccountKeeper, app.StakingKeeper),
params.NewAppModule(), // NOTE: only used for simulation to generate randomized param change proposals
)
@ -337,7 +333,7 @@ func (app *EthermintApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) a
func (app *EthermintApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
var genesisState simapp.GenesisState
app.cdc.MustUnmarshalJSON(req.AppStateBytes, &genesisState)
return app.mm.InitGenesis(ctx, app.cdc, genesisState)
return app.mm.InitGenesis(ctx, genesisState)
}
// LoadHeight loads state at a particular height

View File

@ -17,7 +17,7 @@ func TestEthermintAppExport(t *testing.T) {
db := dbm.NewMemDB()
app := NewEthermintApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0)
genesisState := ModuleBasics.DefaultGenesis(app.cdc)
genesisState := ModuleBasics.DefaultGenesis()
stateBytes, err := codec.MarshalJSONIndent(app.cdc, genesisState)
require.NoError(t, err)

View File

@ -19,8 +19,8 @@ import (
// NewDefaultGenesisState generates the default state for the application.
func NewDefaultGenesisState() simapp.GenesisState {
cdc := ethcdc.MakeCodec(ModuleBasics)
return ModuleBasics.DefaultGenesis(cdc)
_ = ethcdc.MakeCodec(ModuleBasics)
return ModuleBasics.DefaultGenesis()
}
// ExportAppStateAndValidators exports the state of the application for a genesis
@ -37,7 +37,7 @@ func (app *EthermintApp) ExportAppStateAndValidators(
}
// Export genesis to be used by SDK modules
genState := app.mm.ExportGenesis(ctx, app.cdc)
genState := app.mm.ExportGenesis(ctx)
appState, err = codec.MarshalJSONIndent(app.cdc, genState)
if err != nil {
return nil, nil, err

View File

@ -139,7 +139,7 @@ func TestAppImportExport(t *testing.T) {
ctxA := app.NewContext(true, abci.Header{Height: app.LastBlockHeight()})
ctxB := newApp.NewContext(true, abci.Header{Height: app.LastBlockHeight()})
newApp.mm.InitGenesis(ctxB, app.Codec(), genesisState)
newApp.mm.InitGenesis(ctxB, genesisState)
fmt.Printf("comparing stores...\n")

View File

@ -13,7 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/input"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/ethermint/crypto"
@ -29,7 +29,7 @@ func UnsafeExportEthKeyCommand() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin())
kb, err := keyring.NewKeyring(
kb, err := keys.NewKeyring(
sdk.KeyringServiceName(),
viper.GetString(flags.FlagKeyringBackend),
viper.GetString(flags.FlagHome),
@ -44,11 +44,11 @@ func UnsafeExportEthKeyCommand() *cobra.Command {
conf := true
keyringBackend := viper.GetString(flags.FlagKeyringBackend)
switch keyringBackend {
case keyring.BackendFile:
case keys.BackendFile:
decryptPassword, err = input.GetPassword(
"**WARNING this is an unsafe way to export your unencrypted private key**\nEnter key password:",
inBuf)
case keyring.BackendOS:
case keys.BackendOS:
conf, err = input.GetConfirmation(
"**WARNING** this is an unsafe way to export your unencrypted private key, are you sure?",
inBuf)

View File

@ -9,7 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
clientkeys "github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/ethermint/crypto"
@ -67,14 +67,14 @@ func runAddCmd(cmd *cobra.Command, args []string) error {
return clientkeys.RunAddCmd(cmd, args, kb, inBuf)
}
func getKeybase(transient bool, buf io.Reader) (keyring.Keybase, error) {
func getKeybase(transient bool, buf io.Reader) (keys.Keybase, error) {
if transient {
return keyring.NewInMemory(
return keys.NewInMemory(
crypto.EthSecp256k1Options()...,
), nil
}
return keyring.NewKeyring(
return keys.NewKeyring(
sdk.KeyringServiceName(),
viper.GetString(flags.FlagKeyringBackend),
viper.GetString(flags.FlagHome),

View File

@ -22,19 +22,18 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
clientkeys "github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/cosmos/cosmos-sdk/server"
srvconfig "github.com/cosmos/cosmos-sdk/server/config"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/mint"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/ethermint/crypto"
@ -55,7 +54,7 @@ const nodeDirPerm = 0755
// TestnetCmd initializes all files for tendermint testnet and application
func TestnetCmd(ctx *server.Context, cdc *codec.Codec,
mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator,
mbm module.BasicManager, genAccIterator authtypes.GenesisAccountIterator,
) *cobra.Command {
cmd := &cobra.Command{
Use: "testnet",
@ -81,7 +80,7 @@ Note, strict routability for addresses is turned off in the config file.`,
algo, _ := cmd.Flags().GetString(flagKeyAlgo)
return InitTestnet(
cmd, config, cdc, mbm, genBalIterator, outputDir, chainID, minGasPrices,
cmd, config, cdc, mbm, genAccIterator, outputDir, chainID, minGasPrices,
nodeDirPrefix, nodeDaemonHome, nodeCLIHome, startingIPAddress, keyringBackend, algo, numValidators,
)
},
@ -106,7 +105,7 @@ func InitTestnet(
config *tmconfig.Config,
cdc *codec.Codec,
mbm module.BasicManager,
genBalIterator banktypes.GenesisBalancesIterator,
genAccIterator authtypes.GenesisAccountIterator,
outputDir,
chainID,
minGasPrices,
@ -131,7 +130,6 @@ func InitTestnet(
var (
genAccounts []authexported.GenesisAccount
genBalances []banktypes.Balance
genFiles []string
)
@ -173,7 +171,7 @@ func InitTestnet(
memo := fmt.Sprintf("%s@%s:26656", nodeIDs[i], ip)
genFiles = append(genFiles, config.GenesisFile())
kb, err := keyring.NewKeyring(
kb, err := keys.NewKeyring(
sdk.KeyringServiceName(),
keyringBackend,
clientDir,
@ -189,7 +187,7 @@ func InitTestnet(
)
keyPass := clientkeys.DefaultKeyPass
addr, secret, err := GenerateSaveCoinKey(kb, nodeDirName, keyPass, true, keyring.SigningAlgo(algo))
addr, secret, err := GenerateSaveCoinKey(kb, nodeDirName, keyPass, true, keys.SigningAlgo(algo))
if err != nil {
_ = os.RemoveAll(outputDir)
return err
@ -214,9 +212,8 @@ func InitTestnet(
sdk.NewCoin(types.DenomDefault, accStakingTokens),
)
genBalances = append(genBalances, banktypes.Balance{Address: addr, Coins: coins})
genAccounts = append(genAccounts, types.EthAccount{
BaseAccount: authtypes.NewBaseAccount(addr, nil, 0, 0),
BaseAccount: authtypes.NewBaseAccount(addr, coins, nil, 0, 0),
CodeHash: ethcrypto.Keccak256(nil),
})
@ -254,13 +251,13 @@ func InitTestnet(
srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), simappConfig)
}
if err := initGenFiles(cdc, mbm, chainID, genAccounts, genBalances, genFiles, numValidators); err != nil {
if err := initGenFiles(cdc, mbm, chainID, genAccounts, genFiles, numValidators); err != nil {
return err
}
err := collectGenFiles(
cdc, config, chainID, nodeIDs, valPubKeys, numValidators,
outputDir, nodeDirPrefix, nodeDaemonHome, genBalIterator,
outputDir, nodeDirPrefix, nodeDaemonHome, genAccIterator,
)
if err != nil {
return err
@ -271,12 +268,12 @@ func InitTestnet(
}
func initGenFiles(
cdc codec.JSONMarshaler, mbm module.BasicManager, chainID string,
genAccounts []authexported.GenesisAccount, genBalances []banktypes.Balance,
cdc *codec.Codec, mbm module.BasicManager, chainID string,
genAccounts []authexported.GenesisAccount,
genFiles []string, numValidators int,
) error {
appGenState := mbm.DefaultGenesis(cdc)
appGenState := mbm.DefaultGenesis()
// set the accounts in the genesis state
var authGenState authtypes.GenesisState
@ -285,13 +282,6 @@ func initGenFiles(
authGenState.Accounts = genAccounts
appGenState[authtypes.ModuleName] = cdc.MustMarshalJSON(authGenState)
// set the balances in the genesis state
var bankGenState banktypes.GenesisState
cdc.MustUnmarshalJSON(appGenState[banktypes.ModuleName], &bankGenState)
bankGenState.Balances = genBalances
appGenState[banktypes.ModuleName] = cdc.MustMarshalJSON(bankGenState)
var stakingGenState stakingtypes.GenesisState
cdc.MustUnmarshalJSON(appGenState[stakingtypes.ModuleName], &stakingGenState)
@ -304,17 +294,17 @@ func initGenFiles(
govGenState.DepositParams.MinDeposit[0].Denom = types.DenomDefault
appGenState[govtypes.ModuleName] = cdc.MustMarshalJSON(govGenState)
var mintGenState minttypes.GenesisState
cdc.MustUnmarshalJSON(appGenState[minttypes.ModuleName], &mintGenState)
var mintGenState mint.GenesisState
cdc.MustUnmarshalJSON(appGenState[mint.ModuleName], &mintGenState)
mintGenState.Params.MintDenom = types.DenomDefault
appGenState[minttypes.ModuleName] = cdc.MustMarshalJSON(mintGenState)
appGenState[mint.ModuleName] = cdc.MustMarshalJSON(mintGenState)
var crisisGenState crisistypes.GenesisState
cdc.MustUnmarshalJSON(appGenState[crisistypes.ModuleName], &crisisGenState)
var crisisGenState crisis.GenesisState
cdc.MustUnmarshalJSON(appGenState[crisis.ModuleName], &crisisGenState)
crisisGenState.ConstantFee.Denom = types.DenomDefault
appGenState[crisistypes.ModuleName] = cdc.MustMarshalJSON(crisisGenState)
appGenState[crisis.ModuleName] = cdc.MustMarshalJSON(crisisGenState)
appGenStateJSON, err := codec.MarshalJSONIndent(cdc, appGenState)
if err != nil {
@ -338,7 +328,7 @@ func initGenFiles(
// GenerateSaveCoinKey returns the address of a public key, along with the secret
// phrase to recover the private key.
func GenerateSaveCoinKey(keybase keyring.Keybase, keyName, keyPass string, overwrite bool, algo keyring.SigningAlgo) (sdk.AccAddress, string, error) {
func GenerateSaveCoinKey(keybase keys.Keybase, keyName, keyPass string, overwrite bool, algo keys.SigningAlgo) (sdk.AccAddress, string, error) {
// ensure no overwrite
if !overwrite {
_, err := keybase.Get(keyName)
@ -349,7 +339,7 @@ func GenerateSaveCoinKey(keybase keyring.Keybase, keyName, keyPass string, overw
}
// generate a private key, with recovery phrase
info, secret, err := keybase.CreateMnemonic(keyName, keyring.English, keyPass, algo)
info, secret, err := keybase.CreateMnemonic(keyName, keys.English, keyPass, algo)
if err != nil {
return sdk.AccAddress([]byte{}), "", err
}
@ -361,7 +351,7 @@ func collectGenFiles(
cdc *codec.Codec, config *tmconfig.Config, chainID string,
nodeIDs []string, valPubKeys []tmcrypto.PubKey,
numValidators int, outputDir, nodeDirPrefix, nodeDaemonHome string,
genBalIterator banktypes.GenesisBalancesIterator,
genAccIterator authtypes.GenesisAccountIterator,
) error {
var appState json.RawMessage
@ -383,7 +373,7 @@ func collectGenFiles(
return err
}
nodeAppState, err := genutil.GenAppStateFromConfig(cdc, config, initCfg, *genDoc, genBalIterator)
nodeAppState, err := genutil.GenAppStateFromConfig(cdc, config, initCfg, *genDoc, genAccIterator)
if err != nil {
return err
}

View File

@ -13,7 +13,7 @@ import (
clientkeys "github.com/cosmos/cosmos-sdk/client/keys"
clientrpc "github.com/cosmos/cosmos-sdk/client/rpc"
sdkcodec "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
@ -40,7 +40,7 @@ func main() {
tmamino.RegisterKeyType(crypto.PubKeySecp256k1{}, crypto.PubKeyAminoName)
tmamino.RegisterKeyType(crypto.PrivKeySecp256k1{}, crypto.PrivKeyAminoName)
keyring.CryptoCdc = cdc
keys.CryptoCdc = cdc
clientkeys.KeysCdc = cdc
// Read in the configuration file for the sdk

View File

@ -11,17 +11,15 @@ import (
"github.com/tendermint/tendermint/libs/cli"
"github.com/cosmos/cosmos-sdk/client/flags"
sdkcodec "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/cosmos/cosmos-sdk/server"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/genutil"
"github.com/cosmos/ethermint/codec"
"github.com/cosmos/ethermint/crypto"
ethermint "github.com/cosmos/ethermint/types"
@ -37,7 +35,7 @@ const (
// AddGenesisAccountCmd returns add-genesis-account cobra Command.
func AddGenesisAccountCmd(
ctx *server.Context, depCdc *sdkcodec.Codec, cdc *codec.Codec, defaultNodeHome, defaultClientHome string,
ctx *server.Context, cdc *codec.Codec, defaultNodeHome, defaultClientHome string,
) *cobra.Command {
cmd := &cobra.Command{
@ -57,7 +55,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
inBuf := bufio.NewReader(cmd.InOrStdin())
if err != nil {
// attempt to lookup address from Keybase if no address was provided
kb, err := keyring.NewKeyring(
kb, err := keys.NewKeyring(
sdk.KeyringServiceName(),
viper.GetString(flags.FlagKeyringBackend),
viper.GetString(flagClientHome),
@ -91,13 +89,17 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
// create concrete account type based on input parameters
var genAccount authexported.GenesisAccount
balances := bank.Balance{Address: addr, Coins: coins.Sort()}
baseAccount := auth.NewBaseAccount(addr, nil, 0, 0)
// balances := bank.Balance{Address: addr, Coins: coins.Sort()}
coins = coins.Sort()
baseAccount := auth.NewBaseAccount(addr, coins, nil, 0, 0)
if !vestingAmt.IsZero() {
baseVestingAccount := authvesting.NewBaseVestingAccount(baseAccount, vestingAmt.Sort(), vestingEnd)
baseVestingAccount, err := authvesting.NewBaseVestingAccount(baseAccount, vestingAmt.Sort(), vestingEnd)
if err != nil {
return err
}
if (balances.Coins.IsZero() && !baseVestingAccount.OriginalVesting.IsZero()) ||
baseVestingAccount.OriginalVesting.IsAnyGT(balances.Coins) {
if (coins.IsZero() && !baseVestingAccount.OriginalVesting.IsZero()) ||
baseVestingAccount.OriginalVesting.IsAnyGT(coins) {
return errors.New("vesting amount cannot be greater than total amount")
}
@ -123,7 +125,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
}
genFile := config.GenesisFile()
appState, genDoc, err := genutil.GenesisStateFromGenFile(depCdc, genFile)
appState, genDoc, err := genutil.GenesisStateFromGenFile(cdc, genFile)
if err != nil {
return fmt.Errorf("failed to unmarshal genesis state: %w", err)
}
@ -146,17 +148,6 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
appState[auth.ModuleName] = authGenStateBz
bankGenState := bank.GetGenesisStateFromAppState(depCdc, appState)
bankGenState.Balances = append(bankGenState.Balances, balances)
bankGenState.Balances = bank.SanitizeGenesisBalances(bankGenState.Balances)
bankGenStateBz, err := cdc.MarshalJSON(bankGenState)
if err != nil {
return fmt.Errorf("failed to marshal bank genesis state: %w", err)
}
appState[bank.ModuleName] = bankGenStateBz
appStateJSON, err := cdc.MarshalJSON(appState)
if err != nil {
return fmt.Errorf("failed to marshal application genesis state: %w", err)

View File

@ -17,11 +17,11 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client/flags"
clientkeys "github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
@ -42,12 +42,11 @@ func main() {
cobra.EnableCommandSorting = false
cdc := codec.MakeCodec(app.ModuleBasics)
appCodec := codec.NewAppCodec(cdc)
tmamino.RegisterKeyType(crypto.PubKeySecp256k1{}, crypto.PubKeyAminoName)
tmamino.RegisterKeyType(crypto.PrivKeySecp256k1{}, crypto.PrivKeyAminoName)
keyring.CryptoCdc = cdc
keys.CryptoCdc = cdc
genutil.ModuleCdc = cdc
genutiltypes.ModuleCdc = cdc
clientkeys.KeysCdc = cdc
@ -68,16 +67,16 @@ func main() {
client.ValidateChainID(
genutilcli.InitCmd(ctx, cdc, app.ModuleBasics, app.DefaultNodeHome),
),
genutilcli.CollectGenTxsCmd(ctx, cdc, bank.GenesisBalancesIterator{}, app.DefaultNodeHome),
genutilcli.CollectGenTxsCmd(ctx, cdc, auth.GenesisAccountIterator{}, app.DefaultNodeHome),
genutilcli.MigrateGenesisCmd(ctx, cdc),
genutilcli.GenTxCmd(
ctx, cdc, app.ModuleBasics, staking.AppModuleBasic{}, bank.GenesisBalancesIterator{},
ctx, cdc, app.ModuleBasics, staking.AppModuleBasic{}, auth.GenesisAccountIterator{},
app.DefaultNodeHome, app.DefaultCLIHome,
),
genutilcli.ValidateGenesisCmd(ctx, cdc, app.ModuleBasics),
client.TestnetCmd(ctx, cdc, app.ModuleBasics, bank.GenesisBalancesIterator{}),
client.TestnetCmd(ctx, cdc, app.ModuleBasics, auth.GenesisAccountIterator{}),
// AddGenesisAccountCmd allows users to add accounts to the genesis file
AddGenesisAccountCmd(ctx, cdc, appCodec, app.DefaultNodeHome, app.DefaultCLIHome),
AddGenesisAccountCmd(ctx, cdc, app.DefaultNodeHome, app.DefaultCLIHome),
flags.NewCompletionCmd(rootCmd, true),
)
@ -96,7 +95,7 @@ func main() {
func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer) abci.Application {
return app.NewEthermintApp(logger, db, traceStore, true, 0,
baseapp.SetPruning(store.NewPruningOptionsFromString(viper.GetString("pruning"))))
baseapp.SetPruning(storetypes.NewPruningOptionsFromString(viper.GetString("pruning"))))
}
func exportAppStateAndTMValidators(

View File

@ -2,77 +2,20 @@ package codec
import (
"github.com/cosmos/cosmos-sdk/codec"
codecstd "github.com/cosmos/cosmos-sdk/codec/std"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
emintcrypto "github.com/cosmos/ethermint/crypto"
eminttypes "github.com/cosmos/ethermint/types"
ethermint "github.com/cosmos/ethermint/types"
)
var (
_ auth.Codec = (*Codec)(nil)
)
// Codec is a wrapper of the SDK standard Codec. It extends the Account interface
// by adding the EthAccount type for ethereum accounts.
type Codec struct {
*codecstd.Codec
}
func NewAppCodec(amino *codec.Codec) *Codec {
return &Codec{codecstd.NewAppCodec(amino)}
}
// MarshalAccount marshals an Account interface. If the given type implements
// the Marshaler interface, it is treated as a Proto-defined message and
// serialized that way. Otherwise, it falls back on the internal Amino codec.
func (c *Codec) MarshalAccount(accI authexported.Account) ([]byte, error) {
acc := &Account{}
if err := acc.SetAccount(accI); err != nil {
return nil, err
}
return c.Marshaler.MarshalBinaryBare(acc)
}
// UnmarshalAccount returns an Account interface from raw encoded account bytes
// of a Proto-based Account type. An error is returned upon decoding failure.
func (c *Codec) UnmarshalAccount(bz []byte) (authexported.Account, error) {
acc := &Account{}
if err := c.Marshaler.UnmarshalBinaryBare(bz, acc); err != nil {
return nil, err
}
return acc.GetAccount(), nil
}
// MarshalAccountJSON JSON encodes an account object implementing the Account
// interface.
func (c *Codec) MarshalAccountJSON(acc authexported.Account) ([]byte, error) {
return c.Marshaler.MarshalJSON(acc)
}
// UnmarshalAccountJSON returns an Account from JSON encoded bytes.
func (c *Codec) UnmarshalAccountJSON(bz []byte) (authexported.Account, error) {
acc := &Account{}
if err := c.Marshaler.UnmarshalJSON(bz, acc); err != nil {
return nil, err
}
return acc.GetAccount(), nil
}
// MakeCodec registers the necessary types and interfaces for an sdk.App. This
// codec is provided to all the modules the application depends on.
//
// NOTE: This codec will be deprecated in favor of AppCodec once all modules are
// migrated.
// migrated to protobuf.
func MakeCodec(bm module.BasicManager) *codec.Codec {
cdc := codec.New()
@ -81,12 +24,8 @@ func MakeCodec(bm module.BasicManager) *codec.Codec {
sdk.RegisterCodec(cdc)
emintcrypto.RegisterCodec(cdc)
codec.RegisterCrypto(cdc)
eminttypes.RegisterCodec(cdc)
keyring.RegisterCodec(cdc) // temporary. Used to register keyring.Info
// since auth client doesn't use the ethermint account type, we need to set
// our codec instead.
authclient.Codec = NewAppCodec(cdc)
ethermint.RegisterCodec(cdc)
keys.RegisterCodec(cdc) // temporary. Used to register keyring.Info
return cdc
}

View File

@ -1,864 +0,0 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: codec/codec.proto
package codec
import (
fmt "fmt"
github_com_cosmos_cosmos_sdk_x_auth_exported "github.com/cosmos/cosmos-sdk/x/auth/exported"
types "github.com/cosmos/cosmos-sdk/x/auth/types"
types1 "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
types2 "github.com/cosmos/cosmos-sdk/x/supply/types"
types3 "github.com/cosmos/ethermint/types"
proto "github.com/gogo/protobuf/proto"
_ "github.com/regen-network/cosmos-proto"
io "io"
math "math"
math_bits "math/bits"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// Account defines the application-level Account type.
type Account struct {
// sum defines a list of all acceptable concrete Account implementations.
//
// Types that are valid to be assigned to Sum:
// *Account_BaseAccount
// *Account_ContinuousVestingAccount
// *Account_DelayedVestingAccount
// *Account_PeriodicVestingAccount
// *Account_ModuleAccount
// *Account_EthAccount
Sum isAccount_Sum `protobuf_oneof:"sum"`
}
func (m *Account) Reset() { *m = Account{} }
func (m *Account) String() string { return proto.CompactTextString(m) }
func (*Account) ProtoMessage() {}
func (*Account) Descriptor() ([]byte, []int) {
return fileDescriptor_2557dd8a93a64b89, []int{0}
}
func (m *Account) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Account) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Account.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *Account) XXX_Merge(src proto.Message) {
xxx_messageInfo_Account.Merge(m, src)
}
func (m *Account) XXX_Size() int {
return m.Size()
}
func (m *Account) XXX_DiscardUnknown() {
xxx_messageInfo_Account.DiscardUnknown(m)
}
var xxx_messageInfo_Account proto.InternalMessageInfo
type isAccount_Sum interface {
isAccount_Sum()
MarshalTo([]byte) (int, error)
Size() int
}
type Account_BaseAccount struct {
BaseAccount *types.BaseAccount `protobuf:"bytes,1,opt,name=base_account,json=baseAccount,proto3,oneof" json:"base_account,omitempty"`
}
type Account_ContinuousVestingAccount struct {
ContinuousVestingAccount *types1.ContinuousVestingAccount `protobuf:"bytes,2,opt,name=continuous_vesting_account,json=continuousVestingAccount,proto3,oneof" json:"continuous_vesting_account,omitempty"`
}
type Account_DelayedVestingAccount struct {
DelayedVestingAccount *types1.DelayedVestingAccount `protobuf:"bytes,3,opt,name=delayed_vesting_account,json=delayedVestingAccount,proto3,oneof" json:"delayed_vesting_account,omitempty"`
}
type Account_PeriodicVestingAccount struct {
PeriodicVestingAccount *types1.PeriodicVestingAccount `protobuf:"bytes,4,opt,name=periodic_vesting_account,json=periodicVestingAccount,proto3,oneof" json:"periodic_vesting_account,omitempty"`
}
type Account_ModuleAccount struct {
ModuleAccount *types2.ModuleAccount `protobuf:"bytes,5,opt,name=module_account,json=moduleAccount,proto3,oneof" json:"module_account,omitempty"`
}
type Account_EthAccount struct {
EthAccount *types3.EthAccount `protobuf:"bytes,6,opt,name=eth_account,json=ethAccount,proto3,oneof" json:"eth_account,omitempty"`
}
func (*Account_BaseAccount) isAccount_Sum() {}
func (*Account_ContinuousVestingAccount) isAccount_Sum() {}
func (*Account_DelayedVestingAccount) isAccount_Sum() {}
func (*Account_PeriodicVestingAccount) isAccount_Sum() {}
func (*Account_ModuleAccount) isAccount_Sum() {}
func (*Account_EthAccount) isAccount_Sum() {}
func (m *Account) GetSum() isAccount_Sum {
if m != nil {
return m.Sum
}
return nil
}
func (m *Account) GetBaseAccount() *types.BaseAccount {
if x, ok := m.GetSum().(*Account_BaseAccount); ok {
return x.BaseAccount
}
return nil
}
func (m *Account) GetContinuousVestingAccount() *types1.ContinuousVestingAccount {
if x, ok := m.GetSum().(*Account_ContinuousVestingAccount); ok {
return x.ContinuousVestingAccount
}
return nil
}
func (m *Account) GetDelayedVestingAccount() *types1.DelayedVestingAccount {
if x, ok := m.GetSum().(*Account_DelayedVestingAccount); ok {
return x.DelayedVestingAccount
}
return nil
}
func (m *Account) GetPeriodicVestingAccount() *types1.PeriodicVestingAccount {
if x, ok := m.GetSum().(*Account_PeriodicVestingAccount); ok {
return x.PeriodicVestingAccount
}
return nil
}
func (m *Account) GetModuleAccount() *types2.ModuleAccount {
if x, ok := m.GetSum().(*Account_ModuleAccount); ok {
return x.ModuleAccount
}
return nil
}
func (m *Account) GetEthAccount() *types3.EthAccount {
if x, ok := m.GetSum().(*Account_EthAccount); ok {
return x.EthAccount
}
return nil
}
// XXX_OneofWrappers is for the internal use of the proto package.
func (*Account) XXX_OneofWrappers() []interface{} {
return []interface{}{
(*Account_BaseAccount)(nil),
(*Account_ContinuousVestingAccount)(nil),
(*Account_DelayedVestingAccount)(nil),
(*Account_PeriodicVestingAccount)(nil),
(*Account_ModuleAccount)(nil),
(*Account_EthAccount)(nil),
}
}
func init() {
proto.RegisterType((*Account)(nil), "ethermint.codec.v1.Account")
}
func init() { proto.RegisterFile("codec/codec.proto", fileDescriptor_2557dd8a93a64b89) }
var fileDescriptor_2557dd8a93a64b89 = []byte{
// 427 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x4f, 0xeb, 0xd3, 0x30,
0x18, 0xc7, 0x5b, 0xf7, 0x47, 0xc8, 0x54, 0x58, 0x40, 0x2d, 0x3b, 0x14, 0x1d, 0x08, 0xa2, 0x2c,
0x65, 0xce, 0x29, 0xfe, 0x3b, 0x38, 0xff, 0xe0, 0x45, 0x11, 0x0f, 0x1e, 0xbc, 0x94, 0x36, 0x09,
0x6b, 0xd9, 0xda, 0x84, 0x26, 0x29, 0xeb, 0xbb, 0xf0, 0xc5, 0xf8, 0x22, 0xc4, 0xd3, 0x8e, 0x1e,
0x65, 0x7b, 0x15, 0xde, 0x64, 0x49, 0x69, 0x27, 0xed, 0xf6, 0xfb, 0x5d, 0x02, 0xcf, 0xf3, 0x7c,
0xbf, 0xdf, 0x4f, 0x20, 0x4f, 0xc0, 0x10, 0x33, 0x42, 0xb1, 0xa7, 0x4f, 0xc4, 0x33, 0x26, 0x19,
0x84, 0x54, 0x46, 0x34, 0x4b, 0xe2, 0x54, 0x22, 0xd3, 0xce, 0xa7, 0xa3, 0xa1, 0x2c, 0x38, 0x15,
0x9e, 0x3e, 0x8d, 0x6c, 0xf4, 0x50, 0x46, 0x71, 0x46, 0x7c, 0x1e, 0x64, 0xb2, 0xf0, 0x74, 0xcb,
0xc3, 0x4c, 0x24, 0x4c, 0x4c, 0x8e, 0x8b, 0x52, 0x3c, 0x3f, 0x29, 0x16, 0x64, 0xe5, 0x6d, 0xbc,
0x40, 0xc9, 0xc8, 0x6b, 0x32, 0x5e, 0x5d, 0xc6, 0x96, 0x53, 0x21, 0xe3, 0x74, 0xd9, 0x62, 0x7f,
0x7a, 0x81, 0x5d, 0x28, 0xce, 0xd7, 0x45, 0xd3, 0x38, 0xfe, 0xdb, 0x05, 0x57, 0x5f, 0x63, 0xcc,
0x54, 0x2a, 0xe1, 0x7b, 0x70, 0x2d, 0x0c, 0x04, 0xf5, 0x03, 0x53, 0x3b, 0xf6, 0x1d, 0xfb, 0xfe,
0xe0, 0xd1, 0x5d, 0x64, 0x92, 0x7c, 0x41, 0x56, 0x68, 0x83, 0x0e, 0x17, 0x41, 0xf9, 0x14, 0x2d,
0x02, 0x41, 0x4b, 0xe3, 0x07, 0xeb, 0xcb, 0x20, 0xac, 0x4b, 0x98, 0x83, 0x11, 0x66, 0xa9, 0x8c,
0x53, 0xc5, 0x94, 0xf0, 0xcb, 0x4b, 0x57, 0xa9, 0x57, 0x74, 0xea, 0x93, 0xb6, 0x54, 0xa3, 0x3c,
0xa4, 0xbf, 0xa9, 0xfc, 0x5f, 0x4d, 0xb3, 0x46, 0x39, 0xf8, 0xc4, 0x0c, 0x26, 0xe0, 0x36, 0xa1,
0xeb, 0xa0, 0xa0, 0xa4, 0x01, 0xed, 0x68, 0xe8, 0xec, 0x3c, 0xf4, 0xad, 0x31, 0x37, 0x88, 0x37,
0x49, 0xdb, 0x00, 0x72, 0xe0, 0x70, 0x9a, 0xc5, 0x8c, 0xc4, 0xb8, 0xc1, 0xeb, 0x6a, 0xde, 0xe3,
0xf3, 0xbc, 0xcf, 0xa5, 0xbb, 0x01, 0xbc, 0xc5, 0x5b, 0x27, 0xf0, 0x13, 0xb8, 0x91, 0x30, 0xa2,
0xd6, 0xf5, 0x13, 0xf5, 0x34, 0xe7, 0xde, 0xff, 0x1c, 0xf3, 0xd8, 0x07, 0xc2, 0x47, 0xad, 0xae,
0x83, 0xaf, 0x27, 0xc7, 0x0d, 0xf8, 0x02, 0x0c, 0xa8, 0x8c, 0xaa, 0xb0, 0xbe, 0x0e, 0x73, 0x50,
0xfd, 0x2b, 0xf2, 0x29, 0x7a, 0x27, 0xa3, 0xda, 0x0f, 0x68, 0x55, 0x3d, 0x7f, 0xf6, 0xeb, 0xc7,
0x64, 0xfe, 0x60, 0x19, 0xcb, 0x48, 0x85, 0x08, 0xb3, 0xa4, 0x5c, 0xb8, 0x96, 0xb5, 0xa5, 0x1b,
0xce, 0x32, 0x49, 0x09, 0x2a, 0xad, 0x8b, 0x1e, 0xe8, 0x08, 0x95, 0x2c, 0x5e, 0xfe, 0xdc, 0xb9,
0xf6, 0x76, 0xe7, 0xda, 0x7f, 0x76, 0xae, 0xfd, 0x7d, 0xef, 0x5a, 0xdb, 0xbd, 0x6b, 0xfd, 0xde,
0xbb, 0xd6, 0xb7, 0xf1, 0xd9, 0x58, 0xfd, 0x57, 0xc3, 0xbe, 0x5e, 0xe0, 0xd9, 0xbf, 0x00, 0x00,
0x00, 0xff, 0xff, 0xd5, 0xd2, 0x26, 0x71, 0xd8, 0x03, 0x00, 0x00,
}
func (this *Account) GetAccount() github_com_cosmos_cosmos_sdk_x_auth_exported.Account {
if x := this.GetBaseAccount(); x != nil {
return x
}
if x := this.GetContinuousVestingAccount(); x != nil {
return x
}
if x := this.GetDelayedVestingAccount(); x != nil {
return x
}
if x := this.GetPeriodicVestingAccount(); x != nil {
return x
}
if x := this.GetModuleAccount(); x != nil {
return x
}
if x := this.GetEthAccount(); x != nil {
return x
}
return nil
}
func (this *Account) SetAccount(value github_com_cosmos_cosmos_sdk_x_auth_exported.Account) error {
if value == nil {
this.Sum = nil
return nil
}
switch vt := value.(type) {
case *types.BaseAccount:
this.Sum = &Account_BaseAccount{vt}
return nil
case *types1.ContinuousVestingAccount:
this.Sum = &Account_ContinuousVestingAccount{vt}
return nil
case *types1.DelayedVestingAccount:
this.Sum = &Account_DelayedVestingAccount{vt}
return nil
case *types1.PeriodicVestingAccount:
this.Sum = &Account_PeriodicVestingAccount{vt}
return nil
case *types2.ModuleAccount:
this.Sum = &Account_ModuleAccount{vt}
return nil
case *types3.EthAccount:
this.Sum = &Account_EthAccount{vt}
return nil
}
return fmt.Errorf("can't encode value of type %T as message Account", value)
}
func (m *Account) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *Account) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Account) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.Sum != nil {
{
size := m.Sum.Size()
i -= size
if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil {
return 0, err
}
}
}
return len(dAtA) - i, nil
}
func (m *Account_BaseAccount) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Account_BaseAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
if m.BaseAccount != nil {
{
size, err := m.BaseAccount.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintCodec(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *Account_ContinuousVestingAccount) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Account_ContinuousVestingAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
if m.ContinuousVestingAccount != nil {
{
size, err := m.ContinuousVestingAccount.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintCodec(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
}
return len(dAtA) - i, nil
}
func (m *Account_DelayedVestingAccount) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Account_DelayedVestingAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
if m.DelayedVestingAccount != nil {
{
size, err := m.DelayedVestingAccount.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintCodec(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x1a
}
return len(dAtA) - i, nil
}
func (m *Account_PeriodicVestingAccount) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Account_PeriodicVestingAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
if m.PeriodicVestingAccount != nil {
{
size, err := m.PeriodicVestingAccount.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintCodec(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x22
}
return len(dAtA) - i, nil
}
func (m *Account_ModuleAccount) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Account_ModuleAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
if m.ModuleAccount != nil {
{
size, err := m.ModuleAccount.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintCodec(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x2a
}
return len(dAtA) - i, nil
}
func (m *Account_EthAccount) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Account_EthAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
if m.EthAccount != nil {
{
size, err := m.EthAccount.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintCodec(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x32
}
return len(dAtA) - i, nil
}
func encodeVarintCodec(dAtA []byte, offset int, v uint64) int {
offset -= sovCodec(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
}
func (m *Account) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Sum != nil {
n += m.Sum.Size()
}
return n
}
func (m *Account_BaseAccount) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.BaseAccount != nil {
l = m.BaseAccount.Size()
n += 1 + l + sovCodec(uint64(l))
}
return n
}
func (m *Account_ContinuousVestingAccount) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.ContinuousVestingAccount != nil {
l = m.ContinuousVestingAccount.Size()
n += 1 + l + sovCodec(uint64(l))
}
return n
}
func (m *Account_DelayedVestingAccount) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.DelayedVestingAccount != nil {
l = m.DelayedVestingAccount.Size()
n += 1 + l + sovCodec(uint64(l))
}
return n
}
func (m *Account_PeriodicVestingAccount) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.PeriodicVestingAccount != nil {
l = m.PeriodicVestingAccount.Size()
n += 1 + l + sovCodec(uint64(l))
}
return n
}
func (m *Account_ModuleAccount) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.ModuleAccount != nil {
l = m.ModuleAccount.Size()
n += 1 + l + sovCodec(uint64(l))
}
return n
}
func (m *Account_EthAccount) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.EthAccount != nil {
l = m.EthAccount.Size()
n += 1 + l + sovCodec(uint64(l))
}
return n
}
func sovCodec(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozCodec(x uint64) (n int) {
return sovCodec(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *Account) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCodec
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Account: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Account: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field BaseAccount", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCodec
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthCodec
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthCodec
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
v := &types.BaseAccount{}
if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
m.Sum = &Account_BaseAccount{v}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ContinuousVestingAccount", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCodec
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthCodec
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthCodec
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
v := &types1.ContinuousVestingAccount{}
if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
m.Sum = &Account_ContinuousVestingAccount{v}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field DelayedVestingAccount", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCodec
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthCodec
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthCodec
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
v := &types1.DelayedVestingAccount{}
if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
m.Sum = &Account_DelayedVestingAccount{v}
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field PeriodicVestingAccount", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCodec
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthCodec
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthCodec
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
v := &types1.PeriodicVestingAccount{}
if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
m.Sum = &Account_PeriodicVestingAccount{v}
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ModuleAccount", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCodec
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthCodec
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthCodec
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
v := &types2.ModuleAccount{}
if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
m.Sum = &Account_ModuleAccount{v}
iNdEx = postIndex
case 6:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field EthAccount", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCodec
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthCodec
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthCodec
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
v := &types3.EthAccount{}
if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
m.Sum = &Account_EthAccount{v}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipCodec(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthCodec
}
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthCodec
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipCodec(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
depth := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCodec
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCodec
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
case 1:
iNdEx += 8
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCodec
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if length < 0 {
return 0, ErrInvalidLengthCodec
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroupCodec
}
depth--
case 5:
iNdEx += 4
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLengthCodec
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
}
var (
ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowCodec = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupCodec = fmt.Errorf("proto: unexpected end of group")
)

View File

@ -1,25 +0,0 @@
syntax = "proto3";
package ethermint.codec.v1;
import "types/types.proto";
import "third_party/proto/cosmos-proto/cosmos.proto";
import "third_party/proto/cosmos-sdk/x/auth/types/types.proto";
import "third_party/proto/cosmos-sdk/x/auth/vesting/types/types.proto";
import "third_party/proto/cosmos-sdk/x/supply/types/types.proto";
option go_package = "github.com/cosmos/cosmos-sdk/codec";
// Account defines the application-level Account type.
message Account {
option (cosmos_proto.interface_type) = "*github.com/cosmos/cosmos-sdk/x/auth/exported.Account";
// sum defines a list of all acceptable concrete Account implementations.
oneof sum {
cosmos_sdk.x.auth.v1.BaseAccount base_account = 1;
cosmos_sdk.x.auth.vesting.v1.ContinuousVestingAccount continuous_vesting_account = 2;
cosmos_sdk.x.auth.vesting.v1.DelayedVestingAccount delayed_vesting_account = 3;
cosmos_sdk.x.auth.vesting.v1.PeriodicVestingAccount periodic_vesting_account = 4;
cosmos_sdk.x.supply.v1.ModuleAccount module_account = 5;
ethermint.v1.EthAccount eth_account = 6;
}
}

View File

@ -14,43 +14,43 @@ import (
tmcrypto "github.com/tendermint/tendermint/crypto"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys"
)
const (
// EthSecp256k1 defines the ECDSA secp256k1 used on Ethereum
EthSecp256k1 = keyring.SigningAlgo("eth_secp256k1")
EthSecp256k1 = keys.SigningAlgo("eth_secp256k1")
)
// SupportedAlgorithms defines the list of signing algorithms used on Ethermint:
// - eth_secp256k1 (Ethereum)
// - secp256k1 (Tendermint)
var SupportedAlgorithms = []keyring.SigningAlgo{EthSecp256k1, keyring.Secp256k1}
var SupportedAlgorithms = []keys.SigningAlgo{EthSecp256k1, keys.Secp256k1}
// EthSecp256k1Options defines a keyring options for the ethereum Secp256k1 curve.
func EthSecp256k1Options() []keyring.KeybaseOption {
return []keyring.KeybaseOption{
keyring.WithKeygenFunc(EthermintKeygenFunc),
keyring.WithDeriveFunc(DeriveKey),
keyring.WithSupportedAlgos(SupportedAlgorithms),
keyring.WithSupportedAlgosLedger(SupportedAlgorithms),
// EthSecp256k1Options defines a keys options for the ethereum Secp256k1 curve.
func EthSecp256k1Options() []keys.KeybaseOption {
return []keys.KeybaseOption{
keys.WithKeygenFunc(EthermintKeygenFunc),
keys.WithDeriveFunc(DeriveKey),
keys.WithSupportedAlgos(SupportedAlgorithms),
keys.WithSupportedAlgosLedger(SupportedAlgorithms),
}
}
func DeriveKey(mnemonic, bip39Passphrase, hdPath string, algo keyring.SigningAlgo) ([]byte, error) {
func DeriveKey(mnemonic, bip39Passphrase, hdPath string, algo keys.SigningAlgo) ([]byte, error) {
switch algo {
case keyring.Secp256k1:
return keyring.StdDeriveKey(mnemonic, bip39Passphrase, hdPath, algo)
case keys.Secp256k1:
return keys.StdDeriveKey(mnemonic, bip39Passphrase, hdPath, algo)
case EthSecp256k1:
return DeriveSecp256k1(mnemonic, bip39Passphrase, hdPath)
default:
return nil, errors.Wrap(keyring.ErrUnsupportedSigningAlgo, string(algo))
return nil, errors.Wrap(keys.ErrUnsupportedSigningAlgo, string(algo))
}
}
// EthermintKeygenFunc is the key generation function to generate secp256k1 ToECDSA
// from ethereum.
func EthermintKeygenFunc(bz []byte, algo keyring.SigningAlgo) (tmcrypto.PrivKey, error) {
func EthermintKeygenFunc(bz []byte, algo keys.SigningAlgo) (tmcrypto.PrivKey, error) {
if algo != EthSecp256k1 {
return nil, fmt.Errorf("signing algorithm must be %s, got %s", EthSecp256k1, algo)
}

View File

@ -8,7 +8,7 @@ import (
ethcrypto "github.com/ethereum/go-ethereum/crypto"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/cosmos/cosmos-sdk/crypto/keys/hd"
"github.com/cosmos/cosmos-sdk/tests"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -21,7 +21,7 @@ func TestEthermintKeygenFunc(t *testing.T) {
testCases := []struct {
name string
privKey []byte
algo keyring.SigningAlgo
algo keys.SigningAlgo
expPass bool
}{
{
@ -45,7 +45,7 @@ func TestEthermintKeygenFunc(t *testing.T) {
{
"invalid algo",
nil,
keyring.MultiAlgo,
keys.MultiAlgo,
false,
},
}
@ -66,7 +66,7 @@ func TestKeyring(t *testing.T) {
mockIn := strings.NewReader("")
t.Cleanup(cleanup)
kr, err := keyring.NewKeyring("ethermint", keyring.BackendTest, dir, mockIn, EthSecp256k1Options()...)
kr, err := keys.NewKeyring("ethermint", keys.BackendTest, dir, mockIn, EthSecp256k1Options()...)
require.NoError(t, err)
// fail in retrieving key
@ -75,7 +75,7 @@ func TestKeyring(t *testing.T) {
require.Nil(t, info)
mockIn.Reset("password\npassword\n")
info, mnemonic, err := kr.CreateMnemonic("foo", keyring.English, sdk.FullFundraiserPath, EthSecp256k1)
info, mnemonic, err := kr.CreateMnemonic("foo", keys.English, sdk.FullFundraiserPath, EthSecp256k1)
require.NoError(t, err)
require.NotEmpty(t, mnemonic)
require.Equal(t, "foo", info.GetName())
@ -85,15 +85,15 @@ func TestKeyring(t *testing.T) {
params := *hd.NewFundraiserParams(0, sdk.CoinType, 0)
hdPath := params.String()
bz, err := DeriveKey(mnemonic, keyring.DefaultBIP39Passphrase, hdPath, EthSecp256k1)
bz, err := DeriveKey(mnemonic, keys.DefaultBIP39Passphrase, hdPath, EthSecp256k1)
require.NoError(t, err)
require.NotEmpty(t, bz)
bz, err = DeriveKey(mnemonic, keyring.DefaultBIP39Passphrase, hdPath, keyring.Secp256k1)
bz, err = DeriveKey(mnemonic, keys.DefaultBIP39Passphrase, hdPath, keys.Secp256k1)
require.NoError(t, err)
require.NotEmpty(t, bz)
bz, err = DeriveKey(mnemonic, keyring.DefaultBIP39Passphrase, hdPath, keyring.SigningAlgo(""))
bz, err = DeriveKey(mnemonic, keys.DefaultBIP39Passphrase, hdPath, keys.SigningAlgo(""))
require.Error(t, err)
require.Empty(t, bz)
}

View File

@ -4,7 +4,7 @@ import (
cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys"
)
// CryptoCodec is the default amino codec used by ethermint
@ -19,8 +19,8 @@ const (
func init() {
// replace the keyring codec with the ethermint crypto codec to prevent
// amino panics because of unregistered Priv/PubKey
keyring.CryptoCdc = CryptoCodec
keyring.RegisterCodec(CryptoCodec)
keys.CryptoCdc = CryptoCodec
keys.RegisterCodec(CryptoCodec)
cryptoamino.RegisterAmino(CryptoCodec)
RegisterCodec(CryptoCodec)
}

View File

@ -7,16 +7,9 @@ import (
ethcrypto "github.com/ethereum/go-ethereum/crypto"
ethsecp256k1 "github.com/ethereum/go-ethereum/crypto/secp256k1"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
tmcrypto "github.com/tendermint/tendermint/crypto"
)
func init() {
authtypes.RegisterKeyTypeCodec(PubKeySecp256k1{}, PubKeyAminoName)
authtypes.RegisterKeyTypeCodec(PrivKeySecp256k1{}, PrivKeyAminoName)
}
// ----------------------------------------------------------------------------
// secp256k1 Private Key

9
go.mod
View File

@ -6,11 +6,10 @@ require (
github.com/allegro/bigcache v1.2.1 // indirect
github.com/aristanetworks/goarista v0.0.0-20200331225509-2cc472e8fbd6 // indirect
github.com/cespare/cp v1.1.1 // indirect
github.com/cosmos/cosmos-sdk v0.34.4-0.20200403200637-7f78e61b93a5
github.com/cosmos/cosmos-sdk v0.39.1
github.com/deckarep/golang-set v1.7.1 // indirect
github.com/ethereum/go-ethereum v1.9.18
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect
github.com/gogo/protobuf v1.3.1
github.com/gorilla/mux v1.7.4
github.com/gorilla/websocket v1.4.2
github.com/mattn/go-colorable v0.1.7 // indirect
@ -18,19 +17,15 @@ require (
github.com/onsi/gomega v1.8.1 // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/tsdb v0.9.1 // indirect
github.com/regen-network/cosmos-proto v0.1.1-0.20200213154359-02baa11ea7c2
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cobra v1.0.0
github.com/spf13/viper v1.7.1
github.com/status-im/keycard-go v0.0.0-20190424133014-d95853db0f48
github.com/stretchr/testify v1.6.1
github.com/tendermint/tendermint v0.33.4
github.com/tendermint/tendermint v0.33.7
github.com/tendermint/tm-db v0.5.1
github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
gopkg.in/yaml.v2 v2.3.0
)
// forked SDK to avoid breaking changes
replace github.com/cosmos/cosmos-sdk => github.com/Chainsafe/cosmos-sdk v0.34.4-0.20200811134358-723463e1daec

67
go.sum
View File

@ -11,8 +11,8 @@ cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqCl
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/99designs/keyring v1.1.4 h1:x0g0zQ9bQKgNsLo0XSXAy1H8Q1RG/td+5OXJt+Ci8b8=
github.com/99designs/keyring v1.1.4/go.mod h1:657DQuMrBZRtuL/voxVyiyb6zpMehlm5vLB9Qwrv904=
github.com/99designs/keyring v1.1.3 h1:mEV3iyZWjkxQ7R8ia8GcG97vCX5zQQ7n4o8R2BylwQY=
github.com/99designs/keyring v1.1.3/go.mod h1:657DQuMrBZRtuL/voxVyiyb6zpMehlm5vLB9Qwrv904=
github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4=
github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc=
github.com/Azure/azure-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjNuEjKRYAcJU8/ydDI++4=
@ -29,12 +29,8 @@ github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbt
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f h1:4O1om+UVU+Hfcihr1timk8YNXHxzZWgCo7ofnrZRApw=
github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg=
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
github.com/Chainsafe/cosmos-sdk v0.34.4-0.20200811134358-723463e1daec h1:xcqymee4N5YPH9+NKmrNGw0pdfM82VOoohiXIaQwLzo=
github.com/Chainsafe/cosmos-sdk v0.34.4-0.20200811134358-723463e1daec/go.mod h1:brXC4wuGawcC5pQebaWER22hzunmXFLgN8vajUh+xhE=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
@ -74,6 +70,8 @@ github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQ
github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d h1:1aAija9gr0Hyv4KfQcRcwlmFIrhkDmIj2dz5bkg/s/8=
github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d/go.mod h1:icNx/6QdFblhsEjZehARqbNumymUT/ydwlLojFdv7Sk=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@ -87,7 +85,6 @@ github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQj
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d h1:yJzD/yFppdVCf6ApMkVy8cUxV0XrxdP9rVf6D87/Mng=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/btcsuite/btcutil v1.0.2 h1:9iZ1Terx9fMIOtq1VrwdqfsATL9MC2l8ZrUY6YZ2uts=
github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts=
@ -121,6 +118,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cosmos/cosmos-sdk v0.39.1 h1:vhjf9PZh9ph8btAj9aBpHoVITgVVjNBpM3x5Gl/Vwac=
github.com/cosmos/cosmos-sdk v0.39.1/go.mod h1:ry2ROl5n+f2/QXpKJo3rdWNJwll00z7KhIVcxNcl16M=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4=
@ -159,7 +158,6 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw=
github.com/ethereum/go-ethereum v1.9.18 h1:+vzvufVD7+OfQa07IJP20Z7AGZsJaw0M6JIA/WQcqy8=
github.com/ethereum/go-ethereum v1.9.18/go.mod h1:JSSTypSMTkGZtAdAChH2wP5dZEvPGh3nUTuDpH+hNrg=
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ=
@ -184,8 +182,6 @@ github.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gibson042/canonicaljson-go v1.0.3 h1:EAyF8L74AWabkyUmrvEFHEt/AGFQeD6RfwbAuf0j1bI=
github.com/gibson042/canonicaljson-go v1.0.3/go.mod h1:DsLpJTThXyGNO+KZlI85C1/KDcImpP67k/RKVjcaEqo=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
@ -215,16 +211,15 @@ github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4er
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.3.1-0.20190508161146-9fa652df1129/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/golang/mock v1.4.3 h1:GV+pQPG/EUUbkh47niozDcADz6go/dUwhVzdUQHIVRw=
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2-0.20190517061210-b285ee9cfc6c/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
@ -232,7 +227,6 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W
github.com/golang/protobuf v1.4.0 h1:oOuy+ugB+P/kBdUnG5QaMXSIyJ1q38wWSojYCb3z5VQ=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.2-0.20200707131729-196ae77b8a26 h1:lMm2hD9Fy0ynom5+85/pbdkiYcBqM1JWmhpAXLmy0fw=
github.com/golang/snappy v0.0.2-0.20200707131729-196ae77b8a26/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
@ -267,7 +261,6 @@ github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB7
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc=
@ -278,7 +271,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0=
github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f h1:8N8XWLZelZNibkhM1FuF+3Ad3YIbgirjdMiVA0eUkaM=
github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s=
github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is=
github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s=
@ -390,6 +382,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0=
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM=
github.com/minio/highwayhash v1.0.0 h1:iMSDhgUILCr0TNm8LWlSjF8N0ZIj2qbO8WHp6Q/J2BA=
github.com/minio/highwayhash v1.0.0/go.mod h1:xQboMTeM9nY9v/LlAOxFctujiv5+Aq2hR5dxBpaMbdc=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
@ -441,14 +435,6 @@ github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxS
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/otiai10/copy v1.1.1 h1:PH7IFlRQ6Fv9vYmuXbDRLdgTHoP1w483kPNUP2bskpo=
github.com/otiai10/copy v1.1.1/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw=
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
github.com/otiai10/curr v1.0.0 h1:TJIWdbX0B+kpNagQrjgq8bCMrbhiuX73M2XwgtDMoOI=
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
github.com/otiai10/mint v1.3.1 h1:BCmzIS3n71sGfHB5NMNDB3lHYPz8fWSkCAErHed//qc=
github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34=
@ -477,8 +463,6 @@ github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDf
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
github.com/prometheus/client_golang v1.4.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
github.com/prometheus/client_golang v1.5.0 h1:Ctq0iGpCmr3jeP77kbF2UxgvRwzWWz+4Bh9/vJTyg1A=
github.com/prometheus/client_golang v1.5.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
github.com/prometheus/client_golang v1.5.1 h1:bdHYieyGlH+6OLEk2YQha8THib30KP0/yD0YH9m6xcA=
github.com/prometheus/client_golang v1.5.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
@ -506,15 +490,12 @@ github.com/prometheus/tsdb v0.6.2-0.20190402121629-4f204dcbc150/go.mod h1:qhTCs0
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/prometheus/tsdb v0.9.1 h1:IWaAmWkYlgG7/S4iw4IpAQt5Y35QaZM6/GsZ7GsjAuk=
github.com/prometheus/tsdb v0.9.1/go.mod h1:oi49uRhEe9dPUTlS3JRZOwJuVi6tmh10QSgwXEyGCt4=
github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ=
github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc=
github.com/rakyll/statik v0.1.6 h1:uICcfUXpgqtw2VopbIncslhAmE5hwc4g20TEyEENBNs=
github.com/rakyll/statik v0.1.6/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563 h1:dY6ETXrvDG7Sa4vE8ZQG4yqWg6UnOcbqTAahkV813vQ=
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ=
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/regen-network/cosmos-proto v0.1.1-0.20200213154359-02baa11ea7c2 h1:jQK1YoH972Aptd22YKgtNu5jM2X2xMGkyIENOAc71to=
github.com/regen-network/cosmos-proto v0.1.1-0.20200213154359-02baa11ea7c2/go.mod h1:+r7jN10xXCypD4yBgzKOa+vgLz0riqYMHeDcKekxPvA=
github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho=
github.com/rjeczalik/notify v0.9.2 h1:MiTWrPj55mNDHEiIX5YUSKefw/+lCQVoAFmD6oQm5w8=
github.com/rjeczalik/notify v0.9.2/go.mod h1:aErll2f0sUX9PXZnVNyeiObbmTlk5jnMoCa4QEjJeqM=
@ -549,7 +530,6 @@ github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTd
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8=
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
@ -560,7 +540,6 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k=
github.com/spf13/viper v1.6.3/go.mod h1:jUMtyi0/lB5yZH/FjyGAoH7IMNrIhlBf6pXZmbMDvzw=
github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk=
github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
@ -581,7 +560,6 @@ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoH
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@ -600,12 +578,11 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM
github.com/tendermint/go-amino v0.14.1/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso=
github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ=
github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/tendermint/iavl v0.13.3 h1:expgBDY1MX+6/3sqrIxGChbTNf9N9aTJ67SH4bPchCs=
github.com/tendermint/iavl v0.13.3/go.mod h1:2lE7GiWdSvc7kvT78ncIKmkOjCnp6JEnSb2O7B9htLw=
github.com/tendermint/tendermint v0.33.2/go.mod h1:25DqB7YvV1tN3tHsjWoc2vFtlwICfrub9XO6UBO+4xk=
github.com/tendermint/tendermint v0.33.4 h1:NM3G9618yC5PaaxGrcAySc5ylc1PAANeIx42u2Re/jo=
github.com/tendermint/tendermint v0.33.4/go.mod h1:6NW9DVkvsvqmCY6wbRsOo66qGDhMXglRL70aXajvBEA=
github.com/tendermint/tm-db v0.4.1/go.mod h1:JsJ6qzYkCGiGwm5GHl/H5GLI9XLb6qZX7PRe425dHAY=
github.com/tendermint/iavl v0.14.0 h1:Jkff+IFrXxRWtH9Jn/ga/2cxNnzMTv58xEKgCJsKUBg=
github.com/tendermint/iavl v0.14.0/go.mod h1:QmfViflFiXzxKLQE4tAUuWQHq+RSuQFxablW5oJZ6sE=
github.com/tendermint/tendermint v0.33.5/go.mod h1:0yUs9eIuuDq07nQql9BmI30FtYGcEC60Tu5JzB5IezM=
github.com/tendermint/tendermint v0.33.7 h1:b5CQD8ggDtl4u0EbXzabi0MaOw9NrcXker6ijEkAE74=
github.com/tendermint/tendermint v0.33.7/go.mod h1:0yUs9eIuuDq07nQql9BmI30FtYGcEC60Tu5JzB5IezM=
github.com/tendermint/tm-db v0.5.1 h1:H9HDq8UEA7Eeg13kdYckkgwwkQLBnJGgX4PgLJRhieY=
github.com/tendermint/tm-db v0.5.1/go.mod h1:g92zWjHpCYlEvQXvy9M168Su8V1IBEeawpXVVBaK4f4=
github.com/tjfoc/gmsm v1.3.0/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w=
@ -656,8 +633,8 @@ golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200406173513-056763e48d71 h1:DOmugCavvUtnUD114C1Wh+UgTgQZ4pMLzXxi1pSt+/Y=
golang.org/x/crypto v0.0.0-20200406173513-056763e48d71/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@ -723,6 +700,7 @@ golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -741,7 +719,6 @@ golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
@ -815,10 +792,10 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.28.0 h1:bO/TA4OxCOummhSf10siHuG7vJOiwh7SpRpFZDkOgl4=
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
google.golang.org/grpc v1.28.1 h1:C1QC6KzgSiLyBabDi87BbjaGreoRgGUF5nOyvfrAZ1k=
google.golang.org/grpc v1.28.1/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
google.golang.org/grpc v1.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE=
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@ -871,7 +848,5 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=

View File

@ -23,7 +23,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/ethermint/codec"
"github.com/cosmos/ethermint/core"
emintcrypto "github.com/cosmos/ethermint/crypto"
"github.com/cosmos/ethermint/types"
@ -102,12 +101,12 @@ func trapSignals() {
}
// nolint: interfacer
func createAndTestGenesis(t *testing.T, cms sdk.CommitMultiStore, ak auth.AccountKeeper, bk bank.Keeper) {
func createAndTestGenesis(t *testing.T, cms sdk.CommitMultiStore, ak auth.AccountKeeper) {
genBlock := ethcore.DefaultGenesisBlock()
ms := cms.CacheMultiStore()
ctx := sdk.NewContext(ms, abci.Header{}, false, logger)
stateDB := evmtypes.NewCommitStateDB(ctx, storeKey, ak, bk)
stateDB := evmtypes.NewCommitStateDB(ctx, storeKey, ak)
// sort the addresses and insertion of key/value pairs matters
genAddrs := make([]string, len(genBlock.Alloc))
@ -151,7 +150,8 @@ func createAndTestGenesis(t *testing.T, cms sdk.CommitMultiStore, ak auth.Accoun
// verify account mapper state
genAcc := ak.GetAccount(ctx, sdk.AccAddress(genInvestor.Bytes()))
require.NotNil(t, genAcc)
balance := bk.GetBalance(ctx, genAcc.GetAddress(), types.DenomDefault)
balance := sdk.NewCoin(types.DenomDefault, genAcc.GetCoins().AmountOf(types.DenomDefault))
require.Equal(t, sdk.NewIntFromBigInt(b), balance.Amount)
}
@ -173,23 +173,19 @@ func TestImportBlocks(t *testing.T) {
trapSignals()
cdc := newTestCodec()
appCodec := codec.NewAppCodec(cdc)
cms := store.NewCommitMultiStore(db)
// The ParamsKeeper handles parameter storage for the application
bankKey := sdk.NewKVStoreKey(bank.StoreKey)
keyParams := sdk.NewKVStoreKey(params.StoreKey)
tkeyParams := sdk.NewTransientStoreKey(params.TStoreKey)
paramsKeeper := params.NewKeeper(appCodec, keyParams, tkeyParams)
paramsKeeper := params.NewKeeper(cdc, keyParams, tkeyParams)
// Set specific supspaces
authSubspace := paramsKeeper.Subspace(auth.DefaultParamspace)
bankSubspace := paramsKeeper.Subspace(bank.DefaultParamspace)
ak := auth.NewAccountKeeper(appCodec, accKey, authSubspace, types.ProtoAccount)
bk := bank.NewBaseKeeper(appCodec, bankKey, ak, bankSubspace, nil)
ak := auth.NewAccountKeeper(cdc, accKey, authSubspace, types.ProtoAccount)
// mount stores
keys := []*sdk.KVStoreKey{accKey, bankKey, storeKey}
keys := []*sdk.KVStoreKey{accKey, storeKey}
for _, key := range keys {
cms.MountStoreWithDB(key, sdk.StoreTypeIAVL, nil)
}
@ -201,7 +197,7 @@ func TestImportBlocks(t *testing.T) {
require.NoError(t, err)
// set and test genesis block
createAndTestGenesis(t, cms, ak, bk)
createAndTestGenesis(t, cms, ak)
// open blockchain export file
blockchainInput, err := os.Open(flagBlockchain)
@ -246,7 +242,7 @@ func TestImportBlocks(t *testing.T) {
ctx := sdk.NewContext(ms, abci.Header{}, false, logger)
ctx = ctx.WithBlockHeight(int64(block.NumberU64()))
stateDB := createStateDB(ctx, ak, bk)
stateDB := createStateDB(ctx, ak)
if chainConfig.DAOForkSupport && chainConfig.DAOForkBlock != nil && chainConfig.DAOForkBlock.Cmp(block.Number()) == 0 {
applyDAOHardFork(stateDB)
@ -281,8 +277,8 @@ func TestImportBlocks(t *testing.T) {
}
// nolint: interfacer
func createStateDB(ctx sdk.Context, ak auth.AccountKeeper, bk bank.Keeper) *evmtypes.CommitStateDB {
return evmtypes.NewCommitStateDB(ctx, storeKey, ak, bk)
func createStateDB(ctx sdk.Context, ak auth.AccountKeeper) *evmtypes.CommitStateDB {
return evmtypes.NewCommitStateDB(ctx, storeKey, ak)
}
// accumulateRewards credits the coinbase of the given block with the mining

View File

@ -6,21 +6,21 @@ import (
"os"
"strings"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/input"
"github.com/cosmos/cosmos-sdk/client/lcd"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
"github.com/cosmos/ethermint/app"
"github.com/cosmos/ethermint/crypto"
"github.com/ethereum/go-ethereum/rpc"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
const (
@ -45,7 +45,7 @@ func registerRoutes(rs *lcd.RestServer) {
accountName := viper.GetString(flagUnlockKey)
accountNames := strings.Split(accountName, ",")
var keys []crypto.PrivKeySecp256k1
var privkeys []crypto.PrivKeySecp256k1
if len(accountName) > 0 {
var err error
inBuf := bufio.NewReader(os.Stdin)
@ -53,9 +53,9 @@ func registerRoutes(rs *lcd.RestServer) {
keyringBackend := viper.GetString(flags.FlagKeyringBackend)
passphrase := ""
switch keyringBackend {
case keyring.BackendOS:
case keys.BackendOS:
break
case keyring.BackendFile:
case keys.BackendFile:
passphrase, err = input.GetPassword(
"Enter password to unlock key for RPC API: ",
inBuf)
@ -64,13 +64,13 @@ func registerRoutes(rs *lcd.RestServer) {
}
}
keys, err = unlockKeyFromNameAndPassphrase(accountNames, passphrase)
privkeys, err = unlockKeyFromNameAndPassphrase(accountNames, passphrase)
if err != nil {
panic(err)
}
}
apis := GetRPCAPIs(rs.CliCtx, keys)
apis := GetRPCAPIs(rs.CliCtx, privkeys)
// TODO: Allow cli to configure modules https://github.com/ChainSafe/ethermint/issues/74
whitelist := make(map[string]bool)
@ -103,7 +103,7 @@ func registerRoutes(rs *lcd.RestServer) {
}
func unlockKeyFromNameAndPassphrase(accountNames []string, passphrase string) ([]crypto.PrivKeySecp256k1, error) {
keybase, err := keyring.NewKeyring(
keybase, err := keys.NewKeyring(
sdk.KeyringServiceName(),
viper.GetString(flags.FlagKeyringBackend),
viper.GetString(flags.FlagHome),

View File

@ -7,13 +7,10 @@ import (
"log"
"math/big"
"strconv"
"strings"
"sync"
"github.com/gogo/protobuf/jsonpb"
"github.com/spf13/viper"
"github.com/cosmos/ethermint/codec"
"github.com/cosmos/ethermint/crypto"
params "github.com/cosmos/ethermint/rpc/args"
emint "github.com/cosmos/ethermint/types"
@ -34,11 +31,11 @@ import (
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client/utils"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)
@ -137,7 +134,7 @@ func (e *PublicEthAPI) Accounts() ([]common.Address, error) {
addresses := make([]common.Address, 0) // return [] instead of nil if empty
keybase, err := keyring.NewKeyring(
keybase, err := keys.NewKeyring(
sdk.KeyringServiceName(),
viper.GetString(flags.FlagKeyringBackend),
viper.GetString(flags.FlagHome),
@ -205,8 +202,7 @@ func (e *PublicEthAPI) GetTransactionCount(address common.Address, blockNum Bloc
// Get nonce (sequence) from account
from := sdk.AccAddress(address.Bytes())
authclient.Codec = codec.NewAppCodec(ctx.Codec)
accRet := authtypes.NewAccountRetriever(authclient.Codec, ctx)
accRet := authtypes.NewAccountRetriever(ctx)
err := accRet.EnsureExists(from)
if err != nil {
@ -524,7 +520,7 @@ func (e *PublicEthAPI) doCall(
}
var simResponse sdk.SimulationResponse
if err := jsonpb.Unmarshal(strings.NewReader(string(res)), &simResponse); err != nil {
if err := ctx.Codec.UnmarshalBinaryBare(res, &simResponse); err != nil {
return nil, err
}
@ -625,7 +621,8 @@ type Transaction struct {
func bytesToEthTx(cliCtx context.CLIContext, bz []byte) (*evmtypes.MsgEthereumTx, error) {
var stdTx sdk.Tx
err := cliCtx.Codec.UnmarshalBinaryBare(bz, &stdTx)
// TODO: switch to UnmarshalBinaryBare on SDK v0.40.0
err := cliCtx.Codec.UnmarshalBinaryLengthPrefixed(bz, &stdTx)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
}
@ -932,8 +929,7 @@ func (e *PublicEthAPI) generateFromArgs(args params.SendTxArgs) (*evmtypes.MsgEt
if args.Nonce == nil {
// Get nonce (sequence) from account
from := sdk.AccAddress(args.From.Bytes())
authclient.Codec = codec.NewAppCodec(e.cliCtx.Codec)
accRet := authtypes.NewAccountRetriever(authclient.Codec, e.cliCtx)
accRet := authtypes.NewAccountRetriever(e.cliCtx)
err = accRet.EnsureExists(from)
if err != nil {

View File

@ -11,7 +11,7 @@ import (
sdkcontext "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
emintcrypto "github.com/cosmos/ethermint/crypto"
params "github.com/cosmos/ethermint/rpc/args"
@ -29,7 +29,7 @@ type PersonalEthAPI struct {
ethAPI *PublicEthAPI
nonceLock *AddrLocker
keys []emintcrypto.PrivKeySecp256k1
keyInfos []keyring.Info
keyInfos []keys.Info
keybaseLock sync.Mutex
}
@ -51,12 +51,12 @@ func NewPersonalEthAPI(cliCtx sdkcontext.CLIContext, ethAPI *PublicEthAPI, nonce
return api
}
func (e *PersonalEthAPI) getKeybaseInfo() ([]keyring.Info, error) {
func (e *PersonalEthAPI) getKeybaseInfo() ([]keys.Info, error) {
e.keybaseLock.Lock()
defer e.keybaseLock.Unlock()
if e.cliCtx.Keybase == nil {
keybase, err := keyring.NewKeyring(
keybase, err := keys.NewKeyring(
sdk.KeyringServiceName(),
viper.GetString(flags.FlagKeyringBackend),
viper.GetString(flags.FlagHome),
@ -75,7 +75,7 @@ func (e *PersonalEthAPI) getKeybaseInfo() ([]keyring.Info, error) {
// ImportRawKey stores the given hex encoded ECDSA key into the key directory,
// encrypting it with the passphrase.
// Currently, this is not implemented since the feature is not supported by the keyring.
// Currently, this is not implemented since the feature is not supported by the keys.
func (e *PersonalEthAPI) ImportRawKey(privkey, password string) (common.Address, error) {
_, err := crypto.HexToECDSA(privkey)
if err != nil {
@ -122,7 +122,7 @@ func (e *PersonalEthAPI) NewAccount(password string) (common.Address, error) {
}
name := "key_" + time.Now().UTC().Format(time.RFC3339)
info, _, err := e.cliCtx.Keybase.CreateMnemonic(name, keyring.English, password, emintcrypto.EthSecp256k1)
info, _, err := e.cliCtx.Keybase.CreateMnemonic(name, keys.English, password, emintcrypto.EthSecp256k1)
if err != nil {
return common.Address{}, err
}

View File

@ -313,7 +313,7 @@ func TestEth_GetBalance(t *testing.T) {
func TestEth_GetStorageAt(t *testing.T) {
expectedRes := hexutil.Bytes{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
rpcRes := call(t, "eth_getStorageAt", []string{addrA, string(addrAStoreKey), zeroString})
rpcRes := call(t, "eth_getStorageAt", []string{addrA, fmt.Sprint(addrAStoreKey), zeroString})
var storage hexutil.Bytes
err := storage.UnmarshalJSON(rpcRes.Result)
@ -327,7 +327,7 @@ func TestEth_GetStorageAt(t *testing.T) {
func TestEth_GetProof(t *testing.T) {
params := make([]interface{}, 3)
params[0] = addrA
params[1] = []string{string(addrAStoreKey)}
params[1] = []string{fmt.Sprint(addrAStoreKey)}
params[2] = "latest"
rpcRes := call(t, "eth_getProof", params)
require.NotNil(t, rpcRes)
@ -756,7 +756,7 @@ func TestEth_EstimateGas(t *testing.T) {
err := json.Unmarshal(rpcRes.Result, &gas)
require.NoError(t, err)
require.Equal(t, hexutil.Bytes{0xf7, 0xa3}, gas)
require.Equal(t, "0xffac", gas.String())
}
func TestEth_EstimateGas_ContractDeployment(t *testing.T) {

View File

@ -1,10 +0,0 @@
syntax = "proto3";
package cosmos_proto;
import "google/protobuf/descriptor.proto";
option go_package = "github.com/regen-network/cosmos-proto";
extend google.protobuf.MessageOptions {
string interface_type = 93001;
}

View File

@ -1,80 +0,0 @@
syntax = "proto3";
package cosmos_sdk.v1;
import "third_party/proto/gogoproto/gogo.proto";
import "third_party/proto/tendermint/abci/types/types.proto";
option go_package = "github.com/cosmos/cosmos-sdk/types";
option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.stringer_all) = false;
// Coin defines a token with a denomination and an amount.
//
// NOTE: The amount field is an Int which implements the custom method
// signatures required by gogoproto.
message Coin {
option (gogoproto.equal) = true;
string denom = 1;
string amount = 2 [(gogoproto.customtype) = "Int", (gogoproto.nullable) = false];
}
// DecCoin defines a token with a denomination and a decimal amount.
//
// NOTE: The amount field is an Dec which implements the custom method
// signatures required by gogoproto.
message DecCoin {
option (gogoproto.equal) = true;
string denom = 1;
string amount = 2 [(gogoproto.customtype) = "Dec", (gogoproto.nullable) = false];
}
// IntProto defines a Protobuf wrapper around an Int object.
message IntProto {
string int = 1 [(gogoproto.customtype) = "Int", (gogoproto.nullable) = false];
}
// DecProto defines a Protobuf wrapper around a Dec object.
message DecProto {
string dec = 1 [(gogoproto.customtype) = "Dec", (gogoproto.nullable) = false];
}
// ValAddresses defines a repeated set of validator addresses.
message ValAddresses {
option (gogoproto.stringer) = true;
repeated bytes addresses = 1 [(gogoproto.casttype) = "ValAddress"];
}
// GasInfo defines tx execution gas context.
message GasInfo {
// GasWanted is the maximum units of work we allow this tx to perform.
uint64 gas_wanted = 1 [(gogoproto.moretags) = "yaml:\"gas_wanted\""];
// GasUsed is the amount of gas actually consumed.
uint64 gas_used = 2 [(gogoproto.moretags) = "yaml:\"gas_used\""];
}
// Result is the union of ResponseFormat and ResponseCheckTx.
message Result {
option (gogoproto.goproto_getters) = false;
// Data is any data returned from message or handler execution. It MUST be length
// prefixed in order to separate data from multiple message executions.
bytes data = 1;
// Log contains the log information from message or handler execution.
string log = 2;
// Events contains a slice of Event objects that were emitted during message or
// handler execution.
repeated tendermint.abci.types.Event events = 3 [(gogoproto.nullable) = false];
}
// SimulationResponse defines the response generated when a transaction is
// successfully simulated.
message SimulationResponse {
GasInfo gas_info = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
Result result = 2;
}

View File

@ -1,73 +0,0 @@
syntax = "proto3";
package cosmos_sdk.x.auth.v1;
import "third_party/proto/gogoproto/gogo.proto";
import "third_party/proto/cosmos-sdk/types/types.proto";
option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types";
// BaseAccount defines a base account type. It contains all the necessary fields
// for basic account functionality. Any custom account type should extend this
// type for additional functionality (e.g. vesting).
message BaseAccount {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
bytes pub_key = 2 [(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\""];
uint64 account_number = 3 [(gogoproto.moretags) = "yaml:\"account_number\""];
uint64 sequence = 4;
}
// StdFee includes the amount of coins paid in fees and the maximum
// gas to be used by the transaction. The ratio yields an effective "gasprice",
// which must be above some miminum to be accepted into the mempool.
message StdFee {
option (gogoproto.goproto_getters) = false;
option (gogoproto.equal) = true;
repeated cosmos_sdk.v1.Coin amount = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
uint64 gas = 2;
}
// StdSignature defines a signature structure that contains the signature of a
// transaction and an optional public key.
message StdSignature {
option (gogoproto.goproto_getters) = false;
bytes pub_key = 1 [(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\""];
bytes signature = 2;
}
// Params defines the parameters for the auth module.
message Params {
option (gogoproto.equal) = true;
option (gogoproto.goproto_stringer) = false;
uint64 max_memo_characters = 1 [(gogoproto.moretags) = "yaml:\"max_memo_characters\""];
uint64 tx_sig_limit = 2 [(gogoproto.moretags) = "yaml:\"tx_sig_limit\""];
uint64 tx_size_cost_per_byte = 3 [(gogoproto.moretags) = "yaml:\"tx_size_cost_per_byte\""];
uint64 sig_verify_cost_ed25519 = 4
[(gogoproto.customname) = "SigVerifyCostED25519", (gogoproto.moretags) = "yaml:\"sig_verify_cost_ed25519\""];
uint64 sig_verify_cost_secp256k1 = 5
[(gogoproto.customname) = "SigVerifyCostSecp256k1", (gogoproto.moretags) = "yaml:\"sig_verify_cost_secp256k1\""];
}
// StdTxBase defines a transaction base which application-level concrete transaction
// types can extend.
message StdTxBase {
StdFee fee = 1 [(gogoproto.nullable) = false];
repeated StdSignature signatures = 2 [(gogoproto.nullable) = false];
string memo = 3;
}
// StdSignDocBase defines the base structure for which applications can extend
// to define the concrete structure that signers sign over.
message StdSignDocBase {
string chain_id = 1 [(gogoproto.customname) = "ChainID", (gogoproto.moretags) = "yaml:\"chain_id\""];
uint64 account_number = 2 [(gogoproto.moretags) = "yaml:\"account_number\""];
uint64 sequence = 3;
string memo = 4;
StdFee fee = 5 [(gogoproto.nullable) = false];
}

View File

@ -1,76 +0,0 @@
syntax = "proto3";
package cosmos_sdk.x.auth.vesting.v1;
import "third_party/proto/gogoproto/gogo.proto";
import "third_party/proto/cosmos-sdk/types/types.proto";
import "third_party/proto/cosmos-sdk/x/auth/types/types.proto";
option go_package = "github.com/cosmos/cosmos-sdk/x/auth/vesting/types";
// BaseVestingAccount implements the VestingAccount interface. It contains all
// the necessary fields needed for any vesting account implementation.
message BaseVestingAccount {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
cosmos_sdk.x.auth.v1.BaseAccount base_account = 1 [(gogoproto.embed) = true];
repeated cosmos_sdk.v1.Coin original_vesting = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "yaml:\"original_vesting\""
];
repeated cosmos_sdk.v1.Coin delegated_free = 3 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "yaml:\"delegated_free\""
];
repeated cosmos_sdk.v1.Coin delegated_vesting = 4 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "yaml:\"delegated_vesting\""
];
int64 end_time = 5 [(gogoproto.moretags) = "yaml:\"end_time\""];
}
// ContinuousVestingAccount implements the VestingAccount interface. It
// continuously vests by unlocking coins linearly with respect to time.
message ContinuousVestingAccount {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true];
int64 start_time = 2 [(gogoproto.moretags) = "yaml:\"start_time\""];
}
// DelayedVestingAccount implements the VestingAccount interface. It vests all
// coins after a specific time, but non prior. In other words, it keeps them
// locked until a specified time.
message DelayedVestingAccount {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true];
}
// Period defines a length of time and amount of coins that will vest
message Period {
option (gogoproto.goproto_stringer) = false;
int64 length = 1;
repeated cosmos_sdk.v1.Coin amount = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}
// PeriodicVestingAccount implements the VestingAccount interface. It
// periodically vests by unlocking coins during each specified period
message PeriodicVestingAccount {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true];
int64 start_time = 2 [(gogoproto.moretags) = "yaml:\"start_time\""];
repeated Period vesting_periods = 3
[(gogoproto.moretags) = "yaml:\"vesting_periods\"", (gogoproto.nullable) = false];
}

View File

@ -1,32 +0,0 @@
syntax = "proto3";
package cosmos_sdk.x.supply.v1;
import "third_party/proto/gogoproto/gogo.proto";
import "third_party/proto/cosmos-sdk/types/types.proto";
import "third_party/proto/cosmos-sdk/x/auth/types/types.proto";
option go_package = "github.com/cosmos/cosmos-sdk/x/supply/types";
// ModuleAccount defines an account for modules that holds coins on a pool
message ModuleAccount {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
cosmos_sdk.x.auth.v1.BaseAccount base_account = 1
[(gogoproto.embed) = true, (gogoproto.moretags) = "yaml:\"base_account\""];
string name = 2;
repeated string permissions = 3;
}
// Supply represents a struct that passively keeps track of the total supply
// amounts in the network.
message Supply {
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
repeated cosmos_sdk.v1.Coin total = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

View File

@ -1,145 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package gogoproto;
import "google/protobuf/descriptor.proto";
option java_package = "com.google.protobuf";
option java_outer_classname = "GoGoProtos";
option go_package = "github.com/gogo/protobuf/gogoproto";
extend google.protobuf.EnumOptions {
optional bool goproto_enum_prefix = 62001;
optional bool goproto_enum_stringer = 62021;
optional bool enum_stringer = 62022;
optional string enum_customname = 62023;
optional bool enumdecl = 62024;
}
extend google.protobuf.EnumValueOptions {
optional string enumvalue_customname = 66001;
}
extend google.protobuf.FileOptions {
optional bool goproto_getters_all = 63001;
optional bool goproto_enum_prefix_all = 63002;
optional bool goproto_stringer_all = 63003;
optional bool verbose_equal_all = 63004;
optional bool face_all = 63005;
optional bool gostring_all = 63006;
optional bool populate_all = 63007;
optional bool stringer_all = 63008;
optional bool onlyone_all = 63009;
optional bool equal_all = 63013;
optional bool description_all = 63014;
optional bool testgen_all = 63015;
optional bool benchgen_all = 63016;
optional bool marshaler_all = 63017;
optional bool unmarshaler_all = 63018;
optional bool stable_marshaler_all = 63019;
optional bool sizer_all = 63020;
optional bool goproto_enum_stringer_all = 63021;
optional bool enum_stringer_all = 63022;
optional bool unsafe_marshaler_all = 63023;
optional bool unsafe_unmarshaler_all = 63024;
optional bool goproto_extensions_map_all = 63025;
optional bool goproto_unrecognized_all = 63026;
optional bool gogoproto_import = 63027;
optional bool protosizer_all = 63028;
optional bool compare_all = 63029;
optional bool typedecl_all = 63030;
optional bool enumdecl_all = 63031;
optional bool goproto_registration = 63032;
optional bool messagename_all = 63033;
optional bool goproto_sizecache_all = 63034;
optional bool goproto_unkeyed_all = 63035;
}
extend google.protobuf.MessageOptions {
optional bool goproto_getters = 64001;
optional bool goproto_stringer = 64003;
optional bool verbose_equal = 64004;
optional bool face = 64005;
optional bool gostring = 64006;
optional bool populate = 64007;
optional bool stringer = 67008;
optional bool onlyone = 64009;
optional bool equal = 64013;
optional bool description = 64014;
optional bool testgen = 64015;
optional bool benchgen = 64016;
optional bool marshaler = 64017;
optional bool unmarshaler = 64018;
optional bool stable_marshaler = 64019;
optional bool sizer = 64020;
optional bool unsafe_marshaler = 64023;
optional bool unsafe_unmarshaler = 64024;
optional bool goproto_extensions_map = 64025;
optional bool goproto_unrecognized = 64026;
optional bool protosizer = 64028;
optional bool compare = 64029;
optional bool typedecl = 64030;
optional bool messagename = 64033;
optional bool goproto_sizecache = 64034;
optional bool goproto_unkeyed = 64035;
}
extend google.protobuf.FieldOptions {
optional bool nullable = 65001;
optional bool embed = 65002;
optional string customtype = 65003;
optional string customname = 65004;
optional string jsontag = 65005;
optional string moretags = 65006;
optional string casttype = 65007;
optional string castkey = 65008;
optional string castvalue = 65009;
optional bool stdtime = 65010;
optional bool stdduration = 65011;
optional bool wktpointer = 65012;
optional string castrepeated = 65013;
}

View File

@ -1,346 +0,0 @@
syntax = "proto3";
package tendermint.abci.types;
option go_package = "github.com/tendermint/tendermint/abci/types";
// For more information on gogo.proto, see:
// https://github.com/gogo/protobuf/blob/master/extensions.md
import "third_party/proto/gogoproto/gogo.proto";
import "third_party/proto/tendermint/crypto/merkle/merkle.proto";
import "third_party/proto/tendermint/libs/kv/types.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/duration.proto";
// This file is copied from http://github.com/tendermint/abci
// NOTE: When using custom types, mind the warnings.
// https://github.com/gogo/protobuf/blob/master/custom_types.md#warnings-and-issues
option (gogoproto.marshaler_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_registration) = true;
// Generate tests
option (gogoproto.populate_all) = true;
option (gogoproto.equal_all) = true;
option (gogoproto.testgen_all) = true;
//----------------------------------------
// Request types
message Request {
oneof value {
RequestEcho echo = 2;
RequestFlush flush = 3;
RequestInfo info = 4;
RequestSetOption set_option = 5;
RequestInitChain init_chain = 6;
RequestQuery query = 7;
RequestBeginBlock begin_block = 8;
RequestCheckTx check_tx = 9;
RequestDeliverTx deliver_tx = 19;
RequestEndBlock end_block = 11;
RequestCommit commit = 12;
}
}
message RequestEcho {
string message = 1;
}
message RequestFlush {}
message RequestInfo {
string version = 1;
uint64 block_version = 2;
uint64 p2p_version = 3;
}
// nondeterministic
message RequestSetOption {
string key = 1;
string value = 2;
}
message RequestInitChain {
google.protobuf.Timestamp time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
string chain_id = 2;
ConsensusParams consensus_params = 3;
repeated ValidatorUpdate validators = 4 [(gogoproto.nullable) = false];
bytes app_state_bytes = 5;
}
message RequestQuery {
bytes data = 1;
string path = 2;
int64 height = 3;
bool prove = 4;
}
message RequestBeginBlock {
bytes hash = 1;
Header header = 2 [(gogoproto.nullable) = false];
LastCommitInfo last_commit_info = 3 [(gogoproto.nullable) = false];
repeated Evidence byzantine_validators = 4 [(gogoproto.nullable) = false];
}
enum CheckTxType {
New = 0;
Recheck = 1;
}
message RequestCheckTx {
bytes tx = 1;
CheckTxType type = 2;
}
message RequestDeliverTx {
bytes tx = 1;
}
message RequestEndBlock {
int64 height = 1;
}
message RequestCommit {}
//----------------------------------------
// Response types
message Response {
oneof value {
ResponseException exception = 1;
ResponseEcho echo = 2;
ResponseFlush flush = 3;
ResponseInfo info = 4;
ResponseSetOption set_option = 5;
ResponseInitChain init_chain = 6;
ResponseQuery query = 7;
ResponseBeginBlock begin_block = 8;
ResponseCheckTx check_tx = 9;
ResponseDeliverTx deliver_tx = 10;
ResponseEndBlock end_block = 11;
ResponseCommit commit = 12;
}
}
// nondeterministic
message ResponseException {
string error = 1;
}
message ResponseEcho {
string message = 1;
}
message ResponseFlush {}
message ResponseInfo {
string data = 1;
string version = 2;
uint64 app_version = 3;
int64 last_block_height = 4;
bytes last_block_app_hash = 5;
}
// nondeterministic
message ResponseSetOption {
uint32 code = 1;
// bytes data = 2;
string log = 3;
string info = 4;
}
message ResponseInitChain {
ConsensusParams consensus_params = 1;
repeated ValidatorUpdate validators = 2 [(gogoproto.nullable) = false];
}
message ResponseQuery {
uint32 code = 1;
// bytes data = 2; // use "value" instead.
string log = 3; // nondeterministic
string info = 4; // nondeterministic
int64 index = 5;
bytes key = 6;
bytes value = 7;
tendermint.crypto.merkle.Proof proof = 8;
int64 height = 9;
string codespace = 10;
}
message ResponseBeginBlock {
repeated Event events = 1
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
}
message ResponseCheckTx {
uint32 code = 1;
bytes data = 2;
string log = 3; // nondeterministic
string info = 4; // nondeterministic
int64 gas_wanted = 5;
int64 gas_used = 6;
repeated Event events = 7
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
string codespace = 8;
}
message ResponseDeliverTx {
uint32 code = 1;
bytes data = 2;
string log = 3; // nondeterministic
string info = 4; // nondeterministic
int64 gas_wanted = 5;
int64 gas_used = 6;
repeated Event events = 7
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
string codespace = 8;
}
message ResponseEndBlock {
repeated ValidatorUpdate validator_updates = 1 [(gogoproto.nullable) = false];
ConsensusParams consensus_param_updates = 2;
repeated Event events = 3
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"];
}
message ResponseCommit {
// reserve 1
bytes data = 2;
}
//----------------------------------------
// Misc.
// ConsensusParams contains all consensus-relevant parameters
// that can be adjusted by the abci app
message ConsensusParams {
BlockParams block = 1;
EvidenceParams evidence = 2;
ValidatorParams validator = 3;
}
// BlockParams contains limits on the block size.
message BlockParams {
// Note: must be greater than 0
int64 max_bytes = 1;
// Note: must be greater or equal to -1
int64 max_gas = 2;
}
message EvidenceParams {
// Note: must be greater than 0
int64 max_age_num_blocks = 1;
google.protobuf.Duration max_age_duration = 2
[(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
}
// ValidatorParams contains limits on validators.
message ValidatorParams {
repeated string pub_key_types = 1;
}
message LastCommitInfo {
int32 round = 1;
repeated VoteInfo votes = 2 [(gogoproto.nullable) = false];
}
message Event {
string type = 1;
repeated tendermint.libs.kv.Pair attributes = 2
[(gogoproto.nullable) = false, (gogoproto.jsontag) = "attributes,omitempty"];
}
//----------------------------------------
// Blockchain Types
message Header {
// basic block info
Version version = 1 [(gogoproto.nullable) = false];
string chain_id = 2 [(gogoproto.customname) = "ChainID"];
int64 height = 3;
google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
// prev block info
BlockID last_block_id = 5 [(gogoproto.nullable) = false];
// hashes of block data
bytes last_commit_hash = 6; // commit from validators from the last block
bytes data_hash = 7; // transactions
// hashes from the app output from the prev block
bytes validators_hash = 8; // validators for the current block
bytes next_validators_hash = 9; // validators for the next block
bytes consensus_hash = 10; // consensus params for current block
bytes app_hash = 11; // state after txs from the previous block
bytes last_results_hash = 12; // root hash of all results from the txs from the previous block
// consensus info
bytes evidence_hash = 13; // evidence included in the block
bytes proposer_address = 14; // original proposer of the block
}
message Version {
uint64 Block = 1;
uint64 App = 2;
}
message BlockID {
bytes hash = 1;
PartSetHeader parts_header = 2 [(gogoproto.nullable) = false];
}
message PartSetHeader {
int32 total = 1;
bytes hash = 2;
}
// Validator
message Validator {
bytes address = 1;
// PubKey pub_key = 2 [(gogoproto.nullable)=false];
int64 power = 3;
}
// ValidatorUpdate
message ValidatorUpdate {
PubKey pub_key = 1 [(gogoproto.nullable) = false];
int64 power = 2;
}
// VoteInfo
message VoteInfo {
Validator validator = 1 [(gogoproto.nullable) = false];
bool signed_last_block = 2;
}
message PubKey {
string type = 1;
bytes data = 2;
}
message Evidence {
string type = 1;
Validator validator = 2 [(gogoproto.nullable) = false];
int64 height = 3;
google.protobuf.Timestamp time = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
int64 total_voting_power = 5;
}
//----------------------------------------
// Service Definition
service ABCIApplication {
rpc Echo(RequestEcho) returns (ResponseEcho);
rpc Flush(RequestFlush) returns (ResponseFlush);
rpc Info(RequestInfo) returns (ResponseInfo);
rpc SetOption(RequestSetOption) returns (ResponseSetOption);
rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx);
rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx);
rpc Query(RequestQuery) returns (ResponseQuery);
rpc Commit(RequestCommit) returns (ResponseCommit);
rpc InitChain(RequestInitChain) returns (ResponseInitChain);
rpc BeginBlock(RequestBeginBlock) returns (ResponseBeginBlock);
rpc EndBlock(RequestEndBlock) returns (ResponseEndBlock);
}

View File

@ -1,31 +0,0 @@
syntax = "proto3";
package tendermint.crypto.merkle;
option go_package = "github.com/tendermint/tendermint/crypto/merkle";
// For more information on gogo.proto, see:
// https://github.com/gogo/protobuf/blob/master/extensions.md
import "third_party/proto/gogoproto/gogo.proto";
option (gogoproto.marshaler_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.populate_all) = true;
option (gogoproto.equal_all) = true;
//----------------------------------------
// Message types
// ProofOp defines an operation used for calculating Merkle root
// The data could be arbitrary format, providing nessecary data
// for example neighbouring node hash
message ProofOp {
string type = 1;
bytes key = 2;
bytes data = 3;
}
// Proof is Merkle proof defined by the list of ProofOps
message Proof {
repeated ProofOp ops = 1 [(gogoproto.nullable) = false];
}

View File

@ -1,22 +0,0 @@
syntax = "proto3";
package tendermint.libs.kv;
option go_package = "github.com/tendermint/tendermint/libs/kv";
import "third_party/proto/gogoproto/gogo.proto";
option (gogoproto.marshaler_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.goproto_registration) = true;
// Generate tests
option (gogoproto.populate_all) = true;
option (gogoproto.equal_all) = true;
option (gogoproto.testgen_all) = true;
//----------------------------------------
// Abstract types
message Pair {
bytes key = 1;
bytes value = 2;
}

View File

@ -2,6 +2,7 @@ package types
import (
"encoding/json"
"fmt"
"gopkg.in/yaml.v2"
@ -19,10 +20,21 @@ import (
var _ exported.Account = (*EthAccount)(nil)
var _ exported.GenesisAccount = (*EthAccount)(nil)
func init() {
authtypes.RegisterAccountTypeCodec(&EthAccount{}, EthAccountName)
}
// ----------------------------------------------------------------------------
// Main Ethermint account
// ----------------------------------------------------------------------------
// EthAccount implements the auth.Account interface and embeds an
// auth.BaseAccount type. It is compatible with the auth.AccountKeeper.
type EthAccount struct {
*authtypes.BaseAccount `json:"base_account" yaml:"base_account"`
CodeHash []byte `json:"code_hash" yaml:"code_hash"`
}
// ProtoAccount defines the prototype function for BaseAccount used for an
// AccountKeeper.
func ProtoAccount() exported.Account {
@ -32,6 +44,38 @@ func ProtoAccount() exported.Account {
}
}
// EthAddress returns the account address ethereum format.
func (acc EthAccount) EthAddress() ethcmn.Address {
return ethcmn.BytesToAddress(acc.Address.Bytes())
}
// TODO: remove on SDK v0.40
// Balance returns the balance of an account.
func (acc EthAccount) Balance() sdk.Int {
return acc.GetCoins().AmountOf(DenomDefault)
}
// SetBalance sets an account's balance of photons
func (acc *EthAccount) SetBalance(amt sdk.Int) {
coins := acc.GetCoins()
diff := amt.Sub(coins.AmountOf(DenomDefault))
switch {
case diff.IsPositive():
// Increase coins to amount
coins = coins.Add(sdk.NewCoin(DenomDefault, diff))
case diff.IsNegative():
// Decrease coins to amount
coins = coins.Sub(sdk.NewCoins(sdk.NewCoin(DenomDefault, diff.Neg())))
default:
return
}
if err := acc.SetCoins(coins); err != nil {
panic(fmt.Errorf("could not set coins for address %s: %w", acc.EthAddress().String(), err))
}
}
type ethermintAccountPretty struct {
Address sdk.AccAddress `json:"address" yaml:"address"`
Coins sdk.Coins `json:"coins" yaml:"coins"`
@ -45,12 +89,16 @@ type ethermintAccountPretty struct {
func (acc EthAccount) MarshalYAML() (interface{}, error) {
alias := ethermintAccountPretty{
Address: acc.Address,
PubKey: acc.PubKey,
Coins: acc.Coins,
AccountNumber: acc.AccountNumber,
Sequence: acc.Sequence,
CodeHash: ethcmn.Bytes2Hex(acc.CodeHash),
}
if acc.PubKey != nil {
alias.PubKey = acc.PubKey.Bytes()
}
bz, err := yaml.Marshal(alias)
if err != nil {
return nil, err
@ -63,12 +111,16 @@ func (acc EthAccount) MarshalYAML() (interface{}, error) {
func (acc EthAccount) MarshalJSON() ([]byte, error) {
alias := ethermintAccountPretty{
Address: acc.Address,
PubKey: acc.PubKey,
Coins: acc.Coins,
AccountNumber: acc.AccountNumber,
Sequence: acc.Sequence,
CodeHash: ethcmn.Bytes2Hex(acc.CodeHash),
}
if acc.PubKey != nil {
alias.PubKey = acc.PubKey.Bytes()
}
return json.Marshal(alias)
}
@ -81,14 +133,15 @@ func (acc *EthAccount) UnmarshalJSON(bz []byte) error {
}
if alias.PubKey != nil {
pubk, err := tmamino.PubKeyFromBytes(alias.PubKey)
pubKey, err := tmamino.PubKeyFromBytes(alias.PubKey)
if err != nil {
return err
}
acc.BaseAccount.PubKey = pubk.Bytes()
acc.BaseAccount.PubKey = pubKey
}
acc.BaseAccount.Coins = alias.Coins
acc.BaseAccount.Address = alias.Address
acc.BaseAccount.AccountNumber = alias.AccountNumber
acc.BaseAccount.Sequence = alias.Sequence

View File

@ -23,7 +23,8 @@ func init() {
func TestEthermintAccountJSON(t *testing.T) {
pubkey := secp256k1.GenPrivKey().PubKey()
addr := sdk.AccAddress(pubkey.Address())
baseAcc := auth.NewBaseAccount(addr, pubkey, 10, 50)
balance := sdk.NewCoins(sdk.NewCoin(DenomDefault, sdk.OneInt()))
baseAcc := auth.NewBaseAccount(addr, balance, pubkey, 10, 50)
ethAcc := EthAccount{BaseAccount: baseAcc, CodeHash: []byte{1, 2}}
bz, err := json.Marshal(ethAcc)

View File

@ -2,45 +2,15 @@ package types
import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/auth/exported"
)
const (
// Amino encoding name
EthermintAccountName = "ethermint/EthAccount"
// EthAccountName is the amino encoding name for EthAccount
EthAccountName = "ethermint/EthAccount"
)
// Codec defines the interface needed to serialize x/auth state. It must be
// aware of all concrete account types.
type Codec interface {
codec.Marshaler
MarshalAccount(acc exported.Account) ([]byte, error)
UnmarshalAccount(bz []byte) (exported.Account, error)
MarshalAccountJSON(acc exported.Account) ([]byte, error)
UnmarshalAccountJSON(bz []byte) (exported.Account, error)
}
// RegisterCodec registers the account interfaces and concrete types on the
// provided Amino codec.
func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterConcrete(&EthAccount{}, EthermintAccountName, nil)
}
var (
amino = codec.New()
// ModuleCdc references the global x/auth module codec. Note, the codec should
// ONLY be used in certain instances of tests and for JSON encoding as Amino is
// still used for that purpose.
//
// The actual codec used for serialization should be provided to x/auth and
// defined at the application level.
ModuleCdc = codec.NewHybridCodec(amino)
)
func init() {
RegisterCodec(amino)
codec.RegisterCrypto(amino)
cdc.RegisterConcrete(&EthAccount{}, EthAccountName, nil)
}

View File

@ -1,376 +0,0 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: types/types.proto
package types
import (
fmt "fmt"
types "github.com/cosmos/cosmos-sdk/x/auth/types"
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// EthAccount implements the auth.Account interface and embeds an
// auth.BaseAccount type. It is compatible with the auth.AccountKeeper.
type EthAccount struct {
*types.BaseAccount `protobuf:"bytes,1,opt,name=base_account,json=baseAccount,proto3,embedded=base_account" json:"base_account,omitempty" yaml:"base_account"`
CodeHash []byte `protobuf:"bytes,2,opt,name=code_hash,json=codeHash,proto3" json:"code_hash,omitempty" yaml:"code_hash"`
}
func (m *EthAccount) Reset() { *m = EthAccount{} }
func (*EthAccount) ProtoMessage() {}
func (*EthAccount) Descriptor() ([]byte, []int) {
return fileDescriptor_2c0f90c600ad7e2e, []int{0}
}
func (m *EthAccount) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *EthAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_EthAccount.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *EthAccount) XXX_Merge(src proto.Message) {
xxx_messageInfo_EthAccount.Merge(m, src)
}
func (m *EthAccount) XXX_Size() int {
return m.Size()
}
func (m *EthAccount) XXX_DiscardUnknown() {
xxx_messageInfo_EthAccount.DiscardUnknown(m)
}
var xxx_messageInfo_EthAccount proto.InternalMessageInfo
func init() {
proto.RegisterType((*EthAccount)(nil), "ethermint.v1.EthAccount")
}
func init() { proto.RegisterFile("types/types.proto", fileDescriptor_2c0f90c600ad7e2e) }
var fileDescriptor_2c0f90c600ad7e2e = []byte{
// 286 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0xa9, 0x2c, 0x48,
0x2d, 0xd6, 0x07, 0x93, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x3c, 0xa9, 0x25, 0x19, 0xa9,
0x45, 0xb9, 0x99, 0x79, 0x25, 0x7a, 0x65, 0x86, 0x52, 0x6a, 0x25, 0x19, 0x99, 0x45, 0x29, 0xf1,
0x05, 0x89, 0x45, 0x25, 0x95, 0xfa, 0x60, 0x05, 0xfa, 0xe9, 0xf9, 0xe9, 0xf9, 0x08, 0x16, 0x44,
0x97, 0x94, 0x29, 0xa6, 0xba, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, 0x62, 0xdd, 0xe2, 0x94, 0x6c, 0xfd,
0x0a, 0xfd, 0xc4, 0xd2, 0x92, 0x0c, 0x7d, 0x0c, 0xcb, 0x94, 0xd6, 0x30, 0x72, 0x71, 0xb9, 0x96,
0x64, 0x38, 0x26, 0x27, 0xe7, 0x97, 0xe6, 0x95, 0x08, 0x25, 0x72, 0xf1, 0x24, 0x25, 0x16, 0xa7,
0xc6, 0x27, 0x42, 0xf8, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x8a, 0x7a, 0x10, 0xa3, 0xe2,
0x8b, 0x53, 0xb2, 0xf5, 0x2a, 0xf4, 0x40, 0x46, 0xe9, 0x95, 0x19, 0xea, 0x39, 0x25, 0x16, 0xa7,
0x42, 0x35, 0x3a, 0x49, 0x5f, 0xb8, 0x27, 0xcf, 0xf8, 0xe9, 0x9e, 0xbc, 0x70, 0x65, 0x62, 0x6e,
0x8e, 0x95, 0x12, 0xb2, 0x21, 0x4a, 0x41, 0xdc, 0x49, 0x08, 0x95, 0x42, 0x86, 0x5c, 0x9c, 0xc9,
0xf9, 0x29, 0xa9, 0xf1, 0x19, 0x89, 0xc5, 0x19, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0x3c, 0x4e, 0x22,
0x9f, 0xee, 0xc9, 0x0b, 0x40, 0x34, 0xc2, 0xa5, 0x94, 0x82, 0x38, 0x40, 0x6c, 0x8f, 0xc4, 0xe2,
0x0c, 0x2b, 0x8e, 0x8e, 0x05, 0xf2, 0x0c, 0x33, 0x16, 0xc8, 0x33, 0x38, 0x59, 0x9f, 0x78, 0x24,
0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78,
0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x62, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e,
0x72, 0x7e, 0x2e, 0xd4, 0xe3, 0xfa, 0xf0, 0x70, 0x84, 0xf8, 0x38, 0x89, 0x0d, 0xec, 0x65, 0x63,
0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xf8, 0x1c, 0x15, 0x74, 0x01, 0x00, 0x00,
}
func (m *EthAccount) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *EthAccount) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *EthAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.CodeHash) > 0 {
i -= len(m.CodeHash)
copy(dAtA[i:], m.CodeHash)
i = encodeVarintTypes(dAtA, i, uint64(len(m.CodeHash)))
i--
dAtA[i] = 0x12
}
if m.BaseAccount != nil {
{
size, err := m.BaseAccount.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintTypes(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func encodeVarintTypes(dAtA []byte, offset int, v uint64) int {
offset -= sovTypes(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
}
func (m *EthAccount) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.BaseAccount != nil {
l = m.BaseAccount.Size()
n += 1 + l + sovTypes(uint64(l))
}
l = len(m.CodeHash)
if l > 0 {
n += 1 + l + sovTypes(uint64(l))
}
return n
}
func sovTypes(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozTypes(x uint64) (n int) {
return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *EthAccount) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: EthAccount: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: EthAccount: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field BaseAccount", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthTypes
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthTypes
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.BaseAccount == nil {
m.BaseAccount = &types.BaseAccount{}
}
if err := m.BaseAccount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field CodeHash", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthTypes
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthTypes
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.CodeHash = append(m.CodeHash[:0], dAtA[iNdEx:postIndex]...)
if m.CodeHash == nil {
m.CodeHash = []byte{}
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTypes(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthTypes
}
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthTypes
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipTypes(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
depth := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowTypes
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowTypes
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
case 1:
iNdEx += 8
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowTypes
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if length < 0 {
return 0, ErrInvalidLengthTypes
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroupTypes
}
depth--
case 5:
iNdEx += 4
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLengthTypes
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
}
var (
ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group")
)

View File

@ -26,7 +26,7 @@ func BeginBlock(k Keeper, ctx sdk.Context, req abci.RequestBeginBlock) {
// EndBlock updates the accounts and commits states objects to the KV Store.
//
func EndBlock(k Keeper, ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
func EndBlock(k Keeper, ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
// Gas costs are handled within msg handler so costs should be ignored
ctx = ctx.WithBlockGasMeter(sdk.NewInfiniteGasMeter())

View File

@ -19,16 +19,15 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client/utils"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
ethermintcodec "github.com/cosmos/ethermint/codec"
emint "github.com/cosmos/ethermint/types"
"github.com/cosmos/ethermint/x/evm/types"
)
// GetTxCmd defines the CLI commands regarding evm module transactions
func GetTxCmd(storeKey string, cdc *codec.Codec) *cobra.Command {
func GetTxCmd(cdc *codec.Codec) *cobra.Command {
evmTxCmd := &cobra.Command{
Use: types.ModuleName,
Short: "EVM transaction subcommands",
@ -83,8 +82,7 @@ func GetCmdSendTx(cdc *codec.Codec) *cobra.Command {
from := cliCtx.GetFromAddress()
authclient.Codec = ethermintcodec.NewAppCodec(cdc)
_, seq, err := authtypes.NewAccountRetriever(authclient.Codec, cliCtx).GetAccountNumberSequence(from)
_, seq, err := authtypes.NewAccountRetriever(cliCtx).GetAccountNumberSequence(from)
if err != nil {
return errors.Wrap(err, "Could not retrieve account sequence")
}
@ -136,8 +134,7 @@ func GetCmdGenCreateTx(cdc *codec.Codec) *cobra.Command {
from := cliCtx.GetFromAddress()
authclient.Codec = ethermintcodec.NewAppCodec(cdc)
_, seq, err := authtypes.NewAccountRetriever(authclient.Codec, cliCtx).GetAccountNumberSequence(from)
_, seq, err := authtypes.NewAccountRetriever(cliCtx).GetAccountNumberSequence(from)
if err != nil {
return errors.Wrap(err, "Could not retrieve account sequence")
}

View File

@ -1,8 +1,6 @@
package evm
import (
"github.com/ethereum/go-ethereum/common"
sdk "github.com/cosmos/cosmos-sdk/types"
emint "github.com/cosmos/ethermint/types"
@ -37,10 +35,12 @@ func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState) []abci.ValidatorU
}
// set storage to store
err = k.Finalise(ctx, true)
// NOTE: don't delete empty object to prevent import-export simulation failure
err = k.Finalise(ctx, false)
if err != nil {
panic(err)
}
return []abci.ValidatorUpdate{}
}
@ -50,20 +50,16 @@ func ExportGenesis(ctx sdk.Context, k Keeper, ak types.AccountKeeper) GenesisSta
var ethGenAccounts []types.GenesisAccount
accounts := ak.GetAllAccounts(ctx)
var err error
for _, account := range accounts {
ethAccount, ok := account.(*emint.EthAccount)
if !ok {
continue
}
addr := common.BytesToAddress(ethAccount.GetAddress().Bytes())
addr := ethAccount.EthAddress()
var storage types.Storage
err = k.CommitStateDB.ForEachStorage(addr, func(key, value common.Hash) bool {
storage = append(storage, types.NewState(key, value))
return false
})
storage, err := k.GetAccountStorage(ctx, addr)
if err != nil {
panic(err)
}

View File

@ -105,7 +105,7 @@ func handleMsgEthereumTx(ctx sdk.Context, k Keeper, msg types.MsgEthereumTx) (*s
}
// set the events to the result
executionResult.Result.Events = ctx.EventManager().Events().ToABCIEvents()
executionResult.Result.Events = ctx.EventManager().Events()
return executionResult.Result, nil
}
@ -181,6 +181,6 @@ func handleMsgEthermint(ctx sdk.Context, k Keeper, msg types.MsgEthermint) (*sdk
}
// set the events to the result
executionResult.Result.Events = ctx.EventManager().Events().ToABCIEvents()
executionResult.Result.Events = ctx.EventManager().Events()
return executionResult.Result, nil
}

View File

@ -13,7 +13,7 @@ import (
"github.com/cosmos/ethermint/x/evm/types"
ethcmn "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
)
@ -39,12 +39,12 @@ type Keeper struct {
// NewKeeper generates new evm module keeper
func NewKeeper(
cdc *codec.Codec, storeKey sdk.StoreKey, ak types.AccountKeeper, bk types.BankKeeper,
cdc *codec.Codec, storeKey sdk.StoreKey, ak types.AccountKeeper,
) Keeper {
return Keeper{
cdc: cdc,
storeKey: storeKey,
CommitStateDB: types.NewCommitStateDB(sdk.Context{}, storeKey, ak, bk),
CommitStateDB: types.NewCommitStateDB(sdk.Context{}, storeKey, ak),
TxCount: 0,
Bloom: big.NewInt(0),
}
@ -110,7 +110,7 @@ func (k Keeper) GetAllTxLogs(ctx sdk.Context) []types.TransactionLogs {
txsLogs := []types.TransactionLogs{}
for ; iterator.Valid(); iterator.Next() {
hash := ethcmn.BytesToHash(iterator.Key())
hash := common.BytesToHash(iterator.Key())
var logs []*ethtypes.Log
k.cdc.MustUnmarshalBinaryLengthPrefixed(iterator.Value(), &logs)
@ -120,3 +120,17 @@ func (k Keeper) GetAllTxLogs(ctx sdk.Context) []types.TransactionLogs {
}
return txsLogs
}
// GetAccountStorage return state storage associated with an account
func (k Keeper) GetAccountStorage(ctx sdk.Context, address common.Address) (types.Storage, error) {
storage := types.Storage{}
err := k.ForEachStorage(ctx, address, func(key, value common.Hash) bool {
storage = append(storage, types.NewState(key, value))
return false
})
if err != nil {
return types.Storage{}, err
}
return storage, nil
}

View File

@ -8,12 +8,15 @@ import (
"github.com/stretchr/testify/suite"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/ethermint/app"
ethermint "github.com/cosmos/ethermint/types"
"github.com/cosmos/ethermint/x/evm/keeper"
ethcmn "github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
ethcrypto "github.com/ethereum/go-ethereum/crypto"
abci "github.com/tendermint/tendermint/abci/types"
)
@ -41,6 +44,14 @@ func (suite *KeeperTestSuite) SetupTest() {
suite.ctx = suite.app.BaseApp.NewContext(checkTx, abci.Header{Height: 1, ChainID: "3", Time: time.Now().UTC()})
suite.querier = keeper.NewQuerier(suite.app.EvmKeeper)
suite.address = ethcmn.HexToAddress(addrHex)
balance := sdk.NewCoins(sdk.NewCoin(ethermint.DenomDefault, sdk.NewInt(0)))
acc := &ethermint.EthAccount{
BaseAccount: auth.NewBaseAccount(sdk.AccAddress(suite.address.Bytes()), balance, nil, 0, 0),
CodeHash: ethcrypto.Keccak256(nil),
}
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
}
func TestKeeperTestSuite(t *testing.T) {

View File

@ -52,6 +52,11 @@ func (k *Keeper) SetLogs(ctx sdk.Context, hash ethcmn.Hash, logs []*ethtypes.Log
return k.CommitStateDB.WithContext(ctx).SetLogs(hash, logs)
}
// DeleteLogs calls CommitStateDB.DeleteLogs using the passed in context
func (k *Keeper) DeleteLogs(ctx sdk.Context, hash ethcmn.Hash) {
k.CommitStateDB.WithContext(ctx).DeleteLogs(hash)
}
// AddLog calls CommitStateDB.AddLog using the passed in context
func (k *Keeper) AddLog(ctx sdk.Context, log *ethtypes.Log) {
k.CommitStateDB.WithContext(ctx).AddLog(log)

View File

@ -1,6 +1,7 @@
package keeper_test
import (
"fmt"
"math/big"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -11,6 +12,7 @@ import (
"github.com/cosmos/ethermint/crypto"
ethermint "github.com/cosmos/ethermint/types"
"github.com/cosmos/ethermint/x/evm/types"
)
func (suite *KeeperTestSuite) TestBloomFilter() {
@ -67,7 +69,7 @@ func (suite *KeeperTestSuite) TestBloomFilter() {
}
}
func (suite *KeeperTestSuite) TestStateDBBalance() {
func (suite *KeeperTestSuite) TestStateDB_Balance() {
testCase := []struct {
name string
malleate func()
@ -94,19 +96,11 @@ func (suite *KeeperTestSuite) TestStateDBBalance() {
},
big.NewInt(200),
},
{
"sub more than balance",
func() {
suite.app.EvmKeeper.SubBalance(suite.ctx, suite.address, big.NewInt(300))
},
big.NewInt(-100),
},
}
for _, tc := range testCase {
tc.malleate()
suite.Require().Equal(tc.balance, suite.app.EvmKeeper.GetBalance(suite.ctx, suite.address), tc.name)
}
}
@ -116,26 +110,90 @@ func (suite *KeeperTestSuite) TestStateDBNonce() {
suite.Require().Equal(nonce, suite.app.EvmKeeper.GetNonce(suite.ctx, suite.address))
}
func (suite *KeeperTestSuite) TestStateDBState() {
func (suite *KeeperTestSuite) TestStateDB_Error() {
nonce := suite.app.EvmKeeper.GetNonce(suite.ctx, ethcmn.Address{})
suite.Require().Equal(0, int(nonce))
suite.Require().Error(suite.app.EvmKeeper.Error(suite.ctx))
}
func (suite *KeeperTestSuite) TestStateDB_Database() {
suite.Require().Nil(suite.app.EvmKeeper.Database(suite.ctx))
}
func (suite *KeeperTestSuite) TestStateDB_State() {
key := ethcmn.BytesToHash([]byte("foo"))
val := ethcmn.BytesToHash([]byte("bar"))
suite.app.EvmKeeper.SetState(suite.ctx, suite.address, key, val)
suite.Require().Equal(val, suite.app.EvmKeeper.GetState(suite.ctx, suite.address, key))
testCase := []struct {
name string
address ethcmn.Address
key ethcmn.Hash
value ethcmn.Hash
}{
{
"found state",
suite.address,
ethcmn.BytesToHash([]byte("foo")),
ethcmn.BytesToHash([]byte("bar")),
},
{
"state not found",
suite.address,
ethcmn.BytesToHash([]byte("key")),
ethcmn.Hash{},
},
{
"object not found",
ethcmn.Address{},
ethcmn.BytesToHash([]byte("foo")),
ethcmn.Hash{},
},
}
for _, tc := range testCase {
value := suite.app.EvmKeeper.GetState(suite.ctx, tc.address, tc.key)
suite.Require().Equal(tc.value, value, tc.name)
}
}
func (suite *KeeperTestSuite) TestStateDBCode() {
code := []byte("foobar")
func (suite *KeeperTestSuite) TestStateDB_Code() {
testCase := []struct {
name string
address ethcmn.Address
code []byte
malleate func()
}{
{
"no stored code for state object",
suite.address,
nil,
func() {},
},
{
"existing address",
suite.address,
[]byte("code"),
func() {
suite.app.EvmKeeper.SetCode(suite.ctx, suite.address, []byte("code"))
},
},
{
"state object not found",
ethcmn.Address{},
nil,
func() {},
},
}
suite.app.EvmKeeper.SetCode(suite.ctx, suite.address, code)
for _, tc := range testCase {
tc.malleate()
suite.Require().Equal(code, suite.app.EvmKeeper.GetCode(suite.ctx, suite.address))
codelen := len(code)
suite.Require().Equal(codelen, suite.app.EvmKeeper.GetCodeSize(suite.ctx, suite.address))
suite.Require().Equal(tc.code, suite.app.EvmKeeper.GetCode(suite.ctx, tc.address), tc.name)
suite.Require().Equal(len(tc.code), suite.app.EvmKeeper.GetCodeSize(suite.ctx, tc.address), tc.name)
}
}
func (suite *KeeperTestSuite) TestStateDBLogs() {
func (suite *KeeperTestSuite) TestStateDB_Logs() {
testCase := []struct {
name string
log ethtypes.Log
@ -165,6 +223,13 @@ func (suite *KeeperTestSuite) TestStateDBLogs() {
dbLogs, err := suite.app.EvmKeeper.GetLogs(suite.ctx, hash)
suite.Require().NoError(err, tc.name)
suite.Require().Equal(logs, dbLogs, tc.name)
suite.app.EvmKeeper.DeleteLogs(suite.ctx, hash)
dbLogs, err = suite.app.EvmKeeper.GetLogs(suite.ctx, hash)
suite.Require().NoError(err, tc.name)
suite.Require().Empty(dbLogs, tc.name)
suite.app.EvmKeeper.AddLog(suite.ctx, &tc.log)
suite.Require().Equal(logs, suite.app.EvmKeeper.AllLogs(suite.ctx), tc.name)
//resets state but checking to see if storekey still persists.
@ -174,72 +239,122 @@ func (suite *KeeperTestSuite) TestStateDBLogs() {
}
}
func (suite *KeeperTestSuite) TestStateDBPreimage() {
func (suite *KeeperTestSuite) TestStateDB_Preimage() {
hash := ethcmn.BytesToHash([]byte("hash"))
preimage := []byte("preimage")
suite.app.EvmKeeper.AddPreimage(suite.ctx, hash, preimage)
suite.Require().Equal(preimage, suite.app.EvmKeeper.Preimages(suite.ctx)[hash])
}
func (suite *KeeperTestSuite) TestStateDBRefund() {
func (suite *KeeperTestSuite) TestStateDB_Refund() {
testCase := []struct {
name string
amount uint64
name string
addAmount uint64
subAmount uint64
expRefund uint64
expPanic bool
}{
{
"refund",
100,
"refund 0",
0, 0, 0,
false,
},
{
"refund positive amount",
100, 0, 100,
false,
},
{
"refund panic",
100, 200, 100,
true,
},
}
for _, tc := range testCase {
suite.app.EvmKeeper.AddRefund(suite.ctx, tc.amount)
suite.Require().Equal(tc.amount, suite.app.EvmKeeper.GetRefund(suite.ctx), tc.name)
suite.Run(tc.name, func() {
suite.SetupTest() // reset
suite.app.EvmKeeper.SubRefund(suite.ctx, tc.amount)
suite.Require().Equal(uint64(0), suite.app.EvmKeeper.GetRefund(suite.ctx), tc.name)
suite.app.EvmKeeper.AddRefund(suite.ctx, tc.addAmount)
suite.Require().Equal(tc.addAmount, suite.app.EvmKeeper.GetRefund(suite.ctx))
if tc.expPanic {
suite.Panics(func() {
suite.app.EvmKeeper.SubRefund(suite.ctx, tc.subAmount)
})
} else {
suite.app.EvmKeeper.SubRefund(suite.ctx, tc.subAmount)
suite.Require().Equal(tc.expRefund, suite.app.EvmKeeper.GetRefund(suite.ctx))
}
})
}
}
func (suite *KeeperTestSuite) TestStateDBCreateAcct() {
suite.app.EvmKeeper.CreateAccount(suite.ctx, suite.address)
suite.Require().True(suite.app.EvmKeeper.Exist(suite.ctx, suite.address))
func (suite *KeeperTestSuite) TestStateDB_CreateAccount() {
prevBalance := big.NewInt(12)
value := big.NewInt(100)
suite.app.EvmKeeper.AddBalance(suite.ctx, suite.address, value)
testCase := []struct {
name string
address ethcmn.Address
malleate func()
}{
{
"existing account",
suite.address,
func() {
suite.app.EvmKeeper.AddBalance(suite.ctx, suite.address, prevBalance)
},
},
{
"new account",
ethcmn.HexToAddress("0x756F45E3FA69347A9A973A725E3C98bC4db0b4c1"),
func() {
prevBalance = big.NewInt(0)
},
},
}
suite.app.EvmKeeper.CreateAccount(suite.ctx, suite.address)
suite.Require().Equal(value, suite.app.EvmKeeper.GetBalance(suite.ctx, suite.address))
for _, tc := range testCase {
suite.Run(tc.name, func() {
suite.SetupTest() // reset
tc.malleate()
suite.app.EvmKeeper.CreateAccount(suite.ctx, tc.address)
suite.Require().True(suite.app.EvmKeeper.Exist(suite.ctx, tc.address))
suite.Require().Equal(prevBalance, suite.app.EvmKeeper.GetBalance(suite.ctx, tc.address))
})
}
}
func (suite *KeeperTestSuite) TestStateDBClearStateOjb() {
func (suite *KeeperTestSuite) TestStateDB_ClearStateObj() {
priv, err := crypto.GenerateKey()
suite.Require().NoError(err)
suite.app.EvmKeeper.CreateAccount(suite.ctx, suite.address)
suite.Require().True(suite.app.EvmKeeper.Exist(suite.ctx, suite.address))
addr := ethcrypto.PubkeyToAddress(priv.ToECDSA().PublicKey)
suite.app.EvmKeeper.CreateAccount(suite.ctx, addr)
suite.Require().True(suite.app.EvmKeeper.Exist(suite.ctx, addr))
suite.app.EvmKeeper.ClearStateObjects(suite.ctx)
suite.Require().False(suite.app.EvmKeeper.Exist(suite.ctx, suite.address))
suite.Require().False(suite.app.EvmKeeper.Exist(suite.ctx, addr))
}
func (suite *KeeperTestSuite) TestStateDBReset() {
hash := ethcmn.BytesToHash([]byte("hash"))
suite.app.EvmKeeper.CreateAccount(suite.ctx, suite.address)
suite.Require().True(suite.app.EvmKeeper.Exist(suite.ctx, suite.address))
err := suite.app.EvmKeeper.Reset(suite.ctx, hash)
func (suite *KeeperTestSuite) TestStateDB_Reset() {
priv, err := crypto.GenerateKey()
suite.Require().NoError(err)
suite.Require().False(suite.app.EvmKeeper.Exist(suite.ctx, suite.address))
addr := ethcrypto.PubkeyToAddress(priv.ToECDSA().PublicKey)
suite.app.EvmKeeper.CreateAccount(suite.ctx, addr)
suite.Require().True(suite.app.EvmKeeper.Exist(suite.ctx, addr))
err = suite.app.EvmKeeper.Reset(suite.ctx, ethcmn.BytesToHash(nil))
suite.Require().NoError(err)
suite.Require().False(suite.app.EvmKeeper.Exist(suite.ctx, addr))
}
func (suite *KeeperTestSuite) TestStateDBUpdateAcct() {
}
func (suite *KeeperTestSuite) TestSuiteDBPrepare() {
func (suite *KeeperTestSuite) TestSuiteDB_Prepare() {
thash := ethcmn.BytesToHash([]byte("thash"))
bhash := ethcmn.BytesToHash([]byte("bhash"))
txi := 1
@ -248,24 +363,49 @@ func (suite *KeeperTestSuite) TestSuiteDBPrepare() {
suite.Require().Equal(txi, suite.app.EvmKeeper.TxIndex(suite.ctx))
suite.Require().Equal(bhash, suite.app.EvmKeeper.BlockHash(suite.ctx))
}
func (suite *KeeperTestSuite) TestSuiteDBCopyState() {
copyDB := suite.app.EvmKeeper.Copy(suite.ctx)
suite.Require().Equal(suite.app.EvmKeeper.Exist(suite.ctx, suite.address), copyDB.Exist(suite.address))
func (suite *KeeperTestSuite) TestSuiteDB_CopyState() {
testCase := []struct {
name string
log ethtypes.Log
}{
{
"copy state",
ethtypes.Log{
Address: suite.address,
Topics: []ethcmn.Hash{ethcmn.BytesToHash([]byte("topic"))},
Data: []byte("data"),
BlockNumber: 1,
TxHash: ethcmn.Hash{},
TxIndex: 1,
BlockHash: ethcmn.Hash{},
Index: 1,
Removed: false,
},
},
}
for _, tc := range testCase {
hash := ethcmn.BytesToHash([]byte("hash"))
logs := []*ethtypes.Log{&tc.log}
err := suite.app.EvmKeeper.SetLogs(suite.ctx, hash, logs)
suite.Require().NoError(err, tc.name)
copyDB := suite.app.EvmKeeper.Copy(suite.ctx)
suite.Require().Equal(suite.app.EvmKeeper.Exist(suite.ctx, suite.address), copyDB.Exist(suite.address), tc.name)
}
}
func (suite *KeeperTestSuite) TestSuiteDBEmpty() {
func (suite *KeeperTestSuite) TestSuiteDB_Empty() {
suite.Require().True(suite.app.EvmKeeper.Empty(suite.ctx, suite.address))
suite.app.EvmKeeper.SetBalance(suite.ctx, suite.address, big.NewInt(100))
suite.Require().False(suite.app.EvmKeeper.Empty(suite.ctx, suite.address))
}
func (suite *KeeperTestSuite) TestSuiteDBSuicide() {
func (suite *KeeperTestSuite) TestSuiteDB_Suicide() {
testCase := []struct {
name string
amount *big.Int
@ -316,7 +456,6 @@ func (suite *KeeperTestSuite) TestSuiteDBSuicide() {
}
func (suite *KeeperTestSuite) TestCommitStateDB_Commit() {
suite.app.EvmKeeper.AddBalance(suite.ctx, suite.address, big.NewInt(100))
testCase := []struct {
name string
malleate func()
@ -338,13 +477,6 @@ func (suite *KeeperTestSuite) TestCommitStateDB_Commit() {
},
false, true,
},
{
"faled to update state object",
func() {
suite.app.EvmKeeper.SubBalance(suite.ctx, suite.address, big.NewInt(10))
},
false, false,
},
}
for _, tc := range testCase {
@ -374,7 +506,6 @@ func (suite *KeeperTestSuite) TestCommitStateDB_Commit() {
}
func (suite *KeeperTestSuite) TestCommitStateDB_Finalize() {
suite.app.EvmKeeper.AddBalance(suite.ctx, suite.address, big.NewInt(100))
testCase := []struct {
name string
malleate func()
@ -403,13 +534,6 @@ func (suite *KeeperTestSuite) TestCommitStateDB_Finalize() {
},
false, true,
},
{
"faled to update state object",
func() {
suite.app.EvmKeeper.SubBalance(suite.ctx, suite.address, big.NewInt(10))
},
false, false,
},
}
for _, tc := range testCase {
@ -419,6 +543,8 @@ func (suite *KeeperTestSuite) TestCommitStateDB_Finalize() {
if !tc.expPass {
suite.Require().Error(err, tc.name)
hash := suite.app.EvmKeeper.GetCommittedState(suite.ctx, suite.address, ethcmn.BytesToHash([]byte("key")))
suite.Require().NotEqual(ethcmn.Hash{}, hash, tc.name)
continue
}
@ -433,3 +559,86 @@ func (suite *KeeperTestSuite) TestCommitStateDB_Finalize() {
suite.Require().NotNil(acc, tc.name)
}
}
func (suite *KeeperTestSuite) TestCommitStateDB_GetCommittedState() {
hash := suite.app.EvmKeeper.GetCommittedState(suite.ctx, ethcmn.Address{}, ethcmn.BytesToHash([]byte("key")))
suite.Require().Equal(ethcmn.Hash{}, hash)
}
func (suite *KeeperTestSuite) TestCommitStateDB_Snapshot() {
id := suite.app.EvmKeeper.Snapshot(suite.ctx)
suite.Require().NotPanics(func() {
suite.app.EvmKeeper.RevertToSnapshot(suite.ctx, id)
})
suite.Require().Panics(func() {
suite.app.EvmKeeper.RevertToSnapshot(suite.ctx, -1)
}, "invalid revision should panic")
}
func (suite *KeeperTestSuite) TestCommitStateDB_ForEachStorage() {
var storage types.Storage
testCase := []struct {
name string
malleate func()
callback func(key, value ethcmn.Hash) (stop bool)
expValues []ethcmn.Hash
}{
{
"aggregate state",
func() {
for i := 0; i < 5; i++ {
suite.app.EvmKeeper.SetState(suite.ctx, suite.address, ethcmn.BytesToHash([]byte(fmt.Sprintf("key%d", i))), ethcmn.BytesToHash([]byte(fmt.Sprintf("value%d", i))))
}
},
func(key, value ethcmn.Hash) bool {
storage = append(storage, types.NewState(key, value))
return false
},
[]ethcmn.Hash{
ethcmn.BytesToHash([]byte("value0")),
ethcmn.BytesToHash([]byte("value1")),
ethcmn.BytesToHash([]byte("value2")),
ethcmn.BytesToHash([]byte("value3")),
ethcmn.BytesToHash([]byte("value4")),
},
},
{
"filter state",
func() {
suite.app.EvmKeeper.SetState(suite.ctx, suite.address, ethcmn.BytesToHash([]byte("key")), ethcmn.BytesToHash([]byte("value")))
suite.app.EvmKeeper.SetState(suite.ctx, suite.address, ethcmn.BytesToHash([]byte("filterkey")), ethcmn.BytesToHash([]byte("filtervalue")))
},
func(key, value ethcmn.Hash) bool {
if value == ethcmn.BytesToHash([]byte("filtervalue")) {
storage = append(storage, types.NewState(key, value))
return true
}
return false
},
[]ethcmn.Hash{
ethcmn.BytesToHash([]byte("filtervalue")),
},
},
}
for _, tc := range testCase {
suite.Run(tc.name, func() {
suite.SetupTest() // reset
tc.malleate()
suite.app.EvmKeeper.Finalise(suite.ctx, false)
err := suite.app.EvmKeeper.ForEachStorage(suite.ctx, suite.address, tc.callback)
suite.Require().NoError(err)
suite.Require().Equal(len(tc.expValues), len(storage), fmt.Sprintf("Expected values:\n%v\nStorage Values\n%v", tc.expValues, storage))
vals := make([]ethcmn.Hash, len(storage))
for i := range storage {
vals[i] = storage[i].Value
}
suite.Require().ElementsMatch(tc.expValues, vals)
})
storage = types.Storage{}
}
}

View File

@ -35,14 +35,14 @@ func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {
}
// DefaultGenesis is json default structure
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage {
return cdc.MustMarshalJSON(types.DefaultGenesisState())
func (AppModuleBasic) DefaultGenesis() json.RawMessage {
return types.ModuleCdc.MustMarshalJSON(types.DefaultGenesisState())
}
// ValidateGenesis is the validation check of the Genesis
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, bz json.RawMessage) error {
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
var genesisState types.GenesisState
err := cdc.UnmarshalJSON(bz, &genesisState)
err := types.ModuleCdc.UnmarshalJSON(bz, &genesisState)
if err != nil {
return err
}
@ -62,7 +62,7 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command {
// GetTxCmd Gets the root tx command of this module
func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command {
return cli.GetTxCmd(types.ModuleName, cdc)
return cli.GetTxCmd(cdc)
}
//____________________________________________________________________________
@ -122,14 +122,14 @@ func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.V
}
// InitGenesis instantiates the genesis state
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, data json.RawMessage) []abci.ValidatorUpdate {
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate {
var genesisState types.GenesisState
cdc.MustUnmarshalJSON(data, &genesisState)
types.ModuleCdc.MustUnmarshalJSON(data, &genesisState)
return InitGenesis(ctx, am.keeper, genesisState)
}
// ExportGenesis exports the genesis state to be used by daemon
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONMarshaler) json.RawMessage {
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage {
gs := ExportGenesis(ctx, am.keeper, am.ak)
return cdc.MustMarshalJSON(gs)
return types.ModuleCdc.MustMarshalJSON(gs)
}

View File

@ -25,7 +25,7 @@ var testJSON = `{
func (suite *EvmTestSuite) TestInitGenesis() {
am := evm.NewAppModule(suite.app.EvmKeeper, suite.app.AccountKeeper)
in := json.RawMessage([]byte(testJSON))
_ = am.InitGenesis(suite.ctx, suite.codec, in)
_ = am.InitGenesis(suite.ctx, in)
testAddr := common.HexToAddress("0x2cc7fdf9fde6746731d7f11979609d455c2c197a")

View File

@ -13,9 +13,3 @@ type AccountKeeper interface {
SetAccount(ctx sdk.Context, account authexported.Account)
RemoveAccount(ctx sdk.Context, account authexported.Account)
}
// BankKeeper defines the expected interface needed to retrieve account balances.
type BankKeeper interface {
GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
SetBalance(ctx sdk.Context, addr sdk.AccAddress, balance sdk.Coin) error
}

View File

@ -14,14 +14,12 @@ import (
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/params"
ethcmn "github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
ethcrypto "github.com/ethereum/go-ethereum/crypto"
"github.com/cosmos/ethermint/codec"
"github.com/cosmos/ethermint/crypto"
ethermint "github.com/cosmos/ethermint/types"
)
@ -35,18 +33,17 @@ type JournalTestSuite struct {
stateDB *CommitStateDB
}
func newTestCodec() *codec.Codec {
func newTestCodec() *sdkcodec.Codec {
cdc := sdkcodec.New()
RegisterCodec(cdc)
sdk.RegisterCodec(cdc)
crypto.RegisterCodec(cdc)
sdkcodec.RegisterCrypto(cdc)
auth.RegisterCodec(cdc)
ethermint.RegisterCodec(cdc)
appCodec := codec.NewAppCodec(cdc)
return appCodec
return cdc
}
func (suite *JournalTestSuite) SetupTest() {
@ -58,13 +55,14 @@ func (suite *JournalTestSuite) SetupTest() {
suite.address = ethcmn.BytesToAddress(privkey.PubKey().Address().Bytes())
suite.journal = newJournal()
balance := sdk.NewCoins(sdk.NewCoin(ethermint.DenomDefault, sdk.NewInt(100)))
acc := &ethermint.EthAccount{
BaseAccount: auth.NewBaseAccount(sdk.AccAddress(suite.address.Bytes()), nil, 0, 0),
BaseAccount: auth.NewBaseAccount(sdk.AccAddress(suite.address.Bytes()), balance, nil, 0, 0),
CodeHash: ethcrypto.Keccak256(nil),
}
suite.stateDB.accountKeeper.SetAccount(suite.ctx, acc)
suite.stateDB.bankKeeper.SetBalance(suite.ctx, sdk.AccAddress(suite.address.Bytes()), sdk.NewCoin(ethermint.DenomDefault, sdk.NewInt(100)))
// suite.stateDB.bankKeeper.SetBalance(suite.ctx, sdk.AccAddress(suite.address.Bytes()), balance)
suite.stateDB.SetLogs(ethcmn.BytesToHash([]byte("txhash")), []*ethtypes.Log{
{
Address: suite.address,
@ -97,7 +95,7 @@ func (suite *JournalTestSuite) SetupTest() {
// to maintain consistency with the Geth implementation.
func (suite *JournalTestSuite) setup() {
authKey := sdk.NewKVStoreKey(auth.StoreKey)
bankKey := sdk.NewKVStoreKey(bank.StoreKey)
// bankKey := sdk.NewKVStoreKey(bank.StoreKey)
storeKey := sdk.NewKVStoreKey(StoreKey)
db := tmdb.NewDB("state", tmdb.GoLevelDBBackend, "temp")
@ -107,26 +105,24 @@ func (suite *JournalTestSuite) setup() {
cms := store.NewCommitMultiStore(db)
cms.MountStoreWithDB(authKey, sdk.StoreTypeIAVL, db)
cms.MountStoreWithDB(bankKey, sdk.StoreTypeIAVL, db)
// cms.MountStoreWithDB(bankKey, sdk.StoreTypeIAVL, db)
cms.MountStoreWithDB(storeKey, sdk.StoreTypeIAVL, db)
err := cms.LoadLatestVersion()
suite.Require().NoError(err)
appCodec := newTestCodec()
cdc := newTestCodec()
keyParams := sdk.NewKVStoreKey(params.StoreKey)
tkeyParams := sdk.NewTransientStoreKey(params.TStoreKey)
paramsKeeper := params.NewKeeper(appCodec, keyParams, tkeyParams)
paramsKeeper := params.NewKeeper(cdc, keyParams, tkeyParams)
authSubspace := paramsKeeper.Subspace(auth.DefaultParamspace)
bankSubspace := paramsKeeper.Subspace(bank.DefaultParamspace)
ak := auth.NewAccountKeeper(appCodec, authKey, authSubspace, ethermint.ProtoAccount)
bk := bank.NewBaseKeeper(appCodec, bankKey, ak, bankSubspace, nil)
ak := auth.NewAccountKeeper(cdc, authKey, authSubspace, ethermint.ProtoAccount)
suite.ctx = sdk.NewContext(cms, abci.Header{ChainID: "8"}, false, tmlog.NewNopLogger())
suite.stateDB = NewCommitStateDB(suite.ctx, storeKey, ak, bk).WithContext(suite.ctx)
suite.stateDB = NewCommitStateDB(suite.ctx, storeKey, ak).WithContext(suite.ctx)
}
func TestJournalTestSuite(t *testing.T) {
@ -149,7 +145,6 @@ func (suite *JournalTestSuite) TestJournal_append_revert() {
resetObjectChange{
prev: &stateObject{
address: suite.address,
balance: sdk.OneInt(),
},
},
},

View File

@ -46,7 +46,7 @@ type QueryResBlockNumber struct {
}
func (q QueryResBlockNumber) String() string {
return string(q.Number)
return fmt.Sprint(q.Number)
}
// QueryResStorage is response type for storage query
@ -73,7 +73,7 @@ type QueryResNonce struct {
}
func (q QueryResNonce) String() string {
return string(q.Nonce)
return fmt.Sprint(q.Nonce)
}
// QueryETHLogs is response type for tx logs query

View File

@ -65,7 +65,6 @@ type stateObject struct {
dbErr error
stateDB *CommitStateDB
account *types.EthAccount
balance sdk.Int
keyToOriginStorageIndex map[ethcmn.Hash]int
keyToDirtyStorageIndex map[ethcmn.Hash]int
@ -81,7 +80,8 @@ type stateObject struct {
deleted bool
}
func newStateObject(db *CommitStateDB, accProto authexported.Account, balance sdk.Int) *stateObject {
func newStateObject(db *CommitStateDB, accProto authexported.Account) *stateObject {
// func newStateObject(db *CommitStateDB, accProto authexported.Account, balance sdk.Int) *stateObject {
ethermintAccount, ok := accProto.(*types.EthAccount)
if !ok {
panic(fmt.Sprintf("invalid account type for state object: %T", accProto))
@ -95,8 +95,7 @@ func newStateObject(db *CommitStateDB, accProto authexported.Account, balance sd
return &stateObject{
stateDB: db,
account: ethermintAccount,
balance: balance,
address: ethcmn.BytesToAddress(ethermintAccount.GetAddress().Bytes()),
address: ethermintAccount.EthAddress(),
originStorage: Storage{},
dirtyStorage: Storage{},
keyToOriginStorageIndex: make(map[ethcmn.Hash]int),
@ -177,7 +176,8 @@ func (so *stateObject) AddBalance(amount *big.Int) {
return
}
newBalance := so.balance.Add(amt)
// newBalance := so.balance.Add(amt)
newBalance := so.account.GetCoins().AmountOf(types.DenomDefault).Add(amt)
so.SetBalance(newBalance.BigInt())
}
@ -188,7 +188,7 @@ func (so *stateObject) SubBalance(amount *big.Int) {
if amt.IsZero() {
return
}
newBalance := so.balance.Sub(amt)
newBalance := so.account.GetCoins().AmountOf(types.DenomDefault).Sub(amt)
so.SetBalance(newBalance.BigInt())
}
@ -198,14 +198,14 @@ func (so *stateObject) SetBalance(amount *big.Int) {
so.stateDB.journal.append(balanceChange{
account: &so.address,
prev: so.balance,
prev: so.account.GetCoins().AmountOf(types.DenomDefault),
})
so.setBalance(amt)
}
func (so *stateObject) setBalance(amount sdk.Int) {
so.balance = amount
so.account.SetBalance(amount)
}
// SetNonce sets the state object's nonce (i.e sequence number of the account).
@ -236,7 +236,8 @@ func (so *stateObject) markSuicided() {
so.suicided = true
}
// commitState commits all dirty storage to a KVStore.
// commitState commits all dirty storage to a KVStore and resets
// the dirty storage slice to the empty state.
func (so *stateObject) commitState() {
ctx := so.stateDB.ctx
store := prefix.NewStore(ctx.KVStore(so.stateDB.storeKey), AddressStoragePrefix(so.Address()))
@ -291,7 +292,7 @@ func (so stateObject) Address() ethcmn.Address {
// Balance returns the state object's current balance.
func (so *stateObject) Balance() *big.Int {
balance := so.balance.BigInt()
balance := so.account.Balance().BigInt()
if balance == nil {
return zeroBalance
}
@ -388,7 +389,7 @@ func (so *stateObject) GetCommittedState(_ ethstate.Database, key ethcmn.Hash) e
func (so *stateObject) ReturnGas(gas *big.Int) {}
func (so *stateObject) deepCopy(db *CommitStateDB) *stateObject {
newStateObj := newStateObject(db, so.account, so.balance)
newStateObj := newStateObject(db, so.account)
newStateObj.code = so.code
newStateObj.dirtyStorage = so.dirtyStorage.Copy()
@ -402,10 +403,11 @@ func (so *stateObject) deepCopy(db *CommitStateDB) *stateObject {
// empty returns whether the account is considered empty.
func (so *stateObject) empty() bool {
balace := so.account.Balance()
return so.account == nil ||
(so.account != nil &&
so.account.Sequence == 0 &&
(so.balance.BigInt() == nil || so.balance.IsZero()) &&
(balace.BigInt() == nil || balace.IsZero()) &&
bytes.Equal(so.account.CodeHash, emptyCodeHash))
}

View File

@ -108,7 +108,7 @@ func (st StateTransition) TransitionDb(ctx sdk.Context) (*ExecutionResult, error
return nil, errors.New("gas price cannot be nil")
}
evm := st.newEVM(ctx, csdb, gasLimit, gasPrice.BigInt())
evm := st.newEVM(ctx, csdb, gasLimit, gasPrice.Int)
var (
ret []byte

View File

@ -18,7 +18,9 @@ func (suite *StateDBTestSuite) TestTransitionDb() {
addr := sdk.AccAddress(suite.address.Bytes())
balance := sdk.NewCoin(ethermint.DenomDefault, sdk.NewInt(5000))
suite.app.BankKeeper.SetBalance(suite.ctx, addr, balance)
acc := suite.app.AccountKeeper.GetAccount(suite.ctx, addr)
_ = acc.SetCoins(sdk.NewCoins(balance))
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
priv, err := crypto.GenerateKey()
suite.Require().NoError(err)
@ -92,7 +94,7 @@ func (suite *StateDBTestSuite) TestTransitionDb() {
Price: big.NewInt(10),
GasLimit: 11,
Recipient: &recipient,
Amount: big.NewInt(4951),
Amount: big.NewInt(500000),
Payload: []byte("data"),
ChainID: big.NewInt(1),
Csdb: suite.stateDB,
@ -102,24 +104,6 @@ func (suite *StateDBTestSuite) TestTransitionDb() {
},
false,
},
{
"failed to Finalize",
func() {},
types.StateTransition{
AccountNonce: 123,
Price: big.NewInt(10),
GasLimit: 11,
Recipient: &recipient,
Amount: big.NewInt(-5000),
Payload: []byte("data"),
ChainID: big.NewInt(1),
Csdb: suite.stateDB,
TxHash: &ethcmn.Hash{},
Sender: suite.address,
Simulate: false,
},
false,
},
{
"nil gas price",
func() {

View File

@ -43,7 +43,6 @@ type CommitStateDB struct {
storeKey sdk.StoreKey
accountKeeper AccountKeeper
bankKeeper BankKeeper
// array that hold 'live' objects, which will get modified while processing a
// state transition
@ -87,13 +86,12 @@ type CommitStateDB struct {
// CONTRACT: Stores used for state must be cache-wrapped as the ordering of the
// key/value space matters in determining the merkle root.
func NewCommitStateDB(
ctx sdk.Context, storeKey sdk.StoreKey, ak AccountKeeper, bk BankKeeper,
ctx sdk.Context, storeKey sdk.StoreKey, ak AccountKeeper,
) *CommitStateDB {
return &CommitStateDB{
ctx: ctx,
storeKey: storeKey,
accountKeeper: ak,
bankKeeper: bk,
stateObjects: []stateEntry{},
addressToObjectIndex: make(map[ethcmn.Address]int),
stateObjectsDirty: make(map[ethcmn.Address]struct{}),
@ -484,13 +482,25 @@ func (csdb *CommitStateDB) IntermediateRoot(deleteEmptyObjects bool) (ethcmn.Has
// updateStateObject writes the given state object to the store.
func (csdb *CommitStateDB) updateStateObject(so *stateObject) error {
csdb.accountKeeper.SetAccount(csdb.ctx, so.account)
// NOTE: we don't use sdk.NewCoin here to avoid panic on test importer's genesis
newBalance := sdk.Coin{Denom: emint.DenomDefault, Amount: sdk.NewIntFromBigInt(so.Balance())}
if !newBalance.IsValid() {
return fmt.Errorf("invalid balance %s", newBalance)
}
return csdb.bankKeeper.SetBalance(csdb.ctx, so.account.Address, newBalance)
coins := so.account.GetCoins()
balance := coins.AmountOf(newBalance.Denom)
if balance.IsZero() || !balance.Equal(newBalance.Amount) {
coins = coins.Add(newBalance)
}
if err := so.account.SetCoins(coins); err != nil {
return err
}
csdb.accountKeeper.SetAccount(csdb.ctx, so.account)
// return csdb.bankKeeper.SetBalance(csdb.ctx, so.account.Address, newBalance)
return nil
}
// deleteStateObject removes the given state object from the state store.
@ -613,12 +623,13 @@ func (csdb *CommitStateDB) UpdateAccounts() {
continue
}
balance := csdb.bankKeeper.GetBalance(csdb.ctx, emintAcc.GetAddress(), emint.DenomDefault)
if stateEntry.stateObject.Balance() != balance.Amount.BigInt() && balance.IsValid() {
stateEntry.stateObject.balance = balance.Amount
balance := sdk.Coin{
Denom: emint.DenomDefault,
Amount: emintAcc.GetCoins().AmountOf(emint.DenomDefault),
}
if stateEntry.stateObject.Nonce() != emintAcc.GetSequence() {
if stateEntry.stateObject.Balance() != balance.Amount.BigInt() && balance.IsValid() ||
stateEntry.stateObject.Nonce() != emintAcc.GetSequence() {
stateEntry.stateObject.account = emintAcc
}
}
@ -674,7 +685,6 @@ func (csdb *CommitStateDB) Copy() *CommitStateDB {
ctx: csdb.ctx,
storeKey: csdb.storeKey,
accountKeeper: csdb.accountKeeper,
bankKeeper: csdb.bankKeeper,
stateObjects: make([]stateEntry, len(csdb.journal.dirties)),
addressToObjectIndex: make(map[ethcmn.Address]int, len(csdb.journal.dirties)),
stateObjectsDirty: make(map[ethcmn.Address]struct{}, len(csdb.journal.dirties)),
@ -771,7 +781,7 @@ func (csdb *CommitStateDB) createObject(addr ethcmn.Address) (newObj, prevObj *s
acc := csdb.accountKeeper.NewAccountWithAddress(csdb.ctx, sdk.AccAddress(addr.Bytes()))
newObj = newStateObject(csdb, acc, sdk.ZeroInt())
newObj = newStateObject(csdb, acc)
newObj.setNonce(0) // sets the object to dirty
if prevObj == nil {
@ -813,10 +823,8 @@ func (csdb *CommitStateDB) getStateObject(addr ethcmn.Address) (stateObject *sta
return nil
}
balance := csdb.bankKeeper.GetBalance(csdb.ctx, acc.GetAddress(), emint.DenomDefault)
// insert the state object into the live set
so := newStateObject(csdb, acc, balance.Amount)
so := newStateObject(csdb, acc)
csdb.setStateObject(so)
return so

View File

@ -17,7 +17,6 @@ import (
"github.com/cosmos/ethermint/app"
"github.com/cosmos/ethermint/crypto"
ethermint "github.com/cosmos/ethermint/types"
"github.com/cosmos/ethermint/x/evm/keeper"
"github.com/cosmos/ethermint/x/evm/types"
abci "github.com/tendermint/tendermint/abci/types"
@ -27,7 +26,6 @@ type StateDBTestSuite struct {
suite.Suite
ctx sdk.Context
querier sdk.Querier
app *app.EthermintApp
stateDB *types.CommitStateDB
address ethcmn.Address
@ -43,15 +41,16 @@ func (suite *StateDBTestSuite) SetupTest() {
suite.app = app.Setup(checkTx)
suite.ctx = suite.app.BaseApp.NewContext(checkTx, abci.Header{Height: 1})
suite.querier = keeper.NewQuerier(suite.app.EvmKeeper)
suite.stateDB = suite.app.EvmKeeper.CommitStateDB.WithContext(suite.ctx)
privkey, err := crypto.GenerateKey()
suite.Require().NoError(err)
suite.address = ethcmn.BytesToAddress(privkey.PubKey().Address().Bytes())
balance := sdk.NewCoins(sdk.NewCoin(ethermint.DenomDefault, sdk.NewInt(0)))
acc := &ethermint.EthAccount{
BaseAccount: auth.NewBaseAccount(sdk.AccAddress(suite.address.Bytes()), nil, 0, 0),
BaseAccount: auth.NewBaseAccount(sdk.AccAddress(suite.address.Bytes()), balance, nil, 0, 0),
CodeHash: ethcrypto.Keccak256(nil),
}
@ -139,13 +138,6 @@ func (suite *StateDBTestSuite) TestStateDB_Balance() {
},
big.NewInt(200),
},
{
"sub more than balance",
func() {
suite.stateDB.SubBalance(suite.address, big.NewInt(300))
},
big.NewInt(-100),
},
}
for _, tc := range testCase {
@ -528,13 +520,6 @@ func (suite *StateDBTestSuite) TestCommitStateDB_Commit() {
},
false, true,
},
{
"faled to update state object",
func() {
suite.stateDB.SubBalance(suite.address, big.NewInt(10))
},
false, false,
},
}
for _, tc := range testCase {
@ -592,13 +577,6 @@ func (suite *StateDBTestSuite) TestCommitStateDB_Finalize() {
},
false, true,
},
{
"faled to update state object",
func() {
suite.stateDB.SubBalance(suite.address, big.NewInt(10))
},
false, false,
},
}
for _, tc := range testCase {

View File

@ -105,7 +105,8 @@ func TxDecoder(cdc *codec.Codec) sdk.TxDecoder {
// sdk.Tx is an interface. The concrete message types
// are registered by MakeTxCodec
err := cdc.UnmarshalBinaryBare(txBytes, &tx)
// TODO: switch to UnmarshalBinaryBare on SDK v0.40.0
err := cdc.UnmarshalBinaryLengthPrefixed(txBytes, &tx)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrTxDecode, err.Error())
}

View File

@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client/utils"
"github.com/cosmos/ethermint/x/faucet/types"
)

View File

@ -9,7 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client/utils"
"github.com/cosmos/ethermint/x/faucet/types"
)
@ -70,9 +70,10 @@ func requestHandler(cliCtx context.CLIContext) http.HandlerFunc {
}
func fundedHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, _ *http.Request) {
res, height, err := cliCtx.Query(fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryFunded))
if rest.CheckInternalServerError(w, err) {
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}

View File

@ -38,6 +38,6 @@ func handleMsgFund(ctx sdk.Context, keeper Keeper, msg types.MsgFund) (*sdk.Resu
)
return &sdk.Result{
Events: ctx.EventManager().ABCIEvents(),
Events: ctx.EventManager().Events(),
}, nil
}

View File

@ -40,14 +40,14 @@ func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {
// DefaultGenesis returns default genesis state as raw bytes for the faucet
// module.
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage {
return cdc.MustMarshalJSON(types.DefaultGenesisState())
func (AppModuleBasic) DefaultGenesis() json.RawMessage {
return types.ModuleCdc.MustMarshalJSON(types.DefaultGenesisState())
}
// ValidateGenesis performs genesis state validation for the faucet module.
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, bz json.RawMessage) error {
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
var genesisState types.GenesisState
if err := cdc.UnmarshalJSON(bz, &genesisState); err != nil {
if err := types.ModuleCdc.UnmarshalJSON(bz, &genesisState); err != nil {
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
}
@ -112,18 +112,18 @@ func (am AppModule) NewQuerierHandler() sdk.Querier {
// InitGenesis performs genesis initialization for the faucet module. It returns
// no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, data json.RawMessage) []abci.ValidatorUpdate {
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate {
var genesisState types.GenesisState
ModuleCdc.MustUnmarshalJSON(data, &genesisState)
types.ModuleCdc.MustUnmarshalJSON(data, &genesisState)
InitGenesis(ctx, am.keeper, genesisState)
return []abci.ValidatorUpdate{}
}
// ExportGenesis returns the exported genesis state as raw bytes for the faucet
// module.
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONMarshaler) json.RawMessage {
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage {
gs := ExportGenesis(ctx, am.keeper)
return cdc.MustMarshalJSON(gs)
return types.ModuleCdc.MustMarshalJSON(gs)
}
// BeginBlock returns the begin blocker for the faucet module.