Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: tx receipt don't contain events #93

Merged
merged 4 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ replace github.com/cosmos/ibc-go => github.com/crypto-org-chain/ibc-go v1.0.1-ho

// FIXME: update after PR merged: https://github.com/PeggyJV/gravity-bridge/pull/182
replace github.com/peggyjv/gravity-bridge/module => github.com/crypto-org-chain/gravity-bridge/module v0.1.22-0.20210908191543-71021d1bfff2

replace github.com/tharsis/ethermint => github.com/crypto-org-chain/ethermint v0.4.2-0.20210922040229-16124b2166a8
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:ma
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
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/ethermint v0.4.2-0.20210922040229-16124b2166a8 h1:79Q5U4XrxscVHQdecGYT900FojON8kQSZP16dgXW7Hc=
github.com/crypto-org-chain/ethermint v0.4.2-0.20210922040229-16124b2166a8/go.mod h1:okjGPqRHzqT87tf7KdU1Q8FoFYQlBeIyGRkYKr5KrRQ=
github.com/crypto-org-chain/gravity-bridge/module v0.1.22-0.20210908191543-71021d1bfff2 h1:CvcZfg7PHZNTAWsrN/MCa1DxSYlCNtQ2ZgJ7r2tqevM=
github.com/crypto-org-chain/gravity-bridge/module v0.1.22-0.20210908191543-71021d1bfff2/go.mod h1:gixjqIjdEb0CC0Kp4bLaJRoFSMG+irz3qU6gWwmNHik=
github.com/crypto-org-chain/ibc-go v1.0.1-hooks h1:XNW6yqIAjDBbRHt7KlfCmB/mCcwjfghOmUP4SFN3mVY=
Expand Down Expand Up @@ -1021,8 +1023,6 @@ github.com/tendermint/tm-db v0.6.2/go.mod h1:GYtQ67SUvATOcoY8/+x6ylk8Qo02BQyLrAs
github.com/tendermint/tm-db v0.6.3/go.mod h1:lfA1dL9/Y/Y8wwyPp2NMLyn5P5Ptr/gvDFNWtrCWSf8=
github.com/tendermint/tm-db v0.6.4 h1:3N2jlnYQkXNQclQwd/eKV/NzlqPlfK21cpRRIx80XXQ=
github.com/tendermint/tm-db v0.6.4/go.mod h1:dptYhIpJ2M5kUuenLr+Yyf3zQOv1SgBZcl8/BmWlMBw=
github.com/tharsis/ethermint v0.4.2-0.20210920104419-1a01c6a992c0 h1:YXxxvO9MBXyUhfJtytZlhv91dDeeeP5qMBPG7tit4og=
github.com/tharsis/ethermint v0.4.2-0.20210920104419-1a01c6a992c0/go.mod h1:okjGPqRHzqT87tf7KdU1Q8FoFYQlBeIyGRkYKr5KrRQ=
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
9 changes: 5 additions & 4 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3751,12 +3751,13 @@
sha256 = "1sgjf2vaq554ybc0cwkzn17cz2ibzph2rq0dgaw21c2hym09437x"

["github.com/tharsis/ethermint"]
sumVersion = "v0.4.2-0.20210920104419-1a01c6a992c0"
sumVersion = "v0.4.2-0.20210922040229-16124b2166a8"
vendorPath = "github.com/crypto-org-chain/ethermint"
["github.com/tharsis/ethermint".fetch]
type = "git"
url = "https://github.com/tharsis/ethermint"
rev = "1a01c6a992c0fb94d70bb1c7127715874cefd057"
sha256 = "0pi1cvkhi211zj1pffzhnjspif0sx28g1qbnzbqi5zmxr77yqgrm"
url = "https://github.com/crypto-org-chain/ethermint"
rev = "16124b2166a8006a26075cb2fb80c35736231efc"
sha256 = "1dp7fy69rhzhm8ghw7ipakd4jci3yy2skm9x07gwarnr1hcqh0nr"

["github.com/tidwall/gjson"]
sumVersion = "v1.6.7"
Expand Down
41 changes: 40 additions & 1 deletion integration_tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from pathlib import Path

from .utils import ADDRS, deploy_contract
from eth_utils import abi
from hexbytes import HexBytes

from .utils import ADDRS, KEYS, deploy_contract, send_transaction


def test_basic(cluster):
Expand All @@ -9,6 +12,42 @@ def test_basic(cluster):
assert w3.eth.get_balance(ADDRS["community"]) == 10000000000000000000000


def test_events(cluster, suspend_capture):
w3 = cluster.w3
erc20 = deploy_contract(
w3,
Path(__file__).parent
/ "contracts/artifacts/contracts/TestERC20A.sol/TestERC20A.json",
key=KEYS["validator"],
)
tx = erc20.functions.transfer(ADDRS["community"], 10).buildTransaction(
{"from": ADDRS["validator"]}
)
txreceipt = send_transaction(w3, tx, KEYS["validator"])
assert len(txreceipt.logs) == 1
expect_log = {
"address": erc20.address,
"topics": [
HexBytes(
abi.event_signature_to_log_topic("Transfer(address,address,uint256)")
),
HexBytes(b"\x00" * 12 + HexBytes(ADDRS["validator"])),
HexBytes(b"\x00" * 12 + HexBytes(ADDRS["community"])),
],
"data": "0x000000000000000000000000000000000000000000000000000000000000000a",
"transactionIndex": 0,
"logIndex": 0,
"removed": False,
}
assert expect_log.items() <= txreceipt.logs[0].items()

# check block bloom
assert (
w3.eth.get_block(txreceipt.blockNumber).logsBloom
== "0x00000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000002000000000000002000000000000000000000000000000000000000000001000000008000000000000000000041000000000000000000000000000000000000000000000"
)


def test_native_call(cronos):
"""
test contract native call on cronos network
Expand Down
9 changes: 6 additions & 3 deletions integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,17 @@ def supervisorctl(inipath, *args):
)


def deploy_contract(w3, jsonfile, args=()):
def deploy_contract(w3, jsonfile, args=(), key=KEYS["validator"]):
"""
deploy contract and return the deployed contract instance
"""
acct = Account.from_key(key)
info = json.load(open(jsonfile))
contract = w3.eth.contract(abi=info["abi"], bytecode=info["bytecode"])
txhash = contract.constructor(*args).transact({"from": w3.eth.coinbase})
address = w3.eth.wait_for_transaction_receipt(txhash).contractAddress
tx = contract.constructor(*args).buildTransaction({"from": acct.address})
txreceipt = send_transaction(w3, tx, key)
assert txreceipt.status == 1
address = txreceipt.contractAddress
return w3.eth.contract(address=address, abi=info["abi"])


Expand Down