Skip to content

Commit

Permalink
Merge branch 'rossy/cli-warpcore-config' into rossy/warp-refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrossy committed Mar 12, 2024
2 parents eb1742c + b1bc93b commit 9285460
Show file tree
Hide file tree
Showing 108 changed files with 7,455 additions and 743 deletions.
2 changes: 1 addition & 1 deletion .changeset/short-boats-suffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@hyperlane-xyz/cli': patch
---

Update CLI Warp deployment output shape to new WarpCore config
Update CLI Warp route deployment output shape to new WarpCore config
5 changes: 5 additions & 0 deletions .changeset/tasty-eyes-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/sdk': patch
---

Implement message id extraction for CosmWasmCoreAdapter
6 changes: 6 additions & 0 deletions .changeset/wild-horses-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@hyperlane-xyz/infra': patch
'@hyperlane-xyz/sdk': patch
---

Patch transfer ownership in hook deployer
18 changes: 9 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,9 @@ jobs:
strategy:
matrix:
include:
- hook: preset_hook_enabled
- hook: configure_hook_enabled
- test-type: preset_hook_enabled
- test-type: configure_hook_enabled
- test-type: pi_with_core_chain
steps:
- uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -284,18 +285,14 @@ jobs:
~/.cargo
key: ${{ runner.os }}-cargo-cache-${{ hashFiles('./rust/Cargo.lock') }}

- name: cli e2e tests with preset hook config
run: ./typescript/cli/ci-test.sh false
if: matrix.hook == 'preset_hook_enabled'

- name: cli e2e tests with configured hook config
run: ./typescript/cli/ci-test.sh true
if: matrix.hook == 'configure_hook_enabled'
- name: cli e2e tests
run: ./typescript/cli/ci-test.sh ${{ matrix.test-type }}

env-test:
runs-on: ubuntu-latest
needs: [yarn-build]
strategy:
fail-fast: false
matrix:
environment: [mainnet3]
chain: [ethereum, arbitrum, optimism, inevm, viction]
Expand All @@ -304,6 +301,9 @@ jobs:
- environment: testnet4
chain: sepolia
module: core
- environment: mainnet3
chain: inevm
module: warp

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ COPY typescript/sdk/package.json ./typescript/sdk/
COPY typescript/helloworld/package.json ./typescript/helloworld/
COPY typescript/cli/package.json ./typescript/cli/
COPY typescript/infra/package.json ./typescript/infra/
COPY typescript/ccip-server/package.json ./typescript/ccip-server/
COPY solidity/package.json ./solidity/

RUN yarn install && yarn cache clean
Expand Down
1 change: 1 addition & 0 deletions rust/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ target
validatordb
relayerdb
kathydb
hyperlane_db
config/test_config.json
3 changes: 3 additions & 0 deletions rust/Cargo.lock

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

1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ cosmrs = { version = "0.14", default-features = false, features = [
"tokio",
"grpc",
] }
cosmwasm-std = "*"
crunchy = "0.2"
ctrlc = "3.2"
curve25519-dalek = { version = "~3.2", features = ["serde"] }
Expand Down
2 changes: 1 addition & 1 deletion rust/agents/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ tokio = { workspace = true, features = ["rt", "macros", "parking_lot"] }
tracing-futures.workspace = true
tracing.workspace = true

hyperlane-core = { path = "../../hyperlane-core", features = ["agent", "fallback-provider"] }
hyperlane-core = { path = "../../hyperlane-core", features = ["agent", "async"] }
hyperlane-base = { path = "../../hyperlane-base" }
hyperlane-ethereum = { path = "../../chains/hyperlane-ethereum" }

Expand Down
2 changes: 1 addition & 1 deletion rust/agents/relayer/src/msg/pending_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl PendingOperation for PendingMessage {
.await,
"checking if message meets gas payment requirement"
) else {
info!(?tx_cost_estimate, "Gas payment requirement not met yet");
warn!(?tx_cost_estimate, "Gas payment requirement not met yet");
return self.on_reprepare();
};

Expand Down
2 changes: 1 addition & 1 deletion rust/agents/validator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tokio = { workspace = true, features = ["rt", "macros", "parking_lot"] }
tracing-futures.workspace = true
tracing.workspace = true

