Skip to content

Commit 79b28a0

Browse files
authored
fix: missing tx context during vm initialization (#1869)
* fix tx context * add changelog * add test * remove unecessary abi * more robust test * cleanup * fix lint
1 parent 98304d8 commit 79b28a0

File tree

7 files changed

+74
-6
lines changed

7 files changed

+74
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## UNRELEASED
44

5+
* [#1869](https://github.com/crypto-org-chain/cronos/pull/1869) Add missing tx context during vm initialisation
6+
7+
*Sep 4, 2025*
8+
9+
## v1.5.0
10+
511
### State Machine Breaking
612

713
* [#1731](https://github.com/crypto-org-chain/cronos/pull/1804) Upgrade to ibc-go v10.1.1

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ replace (
305305
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
306306
// release/v1.15
307307
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20250815065500-a4fbafcae0dd
308-
// develop
309-
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.22.1-0.20250909102334-034803df81c7
308+
// release/v0.22.x
309+
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.22.1-0.20250916025604-a85d8890cd52
310310
// Fix upstream GHSA-h395-qcrw-5vmq and GHSA-3vp4-m3rf-835h vulnerabilities.
311311
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
312312
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,8 +912,8 @@ github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241217090828-cfbca9fe8254
912912
github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241217090828-cfbca9fe8254/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
913913
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20241217090828-cfbca9fe8254 h1:JzLOFRiKsDtLJt5h0M0jkEIPDKvFFyja7VEp7gG6O9U=
914914
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20241217090828-cfbca9fe8254/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
915-
github.com/crypto-org-chain/ethermint v0.22.1-0.20250909102334-034803df81c7 h1:3DnrW5+m1yKzAHWyQIM1o9MoOzghlDlr3s/GQdQmwu4=
916-
github.com/crypto-org-chain/ethermint v0.22.1-0.20250909102334-034803df81c7/go.mod h1:StA36YNgLruMKlg6FG+fUie0+k3hQS8dapZJzl+CPI4=
915+
github.com/crypto-org-chain/ethermint v0.22.1-0.20250916025604-a85d8890cd52 h1:jmP2dBG1FRNd+GW61zJiy8O4pYGjBCMbPtDZffZ7LBs=
916+
github.com/crypto-org-chain/ethermint v0.22.1-0.20250916025604-a85d8890cd52/go.mod h1:StA36YNgLruMKlg6FG+fUie0+k3hQS8dapZJzl+CPI4=
917917
github.com/crypto-org-chain/go-block-stm v0.0.0-20241213061541-7afe924fb4a6 h1:6KPEi8dWkDSBddQb4NAvEXmNnTXymF3yVeTaT4Hz1iU=
918918
github.com/crypto-org-chain/go-block-stm v0.0.0-20241213061541-7afe924fb4a6/go.mod h1:iwQTX9xMX8NV9k3o2BiWXA0SswpsZrDk5q3gA7nWYiE=
919919
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20250815065500-a4fbafcae0dd h1:ebSnzvM9yKVGFjvoGly7LFQQCS2HuOWMCvQyByJ52Gs=

gomod2nix.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ schema = 3
315315
version = "v0.2.2"
316316
hash = "sha256-0MLfSJKdeK3Z7tWAXTdzwB4091dmyxIX38S5SKH5QAw="
317317
[mod."github.com/evmos/ethermint"]
318-
version = "v0.22.1-0.20250909102334-034803df81c7"
319-
hash = "sha256-7JEYNlsLkWO9LPR92ryqx8M+GkXTUrAz5e9sl0iY8Ow="
318+
version = "v0.22.1-0.20250916025604-a85d8890cd52"
319+
hash = "sha256-UbnRRrKkc6nVOEErYg+JKQl9VqoQX2/CWejlGrwrJgI="
320320
replaced = "github.com/crypto-org-chain/ethermint"
321321
[mod."github.com/fatih/color"]
322322
version = "v1.17.0"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pragma solidity 0.8.21;
2+
3+
contract TestBlockTxProperties {
4+
event TxDetailsEvent(
5+
address indexed origin,
6+
address indexed sender,
7+
uint value,
8+
bytes data,
9+
uint256 price,
10+
uint gas,
11+
bytes4 sig
12+
);
13+
14+
function emitTxDetails() public payable {
15+
emit TxDetailsEvent(tx.origin, msg.sender, msg.value, msg.data, tx.gasprice, gasleft(), msg.sig);
16+
}
17+
}

integration_tests/test_basic.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,3 +1113,47 @@ def test_tx_replacement(cronos):
11131113
{"to": ADDRS["community"], "value": 15, "gasPrice": gas_price},
11141114
)
11151115
assert "has already been mined" in str(exc)
1116+
1117+
1118+
def test_block_tx_properties(cronos):
1119+
"""
1120+
test block tx properties on cronos network
1121+
- deploy test contract
1122+
- call contract
1123+
- check all values are correct in log
1124+
"""
1125+
w3 = cronos.w3
1126+
contract = deploy_contract(
1127+
w3,
1128+
CONTRACTS["TestBlockTxProperties"],
1129+
)
1130+
1131+
tx = contract.functions.emitTxDetails().build_transaction(
1132+
{"from": ADDRS["validator"]}
1133+
)
1134+
receipt = send_transaction(w3, tx)
1135+
1136+
assert receipt.status == 1
1137+
assert len(receipt.logs) == 1
1138+
1139+
assert contract.address == receipt.logs[0]["address"]
1140+
event_signature = HexBytes(
1141+
abi.event_signature_to_log_topic(
1142+
"TxDetailsEvent(address,address,uint256,bytes,uint256,uint256,bytes4)"
1143+
)
1144+
)
1145+
assert event_signature == receipt.logs[0]["topics"][0]
1146+
validator_hex_address = HexBytes(b"\x00" * 12 + HexBytes(ADDRS["validator"]))
1147+
assert validator_hex_address == receipt.logs[0]["topics"][1]
1148+
assert validator_hex_address == receipt.logs[0]["topics"][2]
1149+
1150+
# check event values
1151+
tx_details_event = contract.events.TxDetailsEvent().process_receipt(receipt)
1152+
data = tx_details_event[0]["args"]
1153+
assert data["origin"] == ADDRS["validator"]
1154+
assert data["sender"] == ADDRS["validator"]
1155+
assert data["value"] == 0
1156+
assert data["data"] == bytes.fromhex("8e091b5e")
1157+
assert data["price"] > 0
1158+
assert data["gas"] == 3633
1159+
assert data["sig"] == bytes.fromhex("8e091b5e")

integration_tests/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"TestICA": "TestICA.sol",
6464
"Random": "Random.sol",
6565
"TestRelayer": "TestRelayer.sol",
66+
"TestBlockTxProperties": "TestBlockTxProperties.sol",
6667
}
6768

6869

0 commit comments

Comments
 (0)