Skip to content

Commit 8d0bd41

Browse files
authored
feat(solana): chunked header update + e2e solana->cosmos/cosmos->solana (#760)
1 parent ccdf971 commit 8d0bd41

File tree

100 files changed

+8703
-2071
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+8703
-2071
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ tendermint-light-client-uc-and-membership = { path = "packages/tendermint-light-
6262

6363
solana-ibc-constants = { path = "programs/solana/packages/solana-ibc-constants", default-features = false }
6464
solana-ibc-types = { path = "programs/solana/packages/solana-ibc-types", default-features = false }
65+
brine-ed25519 = { version = "0.2", default-features = false }
6566

6667
serde = { version = "1.0", default-features = false }
6768
serde_json = { version = "1.0", default-features = false }

e2e/interchaintestv8/go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/cosmos/solidity-ibc-eureka/e2e/v8
22

3-
go 1.24.3
3+
go 1.24.5
44

55
require (
66
cosmossdk.io/api v0.9.2
@@ -16,6 +16,7 @@ require (
1616
github.com/cosmos/ibc-go/v10 v10.3.0
1717
github.com/cosmos/ics23/go v0.11.0
1818
github.com/cosmos/interchaintest/v10 v10.0.0
19+
github.com/cosmos/solidity-ibc-eureka/e2e/interchaintestv8/solana/go-anchor v0.0.0-00010101000000-000000000000
1920
github.com/cosmos/solidity-ibc-eureka/packages/go-abigen v0.0.0
2021
github.com/cosmos/solidity-ibc-eureka/packages/go-anchor v0.0.0
2122
github.com/ethereum/go-ethereum v1.16.2
@@ -317,6 +318,8 @@ replace github.com/cosmos/solidity-ibc-eureka/packages/go-abigen => ../../packag
317318

318319
replace github.com/cosmos/solidity-ibc-eureka/packages/go-anchor => ../../packages/go-anchor
319320

321+
replace github.com/cosmos/solidity-ibc-eureka/e2e/interchaintestv8/solana/go-anchor => ./solana/go-anchor
322+
320323
replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
321324

322325
replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7

e2e/interchaintestv8/relayer/solana_and_cosmos_config.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ type SolanaCosmosConfigInfo struct {
1919
// Solana fee payer address (for cosmos-to-solana)
2020
SolanaFeePayer string
2121
// Whether we use the mock client in Cosmos
22-
MockWasmClient bool
22+
Mock bool
2323
}
2424

2525
type SolanaToCosmosModuleConfig struct {
2626
// Solana chain ID
2727
SolanaChainId string `json:"solana_chain_id"`
28-
// Solana RPC URL
29-
SolanaRpcUrl string `json:"solana_rpc_url"`
28+
// Source RPC URL (Solana) - must be "src_rpc_url"
29+
SrcRpcUrl string `json:"src_rpc_url"`
3030
// Target tendermint RPC URL (must be "target_rpc_url" not "tm_rpc_url")
3131
TargetRpcUrl string `json:"target_rpc_url"`
3232
// Signer address for submitting to Cosmos
@@ -40,8 +40,8 @@ type SolanaToCosmosModuleConfig struct {
4040
type CosmosToSolanaModuleConfig struct {
4141
// Source tendermint RPC URL (must be "source_rpc_url")
4242
SourceRpcUrl string `json:"source_rpc_url"`
43-
// Solana RPC URL
44-
SolanaRpcUrl string `json:"solana_rpc_url"`
43+
// Target RPC URL (Solana) - must be "target_rpc_url"
44+
TargetRpcUrl string `json:"target_rpc_url"`
4545
// Solana ICS26 router program ID (must be "solana_ics26_program_id")
4646
SolanaIcs26ProgramId string `json:"solana_ics26_program_id"`
4747
// Solana ICS07 Tendermint light client program ID (must be "solana_ics07_program_id")
@@ -58,11 +58,11 @@ func CreateSolanaCosmosModules(configInfo SolanaCosmosConfigInfo) []ModuleConfig
5858
DstChain: configInfo.CosmosChainID,
5959
Config: SolanaToCosmosModuleConfig{
6060
SolanaChainId: configInfo.SolanaChainID,
61-
SolanaRpcUrl: configInfo.SolanaRPC,
61+
SrcRpcUrl: configInfo.SolanaRPC,
6262
TargetRpcUrl: configInfo.TmRPC,
6363
SignerAddress: configInfo.CosmosSignerAddress,
6464
SolanaIcs26ProgramId: configInfo.ICS26RouterProgramID,
65-
Mock: configInfo.MockWasmClient,
65+
Mock: configInfo.Mock,
6666
},
6767
},
6868
{
@@ -71,7 +71,7 @@ func CreateSolanaCosmosModules(configInfo SolanaCosmosConfigInfo) []ModuleConfig
7171
DstChain: configInfo.SolanaChainID,
7272
Config: CosmosToSolanaModuleConfig{
7373
SourceRpcUrl: configInfo.TmRPC,
74-
SolanaRpcUrl: configInfo.SolanaRPC,
74+
TargetRpcUrl: configInfo.SolanaRPC,
7575
SolanaIcs26ProgramId: configInfo.ICS26RouterProgramID,
7676
SolanaIcs07ProgramId: configInfo.ICS07ProgramID,
7777
SolanaFeePayer: configInfo.SolanaFeePayer,
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
package solana
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"time"
7+
8+
"github.com/cosmos/solidity-ibc-eureka/e2e/v8/testvalues"
9+
10+
"github.com/gagliardetto/solana-go"
11+
"github.com/gagliardetto/solana-go/programs/system"
12+
"github.com/gagliardetto/solana-go/rpc"
13+
)
14+
15+
// WaitForClusterReady waits for the Solana cluster to be fully initialized
16+
func (s *Solana) WaitForClusterReady(ctx context.Context, timeout time.Duration) error {
17+
deadline := time.Now().Add(timeout)
18+
19+
for time.Now().Before(deadline) {
20+
// Check 1: Can we get the latest blockhash?
21+
_, err := s.RPCClient.GetLatestBlockhash(ctx, rpc.CommitmentFinalized)
22+
if err != nil {
23+
time.Sleep(1 * time.Second)
24+
continue
25+
}
26+
27+
// Check 2: Can we get the slot?
28+
slot, err := s.RPCClient.GetSlot(ctx, rpc.CommitmentFinalized)
29+
if err != nil || slot < 5 {
30+
time.Sleep(1 * time.Second)
31+
continue
32+
}
33+
34+
// Check 3: Is the faucet account funded and available?
35+
if s.Faucet != nil {
36+
balance, err := s.RPCClient.GetBalance(ctx, s.Faucet.PublicKey(), rpc.CommitmentFinalized)
37+
if err != nil {
38+
time.Sleep(1 * time.Second)
39+
continue
40+
}
41+
42+
// Ensure faucet has at least 1000 SOL for funding operations
43+
minBalance := uint64(1000_000_000_000) // 1000 SOL in lamports
44+
if balance.Value < minBalance {
45+
return fmt.Errorf("faucet balance too low: %d lamports (need at least %d)", balance.Value, minBalance)
46+
}
47+
}
48+
49+
// Check 4: Can we get the version? (ensures RPC is fully responsive)
50+
_, err = s.RPCClient.GetVersion(ctx)
51+
if err != nil {
52+
time.Sleep(1 * time.Second)
53+
continue
54+
}
55+
56+
// All checks passed
57+
return nil
58+
}
59+
60+
return fmt.Errorf("cluster not ready after %v", timeout)
61+
}
62+
63+
// CreateAndFundWalletWithRetry creates a wallet with retry logic
64+
func (s *Solana) CreateAndFundWalletWithRetry(ctx context.Context, retries int) (*solana.Wallet, error) {
65+
var lastErr error
66+
67+
for i := range retries {
68+
// Wait a bit before retry (except first attempt)
69+
if i > 0 {
70+
time.Sleep(time.Duration(i) * time.Second)
71+
}
72+
73+
wallet := solana.NewWallet()
74+
75+
// Try to fund the wallet
76+
_, err := s.FundUserWithRetry(ctx, wallet.PublicKey(), testvalues.InitialSolBalance, 3)
77+
if err == nil {
78+
// Verify the balance was actually credited
79+
balance, err := s.RPCClient.GetBalance(ctx, wallet.PublicKey(), rpc.CommitmentConfirmed)
80+
if err == nil && balance.Value > 0 {
81+
return wallet, nil
82+
}
83+
}
84+
85+
lastErr = err
86+
}
87+
88+
return nil, fmt.Errorf("failed to create and fund wallet after %d retries: %w", retries, lastErr)
89+
}
90+
91+
// FundUserWithRetry funds a user with retry logic
92+
func (s *Solana) FundUserWithRetry(ctx context.Context, pubkey solana.PublicKey, amount uint64, retries int) (solana.Signature, error) {
93+
var lastErr error
94+
95+
for i := range retries {
96+
// Wait a bit before retry (except first attempt)
97+
if i > 0 {
98+
time.Sleep(time.Duration(i) * time.Second)
99+
}
100+
101+
// Check faucet balance first
102+
faucetBalance, err := s.RPCClient.GetBalance(ctx, s.Faucet.PublicKey(), rpc.CommitmentConfirmed)
103+
if err != nil {
104+
lastErr = fmt.Errorf("failed to get faucet balance: %w", err)
105+
continue
106+
}
107+
108+
if faucetBalance.Value < amount {
109+
lastErr = fmt.Errorf("insufficient faucet balance: %d < %d", faucetBalance.Value, amount)
110+
continue
111+
}
112+
113+
// Get latest blockhash
114+
recent, err := s.RPCClient.GetLatestBlockhash(ctx, rpc.CommitmentFinalized)
115+
if err != nil {
116+
lastErr = fmt.Errorf("failed to get blockhash: %w", err)
117+
continue
118+
}
119+
120+
// Create transfer transaction
121+
tx, err := solana.NewTransaction(
122+
[]solana.Instruction{
123+
system.NewTransferInstruction(
124+
amount,
125+
s.Faucet.PublicKey(),
126+
pubkey,
127+
).Build(),
128+
},
129+
recent.Value.Blockhash,
130+
solana.TransactionPayer(s.Faucet.PublicKey()),
131+
)
132+
if err != nil {
133+
lastErr = fmt.Errorf("failed to create transaction: %w", err)
134+
continue
135+
}
136+
137+
// Sign and broadcast
138+
sig, err := s.SignAndBroadcastTx(ctx, tx, s.Faucet)
139+
if err == nil {
140+
// Wait for confirmation
141+
time.Sleep(2 * time.Second)
142+
143+
// Verify the transfer succeeded
144+
balance, err := s.RPCClient.GetBalance(ctx, pubkey, rpc.CommitmentConfirmed)
145+
if err == nil && balance.Value >= amount {
146+
return sig, nil
147+
}
148+
}
149+
150+
lastErr = err
151+
}
152+
153+
return solana.Signature{}, fmt.Errorf("failed to fund user after %d retries: %w", retries, lastErr)
154+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module github.com/cosmos/solidity-ibc-eureka/e2e/interchaintestv8/solana/go-anchor
2+
3+
go 1.24.5
4+
5+
require (
6+
github.com/gagliardetto/anchor-go v0.3.2
7+
github.com/gagliardetto/binary v0.8.0
8+
github.com/gagliardetto/solana-go v1.12.0
9+
)
10+
11+
require (
12+
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
13+
github.com/blendle/zapdriver v1.3.1 // indirect
14+
github.com/davecgh/go-spew v1.1.1 // indirect
15+
github.com/fatih/color v1.9.0 // indirect
16+
github.com/gagliardetto/treeout v0.1.4 // indirect
17+
github.com/json-iterator/go v1.1.12 // indirect
18+
github.com/klauspost/compress v1.13.6 // indirect
19+
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
20+
github.com/mattn/go-colorable v0.1.4 // indirect
21+
github.com/mattn/go-isatty v0.0.11 // indirect
22+
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
23+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
24+
github.com/modern-go/reflect2 v1.0.2 // indirect
25+
github.com/mostynb/zstdpool-freelist v0.0.0-20201229113212-927304c0c3b1 // indirect
26+
github.com/mr-tron/base58 v1.2.0 // indirect
27+
github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091 // indirect
28+
github.com/stretchr/testify v1.10.0 // indirect
29+
go.mongodb.org/mongo-driver v1.12.2 // indirect
30+
go.uber.org/atomic v1.7.0 // indirect
31+
go.uber.org/multierr v1.6.0 // indirect
32+
go.uber.org/zap v1.21.0 // indirect
33+
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
34+
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
35+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
36+
)

0 commit comments

Comments
 (0)