From 42c83c226399767fbfdf2d4e668e83f186de71b0 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Fri, 10 Jul 2020 11:54:23 +0200 Subject: [PATCH 01/37] bump sdk version to v0.39.0 candidate --- go.mod | 11 ++++------- go.sum | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 9e8dd94b2..9206faa1a 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ 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.38.5-0.20200710094359-4bc422d7759c github.com/deckarep/golang-set v1.7.1 // indirect github.com/ethereum/go-ethereum v1.9.15 github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect @@ -25,12 +25,9 @@ require ( github.com/spf13/viper v1.7.0 github.com/status-im/keycard-go v0.0.0-20190424133014-d95853db0f48 // indirect github.com/stretchr/testify v1.6.1 - github.com/tendermint/go-amino v0.15.1 - github.com/tendermint/tendermint v0.33.4 + github.com/tendermint/go-amino v0.15.1 // indirect + github.com/tendermint/tendermint v0.33.6 github.com/tendermint/tm-db v0.5.1 - golang.org/x/crypto v0.0.0-20200406173513-056763e48d71 + golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 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.20200622114457-35ea97f29c5f diff --git a/go.sum b/go.sum index dd474a012..fc1d90a1a 100644 --- a/go.sum +++ b/go.sum @@ -11,6 +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.3 h1:mEV3iyZWjkxQ7R8ia8GcG97vCX5zQQ7n4o8R2BylwQY= +github.com/99designs/keyring v1.1.3/go.mod h1:657DQuMrBZRtuL/voxVyiyb6zpMehlm5vLB9Qwrv904= 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/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= @@ -74,6 +76,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= @@ -121,6 +125,9 @@ 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.38.5-0.20200710094359-4bc422d7759c h1:ssUvjJq0ZnRQbApi0RRwT79ksW5A7WDLLUAWOXRLR1E= +github.com/cosmos/cosmos-sdk v0.38.5-0.20200710094359-4bc422d7759c/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U= +github.com/cosmos/cosmos-sdk v0.38.5 h1:hLSrm4pvhqbA+zhyY+ltEfpynjLGeKFefctK8kHG6TE= 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= @@ -215,6 +222,8 @@ 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= @@ -387,6 +396,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= @@ -503,6 +514,8 @@ 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.6 h1:uICcfUXpgqtw2VopbIncslhAmE5hwc4g20TEyEENBNs= +github.com/rakyll/statik v0.1.6/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs= github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= @@ -599,9 +612,14 @@ github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN 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/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.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/tendermint v0.33.5/go.mod h1:0yUs9eIuuDq07nQql9BmI30FtYGcEC60Tu5JzB5IezM= +github.com/tendermint/tendermint v0.33.6 h1:W4UOsXY4ROJZ3TLLGVVv71VXD4WK2gJRb3gzeced+mg= +github.com/tendermint/tendermint v0.33.6/go.mod h1:0yUs9eIuuDq07nQql9BmI30FtYGcEC60Tu5JzB5IezM= github.com/tendermint/tm-db v0.4.1/go.mod h1:JsJ6qzYkCGiGwm5GHl/H5GLI9XLb6qZX7PRe425dHAY= github.com/tendermint/tm-db v0.5.1 h1:H9HDq8UEA7Eeg13kdYckkgwwkQLBnJGgX4PgLJRhieY= github.com/tendermint/tm-db v0.5.1/go.mod h1:g92zWjHpCYlEvQXvy9M168Su8V1IBEeawpXVVBaK4f4= @@ -657,6 +675,8 @@ golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4 h1:QmwruyY+bKbDDL0BaglrbZ golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4/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 h1:IaQbIIB2X/Mp/DKctl6ROxz1KyMlKp4uyvL6+kQ7C88= +golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -720,6 +740,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-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -816,6 +837,8 @@ 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= From 31ed7ea87e176bff73050a442ad2022c84a66cfc Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Fri, 10 Jul 2020 12:34:13 +0200 Subject: [PATCH 02/37] updates --- app/ethermint.go | 59 +- codec/codec.go | 92 -- codec/codec.pb.go | 864 ------------------ codec/codec.proto | 25 - third_party/proto/cosmos-proto/cosmos.proto | 10 - .../proto/cosmos-sdk/types/types.proto | 80 -- .../proto/cosmos-sdk/x/auth/types/types.proto | 73 -- .../x/auth/vesting/types/types.proto | 76 -- .../cosmos-sdk/x/supply/types/types.proto | 32 - third_party/proto/gogoproto/gogo.proto | 145 --- .../proto/tendermint/abci/types/types.proto | 346 ------- .../tendermint/crypto/merkle/merkle.proto | 31 - .../proto/tendermint/libs/kv/types.proto | 22 - types/account.go | 8 +- types/codec.go | 19 +- types/types.pb.go | 376 -------- x/evm/client/cli/tx.go | 11 +- x/evm/handler.go | 4 +- x/evm/module.go | 16 +- x/evm/module_test.go | 2 +- x/evm/types/state_transition.go | 2 +- x/faucet/client/cli/tx.go | 2 +- x/faucet/client/rest/tx.go | 2 +- x/faucet/handler.go | 2 +- x/faucet/module.go | 16 +- 25 files changed, 65 insertions(+), 2250 deletions(-) delete mode 100644 codec/codec.go delete mode 100644 codec/codec.pb.go delete mode 100644 codec/codec.proto delete mode 100644 third_party/proto/cosmos-proto/cosmos.proto delete mode 100644 third_party/proto/cosmos-sdk/types/types.proto delete mode 100644 third_party/proto/cosmos-sdk/x/auth/types/types.proto delete mode 100644 third_party/proto/cosmos-sdk/x/auth/vesting/types/types.proto delete mode 100644 third_party/proto/cosmos-sdk/x/supply/types/types.proto delete mode 100644 third_party/proto/gogoproto/gogo.proto delete mode 100644 third_party/proto/tendermint/abci/types/types.proto delete mode 100644 third_party/proto/tendermint/crypto/merkle/merkle.proto delete mode 100644 third_party/proto/tendermint/libs/kv/types.proto delete mode 100644 types/types.pb.go diff --git a/app/ethermint.go b/app/ethermint.go index 864b6e047..3c9b96485 100644 --- a/app/ethermint.go +++ b/app/ethermint.go @@ -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" @@ -137,7 +136,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...) @@ -145,7 +143,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, @@ -163,7 +161,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) @@ -176,34 +174,33 @@ func NewEthermintApp( // use custom Ethermint account for contracts app.AccountKeeper = auth.NewAccountKeeper( - appCodec, keys[auth.StoreKey], app.subspaces[auth.ModuleName], eminttypes.ProtoAccount, + cdc, keys[auth.StoreKey], app.subspaces[auth.ModuleName], eminttypes.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, + app.cdc, keys[evm.StoreKey], app.AccountKeeper, app.BankKeeper, ) // TODO: use protobuf app.FaucetKeeper = faucet.NewKeeper( @@ -212,7 +209,7 @@ func NewEthermintApp( // 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. @@ -222,10 +219,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, ) @@ -239,15 +236,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), @@ -281,14 +278,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 ) @@ -331,7 +328,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 diff --git a/codec/codec.go b/codec/codec.go deleted file mode 100644 index 151bed26e..000000000 --- a/codec/codec.go +++ /dev/null @@ -1,92 +0,0 @@ -package codec - -import ( - "github.com/cosmos/cosmos-sdk/codec" - codecstd "github.com/cosmos/cosmos-sdk/codec/std" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - 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" -) - -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. -func MakeCodec(bm module.BasicManager) *codec.Codec { - cdc := codec.New() - - bm.RegisterCodec(cdc) - vesting.RegisterCodec(cdc) - 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) - - return cdc -} diff --git a/codec/codec.pb.go b/codec/codec.pb.go deleted file mode 100644 index bcc082809..000000000 --- a/codec/codec.pb.go +++ /dev/null @@ -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") -) diff --git a/codec/codec.proto b/codec/codec.proto deleted file mode 100644 index ef979be5c..000000000 --- a/codec/codec.proto +++ /dev/null @@ -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; - } -} diff --git a/third_party/proto/cosmos-proto/cosmos.proto b/third_party/proto/cosmos-proto/cosmos.proto deleted file mode 100644 index a59821d4f..000000000 --- a/third_party/proto/cosmos-proto/cosmos.proto +++ /dev/null @@ -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; -} diff --git a/third_party/proto/cosmos-sdk/types/types.proto b/third_party/proto/cosmos-sdk/types/types.proto deleted file mode 100644 index c26219caa..000000000 --- a/third_party/proto/cosmos-sdk/types/types.proto +++ /dev/null @@ -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; -} diff --git a/third_party/proto/cosmos-sdk/x/auth/types/types.proto b/third_party/proto/cosmos-sdk/x/auth/types/types.proto deleted file mode 100644 index 471f90bad..000000000 --- a/third_party/proto/cosmos-sdk/x/auth/types/types.proto +++ /dev/null @@ -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]; -} diff --git a/third_party/proto/cosmos-sdk/x/auth/vesting/types/types.proto b/third_party/proto/cosmos-sdk/x/auth/vesting/types/types.proto deleted file mode 100644 index 9d02bcc4f..000000000 --- a/third_party/proto/cosmos-sdk/x/auth/vesting/types/types.proto +++ /dev/null @@ -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]; -} diff --git a/third_party/proto/cosmos-sdk/x/supply/types/types.proto b/third_party/proto/cosmos-sdk/x/supply/types/types.proto deleted file mode 100644 index 816fc92d7..000000000 --- a/third_party/proto/cosmos-sdk/x/supply/types/types.proto +++ /dev/null @@ -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" - ]; -} diff --git a/third_party/proto/gogoproto/gogo.proto b/third_party/proto/gogoproto/gogo.proto deleted file mode 100644 index 49e78f99f..000000000 --- a/third_party/proto/gogoproto/gogo.proto +++ /dev/null @@ -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; -} diff --git a/third_party/proto/tendermint/abci/types/types.proto b/third_party/proto/tendermint/abci/types/types.proto deleted file mode 100644 index 7fb4b1bdb..000000000 --- a/third_party/proto/tendermint/abci/types/types.proto +++ /dev/null @@ -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); -} diff --git a/third_party/proto/tendermint/crypto/merkle/merkle.proto b/third_party/proto/tendermint/crypto/merkle/merkle.proto deleted file mode 100644 index 159fc58c9..000000000 --- a/third_party/proto/tendermint/crypto/merkle/merkle.proto +++ /dev/null @@ -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]; -} diff --git a/third_party/proto/tendermint/libs/kv/types.proto b/third_party/proto/tendermint/libs/kv/types.proto deleted file mode 100644 index 1b6a7a58d..000000000 --- a/third_party/proto/tendermint/libs/kv/types.proto +++ /dev/null @@ -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; -} diff --git a/types/account.go b/types/account.go index cc22c2e4e..370bdf7ac 100644 --- a/types/account.go +++ b/types/account.go @@ -19,6 +19,10 @@ import ( var _ exported.Account = (*EthAccount)(nil) var _ exported.GenesisAccount = (*EthAccount)(nil) +func init() { + authtypes.RegisterAccountTypeCodec(EthAccount, EthAccountName) +} + // ---------------------------------------------------------------------------- // Main Ethermint account // ---------------------------------------------------------------------------- @@ -45,7 +49,7 @@ type ethermintAccountPretty struct { func (acc EthAccount) MarshalYAML() (interface{}, error) { alias := ethermintAccountPretty{ Address: acc.Address, - PubKey: acc.PubKey, + PubKey: acc.PubKey.Bytes(), AccountNumber: acc.AccountNumber, Sequence: acc.Sequence, CodeHash: ethcmn.Bytes2Hex(acc.CodeHash), @@ -63,7 +67,7 @@ func (acc EthAccount) MarshalYAML() (interface{}, error) { func (acc EthAccount) MarshalJSON() ([]byte, error) { alias := ethermintAccountPretty{ Address: acc.Address, - PubKey: acc.PubKey, + PubKey: acc.PubKey.Bytes(), AccountNumber: acc.AccountNumber, Sequence: acc.Sequence, CodeHash: ethcmn.Bytes2Hex(acc.CodeHash), diff --git a/types/codec.go b/types/codec.go index 68ca96286..f3031a688 100644 --- a/types/codec.go +++ b/types/codec.go @@ -2,30 +2,17 @@ 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) + cdc.RegisterConcrete(&EthAccount{}, EthAccountName, nil) } var ( diff --git a/types/types.pb.go b/types/types.pb.go deleted file mode 100644 index 8e63f702c..000000000 --- a/types/types.pb.go +++ /dev/null @@ -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") -) diff --git a/x/evm/client/cli/tx.go b/x/evm/client/cli/tx.go index 0e145b5b3..0803c20d1 100644 --- a/x/evm/client/cli/tx.go +++ b/x/evm/client/cli/tx.go @@ -19,10 +19,9 @@ 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" ) @@ -83,8 +82,8 @@ func GetCmdSendTx(cdc *codec.Codec) *cobra.Command { from := cliCtx.GetFromAddress() - authclient.Codec = ethermintcodec.NewAppCodec(cdc) - _, seq, err := authtypes.NewAccountRetriever(authclient.Codec, cliCtx).GetAccountNumberSequence(from) + // authclient.Codec = ethermintcodec.NewAppCodec(cdc) + _, seq, err := authtypes.NewAccountRetriever(cliCtx).GetAccountNumberSequence(from) if err != nil { return errors.Wrap(err, "Could not retrieve account sequence") } @@ -136,8 +135,8 @@ func GetCmdGenCreateTx(cdc *codec.Codec) *cobra.Command { from := cliCtx.GetFromAddress() - authclient.Codec = ethermintcodec.NewAppCodec(cdc) - _, seq, err := authtypes.NewAccountRetriever(authclient.Codec, cliCtx).GetAccountNumberSequence(from) + // authclient.Codec = ethermintcodec.NewAppCodec(cdc) + _, seq, err := authtypes.NewAccountRetriever(cliCtx).GetAccountNumberSequence(from) if err != nil { return errors.Wrap(err, "Could not retrieve account sequence") } diff --git a/x/evm/handler.go b/x/evm/handler.go index 0f0c421d2..56c029fbf 100644 --- a/x/evm/handler.go +++ b/x/evm/handler.go @@ -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 } diff --git a/x/evm/module.go b/x/evm/module.go index 5208c5f9b..a04282f89 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -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 } @@ -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) } diff --git a/x/evm/module_test.go b/x/evm/module_test.go index e3cf29e30..d1d232ea5 100644 --- a/x/evm/module_test.go +++ b/x/evm/module_test.go @@ -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") diff --git a/x/evm/types/state_transition.go b/x/evm/types/state_transition.go index beaa767a8..e7b83a231 100644 --- a/x/evm/types/state_transition.go +++ b/x/evm/types/state_transition.go @@ -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 diff --git a/x/faucet/client/cli/tx.go b/x/faucet/client/cli/tx.go index 42dfe94af..2faf648c9 100644 --- a/x/faucet/client/cli/tx.go +++ b/x/faucet/client/cli/tx.go @@ -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" ) diff --git a/x/faucet/client/rest/tx.go b/x/faucet/client/rest/tx.go index 50cc91a1f..4390cbcf4 100644 --- a/x/faucet/client/rest/tx.go +++ b/x/faucet/client/rest/tx.go @@ -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" ) diff --git a/x/faucet/handler.go b/x/faucet/handler.go index 0550161a2..9124d7043 100644 --- a/x/faucet/handler.go +++ b/x/faucet/handler.go @@ -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 } diff --git a/x/faucet/module.go b/x/faucet/module.go index 46ac8b61b..a770610a7 100644 --- a/x/faucet/module.go +++ b/x/faucet/module.go @@ -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. From 10b146f4d5ef769a9ee542bf27ce1b5a4dbc1ede Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Fri, 10 Jul 2020 13:04:27 +0200 Subject: [PATCH 03/37] update evm --- cmd/emintcli/export.go | 8 +++---- cmd/emintcli/keys.go | 12 +++++------ cmd/emintcli/main.go | 4 ++-- cmd/emintd/genaccounts.go | 4 ++-- cmd/emintd/main.go | 24 ++++++++++----------- codec/codec.go | 35 +++++++++++++++++++++++++++++++ rpc/config.go | 14 ++++++------- rpc/eth_api.go | 10 ++++----- types/account.go | 13 +++++++++--- x/evm/types/expected_keepers.go | 4 ++-- x/evm/types/statedb.go | 37 +++++++++++++++++++++++++++++---- 11 files changed, 118 insertions(+), 47 deletions(-) create mode 100644 codec/codec.go diff --git a/cmd/emintcli/export.go b/cmd/emintcli/export.go index b06ebd560..b0e069b53 100644 --- a/cmd/emintcli/export.go +++ b/cmd/emintcli/export.go @@ -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" emintcrypto "github.com/cosmos/ethermint/crypto" @@ -33,7 +33,7 @@ func unsafeExportEthKeyCommand() *cobra.Command { func runExportCmd(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), @@ -47,11 +47,11 @@ func runExportCmd(cmd *cobra.Command, args []string) error { 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) diff --git a/cmd/emintcli/keys.go b/cmd/emintcli/keys.go index eb4299659..943fdf23b 100644 --- a/cmd/emintcli/keys.go +++ b/cmd/emintcli/keys.go @@ -8,7 +8,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" emintCrypto "github.com/cosmos/ethermint/crypto" @@ -52,17 +52,17 @@ func keyCommands() *cobra.Command { return cmd } -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(keyring.WithKeygenFunc(ethermintKeygenFunc)), nil + return keys.NewInMemory(keys.WithKeygenFunc(ethermintKeygenFunc)), nil } - return keyring.NewKeyring( + return keys.NewKeyring( sdk.KeyringServiceName(), viper.GetString(flags.FlagKeyringBackend), viper.GetString(flags.FlagHome), buf, - keyring.WithKeygenFunc(ethermintKeygenFunc)) + keys.WithKeygenFunc(ethermintKeygenFunc)) } func runAddCmd(cmd *cobra.Command, args []string) error { @@ -75,6 +75,6 @@ func runAddCmd(cmd *cobra.Command, args []string) error { return clientkeys.RunAddCmd(cmd, args, kb, inBuf) } -func ethermintKeygenFunc(bz []byte, algo keyring.SigningAlgo) (crypto.PrivKey, error) { +func ethermintKeygenFunc(bz []byte, algo keys.SigningAlgo) (crypto.PrivKey, error) { return emintCrypto.PrivKeySecp256k1(bz), nil } diff --git a/cmd/emintcli/main.go b/cmd/emintcli/main.go index 6e4a9a8bb..51446a5c5 100644 --- a/cmd/emintcli/main.go +++ b/cmd/emintcli/main.go @@ -21,7 +21,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" @@ -41,7 +41,7 @@ func main() { tmamino.RegisterKeyType(emintcrypto.PubKeySecp256k1{}, emintcrypto.PubKeyAminoName) tmamino.RegisterKeyType(emintcrypto.PrivKeySecp256k1{}, emintcrypto.PrivKeyAminoName) - keyring.CryptoCdc = cdc + keys.CryptoCdc = cdc clientkeys.KeysCdc = cdc // Read in the configuration file for the sdk diff --git a/cmd/emintd/genaccounts.go b/cmd/emintd/genaccounts.go index 94dc5d18b..5f95f6045 100644 --- a/cmd/emintd/genaccounts.go +++ b/cmd/emintd/genaccounts.go @@ -12,7 +12,7 @@ import ( "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/crypto/keys" "github.com/cosmos/cosmos-sdk/server" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" @@ -56,7 +56,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), diff --git a/cmd/emintd/main.go b/cmd/emintd/main.go index aa0d38fbe..4f7cec31d 100644 --- a/cmd/emintd/main.go +++ b/cmd/emintd/main.go @@ -6,10 +6,20 @@ import ( "io" "math/big" + "github.com/spf13/cobra" + "github.com/spf13/viper" + + abci "github.com/tendermint/tendermint/abci/types" + tmamino "github.com/tendermint/tendermint/crypto/encoding/amino" + "github.com/tendermint/tendermint/libs/cli" + "github.com/tendermint/tendermint/libs/log" + tmtypes "github.com/tendermint/tendermint/types" + dbm "github.com/tendermint/tm-db" + "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" sdk "github.com/cosmos/cosmos-sdk/types" @@ -19,19 +29,9 @@ import ( genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/staking" - "github.com/spf13/cobra" - "github.com/spf13/viper" - "github.com/cosmos/ethermint/app" "github.com/cosmos/ethermint/codec" emintcrypto "github.com/cosmos/ethermint/crypto" - - abci "github.com/tendermint/tendermint/abci/types" - tmamino "github.com/tendermint/tendermint/crypto/encoding/amino" - "github.com/tendermint/tendermint/libs/cli" - "github.com/tendermint/tendermint/libs/log" - tmtypes "github.com/tendermint/tendermint/types" - dbm "github.com/tendermint/tm-db" ) const flagInvCheckPeriod = "inv-check-period" @@ -47,7 +47,7 @@ func main() { tmamino.RegisterKeyType(emintcrypto.PubKeySecp256k1{}, emintcrypto.PubKeyAminoName) tmamino.RegisterKeyType(emintcrypto.PrivKeySecp256k1{}, emintcrypto.PrivKeyAminoName) - keyring.CryptoCdc = cdc + keys.CryptoCdc = cdc genutil.ModuleCdc = cdc genutiltypes.ModuleCdc = cdc clientkeys.KeysCdc = cdc diff --git a/codec/codec.go b/codec/codec.go new file mode 100644 index 000000000..b54f268e3 --- /dev/null +++ b/codec/codec.go @@ -0,0 +1,35 @@ +package codec + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "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/vesting" + + emintcrypto "github.com/cosmos/ethermint/crypto" + eminttypes "github.com/cosmos/ethermint/types" +) + +// 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. +func MakeCodec(bm module.BasicManager) *codec.Codec { + cdc := codec.New() + + bm.RegisterCodec(cdc) + vesting.RegisterCodec(cdc) + sdk.RegisterCodec(cdc) + emintcrypto.RegisterCodec(cdc) + codec.RegisterCrypto(cdc) + eminttypes.RegisterCodec(cdc) + keys.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 = cdc + + return cdc +} diff --git a/rpc/config.go b/rpc/config.go index 869103fa3..1886c44f2 100644 --- a/rpc/config.go +++ b/rpc/config.go @@ -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" emintcrypto "github.com/cosmos/ethermint/crypto" "github.com/ethereum/go-ethereum/rpc" - - "github.com/spf13/cobra" - "github.com/spf13/viper" ) const ( @@ -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) @@ -99,7 +99,7 @@ func registerRoutes(rs *lcd.RestServer) { } func unlockKeyFromNameAndPassphrase(accountNames []string, passphrase string) (emintKeys []emintcrypto.PrivKeySecp256k1, err error) { - keybase, err := keyring.NewKeyring( + keybase, err := keys.NewKeyring( sdk.KeyringServiceName(), viper.GetString(flags.FlagKeyringBackend), viper.GetString(flags.FlagHome), diff --git a/rpc/eth_api.go b/rpc/eth_api.go index 22eef2091..562ae2f18 100644 --- a/rpc/eth_api.go +++ b/rpc/eth_api.go @@ -34,7 +34,7 @@ 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" @@ -137,7 +137,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), @@ -204,8 +204,8 @@ 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) + // authclient.Codec = codec.NewAppCodec(ctx.Codec) + accRet := authtypes.NewAccountRetriever(ctx) err := accRet.EnsureExists(from) if err != nil { @@ -932,7 +932,7 @@ func (e *PublicEthAPI) generateFromArgs(args params.SendTxArgs) (*evmtypes.MsgEt // 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 { diff --git a/types/account.go b/types/account.go index 370bdf7ac..e1963b347 100644 --- a/types/account.go +++ b/types/account.go @@ -20,13 +20,20 @@ var _ exported.Account = (*EthAccount)(nil) var _ exported.GenesisAccount = (*EthAccount)(nil) func init() { - authtypes.RegisterAccountTypeCodec(EthAccount, EthAccountName) + 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 { @@ -85,12 +92,12 @@ 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.Address = alias.Address diff --git a/x/evm/types/expected_keepers.go b/x/evm/types/expected_keepers.go index b6ce2a756..7b6a21d9b 100644 --- a/x/evm/types/expected_keepers.go +++ b/x/evm/types/expected_keepers.go @@ -16,6 +16,6 @@ type AccountKeeper interface { // 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 + // GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin + // SetBalance(ctx sdk.Context, addr sdk.AccAddress, balance sdk.Coin) error } diff --git a/x/evm/types/statedb.go b/x/evm/types/statedb.go index 4f3f745ec..4c115736f 100644 --- a/x/evm/types/statedb.go +++ b/x/evm/types/statedb.go @@ -480,13 +480,34 @@ 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) + + // TODO: remove on the next upgrade + coins := so.account.GetCoins() + + var setCoins bool + for _, coin := range coins { + if coin.Denom == newBalance.Denom { + // update the balance for photons + coin.Amount = newBalance.Amount + setCoins = true + } + } + + if !setCoins { + coins = coins.Add(newBalance) + } + + _ = so.account.SetCoins(coins) + // end removal for next upgrade + + 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. @@ -608,7 +629,11 @@ func (csdb *CommitStateDB) UpdateAccounts() { continue } - balance := csdb.bankKeeper.GetBalance(csdb.ctx, emintAcc.GetAddress(), emint.DenomDefault) + // balance := csdb.bankKeeper.GetBalance(csdb.ctx, emintAcc.GetAddress(), emint.DenomDefault) + balance := sdk.Coin{ + Denom: emint.DenomDefault, + Amount: emintAcc.GetCoins().AmountOf(emint.DenomDefault), + } if so.Balance() != balance.Amount.BigInt() && balance.IsValid() { so.balance = balance.Amount } @@ -800,7 +825,11 @@ func (csdb *CommitStateDB) getStateObject(addr ethcmn.Address) (stateObject *sta return nil } - balance := csdb.bankKeeper.GetBalance(csdb.ctx, acc.GetAddress(), emint.DenomDefault) + // balance := csdb.bankKeeper.GetBalance(csdb.ctx, acc.GetAddress(), emint.DenomDefault) + balance := sdk.Coin{ + Denom: emint.DenomDefault, + Amount: acc.GetCoins().AmountOf(emint.DenomDefault), + } // insert the state object into the live set so := newStateObject(csdb, acc, balance.Amount) From 548d50dae032e88636afb267913081e2784e187b Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Fri, 10 Jul 2020 15:47:13 +0200 Subject: [PATCH 04/37] bump commit --- cmd/emintcli/main.go | 11 +++-------- cmd/emintd/genaccounts.go | 22 ++++++++++------------ cmd/emintd/main.go | 14 ++++---------- codec/codec.go | 4 ++-- crypto/secp256k1.go | 8 ++++---- go.mod | 4 ++-- go.sum | 2 ++ rpc/eth_api.go | 9 +++------ types/account_test.go | 5 ----- types/codec.go | 17 ----------------- x/faucet/client/rest/tx.go | 5 +++-- 11 files changed, 33 insertions(+), 68 deletions(-) diff --git a/cmd/emintcli/main.go b/cmd/emintcli/main.go index 51446a5c5..0992a0121 100644 --- a/cmd/emintcli/main.go +++ b/cmd/emintcli/main.go @@ -10,10 +10,8 @@ import ( "github.com/cosmos/ethermint/app" "github.com/cosmos/ethermint/codec" - emintcrypto "github.com/cosmos/ethermint/crypto" "github.com/cosmos/ethermint/rpc" - tmamino "github.com/tendermint/tendermint/crypto/encoding/amino" "github.com/tendermint/tendermint/libs/cli" "github.com/cosmos/cosmos-sdk/client" @@ -31,18 +29,15 @@ import ( ) var ( - cdc = codec.MakeCodec(app.ModuleBasics) + codec.MakeCodec(app.ModuleBasics) ) func main() { // Configure cobra to sort commands cobra.EnableCommandSorting = false - tmamino.RegisterKeyType(emintcrypto.PubKeySecp256k1{}, emintcrypto.PubKeyAminoName) - tmamino.RegisterKeyType(emintcrypto.PrivKeySecp256k1{}, emintcrypto.PrivKeyAminoName) - - keys.CryptoCdc = cdc - clientkeys.KeysCdc = cdc + // keys.CryptoCdc = cdc + // clientkeys.KeysCdc = cdc // Read in the configuration file for the sdk config := sdk.GetConfig() diff --git a/cmd/emintd/genaccounts.go b/cmd/emintd/genaccounts.go index 5f95f6045..aca8ba0ee 100644 --- a/cmd/emintd/genaccounts.go +++ b/cmd/emintd/genaccounts.go @@ -11,14 +11,12 @@ 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/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" @@ -36,7 +34,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{ @@ -89,7 +87,7 @@ 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()} + // balances := bank.Balance{Address: addr, Coins: coins.Sort()} baseAccount := auth.NewBaseAccount(addr, nil, 0, 0) if !vestingAmt.IsZero() { baseVestingAccount := authvesting.NewBaseVestingAccount(baseAccount, vestingAmt.Sort(), vestingEnd) @@ -144,16 +142,16 @@ 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) + // 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) - } + // bankGenStateBz, err := cdc.MarshalJSON(bankGenState) + // if err != nil { + // return fmt.Errorf("failed to marshal bank genesis state: %w", err) + // } - appState[bank.ModuleName] = bankGenStateBz + // appState[bank.ModuleName] = bankGenStateBz appStateJSON, err := cdc.MarshalJSON(appState) if err != nil { diff --git a/cmd/emintd/main.go b/cmd/emintd/main.go index 4f7cec31d..0eb34ecce 100644 --- a/cmd/emintd/main.go +++ b/cmd/emintd/main.go @@ -10,7 +10,6 @@ import ( "github.com/spf13/viper" abci "github.com/tendermint/tendermint/abci/types" - tmamino "github.com/tendermint/tendermint/crypto/encoding/amino" "github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/log" tmtypes "github.com/tendermint/tendermint/types" @@ -23,7 +22,7 @@ import ( "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/store" 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" @@ -31,7 +30,6 @@ import ( "github.com/cosmos/ethermint/app" "github.com/cosmos/ethermint/codec" - emintcrypto "github.com/cosmos/ethermint/crypto" ) const flagInvCheckPeriod = "inv-check-period" @@ -42,10 +40,6 @@ func main() { cobra.EnableCommandSorting = false cdc := codec.MakeCodec(app.ModuleBasics) - appCodec := codec.NewAppCodec(cdc) - - tmamino.RegisterKeyType(emintcrypto.PubKeySecp256k1{}, emintcrypto.PubKeyAminoName) - tmamino.RegisterKeyType(emintcrypto.PrivKeySecp256k1{}, emintcrypto.PrivKeyAminoName) keys.CryptoCdc = cdc genutil.ModuleCdc = cdc @@ -68,15 +62,15 @@ func main() { // CLI commands to initialize the chain rootCmd.AddCommand( withChainIDValidation(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.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), // 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), ) diff --git a/codec/codec.go b/codec/codec.go index b54f268e3..9cdf42331 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -16,7 +16,7 @@ import ( // // NOTE: This codec will be deprecated in favor of AppCodec once all modules are // migrated. -func MakeCodec(bm module.BasicManager) *codec.Codec { +func MakeCodec(bm module.BasicManager) { cdc := codec.New() bm.RegisterCodec(cdc) @@ -31,5 +31,5 @@ func MakeCodec(bm module.BasicManager) *codec.Codec { // our codec instead. // authclient.Codec = cdc - return cdc + // return cdc } diff --git a/crypto/secp256k1.go b/crypto/secp256k1.go index f70c5d880..3b01a6109 100644 --- a/crypto/secp256k1.go +++ b/crypto/secp256k1.go @@ -4,17 +4,17 @@ import ( "bytes" "crypto/ecdsa" + tmamino "github.com/tendermint/tendermint/crypto/encoding/amino" + 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) + tmamino.RegisterKeyType(PubKeySecp256k1{}, PubKeyAminoName) + tmamino.RegisterKeyType(PrivKeySecp256k1{}, PrivKeyAminoName) } // ---------------------------------------------------------------------------- diff --git a/go.mod b/go.mod index 9206faa1a..aa3fc9fc9 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ 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.38.5-0.20200710094359-4bc422d7759c + github.com/cosmos/cosmos-sdk v0.38.5-0.20200710132814-b7f991483072 github.com/deckarep/golang-set v1.7.1 // indirect github.com/ethereum/go-ethereum v1.9.15 github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect @@ -18,7 +18,7 @@ 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/regen-network/cosmos-proto v0.1.1-0.20200213154359-02baa11ea7c2 // indirect github.com/rjeczalik/notify v0.9.2 // indirect github.com/spf13/afero v1.2.2 // indirect github.com/spf13/cobra v1.0.0 diff --git a/go.sum b/go.sum index fc1d90a1a..85c491b1e 100644 --- a/go.sum +++ b/go.sum @@ -127,6 +127,8 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/cosmos-sdk v0.38.5-0.20200710094359-4bc422d7759c h1:ssUvjJq0ZnRQbApi0RRwT79ksW5A7WDLLUAWOXRLR1E= github.com/cosmos/cosmos-sdk v0.38.5-0.20200710094359-4bc422d7759c/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U= +github.com/cosmos/cosmos-sdk v0.38.5-0.20200710132814-b7f991483072 h1:/Dvs6mmP3Pi9wRNtwdWRP8j7g2Cg49/dujTudF9WRGw= +github.com/cosmos/cosmos-sdk v0.38.5-0.20200710132814-b7f991483072/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U= github.com/cosmos/cosmos-sdk v0.38.5 h1:hLSrm4pvhqbA+zhyY+ltEfpynjLGeKFefctK8kHG6TE= 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= diff --git a/rpc/eth_api.go b/rpc/eth_api.go index 562ae2f18..46b002aa6 100644 --- a/rpc/eth_api.go +++ b/rpc/eth_api.go @@ -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" emintcrypto "github.com/cosmos/ethermint/crypto" params "github.com/cosmos/ethermint/rpc/args" emint "github.com/cosmos/ethermint/types" @@ -38,7 +35,7 @@ import ( 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" ) @@ -523,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 } @@ -931,7 +928,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) + // authclient.Codec = codec.NewAppCodec(e.cliCtx.Codec) accRet := authtypes.NewAccountRetriever(e.cliCtx) err = accRet.EnsureExists(from) diff --git a/types/account_test.go b/types/account_test.go index a4c7b2ad3..2e93a707c 100644 --- a/types/account_test.go +++ b/types/account_test.go @@ -15,11 +15,6 @@ import ( emintcrypto "github.com/cosmos/ethermint/crypto" ) -func init() { - tmamino.RegisterKeyType(emintcrypto.PubKeySecp256k1{}, emintcrypto.PubKeyAminoName) - tmamino.RegisterKeyType(emintcrypto.PrivKeySecp256k1{}, emintcrypto.PrivKeyAminoName) -} - func TestEthermintAccountJSON(t *testing.T) { pubkey := secp256k1.GenPrivKey().PubKey() addr := sdk.AccAddress(pubkey.Address()) diff --git a/types/codec.go b/types/codec.go index f3031a688..e793e0ecf 100644 --- a/types/codec.go +++ b/types/codec.go @@ -14,20 +14,3 @@ const ( func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(&EthAccount{}, EthAccountName, 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) -} diff --git a/x/faucet/client/rest/tx.go b/x/faucet/client/rest/tx.go index 4390cbcf4..f475bf963 100644 --- a/x/faucet/client/rest/tx.go +++ b/x/faucet/client/rest/tx.go @@ -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 } From 5f3014a4012541bdecd6fc4fba1fbce6488e9f91 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Fri, 10 Jul 2020 16:49:49 +0200 Subject: [PATCH 05/37] more changes --- app/ante/eth.go | 3 ++- app/ante/utils_test.go | 2 +- app/export.go | 6 +++--- cmd/emintcli/main.go | 4 +--- cmd/emintd/main.go | 4 ++-- codec/codec.go | 4 ++-- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/ante/eth.go b/app/ante/eth.go index 156e134d8..36ce67a4c 100644 --- a/app/ante/eth.go +++ b/app/ante/eth.go @@ -193,7 +193,8 @@ 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 := 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, diff --git a/app/ante/utils_test.go b/app/ante/utils_test.go index 8f4efec39..a8cadaa69 100644 --- a/app/ante/utils_test.go +++ b/app/ante/utils_test.go @@ -80,7 +80,7 @@ func newTestSDKTx( } sigs[i] = auth.StdSignature{ - PubKey: priv.PubKey().Bytes(), + PubKey: priv.PubKey(), Signature: sig, } } diff --git a/app/export.go b/app/export.go index 14674b94c..71a8945bb 100644 --- a/app/export.go +++ b/app/export.go @@ -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 diff --git a/cmd/emintcli/main.go b/cmd/emintcli/main.go index 0992a0121..09b490a9a 100644 --- a/cmd/emintcli/main.go +++ b/cmd/emintcli/main.go @@ -16,10 +16,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - 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/keys" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" @@ -29,7 +27,7 @@ import ( ) var ( - codec.MakeCodec(app.ModuleBasics) + cdc = codec.MakeCodec(app.ModuleBasics) ) func main() { diff --git a/cmd/emintd/main.go b/cmd/emintd/main.go index 0eb34ecce..544c803af 100644 --- a/cmd/emintd/main.go +++ b/cmd/emintd/main.go @@ -20,7 +20,7 @@ import ( clientkeys "github.com/cosmos/cosmos-sdk/client/keys" "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/auth" "github.com/cosmos/cosmos-sdk/x/genutil" @@ -89,7 +89,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( diff --git a/codec/codec.go b/codec/codec.go index 9cdf42331..b54f268e3 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -16,7 +16,7 @@ import ( // // NOTE: This codec will be deprecated in favor of AppCodec once all modules are // migrated. -func MakeCodec(bm module.BasicManager) { +func MakeCodec(bm module.BasicManager) *codec.Codec { cdc := codec.New() bm.RegisterCodec(cdc) @@ -31,5 +31,5 @@ func MakeCodec(bm module.BasicManager) { // our codec instead. // authclient.Codec = cdc - // return cdc + return cdc } From 5a2bd4a030c35bf0d0a7651f4ee9978a73cd84d6 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Fri, 10 Jul 2020 17:48:05 +0200 Subject: [PATCH 06/37] build --- app/ethermint_test.go | 2 +- app/export.go | 2 +- app/simulation_test.go | 2 +- cmd/emintd/genaccounts.go | 16 ++++++++++------ importer/importer_test.go | 16 ++++++++-------- types/account.go | 1 + types/account_test.go | 3 ++- 7 files changed, 24 insertions(+), 18 deletions(-) diff --git a/app/ethermint_test.go b/app/ethermint_test.go index c421b36b4..a0cc47751 100644 --- a/app/ethermint_test.go +++ b/app/ethermint_test.go @@ -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) diff --git a/app/export.go b/app/export.go index 71a8945bb..dfb7d17df 100644 --- a/app/export.go +++ b/app/export.go @@ -19,7 +19,7 @@ import ( // NewDefaultGenesisState generates the default state for the application. func NewDefaultGenesisState() simapp.GenesisState { - ethcdc.MakeCodec(ModuleBasics) + _ = ethcdc.MakeCodec(ModuleBasics) return ModuleBasics.DefaultGenesis() } diff --git a/app/simulation_test.go b/app/simulation_test.go index 57d85e288..a144a8537 100644 --- a/app/simulation_test.go +++ b/app/simulation_test.go @@ -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") diff --git a/cmd/emintd/genaccounts.go b/cmd/emintd/genaccounts.go index aca8ba0ee..83cc18751 100644 --- a/cmd/emintd/genaccounts.go +++ b/cmd/emintd/genaccounts.go @@ -11,6 +11,7 @@ import ( "github.com/tendermint/tendermint/libs/cli" "github.com/cosmos/cosmos-sdk/client/flags" + "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" @@ -19,7 +20,6 @@ import ( authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting" "github.com/cosmos/cosmos-sdk/x/genutil" - "github.com/cosmos/ethermint/codec" ethermint "github.com/cosmos/ethermint/types" ethcrypto "github.com/ethereum/go-ethereum/crypto" @@ -88,12 +88,16 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa var genAccount authexported.GenesisAccount // balances := bank.Balance{Address: addr, Coins: coins.Sort()} - baseAccount := auth.NewBaseAccount(addr, nil, 0, 0) + 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") } @@ -119,7 +123,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) } diff --git a/importer/importer_test.go b/importer/importer_test.go index 3df01cac4..9e0e8d9ef 100644 --- a/importer/importer_test.go +++ b/importer/importer_test.go @@ -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" @@ -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 := 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,23 @@ func TestImportBlocks(t *testing.T) { trapSignals() cdc := newTestCodec() - appCodec := codec.NewAppCodec(cdc) + // appCodec := codec.NewAppCodec(cdc) cms := store.NewCommitMultiStore(db) // The ParamsKeeper handles parameter storage for the application - bankKey := sdk.NewKVStoreKey(bank.StoreKey) + // 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) + bk := bank.NewBaseKeeper(ak, bankSubspace, nil) // mount stores - keys := []*sdk.KVStoreKey{accKey, bankKey, storeKey} + keys := []*sdk.KVStoreKey{accKey, storeKey} for _, key := range keys { cms.MountStoreWithDB(key, sdk.StoreTypeIAVL, nil) } diff --git a/types/account.go b/types/account.go index e1963b347..321047f47 100644 --- a/types/account.go +++ b/types/account.go @@ -56,6 +56,7 @@ type ethermintAccountPretty struct { func (acc EthAccount) MarshalYAML() (interface{}, error) { alias := ethermintAccountPretty{ Address: acc.Address, + Coins: acc.Coins, PubKey: acc.PubKey.Bytes(), AccountNumber: acc.AccountNumber, Sequence: acc.Sequence, diff --git a/types/account_test.go b/types/account_test.go index 2e93a707c..40d0cb90b 100644 --- a/types/account_test.go +++ b/types/account_test.go @@ -18,7 +18,8 @@ import ( 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) From 8d00e0566b0ba46347ac96f4ada3cfb561344f87 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Fri, 10 Jul 2020 18:48:15 +0200 Subject: [PATCH 07/37] genesis --- app/ante/ante_test.go | 55 ++++++++++++++++++++++++++----------------- cmd/emintcli/main.go | 11 +++++++-- cmd/emintd/main.go | 5 ++++ crypto/codec.go | 2 +- crypto/secp256k1.go | 7 ------ types/account.go | 12 ++++++++-- 6 files changed, 58 insertions(+), 34 deletions(-) diff --git a/app/ante/ante_test.go b/app/ante/ante_test.go index a283cb7d2..6b69bee1e 100644 --- a/app/ante/ante_test.go +++ b/app/ante/ante_test.go @@ -42,14 +42,16 @@ 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) + // 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) + // 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 +71,16 @@ 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) + // 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) + // 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 +104,16 @@ 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) + // 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) + // err = suite.app.BankKeeper.SetBalances(suite.ctx, acc2.GetAddress(), newTestCoins()) + // suite.Require().NoError(err) fee := newTestStdFee() msg1 := newTestMsg(addr1, addr2) @@ -150,9 +156,10 @@ 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) + // err := suite.app.BankKeeper.SetBalances(suite.ctx, acc1.GetAddress(), newTestCoins()) + // suite.Require().NoError(err) fee := newTestStdFee() msg1 := newTestMsg(addr1) @@ -201,8 +208,9 @@ 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()) + // err = suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins()) + // suite.Require().NoError(err) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) // require a valid Ethereum tx to pass @@ -243,8 +251,9 @@ 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()) + // err := suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins()) + // suite.Require().NoError(err) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) // require a valid Ethereum tx to pass @@ -270,8 +279,9 @@ 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()) + // err := suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins()) + // suite.Require().NoError(err) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) // require a valid Ethereum tx to pass @@ -292,8 +302,9 @@ 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()) + // err := suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins()) + // suite.Require().NoError(err) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) // require a valid Ethereum tx to pass diff --git a/cmd/emintcli/main.go b/cmd/emintcli/main.go index 09b490a9a..12e2dd9f3 100644 --- a/cmd/emintcli/main.go +++ b/cmd/emintcli/main.go @@ -10,14 +10,18 @@ import ( "github.com/cosmos/ethermint/app" "github.com/cosmos/ethermint/codec" + "github.com/cosmos/ethermint/crypto" "github.com/cosmos/ethermint/rpc" + tmamino "github.com/tendermint/tendermint/crypto/encoding/amino" "github.com/tendermint/tendermint/libs/cli" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + 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/keys" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" @@ -34,8 +38,11 @@ func main() { // Configure cobra to sort commands cobra.EnableCommandSorting = false - // keys.CryptoCdc = cdc - // clientkeys.KeysCdc = cdc + tmamino.RegisterKeyType(crypto.PubKeySecp256k1{}, crypto.PubKeyAminoName) + tmamino.RegisterKeyType(crypto.PrivKeySecp256k1{}, crypto.PrivKeyAminoName) + + keys.CryptoCdc = cdc + clientkeys.KeysCdc = cdc // Read in the configuration file for the sdk config := sdk.GetConfig() diff --git a/cmd/emintd/main.go b/cmd/emintd/main.go index 544c803af..863958d6d 100644 --- a/cmd/emintd/main.go +++ b/cmd/emintd/main.go @@ -10,6 +10,7 @@ import ( "github.com/spf13/viper" abci "github.com/tendermint/tendermint/abci/types" + tmamino "github.com/tendermint/tendermint/crypto/encoding/amino" "github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/libs/log" tmtypes "github.com/tendermint/tendermint/types" @@ -30,6 +31,7 @@ import ( "github.com/cosmos/ethermint/app" "github.com/cosmos/ethermint/codec" + "github.com/cosmos/ethermint/crypto" ) const flagInvCheckPeriod = "inv-check-period" @@ -41,6 +43,9 @@ func main() { cdc := codec.MakeCodec(app.ModuleBasics) + tmamino.RegisterKeyType(crypto.PubKeySecp256k1{}, crypto.PubKeyAminoName) + tmamino.RegisterKeyType(crypto.PrivKeySecp256k1{}, crypto.PrivKeyAminoName) + keys.CryptoCdc = cdc genutil.ModuleCdc = cdc genutiltypes.ModuleCdc = cdc diff --git a/crypto/codec.go b/crypto/codec.go index 1ed97ac51..2e551f20a 100644 --- a/crypto/codec.go +++ b/crypto/codec.go @@ -6,8 +6,8 @@ import ( var cryptoCodec = codec.New() +// Amino encoding names const ( - // Amino encoding names PrivKeyAminoName = "crypto/PrivKeySecp256k1" PubKeyAminoName = "crypto/PubKeySecp256k1" ) diff --git a/crypto/secp256k1.go b/crypto/secp256k1.go index 3b01a6109..0470b2b44 100644 --- a/crypto/secp256k1.go +++ b/crypto/secp256k1.go @@ -4,19 +4,12 @@ import ( "bytes" "crypto/ecdsa" - tmamino "github.com/tendermint/tendermint/crypto/encoding/amino" - ethcrypto "github.com/ethereum/go-ethereum/crypto" ethsecp256k1 "github.com/ethereum/go-ethereum/crypto/secp256k1" tmcrypto "github.com/tendermint/tendermint/crypto" ) -func init() { - tmamino.RegisterKeyType(PubKeySecp256k1{}, PubKeyAminoName) - tmamino.RegisterKeyType(PrivKeySecp256k1{}, PrivKeyAminoName) -} - // ---------------------------------------------------------------------------- // secp256k1 Private Key diff --git a/types/account.go b/types/account.go index 321047f47..9353e3317 100644 --- a/types/account.go +++ b/types/account.go @@ -57,12 +57,15 @@ func (acc EthAccount) MarshalYAML() (interface{}, error) { alias := ethermintAccountPretty{ Address: acc.Address, Coins: acc.Coins, - PubKey: acc.PubKey.Bytes(), 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 @@ -75,12 +78,16 @@ func (acc EthAccount) MarshalYAML() (interface{}, error) { func (acc EthAccount) MarshalJSON() ([]byte, error) { alias := ethermintAccountPretty{ Address: acc.Address, - PubKey: acc.PubKey.Bytes(), + 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) } @@ -101,6 +108,7 @@ func (acc *EthAccount) UnmarshalJSON(bz []byte) error { acc.BaseAccount.PubKey = pubKey } + acc.BaseAccount.Coins = alias.Coins acc.BaseAccount.Address = alias.Address acc.BaseAccount.AccountNumber = alias.AccountNumber acc.BaseAccount.Sequence = alias.Sequence From 27bcec0a7d6d896efd8680e541fd65831856900a Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 14 Jul 2020 11:54:32 +0200 Subject: [PATCH 08/37] fix tests --- x/evm/types/journal_test.go | 25 ++++++++++++------------- x/evm/types/statedb_test.go | 4 +++- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/x/evm/types/journal_test.go b/x/evm/types/journal_test.go index 6c1673b95..3911e30f9 100644 --- a/x/evm/types/journal_test.go +++ b/x/evm/types/journal_test.go @@ -21,7 +21,6 @@ import ( 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 +34,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 +56,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 := ðermint.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 +96,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,23 +106,23 @@ 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) + bk := bank.NewBaseKeeper(ak, bankSubspace, nil) suite.ctx = sdk.NewContext(cms, abci.Header{ChainID: "8"}, false, tmlog.NewNopLogger()) suite.stateDB = NewCommitStateDB(suite.ctx, storeKey, ak, bk).WithContext(suite.ctx) diff --git a/x/evm/types/statedb_test.go b/x/evm/types/statedb_test.go index f8a8c4371..f76aa7203 100644 --- a/x/evm/types/statedb_test.go +++ b/x/evm/types/statedb_test.go @@ -49,8 +49,10 @@ func (suite *StateDBTestSuite) SetupTest() { suite.Require().NoError(err) suite.address = ethcmn.BytesToAddress(privkey.PubKey().Address().Bytes()) + + balance := sdk.NewCoins(sdk.NewCoin(ethermint.DenomDefault, sdk.NewInt(0))) acc := ðermint.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), } From f3fc83b9859f08690cce8c7e25aa0a0749dfa0ac Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 14 Jul 2020 12:01:54 +0200 Subject: [PATCH 09/37] fix tests --- types/account_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/account_test.go b/types/account_test.go index 40d0cb90b..cb13b66e3 100644 --- a/types/account_test.go +++ b/types/account_test.go @@ -15,6 +15,11 @@ import ( emintcrypto "github.com/cosmos/ethermint/crypto" ) +func init() { + tmamino.RegisterKeyType(emintcrypto.PubKeySecp256k1{}, emintcrypto.PubKeyAminoName) + tmamino.RegisterKeyType(emintcrypto.PrivKeySecp256k1{}, emintcrypto.PrivKeyAminoName) +} + func TestEthermintAccountJSON(t *testing.T) { pubkey := secp256k1.GenPrivKey().PubKey() addr := sdk.AccAddress(pubkey.Address()) From af485d62ec0bf98d5400a616fe8e182bbde5b738 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 14 Jul 2020 12:20:23 +0200 Subject: [PATCH 10/37] bump commit --- codec/codec.go | 6 +++--- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/codec/codec.go b/codec/codec.go index b54f268e3..f4d431b49 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -8,14 +8,14 @@ import ( "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" ) // 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() @@ -24,7 +24,7 @@ func MakeCodec(bm module.BasicManager) *codec.Codec { sdk.RegisterCodec(cdc) emintcrypto.RegisterCodec(cdc) codec.RegisterCrypto(cdc) - eminttypes.RegisterCodec(cdc) + ethermint.RegisterCodec(cdc) keys.RegisterCodec(cdc) // temporary. Used to register keyring.Info // since auth client doesn't use the ethermint account type, we need to set diff --git a/go.mod b/go.mod index f1c889d50..e4d10900b 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ 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.38.5-0.20200710132814-b7f991483072 + github.com/cosmos/cosmos-sdk v0.38.5-0.20200714095552-f384592dcf46 github.com/deckarep/golang-set v1.7.1 // indirect github.com/ethereum/go-ethereum v1.9.16 github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect diff --git a/go.sum b/go.sum index eed70cee4..8ac19dca0 100644 --- a/go.sum +++ b/go.sum @@ -119,8 +119,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.38.5-0.20200710132814-b7f991483072 h1:/Dvs6mmP3Pi9wRNtwdWRP8j7g2Cg49/dujTudF9WRGw= -github.com/cosmos/cosmos-sdk v0.38.5-0.20200710132814-b7f991483072/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U= +github.com/cosmos/cosmos-sdk v0.38.5-0.20200714095552-f384592dcf46 h1:oTHQllU2lF0qkvxHJmQwYqOWROTsa3C1TsObiYW+UCc= +github.com/cosmos/cosmos-sdk v0.38.5-0.20200714095552-f384592dcf46/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U= 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= From 728ddcdc86b819e01fc0766fc1ab89205b1afc2f Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 14 Jul 2020 17:57:07 +0200 Subject: [PATCH 11/37] bump commit --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e4d10900b..27d3d3d82 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ 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.38.5-0.20200714095552-f384592dcf46 + github.com/cosmos/cosmos-sdk v0.38.5-0.20200714105024-f63b2ac29901 github.com/deckarep/golang-set v1.7.1 // indirect github.com/ethereum/go-ethereum v1.9.16 github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect diff --git a/go.sum b/go.sum index 8ac19dca0..c9aedd246 100644 --- a/go.sum +++ b/go.sum @@ -119,8 +119,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.38.5-0.20200714095552-f384592dcf46 h1:oTHQllU2lF0qkvxHJmQwYqOWROTsa3C1TsObiYW+UCc= -github.com/cosmos/cosmos-sdk v0.38.5-0.20200714095552-f384592dcf46/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U= +github.com/cosmos/cosmos-sdk v0.38.5-0.20200714105024-f63b2ac29901 h1:zOWM844BeY6ERSOe6TwPMhUop0pcwvxaxE6cDrpj3bE= +github.com/cosmos/cosmos-sdk v0.38.5-0.20200714105024-f63b2ac29901/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U= 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= From 534534ef6bc75a6c89b553fe073103d3092d0d77 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 14 Jul 2020 18:00:42 +0200 Subject: [PATCH 12/37] bump commit --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 27d3d3d82..a9fa3d3c1 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ 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.38.5-0.20200714105024-f63b2ac29901 + github.com/cosmos/cosmos-sdk v0.38.6-0.20200714105024-f63b2ac29901 github.com/deckarep/golang-set v1.7.1 // indirect github.com/ethereum/go-ethereum v1.9.16 github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect diff --git a/go.sum b/go.sum index c9aedd246..266173679 100644 --- a/go.sum +++ b/go.sum @@ -119,8 +119,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.38.5-0.20200714105024-f63b2ac29901 h1:zOWM844BeY6ERSOe6TwPMhUop0pcwvxaxE6cDrpj3bE= -github.com/cosmos/cosmos-sdk v0.38.5-0.20200714105024-f63b2ac29901/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U= +github.com/cosmos/cosmos-sdk v0.38.6-0.20200714105024-f63b2ac29901 h1:m/TPRwa9w3PHmFig6X5/UzGHWrUM4WZ5KnwqoXIwHUo= +github.com/cosmos/cosmos-sdk v0.38.6-0.20200714105024-f63b2ac29901/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U= 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= From acb202e2126f7fe00f5735a254f28d3b676ec65e Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 15 Jul 2020 12:48:19 +0200 Subject: [PATCH 13/37] add keygen func --- cmd/emintcli/export.go | 2 ++ cmd/emintcli/keys.go | 17 ++++++----------- cmd/emintd/genaccounts.go | 2 ++ crypto/secp256k1.go | 8 ++++++++ 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/cmd/emintcli/export.go b/cmd/emintcli/export.go index b0e069b53..cdf2b5db5 100644 --- a/cmd/emintcli/export.go +++ b/cmd/emintcli/export.go @@ -16,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/ethermint/crypto" emintcrypto "github.com/cosmos/ethermint/crypto" ) @@ -38,6 +39,7 @@ func runExportCmd(cmd *cobra.Command, args []string) error { viper.GetString(flags.FlagKeyringBackend), viper.GetString(flags.FlagHome), inBuf, + keys.WithKeygenFunc(crypto.EthermintKeygenFunc), ) if err != nil { return err diff --git a/cmd/emintcli/keys.go b/cmd/emintcli/keys.go index 943fdf23b..9616818fd 100644 --- a/cmd/emintcli/keys.go +++ b/cmd/emintcli/keys.go @@ -4,17 +4,15 @@ import ( "bufio" "io" - "github.com/tendermint/tendermint/crypto" + "github.com/spf13/cobra" + "github.com/spf13/viper" "github.com/cosmos/cosmos-sdk/client/flags" clientkeys "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/crypto/keys" sdk "github.com/cosmos/cosmos-sdk/types" - emintCrypto "github.com/cosmos/ethermint/crypto" - - "github.com/spf13/cobra" - "github.com/spf13/viper" + "github.com/cosmos/ethermint/crypto" ) const ( @@ -54,7 +52,7 @@ func keyCommands() *cobra.Command { func getKeybase(transient bool, buf io.Reader) (keys.Keybase, error) { if transient { - return keys.NewInMemory(keys.WithKeygenFunc(ethermintKeygenFunc)), nil + return keys.NewInMemory(keys.WithKeygenFunc(crypto.EthermintKeygenFunc)), nil } return keys.NewKeyring( @@ -62,7 +60,8 @@ func getKeybase(transient bool, buf io.Reader) (keys.Keybase, error) { viper.GetString(flags.FlagKeyringBackend), viper.GetString(flags.FlagHome), buf, - keys.WithKeygenFunc(ethermintKeygenFunc)) + keys.WithKeygenFunc(crypto.EthermintKeygenFunc), + ) } func runAddCmd(cmd *cobra.Command, args []string) error { @@ -74,7 +73,3 @@ func runAddCmd(cmd *cobra.Command, args []string) error { return clientkeys.RunAddCmd(cmd, args, kb, inBuf) } - -func ethermintKeygenFunc(bz []byte, algo keys.SigningAlgo) (crypto.PrivKey, error) { - return emintCrypto.PrivKeySecp256k1(bz), nil -} diff --git a/cmd/emintd/genaccounts.go b/cmd/emintd/genaccounts.go index 83cc18751..468b4ad82 100644 --- a/cmd/emintd/genaccounts.go +++ b/cmd/emintd/genaccounts.go @@ -20,6 +20,7 @@ import ( authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting" "github.com/cosmos/cosmos-sdk/x/genutil" + "github.com/cosmos/ethermint/crypto" ethermint "github.com/cosmos/ethermint/types" ethcrypto "github.com/ethereum/go-ethereum/crypto" @@ -59,6 +60,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa viper.GetString(flags.FlagKeyringBackend), viper.GetString(flagClientHome), inBuf, + keys.WithKeygenFunc(crypto.EthermintKeygenFunc), ) if err != nil { return err diff --git a/crypto/secp256k1.go b/crypto/secp256k1.go index 0470b2b44..865327a3f 100644 --- a/crypto/secp256k1.go +++ b/crypto/secp256k1.go @@ -4,12 +4,20 @@ import ( "bytes" "crypto/ecdsa" + "github.com/cosmos/cosmos-sdk/crypto/keys" + ethcrypto "github.com/ethereum/go-ethereum/crypto" ethsecp256k1 "github.com/ethereum/go-ethereum/crypto/secp256k1" + "github.com/tendermint/tendermint/crypto" tmcrypto "github.com/tendermint/tendermint/crypto" ) +// EthermintKeygenFunc defines the function to create ECDSA keys +func EthermintKeygenFunc(bz []byte, algo keys.SigningAlgo) (crypto.PrivKey, error) { + return PrivKeySecp256k1(bz), nil +} + // ---------------------------------------------------------------------------- // secp256k1 Private Key From ea5d0c327249d615eea26d1e843a715c94297d79 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 15 Jul 2020 13:35:38 +0200 Subject: [PATCH 14/37] bump version to 0.39.0-rc0 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a9fa3d3c1..f8df988ad 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ 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.38.6-0.20200714105024-f63b2ac29901 + github.com/cosmos/cosmos-sdk v0.39.0-rc0 github.com/deckarep/golang-set v1.7.1 // indirect github.com/ethereum/go-ethereum v1.9.16 github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect diff --git a/go.sum b/go.sum index 266173679..ce1309605 100644 --- a/go.sum +++ b/go.sum @@ -119,8 +119,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.38.6-0.20200714105024-f63b2ac29901 h1:m/TPRwa9w3PHmFig6X5/UzGHWrUM4WZ5KnwqoXIwHUo= -github.com/cosmos/cosmos-sdk v0.38.6-0.20200714105024-f63b2ac29901/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U= +github.com/cosmos/cosmos-sdk v0.39.0-rc0 h1:wH9HcyBIYQULzHhCdS36c4TmRzEaFSZgOVymd2iR71A= +github.com/cosmos/cosmos-sdk v0.39.0-rc0/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U= 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= From 0c2f70882d7c52decf9adec483880d292787d2e8 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 15 Jul 2020 13:37:47 +0200 Subject: [PATCH 15/37] update AnteHandler --- app/ante/ante.go | 4 +--- app/ante/eth.go | 6 ------ 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/app/ante/ante.go b/app/ante/ante.go index 7ea5f7706..544900d4f 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -43,9 +43,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: diff --git a/app/ante/eth.go b/app/ante/eth.go index 36ce67a4c..d6bfabb06 100644 --- a/app/ante/eth.go +++ b/app/ante/eth.go @@ -346,12 +346,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) From 2d9bc52546e30a958a4d5df6527605ac28efb48b Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 15 Jul 2020 13:44:17 +0200 Subject: [PATCH 16/37] fix TxDecoder --- x/evm/types/utils.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x/evm/types/utils.go b/x/evm/types/utils.go index 3b47535b4..552fd57b0 100644 --- a/x/evm/types/utils.go +++ b/x/evm/types/utils.go @@ -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()) } From 1c289e900cafd0865034c34a587001d20a9f3a70 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 15 Jul 2020 13:48:13 +0200 Subject: [PATCH 17/37] lint --- cmd/emintcli/export.go | 3 +-- crypto/secp256k1.go | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cmd/emintcli/export.go b/cmd/emintcli/export.go index cdf2b5db5..ecf3a700b 100644 --- a/cmd/emintcli/export.go +++ b/cmd/emintcli/export.go @@ -17,7 +17,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ethermint/crypto" - emintcrypto "github.com/cosmos/ethermint/crypto" ) func unsafeExportEthKeyCommand() *cobra.Command { @@ -69,7 +68,7 @@ func runExportCmd(cmd *cobra.Command, args []string) error { } // Converts key to Ethermint secp256 implementation - emintKey, ok := privKey.(emintcrypto.PrivKeySecp256k1) + emintKey, ok := privKey.(crypto.PrivKeySecp256k1) if !ok { return fmt.Errorf("invalid private key type, must be Ethereum key: %T", privKey) } diff --git a/crypto/secp256k1.go b/crypto/secp256k1.go index 865327a3f..7bddc374b 100644 --- a/crypto/secp256k1.go +++ b/crypto/secp256k1.go @@ -9,12 +9,11 @@ import ( ethcrypto "github.com/ethereum/go-ethereum/crypto" ethsecp256k1 "github.com/ethereum/go-ethereum/crypto/secp256k1" - "github.com/tendermint/tendermint/crypto" tmcrypto "github.com/tendermint/tendermint/crypto" ) // EthermintKeygenFunc defines the function to create ECDSA keys -func EthermintKeygenFunc(bz []byte, algo keys.SigningAlgo) (crypto.PrivKey, error) { +func EthermintKeygenFunc(bz []byte, algo keys.SigningAlgo) (tmcrypto.PrivKey, error) { return PrivKeySecp256k1(bz), nil } From daf1a1acfd830980a3bded9a9318ae3b43296642 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 15 Jul 2020 14:10:42 +0200 Subject: [PATCH 18/37] fix test --- x/evm/types/state_transition_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/x/evm/types/state_transition_test.go b/x/evm/types/state_transition_test.go index ba8f40a49..77eac1ff4 100644 --- a/x/evm/types/state_transition_test.go +++ b/x/evm/types/state_transition_test.go @@ -18,7 +18,11 @@ 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) + + // suite.app.BankKeeper.SetBalance(suite.ctx, addr, balance) priv, err := crypto.GenerateKey() suite.Require().NoError(err) @@ -92,7 +96,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, From 3f478df7c5abb63aa6d7ff5eb0750fbd1e5791dd Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 15 Jul 2020 14:22:20 +0200 Subject: [PATCH 19/37] update statedb --- rpc/config.go | 9 +++++---- rpc/eth_api.go | 9 +++++---- x/evm/types/statedb.go | 13 ++----------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/rpc/config.go b/rpc/config.go index 1886c44f2..d0a5fddc5 100644 --- a/rpc/config.go +++ b/rpc/config.go @@ -19,7 +19,7 @@ import ( authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" "github.com/cosmos/ethermint/app" - emintcrypto "github.com/cosmos/ethermint/crypto" + "github.com/cosmos/ethermint/crypto" "github.com/ethereum/go-ethereum/rpc" ) @@ -45,7 +45,7 @@ func registerRoutes(rs *lcd.RestServer) { accountName := viper.GetString(flagUnlockKey) accountNames := strings.Split(accountName, ",") - var emintKeys []emintcrypto.PrivKeySecp256k1 + var emintKeys []crypto.PrivKeySecp256k1 if len(accountName) > 0 { var err error inBuf := bufio.NewReader(os.Stdin) @@ -98,12 +98,13 @@ func registerRoutes(rs *lcd.RestServer) { ws.start() } -func unlockKeyFromNameAndPassphrase(accountNames []string, passphrase string) (emintKeys []emintcrypto.PrivKeySecp256k1, err error) { +func unlockKeyFromNameAndPassphrase(accountNames []string, passphrase string) (emintKeys []crypto.PrivKeySecp256k1, err error) { keybase, err := keys.NewKeyring( sdk.KeyringServiceName(), viper.GetString(flags.FlagKeyringBackend), viper.GetString(flags.FlagHome), os.Stdin, + keys.WithKeygenFunc(crypto.EthermintKeygenFunc), ) if err != nil { return @@ -119,7 +120,7 @@ func unlockKeyFromNameAndPassphrase(accountNames []string, passphrase string) (e } var ok bool - emintKey, ok := privKey.(emintcrypto.PrivKeySecp256k1) + emintKey, ok := privKey.(crypto.PrivKeySecp256k1) if !ok { panic(fmt.Sprintf("invalid private key type: %T", privKey)) } diff --git a/rpc/eth_api.go b/rpc/eth_api.go index 46b002aa6..d0e8dc57f 100644 --- a/rpc/eth_api.go +++ b/rpc/eth_api.go @@ -11,7 +11,7 @@ import ( "github.com/spf13/viper" - emintcrypto "github.com/cosmos/ethermint/crypto" + "github.com/cosmos/ethermint/crypto" params "github.com/cosmos/ethermint/rpc/args" emint "github.com/cosmos/ethermint/types" "github.com/cosmos/ethermint/utils" @@ -43,14 +43,14 @@ import ( type PublicEthAPI struct { cliCtx context.CLIContext backend Backend - keys []emintcrypto.PrivKeySecp256k1 + keys []crypto.PrivKeySecp256k1 nonceLock *AddrLocker keybaseLock sync.Mutex } // NewPublicEthAPI creates an instance of the public ETH Web3 API. func NewPublicEthAPI(cliCtx context.CLIContext, backend Backend, nonceLock *AddrLocker, - key []emintcrypto.PrivKeySecp256k1) *PublicEthAPI { + key []crypto.PrivKeySecp256k1) *PublicEthAPI { return &PublicEthAPI{ cliCtx: cliCtx, @@ -139,6 +139,7 @@ func (e *PublicEthAPI) Accounts() ([]common.Address, error) { viper.GetString(flags.FlagKeyringBackend), viper.GetString(flags.FlagHome), e.cliCtx.Input, + keys.WithKeygenFunc(crypto.EthermintKeygenFunc), ) if err != nil { return addresses, err @@ -291,7 +292,7 @@ func (e *PublicEthAPI) ExportAccount(address common.Address, blockNumber BlockNu return string(res), nil } -func checkKeyInKeyring(keys []emintcrypto.PrivKeySecp256k1, address common.Address) (key emintcrypto.PrivKeySecp256k1, exist bool) { +func checkKeyInKeyring(keys []crypto.PrivKeySecp256k1, address common.Address) (key crypto.PrivKeySecp256k1, exist bool) { if len(keys) > 0 { for _, key := range keys { if bytes.Equal(key.PubKey().Address().Bytes(), address.Bytes()) { diff --git a/x/evm/types/statedb.go b/x/evm/types/statedb.go index d16f962f2..baec3c8d2 100644 --- a/x/evm/types/statedb.go +++ b/x/evm/types/statedb.go @@ -494,17 +494,8 @@ func (csdb *CommitStateDB) updateStateObject(so *stateObject) error { // TODO: remove on the next upgrade coins := so.account.GetCoins() - - var setCoins bool - for _, coin := range coins { - if coin.Denom == newBalance.Denom { - // update the balance for photons - coin.Amount = newBalance.Amount - setCoins = true - } - } - - if !setCoins { + balance := coins.AmountOf(newBalance.Denom) + if balance.IsZero() || !balance.Equal(newBalance.Amount) { coins = coins.Add(newBalance) } From 7627f77f77e45f7d8506849010d9464a28b15b26 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 15 Jul 2020 14:26:15 +0200 Subject: [PATCH 20/37] changelog --- CHANGELOG.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4eb12d621..ad4e20521 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. @@ -80,7 +78,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. - * Removes `Hash()` (RLP) function from `MsgEthereumTx` to avoid confusion or misuse in future. \ No newline at end of file +* (`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. From 04c9ed2a4e4f3c11adbe805136df579e7ac6d418 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Mon, 20 Jul 2020 13:28:30 +0200 Subject: [PATCH 21/37] fixes --- .github/workflows/test.yml | 34 +- importer/importer_test.go | 5 +- local_testnet/node0/emintd/config/app.toml | 36 ++ local_testnet/node0/emintd/config/config.toml | 335 ++++++++++++++++++ .../node0/emintd/config/node_key.json | 1 + .../emintd/config/priv_validator_key.json | 11 + .../node0/emintd/data/application.db/CURRENT | 1 + .../node0/emintd/data/application.db/LOCK | 0 .../node0/emintd/data/application.db/LOG | 6 + .../data/application.db/MANIFEST-000000 | Bin 0 -> 54 bytes .../node0/emintd/data/blockstore.db/CURRENT | 1 + .../node0/emintd/data/blockstore.db/LOCK | 0 .../node0/emintd/data/blockstore.db/LOG | 6 + .../emintd/data/blockstore.db/MANIFEST-000000 | Bin 0 -> 54 bytes .../emintd/data/priv_validator_state.json | 5 + .../node0/emintd/data/state.db/CURRENT | 1 + local_testnet/node0/emintd/data/state.db/LOCK | 0 local_testnet/node0/emintd/data/state.db/LOG | 6 + .../emintd/data/state.db/MANIFEST-000000 | Bin 0 -> 54 bytes types/account.go | 33 ++ x/evm/types/journal_test.go | 2 +- x/evm/types/state_object.go | 37 +- x/evm/types/statedb.go | 27 +- 23 files changed, 504 insertions(+), 43 deletions(-) create mode 100644 local_testnet/node0/emintd/config/app.toml create mode 100644 local_testnet/node0/emintd/config/config.toml create mode 100644 local_testnet/node0/emintd/config/node_key.json create mode 100644 local_testnet/node0/emintd/config/priv_validator_key.json create mode 100644 local_testnet/node0/emintd/data/application.db/CURRENT create mode 100644 local_testnet/node0/emintd/data/application.db/LOCK create mode 100644 local_testnet/node0/emintd/data/application.db/LOG create mode 100644 local_testnet/node0/emintd/data/application.db/MANIFEST-000000 create mode 100644 local_testnet/node0/emintd/data/blockstore.db/CURRENT create mode 100644 local_testnet/node0/emintd/data/blockstore.db/LOCK create mode 100644 local_testnet/node0/emintd/data/blockstore.db/LOG create mode 100644 local_testnet/node0/emintd/data/blockstore.db/MANIFEST-000000 create mode 100644 local_testnet/node0/emintd/data/priv_validator_state.json create mode 100644 local_testnet/node0/emintd/data/state.db/CURRENT create mode 100644 local_testnet/node0/emintd/data/state.db/LOCK create mode 100644 local_testnet/node0/emintd/data/state.db/LOG create mode 100644 local_testnet/node0/emintd/data/state.db/MANIFEST-000000 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fe47c9296..18c56b152 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -193,20 +193,20 @@ jobs: run: | make test-rpc if: "env.GIT_DIFF != ''" - # TODO: remove tmp dir to fix this - # test-importer: - # runs-on: ubuntu-latest - # timeout-minutes: 10 - # steps: - # - uses: actions/checkout@v2 - # - uses: technote-space/get-diff-action@v1 - # id: git_diff - # with: - # SUFFIX_FILTER: | - # .go - # .mod - # .sum - # - name: importer-test - # run: | - # make test-import - # if: "env.GIT_DIFF != ''" + test-importer: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + - uses: technote-space/get-diff-action@v1 + id: git_diff + with: + SUFFIX_FILTER: | + .go + .mod + .sum + - name: importer-test + run: | + make test-import + rm -rf importer/tmp + if: "env.GIT_DIFF != ''" diff --git a/importer/importer_test.go b/importer/importer_test.go index 9e0e8d9ef..58967bbce 100644 --- a/importer/importer_test.go +++ b/importer/importer_test.go @@ -207,7 +207,10 @@ func TestImportBlocks(t *testing.T) { blockchainInput, err := os.Open(flagBlockchain) require.Nil(t, err) - defer require.NoError(t, blockchainInput.Close()) + defer func() { + err := blockchainInput.Close() + require.NoError(t, err) + }() // ethereum mainnet config chainContext := core.NewChainContext() diff --git a/local_testnet/node0/emintd/config/app.toml b/local_testnet/node0/emintd/config/app.toml new file mode 100644 index 000000000..f635b3a2a --- /dev/null +++ b/local_testnet/node0/emintd/config/app.toml @@ -0,0 +1,36 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +##### main base config options ##### + +# The minimum gas prices a validator is willing to accept for processing a +# transaction. A transaction's fees must meet the minimum of any denomination +# specified in this config (e.g. 0.25token1;0.0001token2). +minimum-gas-prices = "" + +# default: the last 100 states are kept in addition to every 500th state; pruning at 10 block intervals +# nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node) +# everything: all saved states will be deleted, storing only the current state; pruning at 10 block intervals +# custom: allow pruning options to be manually specified through 'pruning-keep-recent', 'pruning-keep-every', and 'pruning-interval' +pruning = "nothing" + +# These are applied if and only if the pruning strategy is custom. +pruning-keep-recent = "0" +pruning-keep-every = "0" +pruning-interval = "0" + +# HaltHeight contains a non-zero block height at which a node will gracefully +# halt and shutdown that can be used to assist upgrades and testing. +# +# Note: Commitment of state will be attempted on the corresponding block. +halt-height = 0 + +# HaltTime contains a non-zero minimum block time (in Unix seconds) at which +# a node will gracefully halt and shutdown that can be used to assist upgrades +# and testing. +# +# Note: Commitment of state will be attempted on the corresponding block. +halt-time = 0 + +# InterBlockCache enables inter-block caching. +inter-block-cache = true diff --git a/local_testnet/node0/emintd/config/config.toml b/local_testnet/node0/emintd/config/config.toml new file mode 100644 index 000000000..3c02a3089 --- /dev/null +++ b/local_testnet/node0/emintd/config/config.toml @@ -0,0 +1,335 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +# NOTE: Any path below can be absolute (e.g. "/var/myawesomeapp/data") or +# relative to the home directory (e.g. "data"). The home directory is +# "$HOME/.tendermint" by default, but could be changed via $TMHOME env variable +# or --home cmd flag. + +##### main base config options ##### + +# TCP or UNIX socket address of the ABCI application, +# or the name of an ABCI application compiled in with the Tendermint binary +proxy_app = "tcp://127.0.0.1:26658" + +# A custom human readable name for this node +moniker = "Federicos-MBP-2" + +# If this node is many blocks behind the tip of the chain, FastSync +# allows them to catchup quickly by downloading blocks in parallel +# and verifying their commits +fast_sync = true + +# Database backend: goleveldb | cleveldb | boltdb | rocksdb +# * goleveldb (github.com/syndtr/goleveldb - most popular implementation) +# - pure go +# - stable +# * cleveldb (uses levigo wrapper) +# - fast +# - requires gcc +# - use cleveldb build tag (go build -tags cleveldb) +# * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt) +# - EXPERIMENTAL +# - may be faster is some use-cases (random reads - indexer) +# - use boltdb build tag (go build -tags boltdb) +# * rocksdb (uses github.com/tecbot/gorocksdb) +# - EXPERIMENTAL +# - requires gcc +# - use rocksdb build tag (go build -tags rocksdb) +db_backend = "goleveldb" + +# Database directory +db_dir = "data" + +# Output level for logging, including package level options +log_level = "main:info,state:info,mempool:info" + +# Output format: 'plain' (colored text) or 'json' +log_format = "plain" + +##### additional base config options ##### + +# Path to the JSON file containing the initial validator set and other meta data +genesis_file = "config/genesis.json" + +# Path to the JSON file containing the private key to use as a validator in the consensus protocol +priv_validator_key_file = "config/priv_validator_key.json" + +# Path to the JSON file containing the last sign state of a validator +priv_validator_state_file = "data/priv_validator_state.json" + +# TCP or UNIX socket address for Tendermint to listen on for +# connections from an external PrivValidator process +priv_validator_laddr = "" + +# Path to the JSON file containing the private key to use for node authentication in the p2p protocol +node_key_file = "config/node_key.json" + +# Mechanism to connect to the ABCI application: socket | grpc +abci = "socket" + +# TCP or UNIX socket address for the profiling server to listen on +prof_laddr = "localhost:6060" + +# If true, query the ABCI app on connecting to a new peer +# so the app can decide if we should keep the connection or not +filter_peers = false + +##### advanced configuration options ##### + +##### rpc server configuration options ##### +[rpc] + +# TCP or UNIX socket address for the RPC server to listen on +laddr = "tcp://127.0.0.1:26657" + +# A list of origins a cross-domain request can be executed from +# Default value '[]' disables cors support +# Use '["*"]' to allow any origin +cors_allowed_origins = [] + +# A list of methods the client is allowed to use with cross-domain requests +cors_allowed_methods = ["HEAD", "GET", "POST", ] + +# A list of non simple headers the client is allowed to use with cross-domain requests +cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time", ] + +# TCP or UNIX socket address for the gRPC server to listen on +# NOTE: This server only supports /broadcast_tx_commit +grpc_laddr = "" + +# Maximum number of simultaneous connections. +# Does not include RPC (HTTP&WebSocket) connections. See max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +grpc_max_open_connections = 900 + +# Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool +unsafe = true + +# Maximum number of simultaneous connections (including WebSocket). +# Does not include gRPC connections. See grpc_max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +max_open_connections = 900 + +# Maximum number of unique clientIDs that can /subscribe +# If you're using /broadcast_tx_commit, set to the estimated maximum number +# of broadcast_tx_commit calls per block. +max_subscription_clients = 100 + +# Maximum number of unique queries a given client can /subscribe to +# If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to +# the estimated # maximum number of broadcast_tx_commit calls per block. +max_subscriptions_per_client = 5 + +# How long to wait for a tx to be committed during /broadcast_tx_commit. +# WARNING: Using a value larger than 10s will result in increasing the +# global HTTP write timeout, which applies to all connections and endpoints. +# See https://github.com/tendermint/tendermint/issues/3435 +timeout_broadcast_tx_commit = "10s" + +# Maximum size of request body, in bytes +max_body_bytes = 1000000 + +# Maximum size of request header, in bytes +max_header_bytes = 1048576 + +# The path to a file containing certificate that is used to create the HTTPS server. +# Migth be either absolute path or path related to tendermint's config directory. +# If the certificate is signed by a certificate authority, +# the certFile should be the concatenation of the server's certificate, any intermediates, +# and the CA's certificate. +# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. +# Otherwise, HTTP server is run. +tls_cert_file = "" + +# The path to a file containing matching private key that is used to create the HTTPS server. +# Migth be either absolute path or path related to tendermint's config directory. +# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. +# Otherwise, HTTP server is run. +tls_key_file = "" + +##### peer to peer configuration options ##### +[p2p] + +# Address to listen for incoming connections +laddr = "tcp://0.0.0.0:26656" + +# Address to advertise to peers for them to dial +# If empty, will use the same port as the laddr, +# and will introspect on the listener or use UPnP +# to figure out the address. +external_address = "" + +# Comma separated list of seed nodes to connect to +seeds = "" + +# Comma separated list of nodes to keep persistent connections to +persistent_peers = "" + +# UPNP port forwarding +upnp = false + +# Path to address book +addr_book_file = "config/addrbook.json" + +# Set true for strict address routability rules +# Set false for private or local networks +addr_book_strict = true + +# Maximum number of inbound peers +max_num_inbound_peers = 40 + +# Maximum number of outbound peers to connect to, excluding persistent peers +max_num_outbound_peers = 10 + +# List of node IDs, to which a connection will be (re)established ignoring any existing limits +unconditional_peer_ids = "" + +# Maximum pause when redialing a persistent peer (if zero, exponential backoff is used) +persistent_peers_max_dial_period = "0s" + +# Time to wait before flushing messages out on the connection +flush_throttle_timeout = "100ms" + +# Maximum size of a message packet payload, in bytes +max_packet_msg_payload_size = 1024 + +# Rate at which packets can be sent, in bytes/second +send_rate = 5120000 + +# Rate at which packets can be received, in bytes/second +recv_rate = 5120000 + +# Set true to enable the peer-exchange reactor +pex = true + +# Seed mode, in which node constantly crawls the network and looks for +# peers. If another node asks it for addresses, it responds and disconnects. +# +# Does not work if the peer-exchange reactor is disabled. +seed_mode = false + +# Comma separated list of peer IDs to keep private (will not be gossiped to other peers) +private_peer_ids = "" + +# Toggle to disable guard against peers connecting from the same ip. +allow_duplicate_ip = false + +# Peer connection configuration. +handshake_timeout = "20s" +dial_timeout = "3s" + +##### mempool configuration options ##### +[mempool] + +recheck = true +broadcast = true +wal_dir = "" + +# Maximum number of transactions in the mempool +size = 5000 + +# Limit the total size of all txs in the mempool. +# This only accounts for raw transactions (e.g. given 1MB transactions and +# max_txs_bytes=5MB, mempool will only accept 5 transactions). +max_txs_bytes = 1073741824 + +# Size of the cache (used to filter transactions we saw earlier) in transactions +cache_size = 10000 + +# Maximum size of a single transaction. +# NOTE: the max size of a tx transmitted over the network is {max_tx_bytes} + {amino overhead}. +max_tx_bytes = 1048576 + +##### fast sync configuration options ##### +[fastsync] + +# Fast Sync version to use: +# 1) "v0" (default) - the legacy fast sync implementation +# 2) "v1" - refactor of v0 version for better testability +# 3) "v2" - refactor of v1 version for better usability +version = "v0" + +##### consensus configuration options ##### +[consensus] + +wal_file = "data/cs.wal/wal" + +timeout_propose = "3s" +timeout_propose_delta = "500ms" +timeout_prevote = "1s" +timeout_prevote_delta = "500ms" +timeout_precommit = "1s" +timeout_precommit_delta = "500ms" +timeout_commit = "5s" + +# Make progress as soon as we have all the precommits (as if TimeoutCommit = 0) +skip_timeout_commit = false + +# EmptyBlocks mode and possible interval between empty blocks +create_empty_blocks = true +create_empty_blocks_interval = "0s" + +# Reactor sleep duration parameters +peer_gossip_sleep_duration = "100ms" +peer_query_maj23_sleep_duration = "2s" + +##### transactions indexer configuration options ##### +[tx_index] + +# What indexer to use for transactions +# +# Options: +# 1) "null" +# 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). +indexer = "kv" + +# Comma-separated list of compositeKeys to index (by default the only key is "tx.hash") +# Remember that Event has the following structure: type.key +# type: [ +# key: value, +# ... +# ] +# +# You can also index transactions by height by adding "tx.height" key here. +# +# It's recommended to index only a subset of keys due to possible memory +# bloat. This is, of course, depends on the indexer's DB and the volume of +# transactions. +index_keys = "" + +# When set to true, tells indexer to index all compositeKeys (predefined keys: +# "tx.hash", "tx.height" and all keys from DeliverTx responses). +# +# Note this may be not desirable (see the comment above). IndexKeys has a +# precedence over IndexAllKeys (i.e. when given both, IndexKeys will be +# indexed). +index_all_keys = true + +##### instrumentation configuration options ##### +[instrumentation] + +# When true, Prometheus metrics are served under /metrics on +# PrometheusListenAddr. +# Check out the documentation for the list of available metrics. +prometheus = false + +# Address to listen for Prometheus collector(s) connections +prometheus_listen_addr = ":26660" + +# Maximum number of simultaneous connections. +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +max_open_connections = 3 + +# Instrumentation namespace +namespace = "tendermint" diff --git a/local_testnet/node0/emintd/config/node_key.json b/local_testnet/node0/emintd/config/node_key.json new file mode 100644 index 000000000..2afa5f1d6 --- /dev/null +++ b/local_testnet/node0/emintd/config/node_key.json @@ -0,0 +1 @@ +{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"jBfjmymVbKkzWaKXXzU4NNnLeyaMxOOgZaqWxqQwFiIT4Qc2/cxa+DCXxM9hHd8ym3vEV3gy0mecRLSYYRN2PA=="}} \ No newline at end of file diff --git a/local_testnet/node0/emintd/config/priv_validator_key.json b/local_testnet/node0/emintd/config/priv_validator_key.json new file mode 100644 index 000000000..9c6527bf9 --- /dev/null +++ b/local_testnet/node0/emintd/config/priv_validator_key.json @@ -0,0 +1,11 @@ +{ + "address": "DB1DCD4A68723121CBD1E5055147FA712DAC4320", + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "JtkhhbbAVWas2Sb6ZPF4rhXtcQDYJsIh9bvI1U1eU+c=" + }, + "priv_key": { + "type": "tendermint/PrivKeyEd25519", + "value": "9Nb1l6q4mW5is/3NV2zJwykPUWr152/iscZZDm4liN4m2SGFtsBVZqzZJvpk8XiuFe1xANgmwiH1u8jVTV5T5w==" + } +} \ No newline at end of file diff --git a/local_testnet/node0/emintd/data/application.db/CURRENT b/local_testnet/node0/emintd/data/application.db/CURRENT new file mode 100644 index 000000000..feda7d6b2 --- /dev/null +++ b/local_testnet/node0/emintd/data/application.db/CURRENT @@ -0,0 +1 @@ +MANIFEST-000000 diff --git a/local_testnet/node0/emintd/data/application.db/LOCK b/local_testnet/node0/emintd/data/application.db/LOCK new file mode 100644 index 000000000..e69de29bb diff --git a/local_testnet/node0/emintd/data/application.db/LOG b/local_testnet/node0/emintd/data/application.db/LOG new file mode 100644 index 000000000..2834963da --- /dev/null +++ b/local_testnet/node0/emintd/data/application.db/LOG @@ -0,0 +1,6 @@ +=============== Jul 20, 2020 (CEST) =============== +13:25:28.688654 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +13:25:28.700407 db@open opening +13:25:28.701691 version@stat F·[] S·0B[] Sc·[] +13:25:28.707009 db@janitor F·2 G·0 +13:25:28.707056 db@open done T·6.611442ms diff --git a/local_testnet/node0/emintd/data/application.db/MANIFEST-000000 b/local_testnet/node0/emintd/data/application.db/MANIFEST-000000 new file mode 100644 index 0000000000000000000000000000000000000000..9d54f6733b1364dc8d53dd15ca59a6ec36a1c29d GIT binary patch literal 54 zcmdmC5aOo9z{n_-lUkOVlai$8R9TW*o>`pgoS$2eSd>_jU&O?~%*ev9Y~pbaHU>r} JMrI}!1^~s!4paaD literal 0 HcmV?d00001 diff --git a/local_testnet/node0/emintd/data/blockstore.db/CURRENT b/local_testnet/node0/emintd/data/blockstore.db/CURRENT new file mode 100644 index 000000000..feda7d6b2 --- /dev/null +++ b/local_testnet/node0/emintd/data/blockstore.db/CURRENT @@ -0,0 +1 @@ +MANIFEST-000000 diff --git a/local_testnet/node0/emintd/data/blockstore.db/LOCK b/local_testnet/node0/emintd/data/blockstore.db/LOCK new file mode 100644 index 000000000..e69de29bb diff --git a/local_testnet/node0/emintd/data/blockstore.db/LOG b/local_testnet/node0/emintd/data/blockstore.db/LOG new file mode 100644 index 000000000..8d06c963b --- /dev/null +++ b/local_testnet/node0/emintd/data/blockstore.db/LOG @@ -0,0 +1,6 @@ +=============== Jul 20, 2020 (CEST) =============== +13:25:28.712248 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +13:25:28.721629 db@open opening +13:25:28.722192 version@stat F·[] S·0B[] Sc·[] +13:25:28.729858 db@janitor F·2 G·0 +13:25:28.729951 db@open done T·8.272915ms diff --git a/local_testnet/node0/emintd/data/blockstore.db/MANIFEST-000000 b/local_testnet/node0/emintd/data/blockstore.db/MANIFEST-000000 new file mode 100644 index 0000000000000000000000000000000000000000..9d54f6733b1364dc8d53dd15ca59a6ec36a1c29d GIT binary patch literal 54 zcmdmC5aOo9z{n_-lUkOVlai$8R9TW*o>`pgoS$2eSd>_jU&O?~%*ev9Y~pbaHU>r} JMrI}!1^~s!4paaD literal 0 HcmV?d00001 diff --git a/local_testnet/node0/emintd/data/priv_validator_state.json b/local_testnet/node0/emintd/data/priv_validator_state.json new file mode 100644 index 000000000..ca3ad2f74 --- /dev/null +++ b/local_testnet/node0/emintd/data/priv_validator_state.json @@ -0,0 +1,5 @@ +{ + "height": "0", + "round": "0", + "step": 0 +} \ No newline at end of file diff --git a/local_testnet/node0/emintd/data/state.db/CURRENT b/local_testnet/node0/emintd/data/state.db/CURRENT new file mode 100644 index 000000000..feda7d6b2 --- /dev/null +++ b/local_testnet/node0/emintd/data/state.db/CURRENT @@ -0,0 +1 @@ +MANIFEST-000000 diff --git a/local_testnet/node0/emintd/data/state.db/LOCK b/local_testnet/node0/emintd/data/state.db/LOCK new file mode 100644 index 000000000..e69de29bb diff --git a/local_testnet/node0/emintd/data/state.db/LOG b/local_testnet/node0/emintd/data/state.db/LOG new file mode 100644 index 000000000..9f79b762a --- /dev/null +++ b/local_testnet/node0/emintd/data/state.db/LOG @@ -0,0 +1,6 @@ +=============== Jul 20, 2020 (CEST) =============== +13:25:28.730470 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +13:25:28.743149 db@open opening +13:25:28.743558 version@stat F·[] S·0B[] Sc·[] +13:25:28.749470 db@janitor F·2 G·0 +13:25:28.749518 db@open done T·6.332484ms diff --git a/local_testnet/node0/emintd/data/state.db/MANIFEST-000000 b/local_testnet/node0/emintd/data/state.db/MANIFEST-000000 new file mode 100644 index 0000000000000000000000000000000000000000..9d54f6733b1364dc8d53dd15ca59a6ec36a1c29d GIT binary patch literal 54 zcmdmC5aOo9z{n_-lUkOVlai$8R9TW*o>`pgoS$2eSd>_jU&O?~%*ev9Y~pbaHU>r} JMrI}!1^~s!4paaD literal 0 HcmV?d00001 diff --git a/types/account.go b/types/account.go index 9353e3317..7052a24de 100644 --- a/types/account.go +++ b/types/account.go @@ -2,6 +2,7 @@ package types import ( "encoding/json" + "fmt" "gopkg.in/yaml.v2" @@ -43,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"` diff --git a/x/evm/types/journal_test.go b/x/evm/types/journal_test.go index 3911e30f9..1cca93e77 100644 --- a/x/evm/types/journal_test.go +++ b/x/evm/types/journal_test.go @@ -148,7 +148,7 @@ func (suite *JournalTestSuite) TestJournal_append_revert() { resetObjectChange{ prev: &stateObject{ address: suite.address, - balance: sdk.OneInt(), + // balance: sdk.OneInt(), }, }, }, diff --git a/x/evm/types/state_object.go b/x/evm/types/state_object.go index 9bf50e9fa..c8d3728b2 100644 --- a/x/evm/types/state_object.go +++ b/x/evm/types/state_object.go @@ -66,7 +66,7 @@ type stateObject struct { dbErr error stateDB *CommitStateDB account *types.EthAccount - balance sdk.Int + // balance sdk.Int keyToOriginStorageIndex map[ethcmn.Hash]int keyToDirtyStorageIndex map[ethcmn.Hash]int @@ -82,7 +82,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)) @@ -94,9 +95,9 @@ func newStateObject(db *CommitStateDB, accProto authexported.Account, balance sd } return &stateObject{ - stateDB: db, - account: ethermintAccount, - balance: balance, + stateDB: db, + account: ethermintAccount, + // balance: balance, address: ethcmn.BytesToAddress(ethermintAccount.GetAddress().Bytes()), originStorage: Storage{}, dirtyStorage: Storage{}, @@ -178,7 +179,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()) } @@ -189,7 +191,8 @@ func (so *stateObject) SubBalance(amount *big.Int) { if amt.IsZero() { return } - newBalance := so.balance.Sub(amt) + // newBalance := so.balance.Sub(amt) + newBalance := so.account.GetCoins().AmountOf(types.DenomDefault).Sub(amt) so.SetBalance(newBalance.BigInt()) } @@ -199,14 +202,16 @@ 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), + // prev: so.balance, }) so.setBalance(amt) } func (so *stateObject) setBalance(amount sdk.Int) { - so.balance = amount + so.account.SetBalance(amount) + // so.balance = amount } // SetNonce sets the state object's nonce (i.e sequence number of the account). @@ -244,7 +249,9 @@ func (so *stateObject) commitState() { for i, state := range so.dirtyStorage { delete(so.keyToDirtyStorageIndex, state.Key) - so.dirtyStorage = append(so.dirtyStorage[:i], so.dirtyStorage[i+1:]...) + + var dirtyStorage Storage + dirtyStorage = append(so.dirtyStorage[:i], so.dirtyStorage[i+1:]...) // skip no-op changes, persist actual changes idx, ok := so.keyToOriginStorageIndex[state.Key] @@ -267,6 +274,7 @@ func (so *stateObject) commitState() { } store.Set(state.Key.Bytes(), state.Value.Bytes()) + so.dirtyStorage = dirtyStorage } } @@ -288,7 +296,8 @@ 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.balance.BigInt() + balance := so.account.Balance().BigInt() if balance == nil { return zeroBalance } @@ -388,7 +397,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 +411,12 @@ 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()) && + // (so.balance.BigInt() == nil || so.balance.IsZero()) && bytes.Equal(so.account.CodeHash, emptyCodeHash)) } diff --git a/x/evm/types/statedb.go b/x/evm/types/statedb.go index baec3c8d2..9a475d992 100644 --- a/x/evm/types/statedb.go +++ b/x/evm/types/statedb.go @@ -499,7 +499,9 @@ func (csdb *CommitStateDB) updateStateObject(so *stateObject) error { coins = coins.Add(newBalance) } - _ = so.account.SetCoins(coins) + if err := so.account.SetCoins(coins); err != nil { + return err + } // end removal for next upgrade csdb.accountKeeper.SetAccount(csdb.ctx, so.account) @@ -632,11 +634,12 @@ func (csdb *CommitStateDB) UpdateAccounts() { Denom: emint.DenomDefault, Amount: emintAcc.GetCoins().AmountOf(emint.DenomDefault), } - if stateEntry.stateObject.Balance() != balance.Amount.BigInt() && balance.IsValid() { - stateEntry.stateObject.balance = balance.Amount - } + // if stateEntry.stateObject.Balance() != balance.Amount.BigInt() && balance.IsValid() { + // stateEntry.stateObject.balance = balance.Amount + // } - if stateEntry.stateObject.Nonce() != emintAcc.GetSequence() { + if stateEntry.stateObject.Balance() != balance.Amount.BigInt() && balance.IsValid() || + stateEntry.stateObject.Nonce() != emintAcc.GetSequence() { stateEntry.stateObject.account = emintAcc } } @@ -794,7 +797,8 @@ 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, sdk.ZeroInt()) + newObj = newStateObject(csdb, acc) newObj.setNonce(0) // sets the object to dirty if prevObj == nil { @@ -837,13 +841,14 @@ func (csdb *CommitStateDB) getStateObject(addr ethcmn.Address) (stateObject *sta } // balance := csdb.bankKeeper.GetBalance(csdb.ctx, acc.GetAddress(), emint.DenomDefault) - balance := sdk.Coin{ - Denom: emint.DenomDefault, - Amount: acc.GetCoins().AmountOf(emint.DenomDefault), - } + // balance := sdk.Coin{ + // Denom: emint.DenomDefault, + // Amount: acc.GetCoins().AmountOf(emint.DenomDefault), + // } // insert the state object into the live set - so := newStateObject(csdb, acc, balance.Amount) + // so := newStateObject(csdb, acc, balance.Amount) + so := newStateObject(csdb, acc) csdb.setStateObject(so) return so From be7f78c236949b0b2e703bf6e990aa818ca8da3f Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Mon, 20 Jul 2020 13:36:25 +0200 Subject: [PATCH 22/37] remove extra files --- local_testnet/node0/emintd/config/app.toml | 36 -- local_testnet/node0/emintd/config/config.toml | 335 ------------------ .../node0/emintd/config/node_key.json | 1 - .../emintd/config/priv_validator_key.json | 11 - .../node0/emintd/data/application.db/CURRENT | 1 - .../node0/emintd/data/application.db/LOCK | 0 .../node0/emintd/data/application.db/LOG | 6 - .../data/application.db/MANIFEST-000000 | Bin 54 -> 0 bytes .../node0/emintd/data/blockstore.db/CURRENT | 1 - .../node0/emintd/data/blockstore.db/LOCK | 0 .../node0/emintd/data/blockstore.db/LOG | 6 - .../emintd/data/blockstore.db/MANIFEST-000000 | Bin 54 -> 0 bytes .../emintd/data/priv_validator_state.json | 5 - .../node0/emintd/data/state.db/CURRENT | 1 - local_testnet/node0/emintd/data/state.db/LOCK | 0 local_testnet/node0/emintd/data/state.db/LOG | 6 - .../emintd/data/state.db/MANIFEST-000000 | Bin 54 -> 0 bytes 17 files changed, 409 deletions(-) delete mode 100644 local_testnet/node0/emintd/config/app.toml delete mode 100644 local_testnet/node0/emintd/config/config.toml delete mode 100644 local_testnet/node0/emintd/config/node_key.json delete mode 100644 local_testnet/node0/emintd/config/priv_validator_key.json delete mode 100644 local_testnet/node0/emintd/data/application.db/CURRENT delete mode 100644 local_testnet/node0/emintd/data/application.db/LOCK delete mode 100644 local_testnet/node0/emintd/data/application.db/LOG delete mode 100644 local_testnet/node0/emintd/data/application.db/MANIFEST-000000 delete mode 100644 local_testnet/node0/emintd/data/blockstore.db/CURRENT delete mode 100644 local_testnet/node0/emintd/data/blockstore.db/LOCK delete mode 100644 local_testnet/node0/emintd/data/blockstore.db/LOG delete mode 100644 local_testnet/node0/emintd/data/blockstore.db/MANIFEST-000000 delete mode 100644 local_testnet/node0/emintd/data/priv_validator_state.json delete mode 100644 local_testnet/node0/emintd/data/state.db/CURRENT delete mode 100644 local_testnet/node0/emintd/data/state.db/LOCK delete mode 100644 local_testnet/node0/emintd/data/state.db/LOG delete mode 100644 local_testnet/node0/emintd/data/state.db/MANIFEST-000000 diff --git a/local_testnet/node0/emintd/config/app.toml b/local_testnet/node0/emintd/config/app.toml deleted file mode 100644 index f635b3a2a..000000000 --- a/local_testnet/node0/emintd/config/app.toml +++ /dev/null @@ -1,36 +0,0 @@ -# This is a TOML config file. -# For more information, see https://github.com/toml-lang/toml - -##### main base config options ##### - -# The minimum gas prices a validator is willing to accept for processing a -# transaction. A transaction's fees must meet the minimum of any denomination -# specified in this config (e.g. 0.25token1;0.0001token2). -minimum-gas-prices = "" - -# default: the last 100 states are kept in addition to every 500th state; pruning at 10 block intervals -# nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node) -# everything: all saved states will be deleted, storing only the current state; pruning at 10 block intervals -# custom: allow pruning options to be manually specified through 'pruning-keep-recent', 'pruning-keep-every', and 'pruning-interval' -pruning = "nothing" - -# These are applied if and only if the pruning strategy is custom. -pruning-keep-recent = "0" -pruning-keep-every = "0" -pruning-interval = "0" - -# HaltHeight contains a non-zero block height at which a node will gracefully -# halt and shutdown that can be used to assist upgrades and testing. -# -# Note: Commitment of state will be attempted on the corresponding block. -halt-height = 0 - -# HaltTime contains a non-zero minimum block time (in Unix seconds) at which -# a node will gracefully halt and shutdown that can be used to assist upgrades -# and testing. -# -# Note: Commitment of state will be attempted on the corresponding block. -halt-time = 0 - -# InterBlockCache enables inter-block caching. -inter-block-cache = true diff --git a/local_testnet/node0/emintd/config/config.toml b/local_testnet/node0/emintd/config/config.toml deleted file mode 100644 index 3c02a3089..000000000 --- a/local_testnet/node0/emintd/config/config.toml +++ /dev/null @@ -1,335 +0,0 @@ -# This is a TOML config file. -# For more information, see https://github.com/toml-lang/toml - -# NOTE: Any path below can be absolute (e.g. "/var/myawesomeapp/data") or -# relative to the home directory (e.g. "data"). The home directory is -# "$HOME/.tendermint" by default, but could be changed via $TMHOME env variable -# or --home cmd flag. - -##### main base config options ##### - -# TCP or UNIX socket address of the ABCI application, -# or the name of an ABCI application compiled in with the Tendermint binary -proxy_app = "tcp://127.0.0.1:26658" - -# A custom human readable name for this node -moniker = "Federicos-MBP-2" - -# If this node is many blocks behind the tip of the chain, FastSync -# allows them to catchup quickly by downloading blocks in parallel -# and verifying their commits -fast_sync = true - -# Database backend: goleveldb | cleveldb | boltdb | rocksdb -# * goleveldb (github.com/syndtr/goleveldb - most popular implementation) -# - pure go -# - stable -# * cleveldb (uses levigo wrapper) -# - fast -# - requires gcc -# - use cleveldb build tag (go build -tags cleveldb) -# * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt) -# - EXPERIMENTAL -# - may be faster is some use-cases (random reads - indexer) -# - use boltdb build tag (go build -tags boltdb) -# * rocksdb (uses github.com/tecbot/gorocksdb) -# - EXPERIMENTAL -# - requires gcc -# - use rocksdb build tag (go build -tags rocksdb) -db_backend = "goleveldb" - -# Database directory -db_dir = "data" - -# Output level for logging, including package level options -log_level = "main:info,state:info,mempool:info" - -# Output format: 'plain' (colored text) or 'json' -log_format = "plain" - -##### additional base config options ##### - -# Path to the JSON file containing the initial validator set and other meta data -genesis_file = "config/genesis.json" - -# Path to the JSON file containing the private key to use as a validator in the consensus protocol -priv_validator_key_file = "config/priv_validator_key.json" - -# Path to the JSON file containing the last sign state of a validator -priv_validator_state_file = "data/priv_validator_state.json" - -# TCP or UNIX socket address for Tendermint to listen on for -# connections from an external PrivValidator process -priv_validator_laddr = "" - -# Path to the JSON file containing the private key to use for node authentication in the p2p protocol -node_key_file = "config/node_key.json" - -# Mechanism to connect to the ABCI application: socket | grpc -abci = "socket" - -# TCP or UNIX socket address for the profiling server to listen on -prof_laddr = "localhost:6060" - -# If true, query the ABCI app on connecting to a new peer -# so the app can decide if we should keep the connection or not -filter_peers = false - -##### advanced configuration options ##### - -##### rpc server configuration options ##### -[rpc] - -# TCP or UNIX socket address for the RPC server to listen on -laddr = "tcp://127.0.0.1:26657" - -# A list of origins a cross-domain request can be executed from -# Default value '[]' disables cors support -# Use '["*"]' to allow any origin -cors_allowed_origins = [] - -# A list of methods the client is allowed to use with cross-domain requests -cors_allowed_methods = ["HEAD", "GET", "POST", ] - -# A list of non simple headers the client is allowed to use with cross-domain requests -cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time", ] - -# TCP or UNIX socket address for the gRPC server to listen on -# NOTE: This server only supports /broadcast_tx_commit -grpc_laddr = "" - -# Maximum number of simultaneous connections. -# Does not include RPC (HTTP&WebSocket) connections. See max_open_connections -# If you want to accept a larger number than the default, make sure -# you increase your OS limits. -# 0 - unlimited. -# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} -# 1024 - 40 - 10 - 50 = 924 = ~900 -grpc_max_open_connections = 900 - -# Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool -unsafe = true - -# Maximum number of simultaneous connections (including WebSocket). -# Does not include gRPC connections. See grpc_max_open_connections -# If you want to accept a larger number than the default, make sure -# you increase your OS limits. -# 0 - unlimited. -# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} -# 1024 - 40 - 10 - 50 = 924 = ~900 -max_open_connections = 900 - -# Maximum number of unique clientIDs that can /subscribe -# If you're using /broadcast_tx_commit, set to the estimated maximum number -# of broadcast_tx_commit calls per block. -max_subscription_clients = 100 - -# Maximum number of unique queries a given client can /subscribe to -# If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to -# the estimated # maximum number of broadcast_tx_commit calls per block. -max_subscriptions_per_client = 5 - -# How long to wait for a tx to be committed during /broadcast_tx_commit. -# WARNING: Using a value larger than 10s will result in increasing the -# global HTTP write timeout, which applies to all connections and endpoints. -# See https://github.com/tendermint/tendermint/issues/3435 -timeout_broadcast_tx_commit = "10s" - -# Maximum size of request body, in bytes -max_body_bytes = 1000000 - -# Maximum size of request header, in bytes -max_header_bytes = 1048576 - -# The path to a file containing certificate that is used to create the HTTPS server. -# Migth be either absolute path or path related to tendermint's config directory. -# If the certificate is signed by a certificate authority, -# the certFile should be the concatenation of the server's certificate, any intermediates, -# and the CA's certificate. -# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. -# Otherwise, HTTP server is run. -tls_cert_file = "" - -# The path to a file containing matching private key that is used to create the HTTPS server. -# Migth be either absolute path or path related to tendermint's config directory. -# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. -# Otherwise, HTTP server is run. -tls_key_file = "" - -##### peer to peer configuration options ##### -[p2p] - -# Address to listen for incoming connections -laddr = "tcp://0.0.0.0:26656" - -# Address to advertise to peers for them to dial -# If empty, will use the same port as the laddr, -# and will introspect on the listener or use UPnP -# to figure out the address. -external_address = "" - -# Comma separated list of seed nodes to connect to -seeds = "" - -# Comma separated list of nodes to keep persistent connections to -persistent_peers = "" - -# UPNP port forwarding -upnp = false - -# Path to address book -addr_book_file = "config/addrbook.json" - -# Set true for strict address routability rules -# Set false for private or local networks -addr_book_strict = true - -# Maximum number of inbound peers -max_num_inbound_peers = 40 - -# Maximum number of outbound peers to connect to, excluding persistent peers -max_num_outbound_peers = 10 - -# List of node IDs, to which a connection will be (re)established ignoring any existing limits -unconditional_peer_ids = "" - -# Maximum pause when redialing a persistent peer (if zero, exponential backoff is used) -persistent_peers_max_dial_period = "0s" - -# Time to wait before flushing messages out on the connection -flush_throttle_timeout = "100ms" - -# Maximum size of a message packet payload, in bytes -max_packet_msg_payload_size = 1024 - -# Rate at which packets can be sent, in bytes/second -send_rate = 5120000 - -# Rate at which packets can be received, in bytes/second -recv_rate = 5120000 - -# Set true to enable the peer-exchange reactor -pex = true - -# Seed mode, in which node constantly crawls the network and looks for -# peers. If another node asks it for addresses, it responds and disconnects. -# -# Does not work if the peer-exchange reactor is disabled. -seed_mode = false - -# Comma separated list of peer IDs to keep private (will not be gossiped to other peers) -private_peer_ids = "" - -# Toggle to disable guard against peers connecting from the same ip. -allow_duplicate_ip = false - -# Peer connection configuration. -handshake_timeout = "20s" -dial_timeout = "3s" - -##### mempool configuration options ##### -[mempool] - -recheck = true -broadcast = true -wal_dir = "" - -# Maximum number of transactions in the mempool -size = 5000 - -# Limit the total size of all txs in the mempool. -# This only accounts for raw transactions (e.g. given 1MB transactions and -# max_txs_bytes=5MB, mempool will only accept 5 transactions). -max_txs_bytes = 1073741824 - -# Size of the cache (used to filter transactions we saw earlier) in transactions -cache_size = 10000 - -# Maximum size of a single transaction. -# NOTE: the max size of a tx transmitted over the network is {max_tx_bytes} + {amino overhead}. -max_tx_bytes = 1048576 - -##### fast sync configuration options ##### -[fastsync] - -# Fast Sync version to use: -# 1) "v0" (default) - the legacy fast sync implementation -# 2) "v1" - refactor of v0 version for better testability -# 3) "v2" - refactor of v1 version for better usability -version = "v0" - -##### consensus configuration options ##### -[consensus] - -wal_file = "data/cs.wal/wal" - -timeout_propose = "3s" -timeout_propose_delta = "500ms" -timeout_prevote = "1s" -timeout_prevote_delta = "500ms" -timeout_precommit = "1s" -timeout_precommit_delta = "500ms" -timeout_commit = "5s" - -# Make progress as soon as we have all the precommits (as if TimeoutCommit = 0) -skip_timeout_commit = false - -# EmptyBlocks mode and possible interval between empty blocks -create_empty_blocks = true -create_empty_blocks_interval = "0s" - -# Reactor sleep duration parameters -peer_gossip_sleep_duration = "100ms" -peer_query_maj23_sleep_duration = "2s" - -##### transactions indexer configuration options ##### -[tx_index] - -# What indexer to use for transactions -# -# Options: -# 1) "null" -# 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). -indexer = "kv" - -# Comma-separated list of compositeKeys to index (by default the only key is "tx.hash") -# Remember that Event has the following structure: type.key -# type: [ -# key: value, -# ... -# ] -# -# You can also index transactions by height by adding "tx.height" key here. -# -# It's recommended to index only a subset of keys due to possible memory -# bloat. This is, of course, depends on the indexer's DB and the volume of -# transactions. -index_keys = "" - -# When set to true, tells indexer to index all compositeKeys (predefined keys: -# "tx.hash", "tx.height" and all keys from DeliverTx responses). -# -# Note this may be not desirable (see the comment above). IndexKeys has a -# precedence over IndexAllKeys (i.e. when given both, IndexKeys will be -# indexed). -index_all_keys = true - -##### instrumentation configuration options ##### -[instrumentation] - -# When true, Prometheus metrics are served under /metrics on -# PrometheusListenAddr. -# Check out the documentation for the list of available metrics. -prometheus = false - -# Address to listen for Prometheus collector(s) connections -prometheus_listen_addr = ":26660" - -# Maximum number of simultaneous connections. -# If you want to accept a larger number than the default, make sure -# you increase your OS limits. -# 0 - unlimited. -max_open_connections = 3 - -# Instrumentation namespace -namespace = "tendermint" diff --git a/local_testnet/node0/emintd/config/node_key.json b/local_testnet/node0/emintd/config/node_key.json deleted file mode 100644 index 2afa5f1d6..000000000 --- a/local_testnet/node0/emintd/config/node_key.json +++ /dev/null @@ -1 +0,0 @@ -{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"jBfjmymVbKkzWaKXXzU4NNnLeyaMxOOgZaqWxqQwFiIT4Qc2/cxa+DCXxM9hHd8ym3vEV3gy0mecRLSYYRN2PA=="}} \ No newline at end of file diff --git a/local_testnet/node0/emintd/config/priv_validator_key.json b/local_testnet/node0/emintd/config/priv_validator_key.json deleted file mode 100644 index 9c6527bf9..000000000 --- a/local_testnet/node0/emintd/config/priv_validator_key.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "address": "DB1DCD4A68723121CBD1E5055147FA712DAC4320", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "JtkhhbbAVWas2Sb6ZPF4rhXtcQDYJsIh9bvI1U1eU+c=" - }, - "priv_key": { - "type": "tendermint/PrivKeyEd25519", - "value": "9Nb1l6q4mW5is/3NV2zJwykPUWr152/iscZZDm4liN4m2SGFtsBVZqzZJvpk8XiuFe1xANgmwiH1u8jVTV5T5w==" - } -} \ No newline at end of file diff --git a/local_testnet/node0/emintd/data/application.db/CURRENT b/local_testnet/node0/emintd/data/application.db/CURRENT deleted file mode 100644 index feda7d6b2..000000000 --- a/local_testnet/node0/emintd/data/application.db/CURRENT +++ /dev/null @@ -1 +0,0 @@ -MANIFEST-000000 diff --git a/local_testnet/node0/emintd/data/application.db/LOCK b/local_testnet/node0/emintd/data/application.db/LOCK deleted file mode 100644 index e69de29bb..000000000 diff --git a/local_testnet/node0/emintd/data/application.db/LOG b/local_testnet/node0/emintd/data/application.db/LOG deleted file mode 100644 index 2834963da..000000000 --- a/local_testnet/node0/emintd/data/application.db/LOG +++ /dev/null @@ -1,6 +0,0 @@ -=============== Jul 20, 2020 (CEST) =============== -13:25:28.688654 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -13:25:28.700407 db@open opening -13:25:28.701691 version@stat F·[] S·0B[] Sc·[] -13:25:28.707009 db@janitor F·2 G·0 -13:25:28.707056 db@open done T·6.611442ms diff --git a/local_testnet/node0/emintd/data/application.db/MANIFEST-000000 b/local_testnet/node0/emintd/data/application.db/MANIFEST-000000 deleted file mode 100644 index 9d54f6733b1364dc8d53dd15ca59a6ec36a1c29d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 54 zcmdmC5aOo9z{n_-lUkOVlai$8R9TW*o>`pgoS$2eSd>_jU&O?~%*ev9Y~pbaHU>r} JMrI}!1^~s!4paaD diff --git a/local_testnet/node0/emintd/data/blockstore.db/CURRENT b/local_testnet/node0/emintd/data/blockstore.db/CURRENT deleted file mode 100644 index feda7d6b2..000000000 --- a/local_testnet/node0/emintd/data/blockstore.db/CURRENT +++ /dev/null @@ -1 +0,0 @@ -MANIFEST-000000 diff --git a/local_testnet/node0/emintd/data/blockstore.db/LOCK b/local_testnet/node0/emintd/data/blockstore.db/LOCK deleted file mode 100644 index e69de29bb..000000000 diff --git a/local_testnet/node0/emintd/data/blockstore.db/LOG b/local_testnet/node0/emintd/data/blockstore.db/LOG deleted file mode 100644 index 8d06c963b..000000000 --- a/local_testnet/node0/emintd/data/blockstore.db/LOG +++ /dev/null @@ -1,6 +0,0 @@ -=============== Jul 20, 2020 (CEST) =============== -13:25:28.712248 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -13:25:28.721629 db@open opening -13:25:28.722192 version@stat F·[] S·0B[] Sc·[] -13:25:28.729858 db@janitor F·2 G·0 -13:25:28.729951 db@open done T·8.272915ms diff --git a/local_testnet/node0/emintd/data/blockstore.db/MANIFEST-000000 b/local_testnet/node0/emintd/data/blockstore.db/MANIFEST-000000 deleted file mode 100644 index 9d54f6733b1364dc8d53dd15ca59a6ec36a1c29d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 54 zcmdmC5aOo9z{n_-lUkOVlai$8R9TW*o>`pgoS$2eSd>_jU&O?~%*ev9Y~pbaHU>r} JMrI}!1^~s!4paaD diff --git a/local_testnet/node0/emintd/data/priv_validator_state.json b/local_testnet/node0/emintd/data/priv_validator_state.json deleted file mode 100644 index ca3ad2f74..000000000 --- a/local_testnet/node0/emintd/data/priv_validator_state.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "height": "0", - "round": "0", - "step": 0 -} \ No newline at end of file diff --git a/local_testnet/node0/emintd/data/state.db/CURRENT b/local_testnet/node0/emintd/data/state.db/CURRENT deleted file mode 100644 index feda7d6b2..000000000 --- a/local_testnet/node0/emintd/data/state.db/CURRENT +++ /dev/null @@ -1 +0,0 @@ -MANIFEST-000000 diff --git a/local_testnet/node0/emintd/data/state.db/LOCK b/local_testnet/node0/emintd/data/state.db/LOCK deleted file mode 100644 index e69de29bb..000000000 diff --git a/local_testnet/node0/emintd/data/state.db/LOG b/local_testnet/node0/emintd/data/state.db/LOG deleted file mode 100644 index 9f79b762a..000000000 --- a/local_testnet/node0/emintd/data/state.db/LOG +++ /dev/null @@ -1,6 +0,0 @@ -=============== Jul 20, 2020 (CEST) =============== -13:25:28.730470 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -13:25:28.743149 db@open opening -13:25:28.743558 version@stat F·[] S·0B[] Sc·[] -13:25:28.749470 db@janitor F·2 G·0 -13:25:28.749518 db@open done T·6.332484ms diff --git a/local_testnet/node0/emintd/data/state.db/MANIFEST-000000 b/local_testnet/node0/emintd/data/state.db/MANIFEST-000000 deleted file mode 100644 index 9d54f6733b1364dc8d53dd15ca59a6ec36a1c29d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 54 zcmdmC5aOo9z{n_-lUkOVlai$8R9TW*o>`pgoS$2eSd>_jU&O?~%*ev9Y~pbaHU>r} JMrI}!1^~s!4paaD From 393e70f411dfabb5c818656847f79effbb420b94 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Mon, 20 Jul 2020 14:20:44 +0200 Subject: [PATCH 23/37] update make test-import --- x/evm/types/state_object.go | 11 ++++----- x/evm/types/state_transition_test.go | 36 ++++++++++++++-------------- x/evm/types/statedb_test.go | 28 +++++++++++----------- 3 files changed, 37 insertions(+), 38 deletions(-) diff --git a/x/evm/types/state_object.go b/x/evm/types/state_object.go index c8d3728b2..7d9d3c1dc 100644 --- a/x/evm/types/state_object.go +++ b/x/evm/types/state_object.go @@ -242,17 +242,15 @@ 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())) - for i, state := range so.dirtyStorage { + for _, state := range so.dirtyStorage { delete(so.keyToDirtyStorageIndex, state.Key) - var dirtyStorage Storage - dirtyStorage = append(so.dirtyStorage[:i], so.dirtyStorage[i+1:]...) - // skip no-op changes, persist actual changes idx, ok := so.keyToOriginStorageIndex[state.Key] if !ok { @@ -274,8 +272,9 @@ func (so *stateObject) commitState() { } store.Set(state.Key.Bytes(), state.Value.Bytes()) - so.dirtyStorage = dirtyStorage } + + so.dirtyStorage = Storage{} } // commitCode persists the state object's code to the KVStore. diff --git a/x/evm/types/state_transition_test.go b/x/evm/types/state_transition_test.go index 77eac1ff4..7119524a8 100644 --- a/x/evm/types/state_transition_test.go +++ b/x/evm/types/state_transition_test.go @@ -106,24 +106,24 @@ 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: ðcmn.Hash{}, - Sender: suite.address, - Simulate: false, - }, - 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: ðcmn.Hash{}, + // Sender: suite.address, + // Simulate: false, + // }, + // false, + // }, { "nil gas price", func() { diff --git a/x/evm/types/statedb_test.go b/x/evm/types/statedb_test.go index f76aa7203..30363e2a0 100644 --- a/x/evm/types/statedb_test.go +++ b/x/evm/types/statedb_test.go @@ -349,13 +349,13 @@ func (suite *StateDBTestSuite) TestCommitStateDB_Commit() { }, false, true, }, - { - "faled to update state object", - func() { - suite.stateDB.SubBalance(suite.address, big.NewInt(10)) - }, - false, false, - }, + // { + // "faled to update state object", + // func() { + // suite.stateDB.SubBalance(suite.address, big.NewInt(10)) + // }, + // false, false, + // }, } for _, tc := range testCase { @@ -413,13 +413,13 @@ func (suite *StateDBTestSuite) TestCommitStateDB_Finalize() { }, false, true, }, - { - "faled to update state object", - func() { - suite.stateDB.SubBalance(suite.address, big.NewInt(10)) - }, - false, false, - }, + // { + // "faled to update state object", + // func() { + // suite.stateDB.SubBalance(suite.address, big.NewInt(10)) + // }, + // false, false, + // }, } for _, tc := range testCase { From 7cff5684120562ccea8e494e3f01226afeed3d38 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Mon, 20 Jul 2020 14:28:59 +0200 Subject: [PATCH 24/37] rename test --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 18c56b152..860b02fa1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -205,7 +205,7 @@ jobs: .go .mod .sum - - name: importer-test + - name: test-importer run: | make test-import rm -rf importer/tmp From f16da4ae4198abfc2ef32e125b16711379bb57d9 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Mon, 20 Jul 2020 18:29:19 +0200 Subject: [PATCH 25/37] bump SDK version to final release --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f4e21fc6d..1500f262f 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ 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.39.0-rc0 + github.com/cosmos/cosmos-sdk v0.39.0 github.com/deckarep/golang-set v1.7.1 // indirect github.com/ethereum/go-ethereum v1.9.16 github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect diff --git a/go.sum b/go.sum index ce1309605..989757d0c 100644 --- a/go.sum +++ b/go.sum @@ -119,8 +119,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.0-rc0 h1:wH9HcyBIYQULzHhCdS36c4TmRzEaFSZgOVymd2iR71A= -github.com/cosmos/cosmos-sdk v0.39.0-rc0/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U= +github.com/cosmos/cosmos-sdk v0.39.0 h1:lWZQLFxLYQ4ydD01cDZF7tRF8IN2xclDmoNPIJ5Kw44= +github.com/cosmos/cosmos-sdk v0.39.0/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U= 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= From 722bc1fa11f97e3884f822edb7842d52a8d38e7f Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Fri, 31 Jul 2020 09:48:19 +0200 Subject: [PATCH 26/37] update to 0.39.1-rc1 --- go.mod | 2 +- go.sum | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index db6e4531c..510a2eff4 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ 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.39.0 + github.com/cosmos/cosmos-sdk v0.39.1-rc1 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 diff --git a/go.sum b/go.sum index 4d7c8d76f..06c46bf76 100644 --- a/go.sum +++ b/go.sum @@ -121,6 +121,8 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/cosmos-sdk v0.39.0 h1:lWZQLFxLYQ4ydD01cDZF7tRF8IN2xclDmoNPIJ5Kw44= github.com/cosmos/cosmos-sdk v0.39.0/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U= +github.com/cosmos/cosmos-sdk v0.39.1-rc1 h1:Xo+fkvs/4PEDOR1vb5XPbit5ZnP7OnqWYTNqtZ0lKPU= +github.com/cosmos/cosmos-sdk v0.39.1-rc1/go.mod h1:soj4C8lIjJLeUQPBqrM+krbXdnF4cDKaaDgg1JIJYRU= 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= @@ -253,6 +255,7 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc= From 20a5a38bbfc7a27a1fc9e38bb68ec01e7a65b85e Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Fri, 31 Jul 2020 10:11:18 +0200 Subject: [PATCH 27/37] fix evm tests --- go.sum | 1 + x/evm/keeper/keeper_test.go | 11 + x/evm/keeper/statedb.go | 5 + x/evm/keeper/statedb_test.go | 386 ++++++++++++++++++++++++++++------- x/evm/types/statedb_test.go | 17 +- 5 files changed, 332 insertions(+), 88 deletions(-) diff --git a/go.sum b/go.sum index 06c46bf76..52902b86f 100644 --- a/go.sum +++ b/go.sum @@ -255,6 +255,7 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/handlers v1.4.2 h1:0QniY0USkHQ1RGCLfKxeNHK9bkDHGRYGNDFBCS+YARg= github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= diff --git a/x/evm/keeper/keeper_test.go b/x/evm/keeper/keeper_test.go index 16a98317f..b02eee92e 100644 --- a/x/evm/keeper/keeper_test.go +++ b/x/evm/keeper/keeper_test.go @@ -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 := ðermint.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) { diff --git a/x/evm/keeper/statedb.go b/x/evm/keeper/statedb.go index f510f961e..272404b64 100644 --- a/x/evm/keeper/statedb.go +++ b/x/evm/keeper/statedb.go @@ -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) diff --git a/x/evm/keeper/statedb_test.go b/x/evm/keeper/statedb_test.go index 14049a530..fdc291d14 100644 --- a/x/evm/keeper/statedb_test.go +++ b/x/evm/keeper/statedb_test.go @@ -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,18 @@ 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), - }, + // { + // "sub more than balance", + // func() { + // suite.app.EvmKeeper.SubBalance(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 +117,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)) -} -func (suite *KeeperTestSuite) TestStateDBCode() { - code := []byte("foobar") + 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) + } +} - suite.app.EvmKeeper.SetCode(suite.ctx, suite.address, code) +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.Require().Equal(code, suite.app.EvmKeeper.GetCode(suite.ctx, suite.address)) + for _, tc := range testCase { + tc.malleate() - 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 +230,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 +246,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.app.EvmKeeper.SubRefund(suite.ctx, tc.amount) - suite.Require().Equal(uint64(0), suite.app.EvmKeeper.GetRefund(suite.ctx), tc.name) + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + 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) + + addr := ethcrypto.PubkeyToAddress(priv.ToECDSA().PublicKey) - suite.app.EvmKeeper.CreateAccount(suite.ctx, suite.address) - suite.Require().True(suite.app.EvmKeeper.Exist(suite.ctx, suite.address)) + 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) -func (suite *KeeperTestSuite) TestStateDBUpdateAcct() { + 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) TestSuiteDBPrepare() { +func (suite *KeeperTestSuite) TestSuiteDB_Prepare() { thash := ethcmn.BytesToHash([]byte("thash")) bhash := ethcmn.BytesToHash([]byte("bhash")) txi := 1 @@ -248,24 +370,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 +463,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 +484,13 @@ 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, - }, + // { + // "faled to update state object", + // func() { + // suite.app.EvmKeeper.SubBalance(suite.address, big.NewInt(10)) + // }, + // false, false, + // }, } for _, tc := range testCase { @@ -374,7 +520,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 +548,13 @@ 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, - }, + // { + // "faled to update state object", + // func() { + // suite.app.EvmKeeper.SubBalance(suite.address, big.NewInt(10)) + // }, + // false, false, + // }, } for _, tc := range testCase { @@ -419,6 +564,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 +580,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{} + } +} diff --git a/x/evm/types/statedb_test.go b/x/evm/types/statedb_test.go index 5e41c32bf..7780a2985 100644 --- a/x/evm/types/statedb_test.go +++ b/x/evm/types/statedb_test.go @@ -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,7 +41,6 @@ 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() @@ -141,13 +138,13 @@ func (suite *StateDBTestSuite) TestStateDB_Balance() { }, big.NewInt(200), }, - { - "sub more than balance", - func() { - suite.stateDB.SubBalance(suite.address, big.NewInt(300)) - }, - big.NewInt(-100), - }, + // { + // "sub more than balance", + // func() { + // suite.stateDB.SubBalance(suite.address, big.NewInt(300)) + // }, + // big.NewInt(-100), + // }, } for _, tc := range testCase { From 70c535d4bf0dcb90cf769360d1a7daa2c8db1b4b Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Fri, 31 Jul 2020 11:03:29 +0200 Subject: [PATCH 28/37] update RPC --- rpc/eth_api.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rpc/eth_api.go b/rpc/eth_api.go index d0e8dc57f..169e030bd 100644 --- a/rpc/eth_api.go +++ b/rpc/eth_api.go @@ -39,6 +39,10 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) +func init() { + crypto.RegisterCodec(authtypes.ModuleCdc) +} + // PublicEthAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec. type PublicEthAPI struct { cliCtx context.CLIContext @@ -622,7 +626,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()) } @@ -929,7 +934,6 @@ 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(e.cliCtx) err = accRet.EnsureExists(from) From e7cffe3f4efa7bfeb3c3728ad9b8f22adaab4497 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 11 Aug 2020 17:41:26 +0200 Subject: [PATCH 29/37] minor fixes --- cmd/ethermintd/genaccounts.go | 1 - rpc/config.go | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/ethermintd/genaccounts.go b/cmd/ethermintd/genaccounts.go index 63d79e5e8..18d009a65 100644 --- a/cmd/ethermintd/genaccounts.go +++ b/cmd/ethermintd/genaccounts.go @@ -20,7 +20,6 @@ import ( authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting" "github.com/cosmos/cosmos-sdk/x/genutil" - "github.com/cosmos/ethermint/codec" "github.com/cosmos/ethermint/crypto" ethermint "github.com/cosmos/ethermint/types" diff --git a/rpc/config.go b/rpc/config.go index 025046190..68b068167 100644 --- a/rpc/config.go +++ b/rpc/config.go @@ -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) @@ -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) From 75a8b998105453509728d67a0ad01b7fa5b334a5 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 11 Aug 2020 17:49:05 +0200 Subject: [PATCH 30/37] update to rc2 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 721fcf918..c70c43997 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ 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.39.1-rc1 + github.com/cosmos/cosmos-sdk v0.39.1-rc2 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 diff --git a/go.sum b/go.sum index dfd80b554..494ad09bc 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +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-rc1 h1:Xo+fkvs/4PEDOR1vb5XPbit5ZnP7OnqWYTNqtZ0lKPU= -github.com/cosmos/cosmos-sdk v0.39.1-rc1/go.mod h1:soj4C8lIjJLeUQPBqrM+krbXdnF4cDKaaDgg1JIJYRU= +github.com/cosmos/cosmos-sdk v0.39.1-rc2 h1:rj8W64H3tCmfO02doP150soXuydtdJB3yoSKrgN8MZY= +github.com/cosmos/cosmos-sdk v0.39.1-rc2/go.mod h1:soj4C8lIjJLeUQPBqrM+krbXdnF4cDKaaDgg1JIJYRU= 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= From 2c940d275802f97172b30fcf74dce364cb794db2 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 12 Aug 2020 11:52:05 +0200 Subject: [PATCH 31/37] bump to v0.39.1 --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index c70c43997..20bf9d020 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ 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.39.1-rc2 + 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 @@ -23,7 +23,7 @@ require ( 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.6 + 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 diff --git a/go.sum b/go.sum index 494ad09bc..c0f1baf2e 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +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-rc2 h1:rj8W64H3tCmfO02doP150soXuydtdJB3yoSKrgN8MZY= -github.com/cosmos/cosmos-sdk v0.39.1-rc2/go.mod h1:soj4C8lIjJLeUQPBqrM+krbXdnF4cDKaaDgg1JIJYRU= +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= @@ -582,8 +582,8 @@ github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoM 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.6 h1:W4UOsXY4ROJZ3TLLGVVv71VXD4WK2gJRb3gzeced+mg= -github.com/tendermint/tendermint v0.33.6/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= From 8fb63373dec3934ccce98ccfed57213a9af55b52 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Mon, 17 Aug 2020 13:13:30 +0200 Subject: [PATCH 32/37] fix personal API --- rpc/personal_api.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rpc/personal_api.go b/rpc/personal_api.go index 6bc893021..3de537dc3 100644 --- a/rpc/personal_api.go +++ b/rpc/personal_api.go @@ -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 } From 4be4ebc8a853221d2a102784df9cc33f32b4ad3d Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Mon, 17 Aug 2020 13:06:20 +0100 Subject: [PATCH 33/37] fix string type cast ambiguity (#449) --- tests/rpc_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/rpc_test.go b/tests/rpc_test.go index 165ba31a3..7e38aae21 100644 --- a/tests/rpc_test.go +++ b/tests/rpc_test.go @@ -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) From 62a046663e0766f5819ed22b90ecf1e65a166d0e Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 19 Aug 2020 09:48:31 +0200 Subject: [PATCH 34/37] init --- app/ante/ante.go | 4 ++++ rpc/eth_api.go | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/ante/ante.go b/app/ante/ante.go index 544900d4f..86be60c58 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -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 diff --git a/rpc/eth_api.go b/rpc/eth_api.go index 696a7cd8d..a81f7ad61 100644 --- a/rpc/eth_api.go +++ b/rpc/eth_api.go @@ -39,9 +39,9 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) -func init() { - crypto.RegisterCodec(authtypes.ModuleCdc) -} +// func init() { +// crypto.RegisterCodec(authtypes.ModuleCdc) +// } // PublicEthAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec. type PublicEthAPI struct { From b28624edbf5380d1c3d02fa1eae037697a510f49 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 19 Aug 2020 09:53:50 +0200 Subject: [PATCH 35/37] fix estimate gas test --- tests/rpc_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rpc_test.go b/tests/rpc_test.go index 7e38aae21..ccf1274c8 100644 --- a/tests/rpc_test.go +++ b/tests/rpc_test.go @@ -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) { From d4554cddf8f8a1c07c5d3d4bf4a2f398b291da67 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Sun, 23 Aug 2020 23:05:41 +0200 Subject: [PATCH 36/37] minor genesis change --- x/evm/genesis.go | 16 ++++++---------- x/evm/keeper/keeper.go | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/x/evm/genesis.go b/x/evm/genesis.go index 1a45a5c46..c4b49eda2 100644 --- a/x/evm/genesis.go +++ b/x/evm/genesis.go @@ -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) } diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 452e9f365..d2aa4a3a1 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -13,6 +13,7 @@ import ( "github.com/cosmos/ethermint/x/evm/types" + "github.com/ethereum/go-ethereum/common" ethcmn "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" ) @@ -120,3 +121,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 +} From f759f71cf70aa8449628e363397892ebb5261fbc Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Sun, 23 Aug 2020 23:30:08 +0200 Subject: [PATCH 37/37] remove comments from unstable commit (stargate release) --- app/ante/ante_test.go | 22 ---------------------- app/ante/eth.go | 1 - app/ethermint.go | 3 +-- client/testnet.go | 11 +---------- cmd/ethermintd/genaccounts.go | 11 ----------- codec/codec.go | 4 ---- importer/importer_test.go | 18 +++++++----------- rpc/eth_api.go | 5 ----- x/evm/abci.go | 2 +- x/evm/client/cli/tx.go | 4 +--- x/evm/keeper/keeper.go | 7 +++---- x/evm/keeper/statedb_test.go | 21 --------------------- x/evm/module.go | 2 +- x/evm/types/expected_keepers.go | 6 ------ x/evm/types/journal_test.go | 6 +----- x/evm/types/querier.go | 4 ++-- x/evm/types/state_object.go | 13 +++---------- x/evm/types/state_transition_test.go | 20 -------------------- x/evm/types/statedb.go | 19 +------------------ x/evm/types/statedb_test.go | 21 --------------------- 20 files changed, 22 insertions(+), 178 deletions(-) diff --git a/app/ante/ante_test.go b/app/ante/ante_test.go index 6b69bee1e..385ac91e6 100644 --- a/app/ante/ante_test.go +++ b/app/ante/ante_test.go @@ -44,14 +44,10 @@ func (suite *AnteTestSuite) TestValidEthTx() { 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()) @@ -73,14 +69,10 @@ func (suite *AnteTestSuite) TestValidTx() { 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() @@ -106,14 +98,10 @@ func (suite *AnteTestSuite) TestSDKInvalidSigs() { 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) @@ -158,8 +146,6 @@ func (suite *AnteTestSuite) TestSDKInvalidAcc() { 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) @@ -209,8 +195,6 @@ func (suite *AnteTestSuite) TestEthInvalidNonce() { err := acc.SetSequence(10) suite.Require().NoError(err) _ = acc.SetCoins(newTestCoins()) - // err = suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins()) - // suite.Require().NoError(err) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) // require a valid Ethereum tx to pass @@ -252,8 +236,6 @@ func (suite *AnteTestSuite) TestEthInvalidIntrinsicGas() { acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1) _ = acc.SetCoins(newTestCoins()) - // err := suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins()) - // suite.Require().NoError(err) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) // require a valid Ethereum tx to pass @@ -280,8 +262,6 @@ func (suite *AnteTestSuite) TestEthInvalidMempoolFees() { acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1) _ = acc.SetCoins(newTestCoins()) - // err := suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins()) - // suite.Require().NoError(err) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) // require a valid Ethereum tx to pass @@ -303,8 +283,6 @@ func (suite *AnteTestSuite) TestEthInvalidChainID() { acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1) _ = acc.SetCoins(newTestCoins()) - // err := suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins()) - // suite.Require().NoError(err) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) // require a valid Ethereum tx to pass diff --git a/app/ante/eth.go b/app/ante/eth.go index d6bfabb06..d1fbb0070 100644 --- a/app/ante/eth.go +++ b/app/ante/eth.go @@ -193,7 +193,6 @@ 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( diff --git a/app/ethermint.go b/app/ethermint.go index 3221ef945..0aecdb74f 100644 --- a/app/ethermint.go +++ b/app/ethermint.go @@ -206,9 +206,8 @@ func NewEthermintApp( app.subspaces[crisis.ModuleName], invCheckPeriod, app.SupplyKeeper, auth.FeeCollectorName, ) app.EvmKeeper = evm.NewKeeper( - app.cdc, keys[evm.StoreKey], app.AccountKeeper, app.BankKeeper, + app.cdc, keys[evm.StoreKey], app.AccountKeeper, ) - // TODO: use protobuf app.FaucetKeeper = faucet.NewKeeper( app.cdc, keys[faucet.StoreKey], app.SupplyKeeper, ) diff --git a/client/testnet.go b/client/testnet.go index 2125ce706..387e136cf 100644 --- a/client/testnet.go +++ b/client/testnet.go @@ -130,8 +130,7 @@ func InitTestnet( var ( genAccounts []authexported.GenesisAccount - // genBalances []bank.Balance - genFiles []string + genFiles []string ) inBuf := bufio.NewReader(cmd.InOrStdin()) @@ -213,7 +212,6 @@ func InitTestnet( sdk.NewCoin(types.DenomDefault, accStakingTokens), ) - // genBalances = append(genBalances, bank.Balance{Address: addr, Coins: coins}) genAccounts = append(genAccounts, types.EthAccount{ BaseAccount: authtypes.NewBaseAccount(addr, coins, nil, 0, 0), CodeHash: ethcrypto.Keccak256(nil), @@ -284,13 +282,6 @@ func initGenFiles( authGenState.Accounts = genAccounts appGenState[authtypes.ModuleName] = cdc.MustMarshalJSON(authGenState) - // set the balances in the genesis state - // var bankGenState bank.GenesisState - // cdc.MustUnmarshalJSON(appGenState[bank.ModuleName], &bankGenState) - - // bankGenState.Balances = genBalances - // appGenState[bank.ModuleName] = cdc.MustMarshalJSON(bankGenState) - var stakingGenState stakingtypes.GenesisState cdc.MustUnmarshalJSON(appGenState[stakingtypes.ModuleName], &stakingGenState) diff --git a/cmd/ethermintd/genaccounts.go b/cmd/ethermintd/genaccounts.go index 18d009a65..cd6cda747 100644 --- a/cmd/ethermintd/genaccounts.go +++ b/cmd/ethermintd/genaccounts.go @@ -148,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) diff --git a/codec/codec.go b/codec/codec.go index f4d431b49..b8bf06ffa 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -27,9 +27,5 @@ func MakeCodec(bm module.BasicManager) *codec.Codec { ethermint.RegisterCodec(cdc) keys.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 = cdc - return cdc } diff --git a/importer/importer_test.go b/importer/importer_test.go index 1d63554fe..b676823ed 100644 --- a/importer/importer_test.go +++ b/importer/importer_test.go @@ -101,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)) @@ -150,7 +150,7 @@ 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,20 +173,16 @@ 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(cdc, keyParams, tkeyParams) // Set specific supspaces authSubspace := paramsKeeper.Subspace(auth.DefaultParamspace) - bankSubspace := paramsKeeper.Subspace(bank.DefaultParamspace) ak := auth.NewAccountKeeper(cdc, accKey, authSubspace, types.ProtoAccount) - bk := bank.NewBaseKeeper(ak, bankSubspace, nil) // mount stores keys := []*sdk.KVStoreKey{accKey, storeKey} @@ -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 diff --git a/rpc/eth_api.go b/rpc/eth_api.go index a81f7ad61..d39046636 100644 --- a/rpc/eth_api.go +++ b/rpc/eth_api.go @@ -39,10 +39,6 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) -// func init() { -// crypto.RegisterCodec(authtypes.ModuleCdc) -// } - // PublicEthAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec. type PublicEthAPI struct { cliCtx context.CLIContext @@ -206,7 +202,6 @@ 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(ctx) err := accRet.EnsureExists(from) diff --git a/x/evm/abci.go b/x/evm/abci.go index 626a199a3..61c40c7bb 100644 --- a/x/evm/abci.go +++ b/x/evm/abci.go @@ -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()) diff --git a/x/evm/client/cli/tx.go b/x/evm/client/cli/tx.go index 0803c20d1..80355e75b 100644 --- a/x/evm/client/cli/tx.go +++ b/x/evm/client/cli/tx.go @@ -27,7 +27,7 @@ import ( ) // 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", @@ -82,7 +82,6 @@ func GetCmdSendTx(cdc *codec.Codec) *cobra.Command { from := cliCtx.GetFromAddress() - // authclient.Codec = ethermintcodec.NewAppCodec(cdc) _, seq, err := authtypes.NewAccountRetriever(cliCtx).GetAccountNumberSequence(from) if err != nil { return errors.Wrap(err, "Could not retrieve account sequence") @@ -135,7 +134,6 @@ func GetCmdGenCreateTx(cdc *codec.Codec) *cobra.Command { from := cliCtx.GetFromAddress() - // authclient.Codec = ethermintcodec.NewAppCodec(cdc) _, seq, err := authtypes.NewAccountRetriever(cliCtx).GetAccountNumberSequence(from) if err != nil { return errors.Wrap(err, "Could not retrieve account sequence") diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index d2aa4a3a1..d3dcdb3e2 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -14,7 +14,6 @@ import ( "github.com/cosmos/ethermint/x/evm/types" "github.com/ethereum/go-ethereum/common" - ethcmn "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" ) @@ -40,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), } @@ -111,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) diff --git a/x/evm/keeper/statedb_test.go b/x/evm/keeper/statedb_test.go index fdc291d14..01e56637f 100644 --- a/x/evm/keeper/statedb_test.go +++ b/x/evm/keeper/statedb_test.go @@ -96,13 +96,6 @@ func (suite *KeeperTestSuite) TestStateDB_Balance() { }, big.NewInt(200), }, - // { - // "sub more than balance", - // func() { - // suite.app.EvmKeeper.SubBalance(suite.address, big.NewInt(300)) - // }, - // big.NewInt(-100), - // }, } for _, tc := range testCase { @@ -484,13 +477,6 @@ func (suite *KeeperTestSuite) TestCommitStateDB_Commit() { }, false, true, }, - // { - // "faled to update state object", - // func() { - // suite.app.EvmKeeper.SubBalance(suite.address, big.NewInt(10)) - // }, - // false, false, - // }, } for _, tc := range testCase { @@ -548,13 +534,6 @@ func (suite *KeeperTestSuite) TestCommitStateDB_Finalize() { }, false, true, }, - // { - // "faled to update state object", - // func() { - // suite.app.EvmKeeper.SubBalance(suite.address, big.NewInt(10)) - // }, - // false, false, - // }, } for _, tc := range testCase { diff --git a/x/evm/module.go b/x/evm/module.go index a04282f89..e1108e9e4 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -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) } //____________________________________________________________________________ diff --git a/x/evm/types/expected_keepers.go b/x/evm/types/expected_keepers.go index 7b6a21d9b..8e0afc260 100644 --- a/x/evm/types/expected_keepers.go +++ b/x/evm/types/expected_keepers.go @@ -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 -} diff --git a/x/evm/types/journal_test.go b/x/evm/types/journal_test.go index 1cca93e77..04ce0b5b0 100644 --- a/x/evm/types/journal_test.go +++ b/x/evm/types/journal_test.go @@ -14,7 +14,6 @@ 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" @@ -119,13 +118,11 @@ func (suite *JournalTestSuite) setup() { paramsKeeper := params.NewKeeper(cdc, keyParams, tkeyParams) authSubspace := paramsKeeper.Subspace(auth.DefaultParamspace) - bankSubspace := paramsKeeper.Subspace(bank.DefaultParamspace) ak := auth.NewAccountKeeper(cdc, authKey, authSubspace, ethermint.ProtoAccount) - bk := bank.NewBaseKeeper(ak, bankSubspace, nil) 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) { @@ -148,7 +145,6 @@ func (suite *JournalTestSuite) TestJournal_append_revert() { resetObjectChange{ prev: &stateObject{ address: suite.address, - // balance: sdk.OneInt(), }, }, }, diff --git a/x/evm/types/querier.go b/x/evm/types/querier.go index ba40665b9..397c37ca2 100644 --- a/x/evm/types/querier.go +++ b/x/evm/types/querier.go @@ -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 diff --git a/x/evm/types/state_object.go b/x/evm/types/state_object.go index d1da13994..cbf226550 100644 --- a/x/evm/types/state_object.go +++ b/x/evm/types/state_object.go @@ -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 @@ -94,10 +93,9 @@ func newStateObject(db *CommitStateDB, accProto authexported.Account) *stateObje } return &stateObject{ - stateDB: db, - account: ethermintAccount, - // balance: balance, - address: ethcmn.BytesToAddress(ethermintAccount.GetAddress().Bytes()), + stateDB: db, + account: ethermintAccount, + address: ethermintAccount.EthAddress(), originStorage: Storage{}, dirtyStorage: Storage{}, keyToOriginStorageIndex: make(map[ethcmn.Hash]int), @@ -190,7 +188,6 @@ 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()) } @@ -202,7 +199,6 @@ func (so *stateObject) SetBalance(amount *big.Int) { so.stateDB.journal.append(balanceChange{ account: &so.address, prev: so.account.GetCoins().AmountOf(types.DenomDefault), - // prev: so.balance, }) so.setBalance(amt) @@ -210,7 +206,6 @@ func (so *stateObject) SetBalance(amount *big.Int) { func (so *stateObject) setBalance(amount sdk.Int) { so.account.SetBalance(amount) - // so.balance = amount } // SetNonce sets the state object's nonce (i.e sequence number of the account). @@ -297,7 +292,6 @@ 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 @@ -414,7 +408,6 @@ func (so *stateObject) empty() bool { (so.account != nil && so.account.Sequence == 0 && (balace.BigInt() == nil || balace.IsZero()) && - // (so.balance.BigInt() == nil || so.balance.IsZero()) && bytes.Equal(so.account.CodeHash, emptyCodeHash)) } diff --git a/x/evm/types/state_transition_test.go b/x/evm/types/state_transition_test.go index 7119524a8..f2f0742b9 100644 --- a/x/evm/types/state_transition_test.go +++ b/x/evm/types/state_transition_test.go @@ -22,8 +22,6 @@ func (suite *StateDBTestSuite) TestTransitionDb() { _ = acc.SetCoins(sdk.NewCoins(balance)) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) - // suite.app.BankKeeper.SetBalance(suite.ctx, addr, balance) - priv, err := crypto.GenerateKey() suite.Require().NoError(err) recipient := ethcrypto.PubkeyToAddress(priv.ToECDSA().PublicKey) @@ -106,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: ðcmn.Hash{}, - // Sender: suite.address, - // Simulate: false, - // }, - // false, - // }, { "nil gas price", func() { diff --git a/x/evm/types/statedb.go b/x/evm/types/statedb.go index 4f447b16a..95b96b761 100644 --- a/x/evm/types/statedb.go +++ b/x/evm/types/statedb.go @@ -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{}), @@ -490,7 +488,6 @@ func (csdb *CommitStateDB) updateStateObject(so *stateObject) error { return fmt.Errorf("invalid balance %s", newBalance) } - // TODO: remove on the next upgrade coins := so.account.GetCoins() balance := coins.AmountOf(newBalance.Denom) if balance.IsZero() || !balance.Equal(newBalance.Amount) { @@ -500,7 +497,6 @@ func (csdb *CommitStateDB) updateStateObject(so *stateObject) error { if err := so.account.SetCoins(coins); err != nil { return err } - // end removal for next upgrade csdb.accountKeeper.SetAccount(csdb.ctx, so.account) // return csdb.bankKeeper.SetBalance(csdb.ctx, so.account.Address, newBalance) @@ -627,14 +623,10 @@ func (csdb *CommitStateDB) UpdateAccounts() { continue } - // balance := csdb.bankKeeper.GetBalance(csdb.ctx, emintAcc.GetAddress(), emint.DenomDefault) balance := sdk.Coin{ Denom: emint.DenomDefault, Amount: emintAcc.GetCoins().AmountOf(emint.DenomDefault), } - // if stateEntry.stateObject.Balance() != balance.Amount.BigInt() && balance.IsValid() { - // stateEntry.stateObject.balance = balance.Amount - // } if stateEntry.stateObject.Balance() != balance.Amount.BigInt() && balance.IsValid() || stateEntry.stateObject.Nonce() != emintAcc.GetSequence() { @@ -693,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)), @@ -790,7 +781,6 @@ 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 @@ -833,14 +823,7 @@ func (csdb *CommitStateDB) getStateObject(addr ethcmn.Address) (stateObject *sta return nil } - // balance := csdb.bankKeeper.GetBalance(csdb.ctx, acc.GetAddress(), emint.DenomDefault) - // balance := sdk.Coin{ - // Denom: emint.DenomDefault, - // Amount: acc.GetCoins().AmountOf(emint.DenomDefault), - // } - // insert the state object into the live set - // so := newStateObject(csdb, acc, balance.Amount) so := newStateObject(csdb, acc) csdb.setStateObject(so) diff --git a/x/evm/types/statedb_test.go b/x/evm/types/statedb_test.go index 7780a2985..158df4103 100644 --- a/x/evm/types/statedb_test.go +++ b/x/evm/types/statedb_test.go @@ -138,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 { @@ -527,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 { @@ -591,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 {