forked from cerc-io/laconicd-deprecated
chore (deps): Update geth version to v1.10.25 (#1413)
* build(deps): bump github.com/ethereum/go-ethereum Bumps [github.com/ethereum/go-ethereum](https://github.com/ethereum/go-ethereum) from 1.10.19 to 1.10.25. - [Release notes](https://github.com/ethereum/go-ethereum/releases) - [Commits](https://github.com/ethereum/go-ethereum/compare/v1.10.19...v1.10.25) --- updated-dependencies: - dependency-name: github.com/ethereum/go-ethereum dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * wip geth update * fix geth init flag order * add chainId to getTransaction. fix types comparison. update expected values on tests * wip add tracer config * tracers test * update tests * update to v1.10.25 * fix linter python * ignore error * fix lint * additional changes from diff * fix issues * solve lint issues * fix tests * fix flake * wrap types comparison in integration tests * fix integration tests * fix flake * update changelog Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Freddy Caceres <facs95@gmail.com>
This commit is contained in:
co-authored by
dependabot[bot]
Federico Kunze Küllmer
Freddy Caceres
parent
d5917752a6
commit
71e51aabf6
File diff suppressed because one or more lines are too long
@@ -43,7 +43,7 @@ def test_block_filter(cluster):
|
||||
|
||||
def test_event_log_filter_by_contract(cluster):
|
||||
w3: Web3 = cluster.w3
|
||||
contract = deploy_contract(w3, CONTRACTS["Greeter"])
|
||||
contract, _ = deploy_contract(w3, CONTRACTS["Greeter"])
|
||||
assert contract.caller.greet() == "Hello"
|
||||
|
||||
# Create new filter from contract
|
||||
@@ -81,7 +81,7 @@ def test_event_log_filter_by_contract(cluster):
|
||||
def test_event_log_filter_by_address(cluster):
|
||||
w3: Web3 = cluster.w3
|
||||
|
||||
contract = deploy_contract(w3, CONTRACTS["Greeter"])
|
||||
contract, _ = deploy_contract(w3, CONTRACTS["Greeter"])
|
||||
assert contract.caller.greet() == "Hello"
|
||||
|
||||
flt = w3.eth.filter({"address": contract.address})
|
||||
@@ -103,7 +103,7 @@ def test_event_log_filter_by_address(cluster):
|
||||
def test_get_logs(cluster):
|
||||
w3: Web3 = cluster.w3
|
||||
|
||||
contract = deploy_contract(w3, CONTRACTS["Greeter"])
|
||||
contract, _ = deploy_contract(w3, CONTRACTS["Greeter"])
|
||||
|
||||
# without tx
|
||||
assert w3.eth.get_logs({"address": contract.address}) == []
|
||||
|
||||
@@ -34,7 +34,7 @@ def test_pruned_node(pruned):
|
||||
test basic json-rpc apis works in pruned node
|
||||
"""
|
||||
w3 = pruned.w3
|
||||
erc20 = deploy_contract(
|
||||
erc20, _ = deploy_contract(
|
||||
w3,
|
||||
CONTRACTS["TestERC20A"],
|
||||
key=KEYS["validator"],
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
|
||||
from web3 import Web3
|
||||
|
||||
from .expected_constants import (
|
||||
EXPECTED_CALLTRACERS,
|
||||
EXPECTED_CONTRACT_CREATE_TRACER,
|
||||
EXPECTED_STRUCT_TRACER,
|
||||
)
|
||||
from .utils import (
|
||||
ADDRS,
|
||||
CONTRACTS,
|
||||
KEYS,
|
||||
deploy_contract,
|
||||
send_transaction,
|
||||
w3_wait_for_new_blocks,
|
||||
)
|
||||
|
||||
|
||||
def test_tracers(ethermint_rpc_ws):
|
||||
w3: Web3 = ethermint_rpc_ws.w3
|
||||
eth_rpc = w3.provider
|
||||
gas_price = w3.eth.gas_price
|
||||
tx = {"to": ADDRS["community"], "value": 100, "gasPrice": gas_price}
|
||||
tx_hash = send_transaction(w3, tx, KEYS["validator"])["transactionHash"].hex()
|
||||
|
||||
tx_res = eth_rpc.make_request("debug_traceTransaction", [tx_hash])
|
||||
assert tx_res["result"] == EXPECTED_STRUCT_TRACER, ""
|
||||
|
||||
tx_res = eth_rpc.make_request(
|
||||
"debug_traceTransaction", [tx_hash, {"tracer": "callTracer"}]
|
||||
)
|
||||
assert tx_res["result"] == EXPECTED_CALLTRACERS, ""
|
||||
|
||||
tx_res = eth_rpc.make_request(
|
||||
"debug_traceTransaction",
|
||||
[tx_hash, {"tracer": "callTracer", "tracerConfig": "{'onlyTopCall':True}"}],
|
||||
)
|
||||
assert tx_res["result"] == EXPECTED_CALLTRACERS, ""
|
||||
|
||||
_, tx = deploy_contract(
|
||||
w3,
|
||||
CONTRACTS["TestERC20A"],
|
||||
)
|
||||
tx_hash = tx["transactionHash"].hex()
|
||||
|
||||
w3_wait_for_new_blocks(w3, 1)
|
||||
|
||||
tx_res = eth_rpc.make_request(
|
||||
"debug_traceTransaction", [tx_hash, {"tracer": "callTracer"}]
|
||||
)
|
||||
tx_res["result"]["to"] = EXPECTED_CONTRACT_CREATE_TRACER["to"]
|
||||
assert tx_res["result"] == EXPECTED_CONTRACT_CREATE_TRACER, ""
|
||||
@@ -49,8 +49,7 @@ def get_blocks(ethermint_rpc_ws, geth, with_transactions):
|
||||
with_transactions,
|
||||
],
|
||||
)
|
||||
res, err = same_types(eth_rsp, geth_rsp)
|
||||
assert res, err
|
||||
compare_types(eth_rsp, geth_rsp)
|
||||
|
||||
# Get not existing block
|
||||
make_same_rpc_calls(
|
||||
@@ -157,7 +156,7 @@ def test_balance(ethermint_rpc_ws, geth):
|
||||
|
||||
|
||||
def deploy_and_wait(w3, number=1):
|
||||
contract = deploy_contract(
|
||||
contract, _ = deploy_contract(
|
||||
w3,
|
||||
CONTRACTS["TestERC20A"],
|
||||
)
|
||||
@@ -179,8 +178,7 @@ def test_get_storage_at(ethermint_rpc_ws, geth):
|
||||
|
||||
contract = deploy_and_wait(w3)
|
||||
res = eth_rpc.make_request("eth_getStorageAt", [contract.address, "0x0", "latest"])
|
||||
res, err = same_types(res["result"], EXPECTED_GET_STORAGE_AT)
|
||||
assert res, err
|
||||
compare_types(res["result"], EXPECTED_GET_STORAGE_AT)
|
||||
|
||||
|
||||
def send_tnx(w3, tx_value=10):
|
||||
@@ -215,16 +213,15 @@ def test_get_proof(ethermint_rpc_ws, geth):
|
||||
proof = (eth_rpc.make_request(
|
||||
method, [validator, ["0x0"], hex(res["blockNumber"])]
|
||||
))["result"]
|
||||
res, err = same_types(proof, EXPECTED_GET_PROOF)
|
||||
assert res, err
|
||||
compare_types(proof, EXPECTED_GET_PROOF["result"])
|
||||
assert proof["accountProof"], EXPECTED_ACCOUNT_PROOF
|
||||
assert proof["storageProof"][0]["proof"], EXPECTED_STORAGE_PROOF
|
||||
|
||||
proof = (geth_rpc.make_request(
|
||||
_ = send_and_get_hash(w3)
|
||||
proof = eth_rpc.make_request(
|
||||
method, [validator, ["0x0"], "latest"]
|
||||
))["result"]
|
||||
res, err = same_types(proof, EXPECTED_GET_PROOF)
|
||||
assert res, err
|
||||
)
|
||||
compare_types(proof, EXPECTED_GET_PROOF)
|
||||
|
||||
|
||||
def test_get_code(ethermint_rpc_ws, geth):
|
||||
@@ -241,9 +238,8 @@ def test_get_code(ethermint_rpc_ws, geth):
|
||||
# Do an ethereum transfer
|
||||
contract = deploy_and_wait(w3)
|
||||
code = eth_rpc.make_request("eth_getCode", [contract.address, "latest"])
|
||||
expected = {"id": "4", "jsonrpc": "2.0", "result": "0x"}
|
||||
res, err = same_types(code, expected)
|
||||
assert res, err
|
||||
expected = {"id": 4, "jsonrpc": "2.0", "result": "0x"}
|
||||
compare_types(code, expected)
|
||||
|
||||
|
||||
def test_get_block_transaction_count(ethermint_rpc_ws, geth):
|
||||
@@ -255,7 +251,7 @@ def test_get_block_transaction_count(ethermint_rpc_ws, geth):
|
||||
)
|
||||
|
||||
make_same_rpc_calls(
|
||||
eth_rpc, geth_rpc, "eth_getBlockTransactionCountByNumber", ["0x100"]
|
||||
eth_rpc, geth_rpc, "eth_getBlockTransactionCountByNumber", ["0x1000"]
|
||||
)
|
||||
|
||||
tx_hash = send_and_get_hash(w3)
|
||||
@@ -267,9 +263,8 @@ def test_get_block_transaction_count(ethermint_rpc_ws, geth):
|
||||
"eth_getBlockTransactionCountByNumber", [block_number]
|
||||
)
|
||||
|
||||
expected = {"id": "1", "jsonrpc": "2.0", "result": "0x1"}
|
||||
res, err = same_types(block_res, expected)
|
||||
assert res, err
|
||||
expected = {"id": 1, "jsonrpc": "2.0", "result": "0x1"}
|
||||
compare_types(block_res, expected)
|
||||
|
||||
make_same_rpc_calls(
|
||||
eth_rpc,
|
||||
@@ -278,9 +273,8 @@ def test_get_block_transaction_count(ethermint_rpc_ws, geth):
|
||||
["0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd"],
|
||||
)
|
||||
block_res = eth_rpc.make_request("eth_getBlockTransactionCountByHash", [block_hash])
|
||||
expected = {"id": "1", "jsonrpc": "2.0", "result": "0x1"}
|
||||
res, err = same_types(block_res, expected)
|
||||
assert res, err
|
||||
expected = {"id": 1, "jsonrpc": "2.0", "result": "0x1"}
|
||||
compare_types(block_res, expected)
|
||||
|
||||
|
||||
def test_get_transaction(ethermint_rpc_ws, geth):
|
||||
@@ -297,8 +291,8 @@ def test_get_transaction(ethermint_rpc_ws, geth):
|
||||
tx_hash = send_and_get_hash(w3)
|
||||
|
||||
tx_res = eth_rpc.make_request("eth_getTransactionByHash", [tx_hash])
|
||||
res, err = same_types(tx_res, EXPECTED_GET_TRANSACTION)
|
||||
assert res, err
|
||||
|
||||
compare_types(EXPECTED_GET_TRANSACTION, tx_res)
|
||||
|
||||
|
||||
def test_get_transaction_receipt(ethermint_rpc_ws, geth):
|
||||
@@ -315,8 +309,7 @@ def test_get_transaction_receipt(ethermint_rpc_ws, geth):
|
||||
tx_hash = send_and_get_hash(w3)
|
||||
|
||||
tx_res = eth_rpc.make_request("eth_getTransactionReceipt", [tx_hash])
|
||||
res, err = same_types(tx_res["result"], EXPECTED_GET_TRANSACTION_RECEIPT)
|
||||
assert res, err
|
||||
compare_types(tx_res, EXPECTED_GET_TRANSACTION_RECEIPT)
|
||||
|
||||
|
||||
def test_fee_history(ethermint_rpc_ws, geth):
|
||||
@@ -327,10 +320,10 @@ def test_fee_history(ethermint_rpc_ws, geth):
|
||||
|
||||
make_same_rpc_calls(eth_rpc, geth_rpc, "eth_feeHistory", [4, "0x5000", [10, 90]])
|
||||
|
||||
fee_history = eth_rpc.make_request("eth_feeHistory", [4, "latest", [10, 90]])
|
||||
_ = send_and_get_hash(w3)
|
||||
fee_history = eth_rpc.make_request("eth_feeHistory", [4, "latest", [100]])
|
||||
|
||||
res, err = same_types(fee_history["result"], EXPECTED_FEE_HISTORY)
|
||||
assert res, err
|
||||
compare_types(fee_history, EXPECTED_FEE_HISTORY)
|
||||
|
||||
|
||||
def test_estimate_gas(ethermint_rpc_ws, geth):
|
||||
@@ -345,11 +338,19 @@ def test_estimate_gas(ethermint_rpc_ws, geth):
|
||||
make_same_rpc_calls(eth_rpc, geth_rpc, "eth_estimateGas", [{}])
|
||||
|
||||
|
||||
def compare_types(actual, expected):
|
||||
res, err = same_types(actual, expected)
|
||||
if not res:
|
||||
print(err)
|
||||
print(actual)
|
||||
print(expected)
|
||||
assert res, err
|
||||
|
||||
|
||||
def make_same_rpc_calls(rpc1, rpc2, method, params):
|
||||
res1 = rpc1.make_request(method, params)
|
||||
res2 = rpc2.make_request(method, params)
|
||||
res, err = same_types(res1, res2)
|
||||
assert res, err
|
||||
compare_types(res1, res2)
|
||||
|
||||
|
||||
def test_incomplete_send_transaction(ethermint_rpc_ws, geth):
|
||||
@@ -362,37 +363,45 @@ def test_incomplete_send_transaction(ethermint_rpc_ws, geth):
|
||||
make_same_rpc_calls(eth_rpc, geth_rpc, "eth_sendTransaction", [tx])
|
||||
|
||||
|
||||
def same_types(object_a, object_b):
|
||||
|
||||
if isinstance(object_a, dict):
|
||||
if not isinstance(object_b, dict):
|
||||
def same_types(given, expected):
|
||||
if isinstance(given, dict):
|
||||
if not isinstance(expected, dict):
|
||||
return False, "A is dict, B is not"
|
||||
keys = list(set(list(object_a.keys()) + list(object_b.keys())))
|
||||
keys = list(set(list(given.keys()) + list(expected.keys())))
|
||||
for key in keys:
|
||||
if key in object_b and key in object_a:
|
||||
if not same_types(object_a[key], object_b[key]):
|
||||
return False, key + " key on dict are not of same type"
|
||||
else:
|
||||
return False, key + " key on json is not in both results"
|
||||
if key not in expected or key not in given:
|
||||
return False, key + " key not on both json"
|
||||
res, err = same_types(given[key], expected[key])
|
||||
if not res:
|
||||
return res, key + " key failed. Error: " + err
|
||||
return True, ""
|
||||
elif isinstance(object_a, list):
|
||||
if not isinstance(object_b, list):
|
||||
elif isinstance(given, list):
|
||||
if not isinstance(expected, list):
|
||||
return False, "A is list, B is not"
|
||||
if len(object_a) == 0 and len(object_b) == 0:
|
||||
if len(given) == 0 and len(expected) == 0:
|
||||
return True, ""
|
||||
if len(object_a) > 0 and len(object_b) > 0:
|
||||
return same_types(object_a[0], object_b[0])
|
||||
if len(given) > 0 and len(expected) > 0:
|
||||
return same_types(given[0], expected[0])
|
||||
else:
|
||||
return True
|
||||
elif object_a is None and object_b is None:
|
||||
return True, ""
|
||||
elif given is None and expected is None:
|
||||
return True, ""
|
||||
elif type(object_a) is type(object_b):
|
||||
elif type(given) is type(expected):
|
||||
return True, ""
|
||||
elif (
|
||||
type(given) is int
|
||||
and type(expected) is float
|
||||
and given == 0
|
||||
or type(expected) is int
|
||||
and type(given) is float
|
||||
and expected == 0
|
||||
):
|
||||
return True, ""
|
||||
else:
|
||||
return (
|
||||
False,
|
||||
"different types. A is type "
|
||||
+ type(object_a).__name__
|
||||
+ " B is type "
|
||||
+ type(object_b).__name__,
|
||||
"different types. Given object is type "
|
||||
+ type(given).__name__
|
||||
+ " expected object is type "
|
||||
+ type(expected).__name__,
|
||||
)
|
||||
|
||||
@@ -97,7 +97,7 @@ def test_cosmovisor_upgrade(custom_ethermint: Ethermint):
|
||||
print("upgrade height", target_height)
|
||||
|
||||
w3 = custom_ethermint.w3
|
||||
contract = deploy_contract(w3, CONTRACTS["TestERC20A"])
|
||||
contract, _ = deploy_contract(w3, CONTRACTS["TestERC20A"])
|
||||
old_height = w3.eth.block_number
|
||||
old_balance = w3.eth.get_balance(ADDRS["validator"], block_identifier=old_height)
|
||||
old_base_fee = w3.eth.get_block(old_height).baseFeePerGas
|
||||
|
||||
@@ -114,7 +114,7 @@ def wait_for_block_time(cli, t):
|
||||
print("wait for block time", t)
|
||||
while True:
|
||||
now = isoparse((cli.status())["SyncInfo"]["latest_block_time"])
|
||||
print("block time now:", now)
|
||||
print("block time now: ", now)
|
||||
if now >= t:
|
||||
break
|
||||
time.sleep(0.5)
|
||||
@@ -131,7 +131,7 @@ def deploy_contract(w3, jsonfile, args=(), key=KEYS["validator"]):
|
||||
txreceipt = send_transaction(w3, tx, key)
|
||||
assert txreceipt.status == 1
|
||||
address = txreceipt.contractAddress
|
||||
return w3.eth.contract(address=address, abi=info["abi"])
|
||||
return w3.eth.contract(address=address, abi=info["abi"]), txreceipt
|
||||
|
||||
|
||||
def fill_defaults(w3, tx):
|
||||
|
||||
Reference in New Issue
Block a user