Skip to content

Commit 01cafee

Browse files
authored
feat: backport release/v1.6.x to main (#1926)
* feat: check authorization list in e2ee (#1903) * check authorisation list in e2ee * fix golang-ci * fix upgrade * add integration tests * feat: check destination address in the blocklist (#1922) * add check destination address * add changelog * add nil check * fix: add authorisation address check in the blocklist (#1924) * add missing authorisation address * add changelog * remove extra line * fix changelog * python lint
1 parent 9be49c0 commit 01cafee

File tree

5 files changed

+92
-5
lines changed

5 files changed

+92
-5
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@
77
* [#1880](https://github.com/crypto-org-chain/cronos/pull/1880) Move module from v2 to v1 to follow semver convention
88

99

10+
*Dec 1, 2025*
11+
12+
## v1.6.0
13+
14+
### Improvements
15+
16+
* [#1903](https://github.com/crypto-org-chain/cronos/pull/1903) Feat: check authorization list in e2ee.
17+
* [#1922](https://github.com/crypto-org-chain/cronos/pull/1922) Feat: check destination address in the blocklist
18+
* [#1924](https://github.com/crypto-org-chain/cronos/pull/1924) Fix: check authorisation address in the blocklist
19+
20+
### Bug fixes
21+
22+
* [#1918](https://github.com/crypto-org-chain/cronos/pull/1918) Chore: cleanup and improve x/mint params validation and test in cosmos-sdk
23+
1024

1125
*Nov 30, 2025*
1226

app/block_address.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,17 @@ func (bad BlockAddressesDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula
4343
}
4444
}
4545

46-
// check EIP-7702 authorisation list
4746
for _, msg := range tx.GetMsgs() {
4847
msgEthTx, ok := msg.(*evmtypes.MsgEthereumTx)
4948
if ok {
5049
ethTx := msgEthTx.AsTransaction()
50+
// check the destination address
51+
if ethTx.To() != nil {
52+
if _, ok := bad.blockedMap[sdk.AccAddress(ethTx.To().Bytes()).String()]; ok {
53+
return ctx, fmt.Errorf("destination address is blocked: %s", sdk.AccAddress(ethTx.To().Bytes()).String())
54+
}
55+
}
56+
// check EIP-7702 authorisation list
5157
if ethTx.SetCodeAuthorizations() != nil {
5258
for _, auth := range ethTx.SetCodeAuthorizations() {
5359
addr, err := auth.Authority()
@@ -56,6 +62,10 @@ func (bad BlockAddressesDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula
5662
return ctx, fmt.Errorf("signer is blocked: %s", addr.String())
5763
}
5864
}
65+
// check the target address
66+
if _, ok := bad.blockedMap[sdk.AccAddress(auth.Address.Bytes()).String()]; ok {
67+
return ctx, fmt.Errorf("authorisation address is blocked: %s", sdk.AccAddress(auth.Address.Bytes()).String())
68+
}
5969
}
6070
}
6171
}

app/proposal.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,21 @@ func (h *ProposalHandler) ValidateTransaction(tx sdk.Tx, txBz []byte) error {
175175
}
176176
}
177177

178-
// check EIP-7702 authorisation list
179178
for _, msg := range tx.GetMsgs() {
180179
msgEthTx, ok := msg.(*evmtypes.MsgEthereumTx)
181180
if ok {
182181
ethTx := msgEthTx.AsTransaction()
182+
// check the destination address
183+
if ethTx.To() != nil {
184+
encoded, err := h.addressCodec.BytesToString(ethTx.To().Bytes())
185+
if err != nil {
186+
return fmt.Errorf("invalid bech32 address: %s, err: %w", ethTx.To(), err)
187+
}
188+
if _, ok := h.blocklist[encoded]; ok {
189+
return fmt.Errorf("destination address is blocked: %s", encoded)
190+
}
191+
}
192+
// check EIP-7702 authorisation list
183193
if ethTx.SetCodeAuthorizations() != nil {
184194
for _, auth := range ethTx.SetCodeAuthorizations() {
185195
addr, err := auth.Authority()
@@ -188,6 +198,14 @@ func (h *ProposalHandler) ValidateTransaction(tx sdk.Tx, txBz []byte) error {
188198
return fmt.Errorf("signer is blocked: %s", addr.String())
189199
}
190200
}
201+
// check the target address
202+
encoded, err := h.addressCodec.BytesToString(auth.Address.Bytes())
203+
if err != nil {
204+
return fmt.Errorf("invalid bech32 address: %s, err: %w", auth.Address, err)
205+
}
206+
if _, ok := h.blocklist[encoded]; ok {
207+
return fmt.Errorf("authorisation address is blocked: %s", encoded)
208+
}
191209
}
192210
}
193211
}

integration_tests/test_e2ee.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def test_invalid_block_list(cronos):
159159
assert "failed to read header" in str(exc.value)
160160

161161

162-
def test_block_list_eip7702(cronos):
162+
def test_block_list_eip7022(cronos):
163163
gen_validator_identity(cronos)
164164
cli = cronos.cosmos_cli()
165165
w3 = cronos.w3
@@ -208,3 +208,35 @@ def test_block_list_eip7702(cronos):
208208
wait_for_new_blocks(cli, 1)
209209
assert nonce + 1 == get_nonce(cli, sender)
210210
assert w3.eth.get_filter_changes(flt.filter_id) == []
211+
212+
213+
def test_block_list_contract(cronos):
214+
gen_validator_identity(cronos)
215+
cli = cronos.cosmos_cli()
216+
user = cli.address("signer2")
217+
blocked_destination = cli.address("signer1")
218+
# set blocklist
219+
encrypt_to_validators(cli, {"addresses": [blocked_destination]})
220+
tx = {
221+
"from": to_checksum_address(bech32_to_eth(user)),
222+
"to": to_checksum_address(bech32_to_eth(blocked_destination)),
223+
"value": 1,
224+
}
225+
base_port = cronos.base_port(0)
226+
wait_for_port(ports.evmrpc_ws_port(base_port))
227+
w3 = cronos.w3
228+
flt = w3.eth.filter("pending")
229+
assert flt.get_new_entries() == []
230+
231+
txhash = w3.eth.send_transaction(tx).hex()
232+
nonce = get_nonce(cli, user)
233+
# check tx in mempool
234+
assert HexBytes(txhash) in w3.eth.get_filter_changes(flt.filter_id)
235+
236+
# clear blocklist
237+
encrypt_to_validators(cli, {})
238+
239+
# the blocked tx should be unblocked now
240+
wait_for_new_blocks(cli, 1)
241+
assert nonce + 1 == get_nonce(cli, user)
242+
assert w3.eth.get_filter_changes(flt.filter_id) == []

integration_tests/test_mempool.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,26 @@ def test_mempool(cronos_mempool):
7878
assert len(all_pending) == 0
7979

8080

81-
def test_blocked_address(cronos_mempool):
81+
def test_blocked_from_address(cronos_mempool):
8282
cli = cronos_mempool.cosmos_cli(0)
83-
rsp = cli.transfer("signer1", cli.address("validator"), "1basecro")
83+
rsp = cli.transfer("signer1", cli.address("validator"), "1basetcro")
8484
assert rsp["code"] != 0
8585
assert "signer is blocked" in rsp["raw_log"]
8686

8787

88+
def test_blocked_to_contract_address(cronos_mempool):
89+
w3 = cronos_mempool.w3
90+
tx = {
91+
"to": ADDRS["signer1"],
92+
"value": 1,
93+
"from": ADDRS["validator"],
94+
}
95+
tx1_signed = sign_transaction(w3, tx, key=KEYS["validator"])
96+
with pytest.raises(exceptions.Web3RPCError) as exc:
97+
_ = w3.eth.send_raw_transaction(tx1_signed.raw_transaction)
98+
assert "destination address is blocked" in str(exc)
99+
100+
88101
@pytest.mark.flaky(max_runs=3)
89102
def test_mempool_nonce(cronos_mempool):
90103
"""

0 commit comments

Comments
 (0)