From 5b2496553cee953ea845c6651f13099edd70a9ef Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 24 Oct 2018 10:49:37 -0400 Subject: [PATCH] Update to reflect latest SDK changes --- Gopkg.lock | 349 ++++++++++++++++++++++++++++++++------ Gopkg.toml | 26 ++- app/ethermint.go | 34 ++-- handlers/ante.go | 24 +-- handlers/ante_test.go | 235 ------------------------- importer/importer_test.go | 26 +-- types/test_common.go | 17 +- types/tx.go | 18 +- types/wire.go | 16 +- x/evm/types/statedb.go | 16 +- 10 files changed, 391 insertions(+), 370 deletions(-) delete mode 100644 handlers/ante_test.go diff --git a/Gopkg.lock b/Gopkg.lock index 470426e5..d5f6ec0a 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -3,19 +3,27 @@ [[projects]] branch = "master" - digest = "1:60d3b49df18861c92ac49cce49e49f61b3ec927e5b7f39c5ae1128ec5c197b98" + digest = "1:495c7006c2f48b705f0d89fd8449a2ae70622bb748788d9d17caafa65a6769f9" name = "github.com/aristanetworks/goarista" packages = ["monotime"] pruneopts = "T" - revision = "fb622b9b46608fdb39d36447f4d8ef52fe37fc3d" + revision = "33151c4543a79b013e8e6799ef45b2ba88c3cd1c" [[projects]] branch = "master" - digest = "1:b9f5e0f033febe59a62d01e78486c0dd9e4afc9ac5d240aee6ce78a927142e8b" + digest = "1:ad4589ec239820ee99eb01c1ad47ebc5f8e02c4f5103a9b210adff9696d89f36" + name = "github.com/beorn7/perks" + packages = ["quantile"] + pruneopts = "T" + revision = "3a771d992973f24aa725d07868b467d1ddfceafb" + +[[projects]] + branch = "master" + digest = "1:0bd9f11575e82b723837f50e170d010ec29a50aa8ca02a962c439146f03aea55" name = "github.com/btcsuite/btcd" packages = ["btcec"] pruneopts = "T" - revision = "79e00513b1011888b1e675157ab89f527f901cae" + revision = "67e573d211ace594f1366b4ce9d39726c4b19bd0" [[projects]] digest = "1:d0d998526cfb68788229a31c16a557fdf1fbbb510654be6b3732c2758e06b533" @@ -25,29 +33,30 @@ revision = "d4cc87b860166d00d6b5b9e0d3b3d71d6088d4d4" [[projects]] - digest = "1:bc28e755cf6a9fd8e65497514d20c4907973e7a6a6409d30ead3fd37bfeb19a9" + digest = "1:912c494215c339688331953ba09cb9698a4797fe647d93a4e0a117c9c7b960a2" name = "github.com/cosmos/cosmos-sdk" packages = [ "baseapp", + "codec", "store", "types", "version", - "wire", "x/auth", "x/bank", "x/gov", "x/gov/tags", "x/mock", "x/params", + "x/params/subspace", "x/slashing", "x/stake", "x/stake/keeper", + "x/stake/querier", "x/stake/tags", "x/stake/types", ] pruneopts = "T" - revision = "1c38c70468ec721e3a555ba2f3bf5f9da31f0cc9" - version = "v0.24.2" + revision = "075ddce79acb77fe88f849f93fb3036e48ffb555" [[projects]] digest = "1:9f42202ac457c462ad8bb9642806d275af9ab4850cf0b1960b9c6f083d4a309a" @@ -65,6 +74,13 @@ revision = "cbaa98ba5575e67703b32b4b19f73c91f3c4159e" version = "v1.7.1" +[[projects]] + digest = "1:c7644c73a3d23741fdba8a99b1464e021a224b7e205be497271a8003a15ca41b" + name = "github.com/ebuchman/fail-test" + packages = ["."] + pruneopts = "T" + revision = "95f809107225be108efcf10a3509e4ea6ceef3c4" + [[projects]] branch = "master" digest = "1:67d0b50be0549e610017cb91e0b0b745ec0cad7c613bc8e18ff2d1c1fc8825a7" @@ -75,7 +91,7 @@ [[projects]] branch = "ethermint-statedb" - digest = "1:c24d17ef5d37ae7215811cf1cade45822faa232d6bcfbadff30bbeba52225a98" + digest = "1:6fcf36394c3b062f05dcaac00658a3bc49451de7bd289a4c10274c61d6256243" name = "github.com/ethereum/go-ethereum" packages = [ ".", @@ -123,9 +139,17 @@ "trie", ] pruneopts = "T" - revision = "477eb0933b9529f7deeccc233cc815fe34a8ea56" + revision = "411404c27389331f96b2e77bf8bdbbee2f0151f9" source = "github.com/alexanderbez/go-ethereum" +[[projects]] + digest = "1:7fc160b460a6fc506b37fcca68332464c3f2cd57b6e3f111f26c5bbfd2d5518e" + name = "github.com/fsnotify/fsnotify" + packages = ["."] + pruneopts = "T" + revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9" + version = "v1.4.7" + [[projects]] digest = "1:0b9c3ad6c948d57a379da9c4e1cdd989b1c73ddc5ec8673f52a9539ce60a109b" name = "github.com/go-kit/kit" @@ -133,6 +157,10 @@ "log", "log/level", "log/term", + "metrics", + "metrics/discard", + "metrics/internal/lv", + "metrics/prometheus", ] pruneopts = "T" revision = "4dc7be5d2d12881735283bcab7352178e190fc71" @@ -193,18 +221,52 @@ revision = "2e65f85255dbc3072edf28d6b5b8efc472979f5a" [[projects]] - digest = "1:cf296baa185baae04a9a7004efee8511d08e2f5f51d4cbe5375da89722d681db" + digest = "1:3a26588bc48b96825977c1b3df964f8fd842cd6860cc26370588d3563433cf11" + name = "github.com/google/uuid" + packages = ["."] + pruneopts = "T" + revision = "d460ce9f8df2e77fb1ba55ca87fafed96c607494" + version = "v1.0.0" + +[[projects]] + digest = "1:0ead695774eaa7bf1a284d246febe82054767941de80ab2328a194b088f07026" + name = "github.com/gorilla/websocket" + packages = ["."] + pruneopts = "T" + revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b" + version = "v1.2.0" + +[[projects]] + digest = "1:8ec8d88c248041a6df5f6574b87bc00e7e0b493881dad2e7ef47b11dc69093b5" name = "github.com/hashicorp/golang-lru" packages = [ ".", "simplelru", ] pruneopts = "T" - revision = "0fb14efe8c47ae851c0034ed7a448854d3d34cf3" + revision = "20f1fb78b0740ba8c3cb143a61e86ba5c8669768" + version = "v0.5.0" [[projects]] - branch = "master" - digest = "1:202e4a1a283dd740ca9d131787e73bb9d69611a01ef86e82ed262e035b0dd792" + digest = "1:071bcbf82c289fba4d3f63c876bf4f0ba7eda625cd60795e0a03ccbf949e517a" + name = "github.com/hashicorp/hcl" + packages = [ + ".", + "hcl/ast", + "hcl/parser", + "hcl/scanner", + "hcl/strconv", + "hcl/token", + "json/parser", + "json/scanner", + "json/token", + ] + pruneopts = "T" + revision = "8cb6e5b959231cc1119e43259c4a608f9c51a241" + version = "v1.0.0" + +[[projects]] + digest = "1:a33cc2e4fb12c58430d2aae5834ff6e84cb609da97692e1fe2aa0cd5ebc92623" name = "github.com/huin/goupnp" packages = [ ".", @@ -216,7 +278,8 @@ "ssdp", ] pruneopts = "T" - revision = "1395d1447324cbea88d249fbfcfd70ea878fdfca" + revision = "656e61dfadd241c7cbdd22a023fa81ecb6860ea8" + version = "v1.0.0" [[projects]] digest = "1:870d441fe217b8e689d7949fef6e43efbc787e50f200cb1e70dbca9204a1d6be" @@ -259,12 +322,44 @@ revision = "b84e30acd515aadc4b783ad4ff83aff3299bdfe0" [[projects]] - digest = "1:361de06aa7ae272616cbe71c3994a654cc6316324e30998e650f7765b20c5b33" + digest = "1:53e8c5c79716437e601696140e8b1801aae4204f4ec54a504333702a49572c4f" + name = "github.com/magiconair/properties" + packages = ["."] + pruneopts = "T" + revision = "c2353362d570a7bfa228149c62842019201cfb71" + version = "v1.8.0" + +[[projects]] + digest = "1:a8e3d14801bed585908d130ebfc3b925ba642208e6f30d879437ddfc7bb9b413" + name = "github.com/matttproud/golang_protobuf_extensions" + packages = ["pbutil"] + pruneopts = "T" + revision = "c12348ce28de40eed0136aa2b644d0ee0650e56c" + version = "v1.0.1" + +[[projects]] + digest = "1:53bc4cd4914cd7cd52139990d5170d6dc99067ae31c56530621b18b35fc30318" + name = "github.com/mitchellh/mapstructure" + packages = ["."] + pruneopts = "T" + revision = "3536a929edddb9a5b34bd6861dc4a9647cb459fe" + version = "v1.1.2" + +[[projects]] + digest = "1:e5d0bd87abc2781d14e274807a470acd180f0499f8bf5bb18606e9ec22ad9de9" name = "github.com/pborman/uuid" packages = ["."] pruneopts = "T" - revision = "e790cca94e6cc75c7064b1332e63811d4aae1a53" - version = "v1.1" + revision = "adf5a7427709b9deb95d29d3fa8a2bf9cfd388f1" + version = "v1.2" + +[[projects]] + digest = "1:ccf9949c9c53e85dcb7e2905fc620571422567040925381e6baa62f0b7b850fe" + name = "github.com/pelletier/go-toml" + packages = ["."] + pruneopts = "T" + revision = "c01d1270ff3e442a8a57cddc1c92dc1138598194" + version = "v1.2.0" [[projects]] digest = "1:40e195917a951a8bf867cd05de2a46aaf1806c50cf92eebf4c16f78cd196f747" @@ -283,36 +378,121 @@ version = "v1.0.0" [[projects]] - digest = "1:602081d2a289d1f76ea90b806b0c61c19038d76504e9005ccb969864dbaee339" + digest = "1:f4f3858737fd9db5cf3ef8019c918a798a987d4d11f7e531c54dfe70d4708642" + name = "github.com/prometheus/client_golang" + packages = [ + "prometheus", + "prometheus/promhttp", + ] + pruneopts = "T" + revision = "ae27198cdd90bf12cd134ad79d1366a6cf49f632" + +[[projects]] + branch = "master" + digest = "1:185cf55b1f44a1bf243558901c3f06efa5c64ba62cfdcbb1bf7bbe8c3fb68561" + name = "github.com/prometheus/client_model" + packages = ["go"] + pruneopts = "T" + revision = "5c3871d89910bfb32f5fcab2aa4b9ec68e65a99f" + +[[projects]] + branch = "master" + digest = "1:2d9b03513fadf4adf193b3570f5ef65ee57b658d9f11e901a06d17baf2bdc88b" + name = "github.com/prometheus/common" + packages = [ + "expfmt", + "internal/bitbucket.org/ww/goautoneg", + "model", + ] + pruneopts = "T" + revision = "7e9e6cabbd393fc208072eedef99188d0ce788b6" + +[[projects]] + branch = "master" + digest = "1:57bf59ce0c73cef5cc4796a5d64f1ec5b81f6335f242d4a80a62b0a6edc4b77f" + name = "github.com/prometheus/procfs" + packages = [ + ".", + "internal/util", + "nfs", + "xfs", + ] + pruneopts = "T" + revision = "185b4288413d2a0dd0806f78c90dde719829e5ae" + +[[projects]] + digest = "1:523d2c2500965d035691347a6d30befd53fde95fad16e0b94bef5d3d2cca8ff7" + name = "github.com/rcrowley/go-metrics" + packages = ["."] + pruneopts = "T" + revision = "e2704e165165ec55d062f5919b4b29494e9fa790" + +[[projects]] + digest = "1:9787d2d3220cbfd444596afd03ab0abcf391df169b789fbe3eae27fa2e426cf6" name = "github.com/rjeczalik/notify" packages = ["."] pruneopts = "T" - revision = "0f065fa99b48b842c3fd3e2c8b194c6f2b69f6b8" - version = "v0.9.1" + revision = "69d839f37b13a8cb7a78366f7633a4071cb43be7" + version = "v0.9.2" [[projects]] - digest = "1:6cae6970d70fc5fe75bf83c48ee33e9c4c561a62d0b033254bee8dd5942b815a" + digest = "1:a8a03bca5a81878daa4958136f3372af00437c61129ca088a430b0b786b9378a" name = "github.com/rs/cors" packages = ["."] pruneopts = "T" - revision = "3fb1b69b103a84de38a19c3c6ec073dd6caa4d3f" - version = "v1.5.0" + revision = "9a47f48565a795472d43519dd49aac781f3034fb" + version = "v1.6.0" [[projects]] - digest = "1:8be8b3743fc9795ec21bbd3e0fc28ff6234018e1a269b0a7064184be95ac13e0" + digest = "1:b7bf9fd95d38ebe6726a63b7d0320611f7c920c64e2c8313eba0cec51926bf55" + name = "github.com/spf13/afero" + packages = [ + ".", + "mem", + ] + pruneopts = "T" + revision = "d40851caa0d747393da1ffb28f7f9d8b4eeffebd" + version = "v1.1.2" + +[[projects]] + digest = "1:516e71bed754268937f57d4ecb190e01958452336fa73dbac880894164e91c1f" + name = "github.com/spf13/cast" + packages = ["."] + pruneopts = "T" + revision = "8965335b8c7107321228e3e3702cab9832751bac" + version = "v1.2.0" + +[[projects]] + digest = "1:52565bd966162d1f4579757f66ce6a7ca9054e7f6b662f0c7c96e4dd228fd017" name = "github.com/spf13/cobra" packages = ["."] pruneopts = "T" - revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385" - version = "v0.0.3" + revision = "7b2c5ac9fc04fc5efafb60700713d4fa609b777b" + version = "v0.0.1" [[projects]] - digest = "1:9ba911fe3884995431690e7eb180cf848da0d637ba5f61711783b795d031793f" + digest = "1:68ea4e23713989dc20b1bded5d9da2c5f9be14ff9885beef481848edd18c26cb" + name = "github.com/spf13/jwalterweatherman" + packages = ["."] + pruneopts = "T" + revision = "4a4406e478ca629068e7768fc33f3f044173c0a6" + version = "v1.0.0" + +[[projects]] + digest = "1:0f775ea7a72e30d5574267692aaa9ff265aafd15214a7ae7db26bc77f2ca04dc" name = "github.com/spf13/pflag" packages = ["."] pruneopts = "T" - revision = "9a97c102cda95a86cec2345a6f09f55a939babf5" - version = "v1.0.2" + revision = "298182f68c66c05229eb03ac171abe6e309ee79a" + version = "v1.0.3" + +[[projects]] + digest = "1:a8a1cbf83d6ba47a3421e51b5dd1999e1f64f6175c64295d6b42bdea55312a79" + name = "github.com/spf13/viper" + packages = ["."] + pruneopts = "T" + revision = "25b30aa063fc18e48662b86996252eabdcf2f0c7" + version = "v1.0.0" [[projects]] digest = "1:8f39978e4fb2a11d43cc954f2ab458cb38995d4c1557b6d3a7c8cafe0ec2277c" @@ -328,7 +508,7 @@ [[projects]] branch = "master" - digest = "1:ee395d0d8c1719b5a1407f34af93953b4763bacb19a8961aba5b6d312824da41" + digest = "1:ea4a45f31f55c7a42ba3063baa646ac94eb7ee9afe60c1fd2c8b396930222620" name = "github.com/syndtr/goleveldb" packages = [ "leveldb", @@ -345,7 +525,14 @@ "leveldb/util", ] pruneopts = "T" - revision = "ae2bd5eed72d46b28834ec3f60db3a3ebedd8dbd" + revision = "6b91fda63f2e36186f1c9d0e48578defb69c5d43" + +[[projects]] + digest = "1:71ffd1fca92b4972ecd588cf13d9929d4f444659788e9128d055a9126498d41d" + name = "github.com/tendermint/btcd" + packages = ["btcec"] + pruneopts = "T" + revision = "e5840949ff4fff0c56f9b6a541e22b63581ea9df" [[projects]] branch = "master" @@ -360,57 +547,110 @@ revision = "d8387025d2b9d158cf4efb07e7ebf814bcce2057" [[projects]] - digest = "1:0e2addab3f64ece97ca434b2bf2d4e8cb54a4509904a03be8c81da3fc2ddb245" + digest = "1:25c97d29878b5f821bb17a379469f0f923426188241bf2aa81c18728cdc6927c" name = "github.com/tendermint/go-amino" packages = ["."] pruneopts = "T" - revision = "2106ca61d91029c931fd54968c2bb02dc96b1412" - version = "0.10.1" + revision = "faa6e731944e2b7b6a46ad202902851e8ce85bee" + version = "v0.12.0" [[projects]] - digest = "1:bf042d2f7d1252b9dcae8e694e2f0a9b5294cb357c086fd86dc540d2f32c9fdf" + digest = "1:2ecd824e1615a8becefea26637fe24576f3800260f5dc91ffe44b37bdbd27878" name = "github.com/tendermint/iavl" packages = ["."] pruneopts = "T" - revision = "35f66e53d9b01e83b30de68b931f54b2477a94c9" - version = "v0.9.2" + revision = "3acc91fb8811db2c5409a855ae1f8e441fe98e2d" + version = "v0.11.0" [[projects]] - digest = "1:5a60cb048b401c0263c227baf8778ecaf038be531707057607949540486874ef" + digest = "1:b8bd45120cbea639592420b1d5363f102d819ea89d6239f4dae2a0814c76a6d2" name = "github.com/tendermint/tendermint" packages = [ + "abci/client", + "abci/example/code", + "abci/example/kvstore", "abci/server", "abci/types", + "blockchain", + "cmd/tendermint/commands", + "config", + "consensus", + "consensus/types", "crypto", "crypto/ed25519", "crypto/encoding/amino", "crypto/merkle", + "crypto/multisig", + "crypto/multisig/bitarray", "crypto/secp256k1", "crypto/tmhash", + "evidence", + "libs/autofile", "libs/bech32", + "libs/cli", + "libs/cli/flags", + "libs/clist", "libs/common", "libs/db", + "libs/errors", + "libs/events", + "libs/flowrate", "libs/log", "libs/pubsub", "libs/pubsub/query", + "lite", + "lite/client", + "lite/errors", + "lite/proxy", + "mempool", + "node", + "p2p", + "p2p/conn", + "p2p/pex", + "p2p/upnp", + "privval", + "proxy", + "rpc/client", + "rpc/core", + "rpc/core/types", + "rpc/grpc", + "rpc/lib", + "rpc/lib/client", + "rpc/lib/server", + "rpc/lib/types", + "state", + "state/txindex", + "state/txindex/kv", + "state/txindex/null", "types", + "types/time", + "version", ] pruneopts = "T" - revision = "81df19e68ab1519399fccf0cab81cb75bf9d782e" - version = "v0.23.1-rc0" + revision = "90eda9bfb6e6daeed1c8015df41cb36772d91778" + version = "v0.25.1-rc0" [[projects]] branch = "master" - digest = "1:da29cbeb9d244918393b37243c008ab7128688fb017c966aaf876587c010bcdd" + digest = "1:56a43b9f51e5c5ea734e866b82d57c842b022c795a0611ff5f57f3d7c47de45d" name = "golang.org/x/crypto" packages = [ + "chacha20poly1305", + "curve25519", + "hkdf", + "internal/chacha20", + "internal/subtle", + "nacl/box", + "nacl/secretbox", "pbkdf2", + "poly1305", "ripemd160", + "salsa20/salsa", "scrypt", "ssh/terminal", ] pruneopts = "T" - revision = "182538f80094b6a8efaade63a8fd8e0d9d5843dd" + revision = "0c41d7ab0a0ee717d4590a44bcb987dfd9e183eb" [[projects]] digest = "1:5fdc7adede42f80d6201258355d478d856778e21d735f14972abd8ff793fdbf7" @@ -425,6 +665,7 @@ "http2/hpack", "idna", "internal/timeseries", + "netutil", "trace", "websocket", ] @@ -433,7 +674,7 @@ [[projects]] branch = "master" - digest = "1:bfa444982d49ce4ca1360599270a94de12a573ccd3bf04493c79bee09da3170b" + digest = "1:8671b7bf5d02bdeb389f8023184c7f92d12fcf0dec9426e055f3433f5fd706b7" name = "golang.org/x/sys" packages = [ "cpu", @@ -441,7 +682,7 @@ "windows", ] pruneopts = "T" - revision = "fa5fdf94c78965f1aa8423f0cc50b8b8d728b05a" + revision = "44b849a8bc13eb42e95e6c6c5e360481b73ec710" [[projects]] digest = "1:6164911cb5e94e8d8d5131d646613ff82c14f5a8ce869de2f6d80d9889df8c5a" @@ -480,11 +721,11 @@ [[projects]] branch = "master" - digest = "1:e43f1cb3f488a0c2be85939c2a594636f60b442a12a196c778bd2d6c9aca3df7" + digest = "1:849525811c9f6ae1f5bd9b866adb4c9436f4a12d767f48e33bf343596d4aafd7" name = "google.golang.org/genproto" packages = ["googleapis/rpc/status"] pruneopts = "T" - revision = "11092d34479b07829b72e10713b159248caf5dad" + revision = "94acd270e44e65579b9ee3cdab25034d33fed608" [[projects]] digest = "1:adafc60b1d4688759f3fc8f9089e71dd17abd123f4729de6b913bf08c9143770" @@ -528,14 +769,22 @@ pruneopts = "T" revision = "c1b8fa8bdccecb0b8db834ee0b92fdbcfa606dd6" +[[projects]] + digest = "1:342378ac4dcb378a5448dd723f0784ae519383532f5e70ade24132c4c8693202" + name = "gopkg.in/yaml.v2" + packages = ["."] + pruneopts = "T" + revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183" + version = "v2.2.1" + [solve-meta] analyzer-name = "dep" analyzer-version = 1 input-imports = [ "github.com/cosmos/cosmos-sdk/baseapp", + "github.com/cosmos/cosmos-sdk/codec", "github.com/cosmos/cosmos-sdk/store", "github.com/cosmos/cosmos-sdk/types", - "github.com/cosmos/cosmos-sdk/wire", "github.com/cosmos/cosmos-sdk/x/auth", "github.com/cosmos/cosmos-sdk/x/bank", "github.com/cosmos/cosmos-sdk/x/gov", @@ -544,7 +793,6 @@ "github.com/cosmos/cosmos-sdk/x/stake", "github.com/ethereum/go-ethereum/common", "github.com/ethereum/go-ethereum/common/hexutil", - "github.com/ethereum/go-ethereum/common/math", "github.com/ethereum/go-ethereum/consensus", "github.com/ethereum/go-ethereum/consensus/ethash", "github.com/ethereum/go-ethereum/consensus/misc", @@ -554,13 +802,10 @@ "github.com/ethereum/go-ethereum/core/vm", "github.com/ethereum/go-ethereum/crypto", "github.com/ethereum/go-ethereum/crypto/sha3", - "github.com/ethereum/go-ethereum/ethdb", "github.com/ethereum/go-ethereum/params", "github.com/ethereum/go-ethereum/rlp", "github.com/ethereum/go-ethereum/rpc", "github.com/ethereum/go-ethereum/signer/core", - "github.com/ethereum/go-ethereum/trie", - "github.com/hashicorp/golang-lru", "github.com/pkg/errors", "github.com/stretchr/testify/require", "github.com/stretchr/testify/suite", diff --git a/Gopkg.toml b/Gopkg.toml index c177500f..a5c88bd5 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -6,7 +6,9 @@ [[constraint]] name = "github.com/cosmos/cosmos-sdk" - version = "=0.24.2" + # TODO: Remove this once 0.25 has been released + revision = "075ddce79acb77fe88f849f93fb3036e48ffb555" + # version = "=0.24.2" [[constraint]] name = "github.com/hashicorp/golang-lru" @@ -16,14 +18,6 @@ name = "github.com/spf13/cobra" version = "~0.0.1" -[[override]] - name = "github.com/tendermint/iavl" - version = "=v0.9.2" - -[[override]] - name = "github.com/tendermint/tendermint" - version = "=v0.23.1-rc0" - [[constraint]] name = "github.com/stretchr/testify" version = "=1.2.1" @@ -32,9 +26,23 @@ name = "github.com/pkg/errors" version = "=0.8.0" +# dependecy overrides + [[override]] name = "gopkg.in/fatih/set.v0" version = "=0.1.0" +[[override]] + name = "github.com/tendermint/iavl" + version = "=v0.11.0" + +[[override]] + name = "github.com/tendermint/tendermint" + version = "=0.25.1-rc0" + +[[override]] + name = "github.com/tendermint/go-amino" + version = "=v0.12.0" + [prune] go-tests = true diff --git a/app/ethermint.go b/app/ethermint.go index 2b82850e..cd5437db 100644 --- a/app/ethermint.go +++ b/app/ethermint.go @@ -2,9 +2,9 @@ package app import ( bam "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/gov" @@ -35,7 +35,7 @@ type ( EthermintApp struct { *bam.BaseApp - codec *wire.Codec + cdc *codec.Codec accountKey *sdk.KVStoreKey storageKey *sdk.KVStoreKey @@ -47,7 +47,7 @@ type ( paramsKey *sdk.KVStoreKey tParamsKey *sdk.TransientStoreKey - accountMapper auth.AccountMapper + accountKeeper auth.AccountKeeper feeCollKeeper auth.FeeCollectionKeeper coinKeeper bank.Keeper stakeKeeper stake.Keeper @@ -60,17 +60,17 @@ type ( // NewEthermintApp returns a reference to a new initialized Ethermint // application. func NewEthermintApp(logger tmlog.Logger, db dbm.DB, sdkAddr ethcmn.Address) *EthermintApp { - codec := CreateCodec() + cdc := CreateCodec() cms := store.NewCommitMultiStore(db) baseAppOpts := []func(*bam.BaseApp){ func(bApp *bam.BaseApp) { bApp.SetCMS(cms) }, } - baseApp := bam.NewBaseApp(appName, logger, db, types.TxDecoder(codec, sdkAddr), baseAppOpts...) + baseApp := bam.NewBaseApp(appName, logger, db, types.TxDecoder(cdc, sdkAddr), baseAppOpts...) app := &EthermintApp{ BaseApp: baseApp, - codec: codec, + cdc: cdc, accountKey: types.StoreKeyAccount, storageKey: types.StoreKeyStorage, mainKey: types.StoreKeyMain, @@ -83,9 +83,9 @@ func NewEthermintApp(logger tmlog.Logger, db dbm.DB, sdkAddr ethcmn.Address) *Et } // set application keepers and mappers - app.accountMapper = auth.NewAccountMapper(codec, app.accountKey, auth.ProtoBaseAccount) - app.paramsKeeper = params.NewKeeper(app.codec, app.paramsKey) - app.feeCollKeeper = auth.NewFeeCollectionKeeper(app.codec, app.feeCollKey) + app.accountKeeper = auth.NewAccountKeeper(app.cdc, app.accountKey, auth.ProtoBaseAccount) + app.paramsKeeper = params.NewKeeper(app.cdc, app.paramsKey, app.tParamsKey) + app.feeCollKeeper = auth.NewFeeCollectionKeeper(app.cdc, app.feeCollKey) // register message handlers app.Router(). @@ -99,7 +99,7 @@ func NewEthermintApp(logger tmlog.Logger, db dbm.DB, sdkAddr ethcmn.Address) *Et app.SetInitChainer(app.initChainer) app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) - app.SetAnteHandler(handlers.AnteHandler(app.accountMapper, app.feeCollKeeper)) + app.SetAnteHandler(handlers.AnteHandler(app.accountKeeper, app.feeCollKeeper)) app.MountStoresIAVL( app.mainKey, app.accountKey, app.stakeKey, app.slashingKey, @@ -133,7 +133,7 @@ func (app *EthermintApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) var genesisState GenesisState stateJSON := req.AppStateBytes - err := app.codec.UnmarshalJSON(stateJSON, &genesisState) + err := app.cdc.UnmarshalJSON(stateJSON, &genesisState) if err != nil { panic(errors.Wrap(err, "failed to parse application genesis state")) } @@ -145,12 +145,12 @@ func (app *EthermintApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) // CreateCodec creates a new amino wire codec and registers all the necessary // concrete types and interfaces needed for the application. -func CreateCodec() *wire.Codec { - codec := wire.NewCodec() +func CreateCodec() *codec.Codec { + cdc := codec.New() - types.RegisterWire(codec) - auth.RegisterWire(codec) - wire.RegisterCrypto(codec) + types.RegisterCodec(cdc) + auth.RegisterCodec(cdc) + codec.RegisterCrypto(cdc) - return codec + return cdc } diff --git a/handlers/ante.go b/handlers/ante.go index a13ac1ca..dd35b4e2 100644 --- a/handlers/ante.go +++ b/handlers/ante.go @@ -21,15 +21,15 @@ const ( // must implementing. Internal ante handlers will be dependant upon the // transaction type. type internalAnteHandler func( - sdkCtx sdk.Context, tx sdk.Tx, accMapper auth.AccountMapper, + sdkCtx sdk.Context, tx sdk.Tx, accMapper auth.AccountKeeper, ) (newCtx sdk.Context, res sdk.Result, abort bool) // AnteHandler is responsible for attempting to route an Ethereum or SDK // transaction to an internal ante handler for performing transaction-level // processing (e.g. fee payment, signature verification) before being passed // onto it's respective handler. -func AnteHandler(accMapper auth.AccountMapper, _ auth.FeeCollectionKeeper) sdk.AnteHandler { - return func(sdkCtx sdk.Context, tx sdk.Tx) (newCtx sdk.Context, res sdk.Result, abort bool) { +func AnteHandler(ak auth.AccountKeeper, _ auth.FeeCollectionKeeper) sdk.AnteHandler { + return func(sdkCtx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, res sdk.Result, abort bool) { var ( handler internalAnteHandler gasLimit int64 @@ -67,13 +67,13 @@ func AnteHandler(accMapper auth.AccountMapper, _ auth.FeeCollectionKeeper) sdk.A } }() - return handler(newCtx, tx, accMapper) + return handler(newCtx, tx, ak) } } // handleEthTx implements an ante handler for an Ethereum transaction. It // validates the signature and if valid returns an OK result. -func handleEthTx(sdkCtx sdk.Context, tx sdk.Tx, accMapper auth.AccountMapper) (sdk.Context, sdk.Result, bool) { +func handleEthTx(sdkCtx sdk.Context, tx sdk.Tx, ak auth.AccountKeeper) (sdk.Context, sdk.Result, bool) { ethTx, ok := tx.(types.Transaction) if !ok { return sdkCtx, sdk.ErrInternal(fmt.Sprintf("invalid transaction: %T", tx)).Result(), true @@ -92,7 +92,7 @@ func handleEthTx(sdkCtx sdk.Context, tx sdk.Tx, accMapper auth.AccountMapper) (s return sdkCtx, sdk.ErrUnauthorized("signature verification failed").Result(), true } - acc := accMapper.GetAccount(sdkCtx, addr.Bytes()) + acc := ak.GetAccount(sdkCtx, addr.Bytes()) // validate the account nonce (referred to as sequence in the AccountMapper) seq := acc.GetSequence() @@ -106,13 +106,13 @@ func handleEthTx(sdkCtx sdk.Context, tx sdk.Tx, accMapper auth.AccountMapper) (s // own and we should probably not charge for additional gas where we don't have // to. - accMapper.SetAccount(sdkCtx, acc) + ak.SetAccount(sdkCtx, acc) return sdkCtx, sdk.Result{GasWanted: int64(ethTx.Data().GasLimit)}, false } // handleEmbeddedTx implements an ante handler for an SDK transaction. It // validates the signature and if valid returns an OK result. -func handleEmbeddedTx(sdkCtx sdk.Context, tx sdk.Tx, accMapper auth.AccountMapper) (sdk.Context, sdk.Result, bool) { +func handleEmbeddedTx(sdkCtx sdk.Context, tx sdk.Tx, ak auth.AccountKeeper) (sdk.Context, sdk.Result, bool) { stdTx, ok := tx.(auth.StdTx) if !ok { return sdkCtx, sdk.ErrInternal(fmt.Sprintf("invalid transaction: %T", tx)).Result(), true @@ -129,14 +129,14 @@ func handleEmbeddedTx(sdkCtx sdk.Context, tx sdk.Tx, accMapper auth.AccountMappe for i, sig := range stdTx.Signatures { signer := ethcmn.BytesToAddress(signerAddrs[i].Bytes()) - acc, err := validateSignature(sdkCtx, stdTx, signer, sig, accMapper) + acc, err := validateSignature(sdkCtx, stdTx, signer, sig, ak) if err != nil { return sdkCtx, err.Result(), true } // TODO: Fees! - accMapper.SetAccount(sdkCtx, acc) + ak.SetAccount(sdkCtx, acc) signerAccs[i] = acc } @@ -163,12 +163,12 @@ func validateStdTxBasic(stdTx auth.StdTx) (err sdk.Error) { func validateSignature( sdkCtx sdk.Context, stdTx auth.StdTx, signer ethcmn.Address, - sig auth.StdSignature, accMapper auth.AccountMapper, + sig auth.StdSignature, ak auth.AccountKeeper, ) (acc auth.Account, sdkErr sdk.Error) { chainID := sdkCtx.ChainID() - acc = accMapper.GetAccount(sdkCtx, signer.Bytes()) + acc = ak.GetAccount(sdkCtx, signer.Bytes()) if acc == nil { return nil, sdk.ErrUnknownAddress(fmt.Sprintf("no account with address %s found", signer)) } diff --git a/handlers/ante_test.go b/handlers/ante_test.go deleted file mode 100644 index 61bc8743..00000000 --- a/handlers/ante_test.go +++ /dev/null @@ -1,235 +0,0 @@ -package handlers - -import ( - "crypto/ecdsa" - "fmt" - "math/big" - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" - "github.com/cosmos/cosmos-sdk/x/stake" - "github.com/cosmos/ethermint/types" - ethcrypto "github.com/ethereum/go-ethereum/crypto" - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/libs/log" -) - -// TODO: These tests will radically change as the ante handler develops - -func TestEthTxBadSig(t *testing.T) { - tx := types.NewTransaction(uint64(0), types.TestAddr1, big.NewInt(10), 1000, big.NewInt(100), []byte{}) - - // create bad signature - tx.Sign(big.NewInt(100), types.TestPrivKey2) - - ms, key := createTestMultiStore() - ctx := sdk.NewContext(ms, abci.Header{ChainID: types.TestChainID.String()}, false, nil) - accMapper := auth.NewAccountMapper(types.NewTestCodec(), key, auth.ProtoBaseAccount) - - handler := AnteHandler(accMapper, auth.FeeCollectionKeeper{}) - _, res, abort := handler(ctx, *tx) - - require.True(t, abort, "expected ante handler to abort") - require.Equal(t, sdk.ABCICodeType(0x10004), res.Code, fmt.Sprintf("invalid code returned on bad tx: %s", res.Log)) -} - -func TestEthTxInsufficientGas(t *testing.T) { - tx := types.NewTransaction(uint64(0), types.TestAddr1, big.NewInt(0), 0, big.NewInt(0), []byte{}) - tx.Sign(types.TestChainID, types.TestPrivKey1) - - ms, key := createTestMultiStore() - ctx := sdk.NewContext(ms, abci.Header{ChainID: types.TestChainID.String()}, false, nil) - accMapper := auth.NewAccountMapper(types.NewTestCodec(), key, auth.ProtoBaseAccount) - - handler := AnteHandler(accMapper, auth.FeeCollectionKeeper{}) - _, res, abort := handler(ctx, *tx) - - require.True(t, abort, "expected ante handler to abort") - require.Equal(t, sdk.ABCICodeType(0x1000c), res.Code, fmt.Sprintf("invalid code returned on bad tx: %s", res.Log)) -} - -func TestEthTxIncorrectNonce(t *testing.T) { - // create transaction with wrong nonce 12 - tx := types.NewTransaction(12, types.TestAddr2, big.NewInt(50), 1000, big.NewInt(1000), []byte("test_bytes")) - tx.Sign(types.TestChainID, types.TestPrivKey1) - - ms, key := createTestMultiStore() - ctx := sdk.NewContext(ms, abci.Header{ChainID: types.TestChainID.String()}, false, log.NewNopLogger()) - accMapper := auth.NewAccountMapper(types.NewTestCodec(), key, auth.ProtoBaseAccount) - - // set account in accountMapper - acc := accMapper.NewAccountWithAddress(ctx, types.TestAddr1.Bytes()) - accMapper.SetAccount(ctx, acc) - - handler := AnteHandler(accMapper, auth.FeeCollectionKeeper{}) - _, res, abort := handler(ctx, *tx) - - require.True(t, abort, "expected ante handler to abort") - require.Equal(t, sdk.ABCICodeType(0x10003), res.Code, fmt.Sprintf("invalid code returned on bad tx: %s", res.Log)) -} - -func TestEmbeddedTxBadSig(t *testing.T) { - testCodec := types.NewTestCodec() - testFee := types.NewTestStdFee() - - msgs := []sdk.Msg{sdk.NewTestMsg()} - tx := types.NewTestStdTx( - types.TestChainID, msgs, []int64{0}, []int64{0}, []*ecdsa.PrivateKey{types.TestPrivKey1}, testFee, - ) - - // create bad signature - signBytes := types.GetStdTxSignBytes(big.NewInt(100).String(), 1, 1, testFee, msgs, "") - sig, _ := ethcrypto.Sign(signBytes, types.TestPrivKey1) - (tx.(auth.StdTx)).Signatures[0].Signature = sig - - ms, key := createTestMultiStore() - ctx := sdk.NewContext(ms, abci.Header{ChainID: types.TestChainID.String()}, false, nil) - accMapper := auth.NewAccountMapper(testCodec, key, auth.ProtoBaseAccount) - - // set account in accountMapper - acc := accMapper.NewAccountWithAddress(ctx, types.TestAddr1.Bytes()) - accMapper.SetAccount(ctx, acc) - - handler := AnteHandler(accMapper, auth.FeeCollectionKeeper{}) - _, res, abort := handler(ctx, tx) - - require.True(t, abort, "expected ante handler to abort") - require.Equal(t, sdk.ABCICodeType(0x10004), res.Code, fmt.Sprintf("invalid code returned on bad tx: %s", res.Log)) -} - -func TestEmbeddedTxInvalidMultiMsg(t *testing.T) { - testCodec := types.NewTestCodec() - testCodec.RegisterConcrete(stake.MsgDelegate{}, "test/MsgDelegate", nil) - - msgs := []sdk.Msg{ - stake.NewMsgDelegate(types.TestAddr1.Bytes(), types.TestAddr2.Bytes(), sdk.NewCoin("steak", sdk.NewInt(50))), - stake.NewMsgDelegate(types.TestAddr2.Bytes(), types.TestAddr2.Bytes(), sdk.NewCoin("steak", sdk.NewInt(50))), - } - - // create transaction with only one signer - tx := types.NewTestStdTx( - types.TestChainID, msgs, []int64{0}, []int64{0}, []*ecdsa.PrivateKey{types.TestPrivKey1}, types.NewTestStdFee(), - ) - - ms, key := createTestMultiStore() - ctx := sdk.NewContext(ms, abci.Header{ChainID: types.TestChainID.String()}, false, nil) - accMapper := auth.NewAccountMapper(testCodec, key, auth.ProtoBaseAccount) - - // set accounts in accountMapper - acc1 := accMapper.NewAccountWithAddress(ctx, types.TestAddr1.Bytes()) - accMapper.SetAccount(ctx, acc1) - - acc2 := accMapper.NewAccountWithAddress(ctx, types.TestAddr1.Bytes()) - accMapper.SetAccount(ctx, acc2) - - handler := AnteHandler(accMapper, auth.FeeCollectionKeeper{}) - _, res, abort := handler(ctx, tx) - - require.True(t, abort, "expected ante handler to abort") - require.Equal(t, sdk.ABCICodeType(0x10004), res.Code, fmt.Sprintf("invalid code returned on bad tx: %s", res.Log)) -} - -func TestEmbeddedTxInvalidAccountNumber(t *testing.T) { - testCodec := types.NewTestCodec() - testCodec.RegisterConcrete(stake.MsgDelegate{}, "test/MsgDelegate", nil) - - msgs := []sdk.Msg{ - stake.NewMsgDelegate(types.TestAddr1.Bytes(), types.TestAddr2.Bytes(), sdk.NewCoin("steak", sdk.NewInt(50))), - } - - // create a transaction with an invalid account number - tx := types.NewTestStdTx( - types.TestChainID, msgs, []int64{3}, []int64{0}, []*ecdsa.PrivateKey{types.TestPrivKey1}, types.NewTestStdFee(), - ) - - ms, key := createTestMultiStore() - ctx := sdk.NewContext(ms, abci.Header{ChainID: types.TestChainID.String()}, false, nil) - accMapper := auth.NewAccountMapper(testCodec, key, auth.ProtoBaseAccount) - - // set account in accountMapper - acc := accMapper.NewAccountWithAddress(ctx, types.TestAddr1.Bytes()) - acc.SetAccountNumber(4) - accMapper.SetAccount(ctx, acc) - - handler := AnteHandler(accMapper, auth.FeeCollectionKeeper{}) - _, res, abort := handler(ctx, tx) - - require.True(t, abort, "expected ante handler to abort") - require.Equal(t, sdk.ABCICodeType(0x10003), res.Code, fmt.Sprintf("invalid code returned on bad tx: %s", res.Log)) -} - -func TestEmbeddedTxInvalidSequence(t *testing.T) { - testCodec := types.NewTestCodec() - testCodec.RegisterConcrete(stake.MsgDelegate{}, "test/MsgDelegate", nil) - - msgs := []sdk.Msg{ - stake.NewMsgDelegate(types.TestAddr1.Bytes(), types.TestAddr2.Bytes(), sdk.NewCoin("steak", sdk.NewInt(50))), - } - - // create transaction with an invalid sequence (nonce) - tx := types.NewTestStdTx( - types.TestChainID, msgs, []int64{4}, []int64{2}, []*ecdsa.PrivateKey{types.TestPrivKey1}, types.NewTestStdFee(), - ) - - ms, key := createTestMultiStore() - ctx := sdk.NewContext(ms, abci.Header{ChainID: types.TestChainID.String()}, false, nil) - accMapper := auth.NewAccountMapper(types.NewTestCodec(), key, auth.ProtoBaseAccount) - - // set account in accountMapper - acc := accMapper.NewAccountWithAddress(ctx, types.TestAddr1.Bytes()) - acc.SetAccountNumber(4) - acc.SetSequence(3) - accMapper.SetAccount(ctx, acc) - - handler := AnteHandler(accMapper, auth.FeeCollectionKeeper{}) - _, res, abort := handler(ctx, tx) - - require.True(t, abort, "expected ante handler to abort") - require.Equal(t, sdk.ABCICodeType(0x10003), res.Code, fmt.Sprintf("invalid code returned on bad tx: %s", res.Log)) -} - -func TestEmbeddedTxValid(t *testing.T) { - testCodec := types.NewTestCodec() - testCodec.RegisterConcrete(stake.MsgDelegate{}, "test/MsgDelegate", nil) - - msgs := []sdk.Msg{ - stake.NewMsgDelegate(types.TestAddr1.Bytes(), types.TestAddr2.Bytes(), sdk.NewCoin("steak", sdk.NewInt(50))), - stake.NewMsgDelegate(types.TestAddr2.Bytes(), types.TestAddr2.Bytes(), sdk.NewCoin("steak", sdk.NewInt(50))), - } - - // create a valid transaction - tx := types.NewTestStdTx( - types.TestChainID, msgs, []int64{4, 5}, []int64{3, 1}, - []*ecdsa.PrivateKey{types.TestPrivKey1, types.TestPrivKey2}, types.NewTestStdFee(), - ) - - ms, key := createTestMultiStore() - ctx := sdk.NewContext(ms, abci.Header{ChainID: types.TestChainID.String()}, false, nil) - accMapper := auth.NewAccountMapper(types.NewTestCodec(), key, auth.ProtoBaseAccount) - - // set accounts in the accountMapper - acc1 := accMapper.NewAccountWithAddress(ctx, types.TestAddr1.Bytes()) - acc1.SetAccountNumber(4) - acc1.SetSequence(3) - accMapper.SetAccount(ctx, acc1) - - acc2 := accMapper.NewAccountWithAddress(ctx, types.TestAddr2.Bytes()) - acc2.SetAccountNumber(5) - acc2.SetSequence(1) - accMapper.SetAccount(ctx, acc2) - - handler := AnteHandler(accMapper, auth.FeeCollectionKeeper{}) - _, res, abort := handler(ctx, tx) - - require.False(t, abort, "expected ante handler to not abort") - require.True(t, res.IsOK(), fmt.Sprintf("result not OK on valid Tx: %s", res.Log)) - - // Ensure account state updated correctly - seq1, _ := accMapper.GetSequence(ctx, types.TestAddr1.Bytes()) - seq2, _ := accMapper.GetSequence(ctx, types.TestAddr2.Bytes()) - - require.Equal(t, int64(4), seq1, "account nonce did not increment correctly") - require.Equal(t, int64(2), seq2, "account nonce did not increment correctly") -} diff --git a/importer/importer_test.go b/importer/importer_test.go index 5fd30a3e..879de57f 100644 --- a/importer/importer_test.go +++ b/importer/importer_test.go @@ -13,9 +13,9 @@ import ( "testing" "time" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/ethermint/core" @@ -63,14 +63,14 @@ func init() { flag.Parse() } -func newTestCodec() *wire.Codec { - codec := wire.NewCodec() +func newTestCodec() *codec.Codec { + cdc := codec.New() - types.RegisterWire(codec) - auth.RegisterWire(codec) - wire.RegisterCrypto(codec) + types.RegisterCodec(cdc) + auth.RegisterCodec(cdc) + codec.RegisterCrypto(cdc) - return codec + return cdc } func cleanup() { @@ -93,12 +93,12 @@ func trapSignals() { }() } -func createAndTestGenesis(t *testing.T, cms sdk.CommitMultiStore, am auth.AccountMapper) { +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, err := evmtypes.NewCommitStateDB(ctx, am, storageKey, codeKey) + stateDB, err := evmtypes.NewCommitStateDB(ctx, ak, storageKey, codeKey) require.NoError(t, err, "failed to create a StateDB instance") // sort the addresses and insertion of key/value pairs matters @@ -142,7 +142,7 @@ func createAndTestGenesis(t *testing.T, cms sdk.CommitMultiStore, am auth.Accoun require.Equal(t, "BF58E5FE5A725463C8FEB755F6A6940584E60F0D", fmt.Sprintf("%X", commitID.Hash)) // verify account mapper state - genAcc := am.GetAccount(ctx, sdk.AccAddress(genInvestor.Bytes())) + genAcc := ak.GetAccount(ctx, sdk.AccAddress(genInvestor.Bytes())) require.NotNil(t, genAcc) require.Equal(t, sdk.NewIntFromBigInt(b), genAcc.GetCoins().AmountOf(types.DenomDefault)) } @@ -169,7 +169,7 @@ func TestImportBlocks(t *testing.T) { cms := store.NewCommitMultiStore(db) // create account mapper - am := auth.NewAccountMapper( + am := auth.NewAccountKeeper( cdc, accKey, types.ProtoBaseAccount, @@ -263,8 +263,8 @@ func TestImportBlocks(t *testing.T) { } } -func createStateDB(t *testing.T, ctx sdk.Context, am auth.AccountMapper) *evmtypes.CommitStateDB { - stateDB, err := evmtypes.NewCommitStateDB(ctx, am, storageKey, codeKey) +func createStateDB(t *testing.T, ctx sdk.Context, ak auth.AccountKeeper) *evmtypes.CommitStateDB { + stateDB, err := evmtypes.NewCommitStateDB(ctx, ak, storageKey, codeKey) require.NoError(t, err, "failed to create a StateDB instance") return stateDB diff --git a/types/test_common.go b/types/test_common.go index 155debc5..80c5cde9 100644 --- a/types/test_common.go +++ b/types/test_common.go @@ -5,14 +5,15 @@ import ( "crypto/ecdsa" "math/big" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/x/auth" ethcmn "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" ethcrypto "github.com/ethereum/go-ethereum/crypto" ) +// test variables var ( TestSDKAddr = GenerateEthAddress() TestChainID = big.NewInt(3) @@ -24,15 +25,15 @@ var ( TestAddr2 = PrivKeyToEthAddress(TestPrivKey2) ) -func NewTestCodec() *wire.Codec { - codec := wire.NewCodec() +func NewTestCodec() *codec.Codec { + cdc := codec.New() - RegisterWire(codec) - auth.RegisterWire(codec) - wire.RegisterCrypto(codec) - codec.RegisterConcrete(&sdk.TestMsg{}, "test/TestMsg", nil) + RegisterCodec(cdc) + auth.RegisterCodec(cdc) + codec.RegisterCrypto(cdc) + cdc.RegisterConcrete(&sdk.TestMsg{}, "test/TestMsg", nil) - return codec + return cdc } func NewTestStdFee() auth.StdFee { diff --git a/types/tx.go b/types/tx.go index 00a696c9..016cd83f 100644 --- a/types/tx.go +++ b/types/tx.go @@ -8,8 +8,8 @@ import ( "math/big" "sync/atomic" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/wire" ethcmn "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" ethcrypto "github.com/ethereum/go-ethereum/crypto" @@ -18,9 +18,12 @@ import ( "github.com/pkg/errors" ) +// TODO: Move to the EVM module + +// message constants const ( - // TypeTxEthereum reflects an Ethereum Transaction type. - TypeTxEthereum = "Ethereum" + TypeTxEthereum = "Ethereum" + RouteTxEthereum = "evm" ) // ---------------------------------------------------------------------------- @@ -238,9 +241,8 @@ func (tx Transaction) VerifySig(chainID *big.Int) (ethcmn.Address, error) { // Type implements the sdk.Msg interface. It returns the type of the // Transaction. -func (tx Transaction) Type() string { - return TypeTxEthereum -} +func (tx Transaction) Type() string { return TypeTxEthereum } +func (tx Transaction) Route() string { return RouteTxEthereum } // ValidateBasic implements the sdk.Msg interface. It performs basic validation // checks of a Transaction. If returns an sdk.Error if validation fails. @@ -283,7 +285,7 @@ func (tx Transaction) hasEmbeddedTx(addr ethcmn.Address) bool { // // CONTRACT: The payload field of an Ethereum transaction must contain a valid // encoded SDK transaction. -func (tx Transaction) GetEmbeddedTx(codec *wire.Codec) (sdk.Tx, sdk.Error) { +func (tx Transaction) GetEmbeddedTx(codec *codec.Codec) (sdk.Tx, sdk.Error) { var etx sdk.Tx err := codec.UnmarshalBinary(tx.data.Payload, &etx) @@ -301,7 +303,7 @@ func (tx Transaction) GetEmbeddedTx(codec *wire.Codec) (sdk.Tx, sdk.Error) { // TxDecoder returns an sdk.TxDecoder that given raw transaction bytes and an // SDK address, attempts to decode them into a Transaction or an EmbeddedTx or // returning an error if decoding fails. -func TxDecoder(codec *wire.Codec, sdkAddress ethcmn.Address) sdk.TxDecoder { +func TxDecoder(codec *codec.Codec, sdkAddress ethcmn.Address) sdk.TxDecoder { return func(txBytes []byte) (sdk.Tx, sdk.Error) { var tx = Transaction{} diff --git a/types/wire.go b/types/wire.go index ad1f2e30..cc3783a8 100644 --- a/types/wire.go +++ b/types/wire.go @@ -1,20 +1,20 @@ package types import ( + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/wire" ) -var typesCodec = wire.NewCodec() +var typesCodec = codec.New() func init() { - RegisterWire(typesCodec) + RegisterCodec(typesCodec) } -// RegisterWire registers all the necessary types with amino for the given +// RegisterCodec registers all the necessary types with amino for the given // codec. -func RegisterWire(codec *wire.Codec) { - sdk.RegisterWire(codec) - codec.RegisterConcrete(&Transaction{}, "types/Transaction", nil) - codec.RegisterConcrete(&Account{}, "types/Account", nil) +func RegisterCodec(cdc *codec.Codec) { + sdk.RegisterCodec(cdc) + cdc.RegisterConcrete(&Transaction{}, "types/Transaction", nil) + cdc.RegisterConcrete(&Account{}, "types/Account", nil) } diff --git a/x/evm/types/statedb.go b/x/evm/types/statedb.go index 9dec051b..bb367871 100644 --- a/x/evm/types/statedb.go +++ b/x/evm/types/statedb.go @@ -33,7 +33,7 @@ type CommitStateDB struct { // StateDB interface. Perhaps there is a better way. ctx sdk.Context - am auth.AccountMapper + ak auth.AccountKeeper storageKey sdk.StoreKey codeKey sdk.StoreKey @@ -76,10 +76,10 @@ 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, am auth.AccountMapper, storageKey, codeKey sdk.StoreKey) (*CommitStateDB, error) { +func NewCommitStateDB(ctx sdk.Context, ak auth.AccountKeeper, storageKey, codeKey sdk.StoreKey) (*CommitStateDB, error) { return &CommitStateDB{ ctx: ctx, - am: am, + ak: ak, storageKey: storageKey, codeKey: codeKey, stateObjects: make(map[ethcmn.Address]*stateObject), @@ -401,13 +401,13 @@ func (csdb *CommitStateDB) IntermediateRoot(deleteEmptyObjects bool) ethcmn.Hash // updateStateObject writes the given state object to the store. func (csdb *CommitStateDB) updateStateObject(so *stateObject) { - csdb.am.SetAccount(csdb.ctx, so.account) + csdb.ak.SetAccount(csdb.ctx, so.account) } // deleteStateObject removes the given state object from the state store. func (csdb *CommitStateDB) deleteStateObject(so *stateObject) { so.deleted = true - csdb.am.RemoveAccount(csdb.ctx, so.account) + csdb.ak.RemoveAccount(csdb.ctx, so.account) } // ---------------------------------------------------------------------------- @@ -556,7 +556,7 @@ func (csdb *CommitStateDB) Copy() ethstate.StateDB { // copy all the basic fields, initialize the memory ones state := &CommitStateDB{ ctx: csdb.ctx, - am: csdb.am, + ak: csdb.ak, storageKey: csdb.storageKey, codeKey: csdb.codeKey, stateObjects: make(map[ethcmn.Address]*stateObject, len(csdb.journal.dirties)), @@ -651,7 +651,7 @@ func (csdb *CommitStateDB) GetOrNewStateObject(addr ethcmn.Address) ethstate.Sta func (csdb *CommitStateDB) createObject(addr ethcmn.Address) (newObj, prevObj *stateObject) { prevObj = csdb.getStateObject(addr) - acc := csdb.am.NewAccountWithAddress(csdb.ctx, sdk.AccAddress(addr.Bytes())) + acc := csdb.ak.NewAccountWithAddress(csdb.ctx, sdk.AccAddress(addr.Bytes())) newObj = newObject(csdb, acc) newObj.setNonce(0) // sets the object to dirty @@ -685,7 +685,7 @@ func (csdb *CommitStateDB) getStateObject(addr ethcmn.Address) (stateObject *sta } // otherwise, attempt to fetch the account from the account mapper - acc := csdb.am.GetAccount(csdb.ctx, addr.Bytes()) + acc := csdb.ak.GetAccount(csdb.ctx, addr.Bytes()) if acc == nil { csdb.setError(fmt.Errorf("no account found for address: %X", addr.Bytes())) return nil