Skip to content

Commit

Permalink
Feature: support logs for evm hooks (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-nguy authored May 23, 2022
1 parent 8fa3299 commit 3c7d726
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 57 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- [cronos#429](https://github.com/crypto-org-chain/cronos/pull/429) Update ethermint to main, ibc-go to v3.0.0, cosmos sdk to v0.45.4 and gravity to latest, remove v0.7.0 related upgradeHandler.

### Improvements

- [cronos#418](https://github.com/crypto-org-chain/cronos/pull/418) Support logs in evm-hooks and return id for SendToEthereum events
- [cronos#489](https://github.com/crypto-org-chain/cronos/pull/489) Enable jemalloc memory allocator, and update rocksdb src to `v6.29.5`.

*May 3, 2022*
Expand Down
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ require (
github.com/spf13/cobra v1.4.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.1
github.com/tendermint/tendermint v0.34.19
github.com/tendermint/tendermint v0.34.20-0.20220517115723-e6f071164839
github.com/tendermint/tm-db v0.6.7
github.com/tharsis/ethermint v0.6.1-0.20220503175102-93d15db4d086
github.com/tharsis/ethermint v0.6.1-0.20220519101126-9edc87d1147f
google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4
google.golang.org/grpc v1.45.0
google.golang.org/grpc v1.46.2
google.golang.org/protobuf v1.28.0
gopkg.in/yaml.v2 v2.4.0
)
Expand Down Expand Up @@ -62,10 +62,10 @@ require (
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect
github.com/edsrzf/mmap-go v1.0.0 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/go-stack/stack v1.8.0 // indirect
Expand Down Expand Up @@ -95,7 +95,7 @@ require (
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/lib/pq v1.10.4 // indirect
github.com/lib/pq v1.10.6 // indirect
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
Expand All @@ -111,7 +111,7 @@ require (
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
Expand Down Expand Up @@ -153,7 +153,7 @@ require (
replace (
// TODO: fix keyring upstream
github.com/99designs/keyring => github.com/crypto-org-chain/keyring v1.1.6-fixes
github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.4
github.com/cosmos/cosmos-sdk => github.com/crypto-org-chain/cosmos-sdk v0.44.4-0.20220518050709-bd4ca739c699

// TODO: remove when middleware will be implemented
github.com/cosmos/ibc-go/v3 => github.com/crypto-org-chain/ibc-go/v3 v3.0.0-hooks
Expand Down
23 changes: 14 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,6 @@ 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/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44=
github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU=
github.com/cosmos/cosmos-sdk v0.45.4 h1:eStDAhJdMY8n5arbBRe+OwpNeBSunxSBHp1g55ulfdA=
github.com/cosmos/cosmos-sdk v0.45.4/go.mod h1:WOqtDxN3eCCmnYLVla10xG7lEXkFjpTaqm2a2WasgCc=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
Expand All @@ -274,6 +272,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/crypto-org-chain/cosmos-sdk v0.44.4-0.20220518050709-bd4ca739c699 h1:ktGdNahHd9qCoUxboMajlZ9HexLfPvW2QsciQia8fL8=
github.com/crypto-org-chain/cosmos-sdk v0.44.4-0.20220518050709-bd4ca739c699/go.mod h1:YkIkmgbvtkoaWjW7NDSVzzdKZRwCiwqt5PbJzXyJ+qM=
github.com/crypto-org-chain/gravity-bridge/module/v2 v2.0.0-20220509015341-a016e2b04866 h1:biYuh4CJV/d8jDpWYvV/7MKFx2KF6J6zvYulasfV/7Y=
github.com/crypto-org-chain/gravity-bridge/module/v2 v2.0.0-20220509015341-a016e2b04866/go.mod h1:oZBIK8vfPH8IaS7vTnydkf1GkStt7YRumpn/PD2QHVY=
github.com/crypto-org-chain/ibc-go/v3 v3.0.0-hooks h1:A0/O8ylYOb+R+m22S0OlMEBFRdfpHD8trte/D4qeMpQ=
Expand Down Expand Up @@ -370,8 +370,9 @@ github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
Expand All @@ -394,8 +395,9 @@ github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgO
github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4=
github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
github.com/go-kit/log v0.2.0 h1:7i2K3eKTos3Vc0enKCfnVcgHh2olr/MyfboYq7cAcFw=
github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
Expand Down Expand Up @@ -739,8 +741,9 @@ github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgx
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk=
github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs=
github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs=
github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM=
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
Expand Down Expand Up @@ -950,8 +953,9 @@ github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3O
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM=
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk=
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34=
github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
Expand Down Expand Up @@ -1117,14 +1121,15 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM
github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E=
github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/tendermint/tendermint v0.34.14/go.mod h1:FrwVm3TvsVicI9Z7FlucHV6Znfd5KBc/Lpp69cCwtk0=
github.com/tendermint/tendermint v0.34.19 h1:y0P1qI5wSa9IRuhKnTDA6IUcOrLi1hXJuALR+R7HFEk=
github.com/tendermint/tendermint v0.34.19/go.mod h1:R5+wgIwSxMdKQcmOaeudL0Cjkr3HDkhpcdum6VeU3R4=
github.com/tendermint/tendermint v0.34.20-0.20220517115723-e6f071164839 h1:84fLknaRpFmZ33teqQSKq5tksqPDk90vhbz53Ngp4a8=
github.com/tendermint/tendermint v0.34.20-0.20220517115723-e6f071164839/go.mod h1:Rlthqx2Hq440neL9pfBGV1TJGqqTqT++bvkL1yvpytY=
github.com/tendermint/tm-db v0.6.4/go.mod h1:dptYhIpJ2M5kUuenLr+Yyf3zQOv1SgBZcl8/BmWlMBw=
github.com/tendermint/tm-db v0.6.6/go.mod h1:wP8d49A85B7/erz/r4YbKssKw6ylsO/hKtFk7E1aWZI=
github.com/tendermint/tm-db v0.6.7 h1:fE00Cbl0jayAoqlExN6oyQJ7fR/ZtoVOmvPJ//+shu8=
github.com/tendermint/tm-db v0.6.7/go.mod h1:byQDzFkZV1syXr/ReXS808NxA2xvyuuVgXOJ/088L6I=
github.com/tharsis/ethermint v0.6.1-0.20220503175102-93d15db4d086 h1:t8VMWgG9LmFjslPPCc5vK4UYyU/uEMnkZ7xlqVDaSYU=
github.com/tharsis/ethermint v0.6.1-0.20220503175102-93d15db4d086/go.mod h1:iSfKPtakU/uF9qp7VGW9/1UbSh6nm0INvFGlf448DY0=
github.com/tharsis/ethermint v0.6.1-0.20220519101126-9edc87d1147f h1:TFGFpoBDFH8T32vQuQAAGsKv3CG9+C2IiFz2Q2XOPz4=
github.com/tharsis/ethermint v0.6.1-0.20220519101126-9edc87d1147f/go.mod h1:49KSfeqDTj6V3res/s+PsskRk8PVR4tly6LJfjHmulc=
github.com/tidwall/gjson v1.6.7/go.mod h1:zeFuBCIqD4sN/gmqBzZ4j7Jd6UcA2Fc56x7QFsv+8fI=
github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
Expand Down
45 changes: 23 additions & 22 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1030,12 +1030,13 @@
sha256 = "10x22k92ra1sdddj2pksprfhsm683sldflcnjm8nfz4rjjhjwkay"

["github.com/cosmos/cosmos-sdk"]
sumVersion = "v0.45.4"
sumVersion = "v0.44.4-0.20220518050709-bd4ca739c699"
vendorPath = "github.com/crypto-org-chain/cosmos-sdk"
["github.com/cosmos/cosmos-sdk".fetch]
type = "git"
url = "https://github.com/cosmos/cosmos-sdk"
rev = "ad9e5620fb3445c716e9de45cfcdb56e8f1745bf"
sha256 = "0ykh1rd3qidwbcmas644p1f016ym85b22ivmhshdbhms38aqbkyj"
url = "https://github.com/crypto-org-chain/cosmos-sdk"
rev = "bd4ca739c699553043160431ea6a6310da77aeff"
sha256 = "0wc79srk4j9y5k8dn7xd08m1a0a3gvgnyi559z2qm2apkwdm9j4q"

["github.com/cosmos/go-bip39"]
sumVersion = "v1.0.0"
Expand Down Expand Up @@ -1472,12 +1473,12 @@
sha256 = "0d5njmwkfq2809vlimnlvy8ir6kln0c4cgdwr680fwsclpbr43qs"

["github.com/fsnotify/fsnotify"]
sumVersion = "v1.5.1"
sumVersion = "v1.5.4"
["github.com/fsnotify/fsnotify".fetch]
type = "git"
url = "https://github.com/fsnotify/fsnotify"
rev = "466b39d216616549a37ee93c7c47775f6a010790"
sha256 = "0xpdprvab4zgn5igymc5468hk5s429cqyxml9xjsk0cn53rikj87"
rev = "0f4b979323bea7ee6677faa4a88078ec558b1b80"
sha256 = "076q5iibk03m5njqah4xwm6dz7ywyn7bdyis97gg09n0j2g8iyw8"

["github.com/gballet/go-libpcsclite"]
sumVersion = "v0.0.0-20190607065134-2772fd86a8ff"
Expand Down Expand Up @@ -1569,12 +1570,12 @@
sha256 = "15cm24sjyvwxpprfha2k0s3c1hhpg5y2kljnw04hayfyazqc79wl"

["github.com/go-kit/log"]
sumVersion = "v0.2.0"
sumVersion = "v0.2.1"
["github.com/go-kit/log".fetch]
type = "git"
url = "https://github.com/go-kit/log"
rev = "71fa7d7d64785c98d3814e53b3544fd8cccff897"
sha256 = "13gbqrwvqy9j903j44x0kix5gnn34a8hl8skbdijy7arpkxpj6h3"
rev = "0b69c7049332e99c25d5fd0f4d08317cfe45e7d8"
sha256 = "1xjv2g1cd1iaghhm1c1zw0lcz89a9zq5xradyjipvrbqxbxckqm6"

["github.com/go-logfmt/logfmt"]
sumVersion = "v0.5.1"
Expand Down Expand Up @@ -2687,12 +2688,12 @@
sha256 = "1d4g1vkhc1180l1n7q48vl84b27c7cziywml78cyijbcdz2f8vim"

["github.com/lib/pq"]
sumVersion = "v1.10.4"
sumVersion = "v1.10.6"
["github.com/lib/pq".fetch]
type = "git"
url = "https://github.com/lib/pq"
rev = "8446d16b8935fdf2b5c0fe333538ac395e3e1e4b"
sha256 = "0kdr257l1gq82bx2g3qjab6haj31ib8ljbyaa1rg1xsva5j17ngx"
rev = "8c6de565f76fb5cd40a5c1b8ce583fbc3ba1bd0e"
sha256 = "0qf9xd8g1750q2hcn04r7086lv009bj0ddrsn8xc57v67zk3vglc"

["github.com/libp2p/go-buffer-pool"]
sumVersion = "v0.0.2"
Expand Down Expand Up @@ -3404,12 +3405,12 @@
sha256 = "0nri6hkfb0z3dkxf2fsfidr4bxbn91rjsqhg5s0c2jplf0aclppz"

["github.com/prometheus/client_golang"]
sumVersion = "v1.12.1"
sumVersion = "v1.12.2"
["github.com/prometheus/client_golang".fetch]
type = "git"
url = "https://github.com/prometheus/client_golang"
rev = "2e1c4818ccfdcf953ce399cadad615ff2bed968c"
sha256 = "0d46nindizpjgdygryc140fd94j1qfkzwyzwh9p2g3zp6v4fw0s1"
rev = "e203144f43306c1f344fbc548fd02c4b79962e30"
sha256 = "0caz7dxlfqc1x05rdk6bsgjbrz2v0sswnkk17sp8j57zqb44gk3p"

["github.com/prometheus/client_model"]
sumVersion = "v0.2.0"
Expand Down Expand Up @@ -3852,12 +3853,12 @@
sha256 = "1zcms3l5fihzg8nf4vhdk18qpn1jkbm3rpkjfpskfcrgzlxk6vi5"

["github.com/tendermint/tendermint"]
sumVersion = "v0.34.19"
sumVersion = "v0.34.20-0.20220517115723-e6f071164839"
["github.com/tendermint/tendermint".fetch]
type = "git"
url = "https://github.com/tendermint/tendermint"
rev = "2f231ceb952a2426cf3c0abaf0b455aadd11e5b2"
sha256 = "1j04xnaf2l1swj5rfijiq7632v6nnj8mvn0gmd6qbqjgy5q47frm"
rev = "e6f07116483973914eb1c71ade39b0499f84bbe2"
sha256 = "1ayhsmzac4nam4s621qss2ym4mdqwq1nrv5farxv8cnjlsc826hb"

["github.com/tendermint/tm-db"]
sumVersion = "v0.6.7"
Expand All @@ -3868,12 +3869,12 @@
sha256 = "0nlf9w791ln0n49fiaczy7bsr0i1cnrrm78frhv4k9kbn13gfpw6"

["github.com/tharsis/ethermint"]
sumVersion = "v0.6.1-0.20220503175102-93d15db4d086"
sumVersion = "v0.6.1-0.20220519101126-9edc87d1147f"
["github.com/tharsis/ethermint".fetch]
type = "git"
url = "https://github.com/tharsis/ethermint"
rev = "93d15db4d086d65eb0a7bee744b453e5ae416ac0"
sha256 = "1ppxkqcxpbz7di7v43nxdrd3m97bxyz0i07y2pxqr7xla4vdardm"
rev = "9edc87d1147f3513d99370f41f7547c993e54572"
sha256 = "142bynf016f3g5k9dvzi057yk4zyckdah3lgs773p1ygspkwvl0d"

["github.com/tidwall/gjson"]
sumVersion = "v1.6.7"
Expand Down
21 changes: 21 additions & 0 deletions integration_tests/test_gravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import toml
from dateutil.parser import isoparse
from eth_account.account import Account
from eth_utils import abi
from hexbytes import HexBytes
from pystarport import ports

Expand Down Expand Up @@ -228,6 +229,17 @@ def check_gravity_native_tokens():
"check the balance of gravity native token"
return cli.balance(eth_to_bech32(recipient), denom=denom) == amount

def get_id_from_receipt(receipt):
"check the id after sendToEthereum call"
for _, log in enumerate(receipt.logs):
if log.topics[0] == HexBytes(
abi.event_signature_to_log_topic(
"__CronosSendToEthereumResponse(uint256)"
)
):
return log.data
return "0x0000000000000000000000000000000000000000000000000000000000000000"

if gravity.cronos.enable_auto_deployment:
wait_for_fn("send-to-crc20", check_auto_deployment)

Expand All @@ -236,6 +248,15 @@ def check_gravity_native_tokens():
ADDRS["validator"], amount, 0
).buildTransaction({"from": ADDRS["community"]})
txreceipt = send_transaction(cronos_w3, tx, KEYS["community"])
# CRC20 emit 3 logs for send_to_ethereum:
# burn
# __CronosSendToEthereum
# __CronosSendToEthereumResponse
assert len(txreceipt.logs) == 3
assert (
get_id_from_receipt(txreceipt)
== "0x0000000000000000000000000000000000000000000000000000000000000001"
), "should be able to get id"
assert txreceipt.status == 1, "should success"
else:
wait_for_fn("send-to-gravity-native", check_gravity_native_tokens)
Expand Down
35 changes: 32 additions & 3 deletions x/cronos/keeper/evm_hooks.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package keeper

import (
"math/big"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/crypto-org-chain/cronos/x/cronos/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
ethtypes "github.com/ethereum/go-ethereum/core/types"

"github.com/crypto-org-chain/cronos/x/cronos/types"
)

// LogProcessEvmHook is an evm hook that convert specific contract logs into native module calls
Expand All @@ -26,6 +27,7 @@ func NewLogProcessEvmHook(handlers ...types.EvmLogHandler) *LogProcessEvmHook {

// PostTxProcessing implements EvmHook interface
func (h LogProcessEvmHook) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error {
addLogToReceiptFunc := newFuncAddLogToReceipt(receipt)
for _, log := range receipt.Logs {
if len(log.Topics) == 0 {
continue
Expand All @@ -34,10 +36,37 @@ func (h LogProcessEvmHook) PostTxProcessing(ctx sdk.Context, msg core.Message, r
if !ok {
continue
}
err := handler.Handle(ctx, log.Address, log.Data)
err := handler.Handle(ctx, log.Address, log.Data, addLogToReceiptFunc)
if err != nil {
return err
}
}
return nil
}

// newFuncAddLogToReceipt return a function to add additional logs to the receipt
func newFuncAddLogToReceipt(receipt *ethtypes.Receipt) func(contractAddress common.Address, logSig common.Hash, logData []byte) {
return func(contractAddress common.Address, logSig common.Hash, logData []byte) {
if receipt.BlockNumber == nil {
return
}
newLog := &ethtypes.Log{
Address: contractAddress,
Topics: []common.Hash{logSig},
Data: logData,
BlockNumber: receipt.BlockNumber.Uint64(),
TxHash: receipt.TxHash,
TxIndex: receipt.TransactionIndex,
BlockHash: receipt.BlockHash,
Index: uint(len(receipt.Logs)),
Removed: false,
}

// Compute block bloom filter and set to the receipt
bloom := receipt.Bloom.Big()
bloom.Or(bloom, big.NewInt(0).SetBytes(ethtypes.LogsBloom([]*ethtypes.Log{newLog})))
receipt.Bloom = ethtypes.BytesToBloom(bloom.Bytes())

receipt.Logs = append(receipt.Logs, newLog)
}
}
Loading

0 comments on commit 3c7d726

Please sign in to comment.