Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: increase e2e stability #419

Merged
merged 17 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/actions/foundry-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ name: foundry-setup
runs:
using: composite
steps:
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,11 @@ jobs:
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
target: wasm32-unknown-unknown
targets: wasm32-unknown-unknown
- name: Install cargo-run-script and cosmwasm-check
uses: actions-rs/cargo@v1
with:
Expand Down
50 changes: 26 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ members = [
"packages/solidity",
"packages/relayer-lib",
"packages/sp1-ics07-tendermint-prover",
"packages/sp1-ics07-tendermint-utils",
"packages/utils",

"programs/relayer",
"programs/operator",
Expand All @@ -27,8 +27,8 @@ keywords = ["cosmos", "ibc", "sp1", "tendermint", "ethereum", "bridge", "solid
[workspace.dependencies]
ibc-eureka-solidity-types = { path = "packages/solidity", default-features = false }
ibc-eureka-relayer-lib = { path = "packages/relayer-lib", default-features = false }
ibc-eureka-utils = { path = "packages/utils", default-features = false }
sp1-ics07-tendermint-prover = { path = "packages/sp1-ics07-tendermint-prover", default-features = false }
sp1-ics07-tendermint-utils = { path = "packages/sp1-ics07-tendermint-utils", default-features = false }
sp1-ics07-tendermint-update-client = { path = "programs/sp1-programs/update-client", default-features = false }
sp1-ics07-tendermint-membership = { path = "programs/sp1-programs/membership", default-features = false }
ethereum-trie-db = { path = "packages/ethereum/ethereum-trie-db", default-features = false }
Expand Down Expand Up @@ -67,6 +67,7 @@ time = { version = "0.3", default-features = false }
dotenv = { version = "0.15", default-features = false }
thiserror = { version = "2.0", default-features = false }
reqwest = { version = "0.12", default-features = false }
reqwest_0_11 = { package = "reqwest", version = "0.11", default-features = false }

tendermint = { version = "0.40", default-features = false }
tendermint-rpc = { version = "0.40", default-features = false }
Expand Down
21 changes: 14 additions & 7 deletions e2e/interchaintestv8/chainconfig/kurtosis.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var (
CLImage: "ethpandaops/lodestar:unstable",
ELType: "geth",
ELImage: "ethpandaops/geth:prague-devnet-6",
ELExtraParams: []string{"--gcmode=archive"},
ELLogLevel: "info",
ValidatorCount: 64,
},
Expand Down Expand Up @@ -80,12 +81,13 @@ type kurtosisNetworkParams struct {
}

type kurtosisParticipant struct {
CLType string `json:"cl_type"`
CLImage string `json:"cl_image"`
ELType string `json:"el_type"`
ELImage string `json:"el_image"`
ELLogLevel string `json:"el_log_level"`
ValidatorCount uint64 `json:"validator_count"`
CLType string `json:"cl_type"`
CLImage string `json:"cl_image"`
ELType string `json:"el_type"`
ELImage string `json:"el_image"`
ELExtraParams []string `json:"el_extra_params"`
ELLogLevel string `json:"el_log_level"`
ValidatorCount uint64 `json:"validator_count"`
}

type kurtosisNetworkConfigParams struct {
Expand Down Expand Up @@ -153,8 +155,13 @@ func SpinUpKurtosisPoS(ctx context.Context) (EthKurtosisChain, error) {
beaconRPC := fmt.Sprintf("http://localhost:%d", beaconPortSpec.GetNumber())

// Wait for the chain to finalize
beaconAPIClient := ethereum.NewBeaconAPIClient(beaconRPC)
var beaconAPIClient ethereum.BeaconAPIClient
err = testutil.WaitForCondition(30*time.Minute, 5*time.Second, func() (bool, error) {
beaconAPIClient, err = ethereum.NewBeaconAPIClient(ctx, beaconRPC)
if err != nil {
return false, nil
}

finalizedBlocksResp, err := beaconAPIClient.GetFinalizedBlocks()
fmt.Printf("Waiting for chain to finalize, finalizedBlockResp: %+v, err: %s\n", finalizedBlocksResp, err)
if err != nil {
Expand Down
39 changes: 38 additions & 1 deletion e2e/interchaintestv8/e2esuite/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ func populateQueryReqToPath(ctx context.Context, chain *cosmos.CosmosChain) erro

func ABCIQuery(ctx context.Context, chain *cosmos.CosmosChain, req *abci.RequestQuery) (*abci.ResponseQuery, error) {
// Create a connection to the gRPC server.
path := "cosmos.base.tendermint.v1beta1.Service/ABCIQuery"
grpcConn, err := grpc.Dial(
chain.GetHostGRPCAddress(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
retryConfig(),
)
if err != nil {
return &abci.ResponseQuery{}, err
Expand All @@ -55,7 +57,7 @@ func ABCIQuery(ctx context.Context, chain *cosmos.CosmosChain, req *abci.Request
defer grpcConn.Close()

resp := &abci.ResponseQuery{}
err = grpcConn.Invoke(ctx, "cosmos.base.tendermint.v1beta1.Service/ABCIQuery", req, resp)
err = grpcConn.Invoke(ctx, path, req, resp)
if err != nil {
return &abci.ResponseQuery{}, err
}
Expand All @@ -74,6 +76,7 @@ func GRPCQuery[T any](ctx context.Context, chain *cosmos.CosmosChain, req proto.
grpcConn, err := grpc.Dial(
chain.GetHostGRPCAddress(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
retryConfig(),
)
if err != nil {
return nil, err
Expand All @@ -95,6 +98,7 @@ func queryFileDescriptors(ctx context.Context, chain *cosmos.CosmosChain) (*refl
grpcConn, err := grpc.Dial(
chain.GetHostGRPCAddress(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
retryConfig(),
)
if err != nil {
return nil, err
Expand All @@ -113,3 +117,36 @@ func queryFileDescriptors(ctx context.Context, chain *cosmos.CosmosChain) (*refl

return resp, nil
}

func retryConfig() grpc.DialOption {
policy := `{
"methodConfig": [{
"name": [{}],
"retryPolicy": {
"MaxAttempts": 4,
"InitialBackoff": ".01s",
"MaxBackoff": ".01s",
"BackoffMultiplier": 1.0,
"RetryableStatusCodes": [
"CANCELLED",
"UNKNOWN",
"DEADLINE_EXCEEDED",
"NOT_FOUND",
"ALREADY_EXISTS",
"PERMISSION_DENIED",
"RESOURCE_EXHAUSTED",
"FAILED_PRECONDITION",
"ABORTED",
"OUT_OF_RANGE",
"UNIMPLEMENTED",
"INTERNAL",
"UNAVAILABLE",
"DATA_LOSS",
"UNAUTHENTICATED"
]
}
}]
}`

return grpc.WithDefaultServiceConfig(policy)
Comment on lines +121 to +151
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to create this in a type safe way or with a builder. (Not that I think we should build one, but asking if grpc already has a builder or something similar)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good question. I'll check!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem like this exists in the go version of the library :/

}
11 changes: 6 additions & 5 deletions e2e/interchaintestv8/ethereum/beaconapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,17 @@ func (b BeaconAPIClient) Close() {
b.cancel()
}

func NewBeaconAPIClient(beaconAPIAddress string) BeaconAPIClient {
ctx, cancel := context.WithCancel(context.Background())
func NewBeaconAPIClient(ctx context.Context, beaconAPIAddress string) (BeaconAPIClient, error) {
ctx, cancel := context.WithCancel(ctx)
client, err := ethttp.New(ctx,
// WithAddress supplies the address of the beacon node, as a URL.
ethttp.WithAddress(beaconAPIAddress),
// LogLevel supplies the level of logging to carry out.
ethttp.WithLogLevel(zerolog.WarnLevel),
)
if err != nil {
panic(err)
cancel()
return BeaconAPIClient{}, err
}

return BeaconAPIClient{
Expand All @@ -89,13 +90,13 @@ func NewBeaconAPIClient(beaconAPIAddress string) BeaconAPIClient {
url: beaconAPIAddress,
Retries: 60,
RetryWait: 10 * time.Second,
}
}, nil
}

func retry[T any](retries int, waitTime time.Duration, fn func() (T, error)) (T, error) {
var err error
var result T
for i := 0; i < retries; i++ {
for range retries {
result, err = fn()
if err == nil {
return result, nil
Expand Down
4 changes: 2 additions & 2 deletions e2e/interchaintestv8/ethereum/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (e *Ethereum) BroadcastTx(ctx context.Context, userKey *ecdsa.PrivateKey, g

func (e Ethereum) ForgeScript(deployer *ecdsa.PrivateKey, solidityContract string, args ...string) ([]byte, error) {
args = append(args, "script", "--rpc-url", e.RPC, "--private-key",
hex.EncodeToString(deployer.D.Bytes()), "--broadcast",
hex.EncodeToString(crypto.FromECDSA(deployer)), "--broadcast",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, curious if you know why it was less stable before

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100%, but there is a different handling of the private key bytes (something about fixed sized buffers and whatnot). But this seems to be the correct way, at least.

"--non-interactive", "-vvvv", solidityContract,
)
cmd := exec.Command(
Expand Down Expand Up @@ -162,7 +162,7 @@ func (e Ethereum) SendEth(key *ecdsa.PrivateKey, toAddress string, amount math.I
"send",
toAddress,
"--value", amount.String(),
"--private-key", fmt.Sprintf("0x%s", ethcommon.Bytes2Hex(key.D.Bytes())),
"--private-key", fmt.Sprintf("0x%s", hex.EncodeToString(crypto.FromECDSA(key))),
"--rpc-url", e.RPC,
)
cmd.Stdout = os.Stdout
Expand Down
4 changes: 2 additions & 2 deletions packages/relayer-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ license = { workspace = true }
[features]
default = ["sp1-toolchain"]
# sp1-toolchain requires sp1 toolchain to be installed to build
sp1-toolchain = ["dep:sp1-ics07-tendermint-prover", "dep:sp1-ics07-tendermint-utils"]
sp1-toolchain = ["dep:sp1-ics07-tendermint-prover", "dep:ibc-eureka-utils"]

[dependencies]
ibc-eureka-solidity-types = { workspace = true, features = ["rpc"] }
ibc-eureka-utils = { workspace = true, optional = true }

sp1-ics07-tendermint-prover = { workspace = true, optional = true }
sp1-ics07-tendermint-utils = { workspace = true, optional = true }

ethereum-apis = { workspace = true }
ethereum-light-client = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion packages/relayer-lib/src/tx_builder/cosmos_to_cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! the Cosmos SDK chain from events received from another Cosmos SDK chain.

use anyhow::Result;
use ibc_eureka_utils::{light_block::LightBlockExt, rpc::TendermintRpcExt};
use ibc_proto_eureka::{
cosmos::tx::v1beta1::TxBody,
google::protobuf::Any,
Expand All @@ -11,7 +12,6 @@ use ibc_proto_eureka::{
},
};
use prost::Message;
use sp1_ics07_tendermint_utils::{light_block::LightBlockExt, rpc::TendermintRpcExt};
use tendermint_rpc::HttpClient;

use crate::{
Expand Down
3 changes: 1 addition & 2 deletions packages/relayer-lib/src/tx_builder/cosmos_to_eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ use ibc_eureka_solidity_types::{
msgs::IICS07TendermintMsgs::ClientState,
sp1_ics07::sp1_ics07_tendermint,
};

use ibc_eureka_utils::rpc::TendermintRpcExt;
use sp1_ics07_tendermint_prover::prover::Sp1Prover;
use sp1_ics07_tendermint_utils::rpc::TendermintRpcExt;
use tendermint_rpc::HttpClient;

use sp1_prover::components::SP1ProverComponents;
Expand Down
2 changes: 1 addition & 1 deletion packages/relayer-lib/src/tx_builder/eth_to_cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use ethereum_types::consensus::light_client_header::{
use ethereum_types::consensus::sync_committee::SyncCommittee;
use ethereum_types::execution::account_proof::AccountProof;
use ibc_eureka_solidity_types::ics26::router::routerInstance;
use ibc_eureka_utils::rpc::TendermintRpcExt;
use ibc_proto_eureka::cosmos::tx::v1beta1::TxBody;
use ibc_proto_eureka::google::protobuf::Any;
use ibc_proto_eureka::ibc::core::client::v1::{Height, MsgUpdateClient};
Expand All @@ -23,7 +24,6 @@ use ibc_proto_eureka::ibc::lightclients::wasm::v1::{
ClientState as WasmClientState, ConsensusState as WasmConsensusState,
};
use prost::Message;
use sp1_ics07_tendermint_utils::rpc::TendermintRpcExt;
use tendermint_rpc::{Client, HttpClient};

use crate::utils::{cosmos, wait_for_condition, wait_for_condition_with_capture};
Expand Down
2 changes: 1 addition & 1 deletion packages/relayer-lib/src/utils/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use ethereum_light_client::membership::evm_ics26_commitment_path;
use ethereum_types::execution::storage_proof::StorageProof;
use futures::future;
use ibc_eureka_solidity_types::ics26::IICS26RouterMsgs::Packet;
use ibc_eureka_utils::rpc::TendermintRpcExt;
use ibc_proto_eureka::{
ibc::core::{
channel::v2::{Acknowledgement, MsgAcknowledgement, MsgRecvPacket, MsgTimeout},
client::v1::Height,
},
Protobuf,
};
use sp1_ics07_tendermint_utils::rpc::TendermintRpcExt;
use tendermint_rpc::HttpClient;

use crate::events::{EurekaEvent, EurekaEventWithHeight};
Expand Down
Loading
Loading