hyperlane-core = { path = "../../hyperlane-core", features = ["agent", "fallback-provider"] }
hyperlane-core = { path = "../../hyperlane-core", features = ["agent", "async"] }
hyperlane-base = { path = "../../hyperlane-base" }
hyperlane-ethereum = { path = "../../chains/hyperlane-ethereum" }
hyperlane-cosmos = { path = "../../chains/hyperlane-cosmos" }
Expand Down
68 changes: 41 additions & 27 deletions rust/agents/validator/src/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ use std::sync::Arc;
use std::time::{Duration, Instant};
use std::vec;

use eyre::{bail, Result};
use hyperlane_core::MerkleTreeHook;
use hyperlane_core::rpc_clients::call_and_retry_indefinitely;
use hyperlane_core::{ChainCommunicationError, ChainResult, MerkleTreeHook};
use prometheus::IntGauge;
use tokio::time::sleep;
use tracing::{debug, info};
use tracing::{error, instrument};
use tracing::{debug, error, info};

use hyperlane_base::{db::HyperlaneRocksDB, CheckpointSyncer, CoreMetrics};
use hyperlane_core::{
Expand Down Expand Up @@ -60,29 +59,28 @@ impl ValidatorSubmitter {

/// Submits signed checkpoints from index 0 until the target checkpoint (inclusive).
/// Runs idly forever once the target checkpoint is reached to avoid exiting the task.
#[instrument(err, skip(self), fields(domain=%self.merkle_tree_hook.domain()))]
pub(crate) async fn backfill_checkpoint_submitter(
self,
target_checkpoint: Checkpoint,
) -> Result<()> {
pub(crate) async fn backfill_checkpoint_submitter(self, target_checkpoint: Checkpoint) {
let mut tree = IncrementalMerkle::default();
self.submit_checkpoints_until_correctness_checkpoint(&mut tree, &target_checkpoint)
.await?;
call_and_retry_indefinitely(|| {
let target_checkpoint = target_checkpoint;
let self_clone = self.clone();
Box::pin(async move {
self_clone
.submit_checkpoints_until_correctness_checkpoint(&mut tree, &target_checkpoint)
.await?;
Ok(())
})
})
.await;

info!(
?target_checkpoint,
"Backfill checkpoint submitter successfully reached target checkpoint"
);

// TODO: remove this once validator is tolerant of tasks exiting.
loop {
sleep(Duration::from_secs(u64::MAX)).await;
}
}

/// Submits signed checkpoints indefinitely, starting from the `tree`.
#[instrument(err, skip(self, tree), fields(domain=%self.merkle_tree_hook.domain()))]
pub(crate) async fn checkpoint_submitter(self, mut tree: IncrementalMerkle) -> Result<()> {
pub(crate) async fn checkpoint_submitter(self, mut tree: IncrementalMerkle) {
// How often to log checkpoint info - once every minute
let checkpoint_info_log_period = Duration::from_secs(60);
// The instant in which we last logged checkpoint info, if at all
Expand All @@ -102,10 +100,12 @@ impl ValidatorSubmitter {

loop {
// Lag by reorg period because this is our correctness checkpoint.
let latest_checkpoint = self
.merkle_tree_hook
.latest_checkpoint(self.reorg_period)
.await?;
let latest_checkpoint = call_and_retry_indefinitely(|| {
let merkle_tree_hook = self.merkle_tree_hook.clone();
Box::pin(async move { merkle_tree_hook.latest_checkpoint(self.reorg_period).await })
})
.await;

self.metrics
.latest_checkpoint_observed
.set(latest_checkpoint.index as i64);
Expand Down Expand Up @@ -133,8 +133,20 @@ impl ValidatorSubmitter {
continue;
}

self.submit_checkpoints_until_correctness_checkpoint(&mut tree, &latest_checkpoint)
.await?;
tree = call_and_retry_indefinitely(|| {
let mut tree = tree;
let self_clone = self.clone();
Box::pin(async move {
self_clone
.submit_checkpoints_until_correctness_checkpoint(
&mut tree,
&latest_checkpoint,
)
.await?;
Ok(tree)
})
})
.await;

self.metrics
.latest_checkpoint_processed
Expand All @@ -150,7 +162,7 @@ impl ValidatorSubmitter {
&self,
tree: &mut IncrementalMerkle,
correctness_checkpoint: &Checkpoint,
) -> Result<()> {
) -> ChainResult<()> {
// This should never be called with a tree that is ahead of the correctness checkpoint.
assert!(
!tree_exceeds_checkpoint(correctness_checkpoint, tree),
Expand Down Expand Up @@ -213,7 +225,9 @@ impl ValidatorSubmitter {
?correctness_checkpoint,
"Incorrect tree root, something went wrong"
);
bail!("Incorrect tree root, something went wrong");
return Err(ChainCommunicationError::CustomError(
"Incorrect tree root, something went wrong".to_string(),
));
}

if !checkpoint_queue.is_empty() {
Expand All @@ -238,7 +252,7 @@ impl ValidatorSubmitter {
async fn sign_and_submit_checkpoints(
&self,
checkpoints: Vec<CheckpointWithMessageId>,
) -> Result<()> {
) -> ChainResult<()> {
let last_checkpoint = checkpoints.as_slice()[checkpoints.len() - 1];

for queued_checkpoint in checkpoints {
Expand Down
9 changes: 3 additions & 6 deletions rust/agents/validator/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ impl BaseAgent for Validator {
.expect("Failed to create server");
let server_task = tokio::spawn(async move {
server.run(routes);
Ok(())
})
.instrument(info_span!("Validator server"));
tasks.push(server_task);
Expand All @@ -150,7 +149,6 @@ impl BaseAgent for Validator {
tasks.push(
tokio::spawn(async move {
signer_instance.run().await;
Ok(())
})
.instrument(info_span!("SingletonSigner")),
);
Expand All @@ -168,7 +166,6 @@ impl BaseAgent for Validator {
tasks.push(
tokio::spawn(async move {
metrics_updater.spawn().await.unwrap();
Ok(())
})
.instrument(info_span!("MetricsUpdater")),
);
Expand Down Expand Up @@ -200,14 +197,15 @@ impl BaseAgent for Validator {
}
}

// Note that this only returns an error if one of the tasks panics
if let Err(err) = try_join_all(tasks).await {
error!(?err, "One of the validator tasks returned an error");
}
}
}

impl Validator {
async fn run_merkle_tree_hook_sync(&self) -> Instrumented<JoinHandle<Result<()>>> {
async fn run_merkle_tree_hook_sync(&self) -> Instrumented<JoinHandle<()>> {
let index_settings =
self.as_ref().settings.chains[self.origin_chain.name()].index_settings();
let contract_sync = self.merkle_tree_hook_sync.clone();
Expand All @@ -216,12 +214,11 @@ impl Validator {
.await;
tokio::spawn(async move {
contract_sync.clone().sync("merkle_tree_hook", cursor).await;
Ok(())
})
.instrument(info_span!("MerkleTreeHookSyncer"))
}

async fn run_checkpoint_submitters(&self) -> Vec<Instrumented<JoinHandle<Result<()>>>> {
async fn run_checkpoint_submitters(&self) -> Vec<Instrumented<JoinHandle<()>>> {
let submitter = ValidatorSubmitter::new(
self.interval,
self.reorg_period,
Expand Down
4 changes: 3 additions & 1 deletion rust/chains/hyperlane-cosmos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ async-trait = { workspace = true }
base64 = { workspace = true }
bech32 = { workspace = true }
cosmrs = { workspace = true, features = ["cosmwasm", "tokio", "grpc", "rpc"] }
cosmwasm-std = { workspace = true }
derive-new = { workspace = true }
futures = { workspace = true }
hex = { workspace = true }
http = { workspace = true }
hyperlane-cosmwasm-interface.workspace = true
Expand All @@ -39,4 +41,4 @@ tracing = { workspace = true }
tracing-futures = { workspace = true }
url = { workspace = true }

hyperlane-core = { path = "../../hyperlane-core", features = ["fallback-provider"]}
hyperlane-core = { path = "../../hyperlane-core", features = ["async"]}
3 changes: 3 additions & 0 deletions rust/chains/hyperlane-cosmos/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ pub enum HyperlaneCosmosError {
#[error("{0}")]
/// Cosmrs Tendermint Error
CosmrsTendermintError(#[from] cosmrs::tendermint::Error),
#[error("{0}")]
/// CosmWasm Error
CosmWasmError(#[from] cosmwasm_std::StdError),
/// Tonic error
#[error("{0}")]
Tonic(#[from] tonic::transport::Error),
Expand Down
Loading

0 comments on commit 9285460

Please sign in to comment.