Skip to content

Commit e822b8f

Browse files
authored
Re-enable Autobahn interop and recovery tests on the EVM-only chain (#4353)
This is part 1 of re-enabling all Autobahn tests in EVM-only mode. This PR enables some of them and others will be enabled once precompiles and RPC methods are available in EVM only. Since #4316, Autobahn runs the EVM-only executor, and most Autobahn integration coverage was disabled or skipped. Even plain-EVM suites could not run: the shared hardhat setup looked up each test account's Sei address, a Cosmos query the EVM-only chain cannot answer, so every suite failed before its first test, and `SetCodeTxTest.js` signed for the old chain ID. The Autobahn Basic `Recovery` test was skipped until the durable execution cursor reached `main`, which it now has (#4351). The setup now skips the Sei address lookup on the EVM-only chain and behaves as before on every other chain, and `SetCodeTxTest.js` reads the chain ID from the node. `SeiSoloTest.js` is skipped on the EVM-only chain, because it claims Sei-account and CosmWasm balances that chain does not have; it still runs on the non-Autobahn row. With that, the "Autobahn EVM Interoperability (Misc Tests)" row passes and is re-enabled, and `Recovery` is un-skipped. `TestAutobahnStartup` also reads the sender's nonce before signing, so it can run more than once on the same cluster. The other Autobahn rows stay disabled because what they test is not on the EVM-only chain yet. The compat and RPC fixture suites need RPC methods it does not serve (`debug_trace*`, reading state at past blocks, `eth_getStorageAt`, `eth_getBlockReceipts`, filters, `web3_clientVersion`, WebSocket), the precompile suite needs Sei precompiles, and the upgrade suites need a governance-driven upgrade. The Giga suite also has test-side fixes to make: it assumes a new account starts with a zero balance, and one test hangs. Those rows will be re-enabled in follow-ups as the missing methods land. Tested locally on an EVM-only Autobahn cluster: - [x] `evm_interoperability_misc_tests.sh` passes end to end (`SeiSoloTest.js` 3 pending, `SetCodeTxTest.js` 1 passing, `TransientStorageTest.js` 19 passing) - [x] `EVMCompatabilityTest.js` gets past setup (59 passing; the rest need the missing RPC methods) - [x] `TestAutobahnStartup` passes twice in a row on the same cluster - [x] Autobahn Basic `Recovery` passes (`make autobahn-integration-test`) - [x] Non-Autobahn rows unchanged (covered by CI)
1 parent 8def26b commit e822b8f

7 files changed

Lines changed: 78 additions & 45 deletions

File tree

‎.github/workflows/integration-test-matrix.json‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
]
3232
},
3333
{
34-
"_comment": "Disabled: needs precompile RPC and eth_estimateGas, which EVM-only Autobahn does not serve. TODO(autobahn): re-enable with the other Autobahn EVM rows.",
34+
"_comment": "Disabled: EVMPrecompileTest needs Sei precompiles, AssociateTest and the FlatKV fixture need Cosmos address association, and RPC to access state at past blocks, which EVM-only Autobahn does not serve. TODO(autobahn): re-enable with the other Autobahn EVM rows.",
3535
"name": "Autobahn EVM Module (Precompile & Endpoints)",
3636
"disabled": true,
3737
"env": "AUTOBAHN=true GIGA_EXECUTOR=true GIGA_STORAGE=true GIGA_OCC=true",
@@ -57,9 +57,7 @@
5757
]
5858
},
5959
{
60-
"_comment": "Disabled: needs eth_estimateGas and CW/EVM interop RPC, which EVM-only Autobahn does not serve. TODO(autobahn): re-enable with the other Autobahn EVM rows.",
6160
"name": "Autobahn EVM Interoperability (Misc Tests)",
62-
"disabled": true,
6361
"env": "AUTOBAHN=true GIGA_EXECUTOR=true GIGA_STORAGE=true GIGA_OCC=true",
6462
"scripts": [
6563
"./integration_test/evm_module/scripts/evm_interoperability_misc_tests.sh"

‎contracts/test/SeiSoloTest.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { expect } = require("chai");
22

33
const { setupSigners, getAdmin, getSeiBalance, printClaimMsg, addKey, getKeySeiAddress, fundSeiAddress,hex2uint8,
4-
deployWasm, printClaimSpecificMsg, WASM, queryWasm, printClaimMsgBySender
4+
deployWasm, printClaimSpecificMsg, WASM, queryWasm, printClaimMsgBySender, isEvmOnlyChain
55
} = require("./lib");
66

77

@@ -11,6 +11,12 @@ describe("Sei Solo Tester", function () {
1111
let admin;
1212

1313
before(async function () {
14+
// Solo claims move a Sei account's bank and CW20 balances to an EVM
15+
// address. The EVM-only Autobahn chain has no Sei accounts or CosmWasm.
16+
if (await isEvmOnlyChain()) {
17+
this.skip()
18+
return
19+
}
1420
accounts = await setupSigners(await hre.ethers.getSigners());
1521
admin = await getAdmin();
1622
})

‎contracts/test/SetCodeTxTest.js‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ const { privateKeyToAccount } = require('viem/accounts');
44
const { ethers } = require("hardhat");
55
const { expect } = require("chai");
66

7-
const seilocal = defineChain({
8-
id: 713714,
7+
// seilocal describes the local chain to viem. The chain ID is read from the
8+
// network under test, since the EVM-only Autobahn chain uses a different one.
9+
const seilocal = (id) => defineChain({
10+
id,
911
name: 'Sei',
1012
nativeCurrency: {
1113
decimals: 12,
@@ -34,7 +36,7 @@ describe("EIP-7702 Transaction Test", function () {
3436
account = privateKeyToAccount('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80');
3537
walletClient = createWalletClient({
3638
account,
37-
chain: seilocal,
39+
chain: seilocal(Number(await ethers.provider.send("eth_chainId", []))),
3840
transport: http()
3941
});
4042
await fundAddress(await account.address);

‎contracts/test/lib.js‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,22 @@ function _wrapSignerWithNonceRetry(signer) {
760760
return signer
761761
}
762762

763+
// EVM chain ID of the Autobahn EVM-only executor (AutobahnEVMOnlyChainID in
764+
// sei-tendermint/config/autobahn.go). That chain has no Cosmos accounts, so an
765+
// EVM address has no Sei address to look up.
766+
const EVM_ONLY_CHAIN_ID = 713715
767+
768+
// isEvmOnlyChain reports whether the network under test is the Autobahn
769+
// EVM-only chain.
770+
async function isEvmOnlyChain() {
771+
return Number(await ethers.provider.send("eth_chainId", [])) === EVM_ONLY_CHAIN_ID
772+
}
773+
774+
// setupSigners funds each signer and returns it with its EVM address and, on a
775+
// chain with Cosmos accounts, its Sei address. On the EVM-only chain seiAddress
776+
// is null.
763777
async function setupSigners(signers) {
778+
const evmOnly = await isEvmOnlyChain()
764779
const result = []
765780
for(let signer of signers) {
766781
_wrapSignerWithNonceRetry(signer)
@@ -771,7 +786,7 @@ async function setupSigners(signers) {
771786
value: 0
772787
});
773788
await resp.wait()
774-
const seiAddress = await getSeiAddress(evmAddress);
789+
const seiAddress = evmOnly ? null : await getSeiAddress(evmAddress);
775790
result.push({
776791
seiAddress,
777792
evmAddress,
@@ -1003,6 +1018,7 @@ function hex2uint8(hex) {
10031018
}
10041019

10051020
module.exports = {
1021+
isEvmOnlyChain,
10061022
fundAddress,
10071023
fundSeiAddress,
10081024
getSeiBalance,

‎integration_test/autobahn/autobahn_test.go‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -650,14 +650,6 @@ func testHaltsBeyondMaxFaults(t *testing.T) {
650650
// Self-contained: killNode is idempotent, so this works whether run in
651651
// isolation or after LivenessUnderMaxFaults / HaltsBeyondMaxFaults.
652652
func testRecovery(t *testing.T) {
653-
// TODO(autobahn): re-enable once the durable EVM-only execution cursor
654-
// (sei-protocol/sei-chain#4231, on giga-1) reaches main. Without it
655-
// evmOnlyApplication keeps committedHeight in memory only, so a restarted
656-
// validator reports height 0, re-runs InitChain, and replays block 1 onto
657-
// FlatKV state that is already ahead — it panics with "nonce too low"
658-
// instead of rejoining, and quorum never returns.
659-
t.Skip("EVM-only validators cannot restart until the durable execution cursor lands on main")
660-
661653
assertAutobahnEnabled(t)
662654
for i := 0; i <= maxFaults; i++ {
663655
killNode(t, clusterSize-1-i)

‎integration_test/evm_module/scripts/evm_interoperability_misc_tests.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ set -e
44

55
cd contracts
66
npm ci
7+
# Skipped internally on the EVM-only Autobahn chain (reported as pending): Sei
8+
# Solo claims move Sei account and CosmWasm balances, which that chain lacks.
79
npx hardhat test --network seilocal test/SeiSoloTest.js
810
npx hardhat test --network seilocal test/SetCodeTxTest.js
911
npx hardhat test --network seilocal test/TransientStorageTest.js

‎integration_test/runner/autobahn_startup_test.go‎

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/ethereum/go-ethereum/common"
1414
"github.com/ethereum/go-ethereum/common/hexutil"
1515
ethtypes "github.com/ethereum/go-ethereum/core/types"
16+
"github.com/ethereum/go-ethereum/crypto"
1617

1718
"github.com/sei-protocol/sei-chain/giga/evmonly/cmd/evmonly-loadtest/scenarios"
1819
"github.com/sei-protocol/sei-chain/integration_test/runner"
@@ -38,12 +39,6 @@ type evmRPCResponse struct {
3839
} `json:"error,omitempty"`
3940
}
4041

41-
type startupState struct{}
42-
43-
func (startupState) SetBalance(common.Address, *big.Int) {}
44-
func (startupState) SetCode(common.Address, []byte) {}
45-
func (startupState) SetState(common.Address, common.Hash, common.Hash) {}
46-
4742
// TestAutobahnStartup is the startup gate for AUTOBAHN=true clusters. Autobahn
4843
// serves the EVM JSON-RPC only, so the Tendermint RPC queries TestStartup makes
4944
// have nothing to answer them. With empty blocks off, a committed transfer is
@@ -54,29 +49,7 @@ func TestAutobahnStartup(t *testing.T) {
5449
}
5550

5651
func assertAutobahnCommittedTx(t *testing.T) {
57-
cfg := scenarios.Config{
58-
TxsPerBlock: 1,
59-
ChainID: new(big.Int).SetUint64(tmconfig.AutobahnEVMOnlyChainID),
60-
GasPrice: big.NewInt(1_000_000_000),
61-
SenderBalance: new(big.Int).Lsh(big.NewInt(1), 200),
62-
TransferValue: big.NewInt(1),
63-
TxGasLimit: 21_000,
64-
SameSender: true,
65-
}
66-
workload, err := scenarios.NewTransferWorkload(cfg, startupState{})
67-
if err != nil {
68-
t.Fatalf("create startup transfer: %v", err)
69-
}
70-
block, err := workload.BuildBlock(t.Context(), autobahnStartupSender)
71-
if err != nil {
72-
t.Fatalf("build startup transfer: %v", err)
73-
}
74-
raw := block.Txs[0]
75-
tx := new(ethtypes.Transaction)
76-
if err := tx.UnmarshalBinary(raw); err != nil {
77-
t.Fatalf("decode startup transfer: %v", err)
78-
}
79-
52+
tx, raw := buildStartupTransfer(t)
8053
sent, err := evmRPCInContainer(autobahnStartupContainer, "eth_sendRawTransaction", []any{hexutil.Encode(raw)})
8154
if err != nil {
8255
t.Fatalf("send startup transfer: %v", err)
@@ -97,6 +70,50 @@ func assertAutobahnCommittedTx(t *testing.T) {
9770
t.Fatalf("startup transfer %s was not confirmed within %s", tx.Hash(), autobahnStartupTimeout)
9871
}
9972

73+
// buildStartupTransfer returns a signed 1 wei self-transfer from the startup
74+
// sender at its next nonce, together with its raw encoding.
75+
func buildStartupTransfer(t *testing.T) (*ethtypes.Transaction, []byte) {
76+
t.Helper()
77+
key, err := scenarios.DeterministicPrivateKey(autobahnStartupSender)
78+
if err != nil {
79+
t.Fatalf("derive startup sender key: %v", err)
80+
}
81+
sender := crypto.PubkeyToAddress(key.PublicKey)
82+
signer := ethtypes.LatestSignerForChainID(new(big.Int).SetUint64(tmconfig.AutobahnEVMOnlyChainID))
83+
tx, err := ethtypes.SignNewTx(key, signer, &ethtypes.LegacyTx{
84+
Nonce: committedNonce(t, sender),
85+
GasPrice: big.NewInt(1_000_000_000),
86+
Gas: 21_000,
87+
To: &sender,
88+
Value: big.NewInt(1),
89+
})
90+
if err != nil {
91+
t.Fatalf("sign startup transfer: %v", err)
92+
}
93+
raw, err := tx.MarshalBinary()
94+
if err != nil {
95+
t.Fatalf("encode startup transfer: %v", err)
96+
}
97+
return tx, raw
98+
}
99+
100+
// committedNonce returns the nonce the chain expects next from sender.
101+
func committedNonce(t *testing.T, sender common.Address) uint64 {
102+
t.Helper()
103+
resp, err := evmRPCInContainer(autobahnStartupContainer, "eth_getTransactionCount", []any{sender, "latest"})
104+
if err != nil {
105+
t.Fatalf("read startup sender nonce: %v", err)
106+
}
107+
if resp.Error != nil {
108+
t.Fatalf("read startup sender nonce: rpc %d %s", resp.Error.Code, resp.Error.Message)
109+
}
110+
var nonce hexutil.Uint64
111+
if err := json.Unmarshal(resp.Result, &nonce); err != nil {
112+
t.Fatalf("decode startup sender nonce %s: %v", resp.Result, err)
113+
}
114+
return uint64(nonce)
115+
}
116+
100117
func evmRPCInContainer(container, method string, params any) (*evmRPCResponse, error) {
101118
body, err := json.Marshal(map[string]any{
102119
"jsonrpc": "2.0", "id": 1, "method": method, "params": params,

0 commit comments

Comments
 (0)