Skip to content

Commit 6d487de

Browse files
committed
Merge branch 'master' of github.com:0xsequence/go-sequence into relayer-front-update
2 parents 6699da6 + ea93185 commit 6d487de

18 files changed

Lines changed: 798 additions & 66 deletions

File tree

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ start-testchain-anvil:
4646
start-testchain-anvil-verbose:
4747
cd ./testutil/testchain && pnpm start:anvil:verbose
4848

49+
# Fork a chain: make start-testchain-fork FORK_URL=https://nodes.sequence.app/polygon-zkevm
50+
FORK_URL ?= https://nodes.sequence.app/polygon-zkevm
51+
start-testchain-fork:
52+
cd ./testutil/testchain && FORK_URL="$(FORK_URL)" pnpm start:anvil:fork -- "$(FORK_URL)"
53+
54+
start-testchain-fork-verbose:
55+
cd ./testutil/testchain && FORK_URL="$(FORK_URL)" pnpm start:anvil:fork:verbose -- "$(FORK_URL)"
56+
4957
check-testchain-running:
5058
@curl http://localhost:8545 -H"Content-type: application/json" -X POST -d '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' --write-out '%{http_code}' --silent --output /dev/null | grep 200 > /dev/null \
5159
|| { echo "*****"; echo "Oops! testchain is not running. Please run 'make start-testchain' in another terminal."; echo "*****"; exit 1; }

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ For documentation on sequence, please see our [docs](https://docs.sequence.xyz)
1414
2. `make start-testchain` -- starts the test ethereum chain (id 1337)
1515
3. (in a separate terminal) `make test` -- runs test suite
1616

17+
To run tests against a forked chain instead: `make start-testchain-fork` (default fork URL is Polygon ZK EVM). Override with `make start-testchain-fork FORK_URL=https://your-rpc-url`.
18+
1719

1820
## Testing
1921

auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func EIP6492ValidateSignature() ethauth.ValidatorFunc {
101101
return false, "", fmt.Errorf("sig is invalid: %w", err)
102102
}
103103

104-
isValid, err := eip6492.ValidateEIP6492Offchain(ctx, provider, signer, hash, sig, nil)
104+
isValid, err := eip6492.ValidateEIP6492(ctx, provider, signer, hash, sig, nil)
105105
if err != nil {
106106
return false, "", fmt.Errorf("failed to validate: %w", err)
107107
}

core/v2/v2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ func (l *signatureTreeDynamicSignatureLeaf) recover(ctx context.Context, payload
10361036
signature := l.signature
10371037

10381038
if provider != nil {
1039-
isValid, err := eip6492.ValidateEIP6492Offchain(ctx, provider, l.address, payload.Digest().Hash, signature, nil)
1039+
isValid, err := eip6492.ValidateEIP6492(ctx, provider, l.address, payload.Digest().Hash, signature, nil)
10401040
if err != nil {
10411041
return nil, nil, fmt.Errorf("unable to validate signature for %v: %w", l.address, err)
10421042
}

core/v3/v3.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ func (l *signatureTreeSignatureERC1271Leaf) recover(ctx context.Context, payload
11221122
signature := l.Signature
11231123

11241124
if provider != nil {
1125-
isValid, err := eip6492.ValidateEIP6492Offchain(ctx, provider, l.Address, payload.Digest().Hash, signature, nil)
1125+
isValid, err := eip6492.ValidateEIP6492(ctx, provider, l.Address, payload.Digest().Hash, signature, nil)
11261126
if err != nil {
11271127
return nil, nil, fmt.Errorf("unable to validate ERC-1271 signature: %w", err)
11281128
}

eip6492_live_test.go

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
package sequence_test
2+
3+
import (
4+
"context"
5+
"strings"
6+
"testing"
7+
8+
"github.com/0xsequence/ethkit/go-ethereum/accounts"
9+
"github.com/0xsequence/ethkit/go-ethereum/common"
10+
"github.com/0xsequence/go-sequence"
11+
"github.com/0xsequence/go-sequence/lib/eip6492"
12+
"github.com/stretchr/testify/require"
13+
)
14+
15+
// These tests require a live testchain (make start-testchain or make start-testchain-fork).
16+
// They create a Sequence wallet, sign a message, wrap in EIP-6492, and validate via
17+
// ValidateEIP6492Offchain or ValidateEIP6492Onchain. Onchain tests skip if the validator
18+
// is not deployed at EIP_6492_ADDRESS on the chain.
19+
20+
func TestEIP6492Live_ValidateSequenceWalletMessage_Offchain(t *testing.T) {
21+
// V2 counterfactual wallet on testchain
22+
wallet, err := testChain.V2DummySequenceWallet(10, true)
23+
require.NoError(t, err)
24+
25+
message := []byte("hello world!")
26+
_, eip191Message := accounts.TextAndHash(message)
27+
28+
sig, err := wallet.SignMessage([]byte(eip191Message))
29+
require.NoError(t, err)
30+
31+
wrapped, err := sequence.EIP6492Signature(sig, wallet.GetWalletConfig())
32+
require.NoError(t, err)
33+
34+
digest := common.BytesToHash(accounts.TextHash(message))
35+
ctx := context.Background()
36+
37+
valid, err := eip6492.ValidateEIP6492Offchain(ctx, testChain.Provider, wallet.Address(), digest, wrapped, nil)
38+
require.NoError(t, err)
39+
require.True(t, valid, "EIP-6492 offchain validation should succeed for Sequence wallet message signature")
40+
}
41+
42+
func TestEIP6492Live_ValidateSequenceWalletMessage_ViaIsValidMessageSignature(t *testing.T) {
43+
// Same flow as above but via the public API to ensure full path works
44+
wallet, err := testChain.V2DummySequenceWallet(11, true)
45+
require.NoError(t, err)
46+
47+
message := []byte("eip6492 live test")
48+
_, eip191Message := accounts.TextAndHash(message)
49+
50+
sig, err := wallet.SignMessage([]byte(eip191Message))
51+
require.NoError(t, err)
52+
53+
wrapped, err := sequence.EIP6492Signature(sig, wallet.GetWalletConfig())
54+
require.NoError(t, err)
55+
56+
isValid, err := sequence.IsValidMessageSignature(
57+
wallet.Address(),
58+
message,
59+
wrapped,
60+
testChain.ChainID(),
61+
testChain.Provider,
62+
nil,
63+
)
64+
require.NoError(t, err)
65+
require.True(t, isValid, "IsValidMessageSignature should succeed for EIP-6492 wrapped Sequence wallet signature")
66+
}
67+
68+
func TestEIP6492Live_ValidateDeployedSequenceWallet_Offchain(t *testing.T) {
69+
// Deploy the wallet first, then validate (tests both counterfactual deploy path and already-deployed path)
70+
wallet, err := testChain.V2DummySequenceWallet(12, false)
71+
require.NoError(t, err)
72+
73+
message := []byte("deployed wallet sign")
74+
_, eip191Message := accounts.TextAndHash(message)
75+
76+
sig, err := wallet.SignMessage([]byte(eip191Message))
77+
require.NoError(t, err)
78+
79+
wrapped, err := sequence.EIP6492Signature(sig, wallet.GetWalletConfig())
80+
require.NoError(t, err)
81+
82+
digest := common.BytesToHash(accounts.TextHash(message))
83+
ctx := context.Background()
84+
85+
valid, err := eip6492.ValidateEIP6492Offchain(ctx, testChain.Provider, wallet.Address(), digest, wrapped, nil)
86+
require.NoError(t, err)
87+
require.True(t, valid, "EIP-6492 offchain validation should succeed for deployed Sequence wallet")
88+
}
89+
90+
func TestEIP6492Live_ValidateSequenceWalletMessage_Onchain(t *testing.T) {
91+
// Same as offchain test but via pre-deployed validator at EIP_6492_ADDRESS.
92+
// Skips if the validator is not deployed on this chain.
93+
wallet, err := testChain.V2DummySequenceWallet(13, true)
94+
require.NoError(t, err)
95+
96+
message := []byte("hello world onchain!")
97+
_, eip191Message := accounts.TextAndHash(message)
98+
99+
sig, err := wallet.SignMessage([]byte(eip191Message))
100+
require.NoError(t, err)
101+
102+
wrapped, err := sequence.EIP6492Signature(sig, wallet.GetWalletConfig())
103+
require.NoError(t, err)
104+
105+
digest := common.BytesToHash(accounts.TextHash(message))
106+
ctx := context.Background()
107+
108+
valid, err := eip6492.ValidateEIP6492Onchain(ctx, testChain.Provider, wallet.Address(), digest, wrapped, nil)
109+
if err != nil && strings.Contains(err.Error(), "returned no data") {
110+
t.Skipf("EIP-6492 validator not deployed on this chain: %v", err)
111+
}
112+
require.NoError(t, err)
113+
require.True(t, valid, "EIP-6492 onchain validation should succeed for Sequence wallet message signature")
114+
}
115+
116+
func TestEIP6492Live_ValidateDeployedSequenceWallet_Onchain(t *testing.T) {
117+
// Deployed wallet, validated via onchain contract. Skips if validator not deployed.
118+
wallet, err := testChain.V2DummySequenceWallet(14, false)
119+
require.NoError(t, err)
120+
121+
message := []byte("deployed wallet onchain sign")
122+
_, eip191Message := accounts.TextAndHash(message)
123+
124+
sig, err := wallet.SignMessage([]byte(eip191Message))
125+
require.NoError(t, err)
126+
127+
wrapped, err := sequence.EIP6492Signature(sig, wallet.GetWalletConfig())
128+
require.NoError(t, err)
129+
130+
digest := common.BytesToHash(accounts.TextHash(message))
131+
ctx := context.Background()
132+
133+
valid, err := eip6492.ValidateEIP6492Onchain(ctx, testChain.Provider, wallet.Address(), digest, wrapped, nil)
134+
if err != nil && strings.Contains(err.Error(), "returned no data") {
135+
t.Skipf("EIP-6492 validator not deployed on this chain: %v", err)
136+
}
137+
require.NoError(t, err)
138+
require.True(t, valid, "EIP-6492 onchain validation should succeed for deployed Sequence wallet")
139+
}

go.mod

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
module github.com/0xsequence/go-sequence
22

3-
go 1.24.0
4-
5-
toolchain go1.24.2
3+
go 1.25.0
64

75
// replace github.com/0xsequence/ethkit => ../ethkit
86

97
require (
10-
github.com/0xsequence/ethkit v1.39.0
8+
github.com/0xsequence/ethkit v1.43.0
119
github.com/0xsequence/go-ethauth v0.14.0
1210
github.com/BurntSushi/toml v1.2.1
1311
github.com/davecgh/go-spew v1.1.1
@@ -19,7 +17,7 @@ require (
1917
github.com/spf13/cobra v1.10.1
2018
github.com/stretchr/testify v1.11.1
2119
go.uber.org/mock v0.6.0
22-
golang.org/x/crypto v0.45.0
20+
golang.org/x/crypto v0.49.0
2321
)
2422

2523
require (
@@ -54,9 +52,9 @@ require (
5452
github.com/supranational/blst v0.3.16 // indirect
5553
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
5654
github.com/zeebo/xxh3 v1.0.2 // indirect
57-
golang.org/x/net v0.47.0 // indirect
58-
golang.org/x/sync v0.18.0 // indirect
59-
golang.org/x/sys v0.38.0 // indirect
60-
golang.org/x/text v0.31.0 // indirect
55+
golang.org/x/net v0.51.0 // indirect
56+
golang.org/x/sync v0.20.0 // indirect
57+
golang.org/x/sys v0.42.0 // indirect
58+
golang.org/x/text v0.35.0 // indirect
6159
gopkg.in/yaml.v3 v3.0.1 // indirect
6260
)

go.sum

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.work

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
go 1.24.0
2-
3-
toolchain go1.24.2
1+
go 1.25.0
42

53
use (
64
.

0 commit comments

Comments
 (0)