EVM Transaction handler and contract creation (#96)

* WIP implementing state transition function

* Error handling and application setup fix

* Fixed error comment

* Allow creation of state objects with a BaseAccount

* Fixed parameters and finalise state after transaction

* updated transaction signing and cli signature

* Set up consistent account encoding and decoding

* Update txbuilder to get sequence before generating eth tx

* Added create functionality to the CLI command

* Remove need to copy over context for statedb interactions

* Updated account retriever

* Cleaned up handler code and updated TODO

* Make recoverEthSig private again

* Add error check for committing to kv store

* Remove commented out code

* Update evm chain config for state transition

* Add time in context for dapps
This commit is contained in:
Austin Abell
2019-09-18 09:51:18 -04:00
committed by GitHub
parent 72fc3ca3af
commit 1b5c33cf33
10 changed files with 291 additions and 33 deletions
+7 -3
View File
@@ -25,6 +25,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/supply"
eminttypes "github.com/cosmos/ethermint/types"
evmtypes "github.com/cosmos/ethermint/x/evm/types"
abci "github.com/tendermint/tendermint/abci/types"
@@ -79,6 +80,8 @@ func MakeCodec() *codec.Codec {
ModuleBasics.RegisterCodec(cdc)
sdk.RegisterCodec(cdc)
codec.RegisterCrypto(cdc)
eminttypes.RegisterCodec(cdc)
return cdc
}
@@ -128,7 +131,7 @@ func NewEthermintApp(
keys := sdk.NewKVStoreKeys(bam.MainStoreKey, auth.StoreKey, staking.StoreKey,
supply.StoreKey, mint.StoreKey, distr.StoreKey, slashing.StoreKey,
gov.StoreKey, params.StoreKey)
gov.StoreKey, params.StoreKey, evmtypes.EvmStoreKey, evmtypes.EvmCodeKey)
tkeys := sdk.NewTransientStoreKeys(staking.TStoreKey, params.TStoreKey)
app := &EthermintApp{
@@ -151,7 +154,7 @@ func NewEthermintApp(
crisisSubspace := app.paramsKeeper.Subspace(crisis.DefaultParamspace)
// add keepers
app.accountKeeper = auth.NewAccountKeeper(app.cdc, keys[auth.StoreKey], authSubspace, auth.ProtoBaseAccount)
app.accountKeeper = auth.NewAccountKeeper(app.cdc, keys[auth.StoreKey], authSubspace, eminttypes.ProtoBaseAccount)
app.bankKeeper = bank.NewBaseKeeper(app.accountKeeper, bankSubspace, bank.DefaultCodespace, app.ModuleAccountAddrs())
app.supplyKeeper = supply.NewKeeper(app.cdc, keys[supply.StoreKey], app.accountKeeper, app.bankKeeper, maccPerms)
stakingKeeper := staking.NewKeeper(app.cdc, keys[staking.StoreKey], tkeys[staking.TStoreKey],
@@ -162,6 +165,7 @@ func NewEthermintApp(
app.slashingKeeper = slashing.NewKeeper(app.cdc, keys[slashing.StoreKey], &stakingKeeper,
slashingSubspace, slashing.DefaultCodespace)
app.crisisKeeper = crisis.NewKeeper(crisisSubspace, invCheckPeriod, app.supplyKeeper, auth.FeeCollectorName)
app.evmKeeper = evm.NewKeeper(app.accountKeeper, keys[evmtypes.EvmStoreKey], keys[evmtypes.EvmCodeKey], cdc)
// register the proposal types
govRouter := gov.NewRouter()
@@ -204,7 +208,7 @@ func NewEthermintApp(
app.mm.SetOrderInitGenesis(
genaccounts.ModuleName, distr.ModuleName, staking.ModuleName,
auth.ModuleName, bank.ModuleName, slashing.ModuleName, gov.ModuleName,
mint.ModuleName, supply.ModuleName, crisis.ModuleName, genutil.ModuleName,
mint.ModuleName, supply.ModuleName, crisis.ModuleName, genutil.ModuleName, evmtypes.ModuleName,
)
app.mm.RegisterInvariants(&app.crisisKeeper)