Skip to content

Commit

Permalink
Merge branch 'main' into dan/cosmos-gas-price-config
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-savu committed Dec 19, 2023
2 parents 4d78237 + 8e44bc1 commit 08c3d9a
Show file tree
Hide file tree
Showing 59 changed files with 866 additions and 756 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ jobs:
working-directory: ./rust

- name: agent tests with CosmWasm
run: RUST_BACKTRACE=1 cargo test --package run-locally --bin run-locally -- cosmos::test --nocapture
run: RUST_BACKTRACE=1 cargo test --package run-locally --bin run-locally --features cosmos -- cosmos::test --nocapture
working-directory: ./rust

- name: agent tests excluding CosmWasm
Expand Down
76 changes: 39 additions & 37 deletions rust/Cargo.lock

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

3 changes: 2 additions & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ derive_builder = "0.12"
derive_more = "0.99"
ed25519-dalek = "~1.0"
enum_dispatch = "0.3"
eyre = "0.6"
eyre = "=0.6.8"
fixed-hash = "0.8.0"
fuels = "0.38"
fuels-code-gen = "0.38"
Expand All @@ -94,6 +94,7 @@ hpl-interface = "=0.0.6-rc3"
hyper = "0.14"
hyper-tls = "0.5.0"
itertools = "0.11.0"
jobserver = "=0.1.26"
jsonrpc-core = "18.0"
k256 = { version = "0.13.1", features = ["std", "ecdsa"] }
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion rust/agents/scraper/src/db/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl ScraperDb {
{
Ok(Some(HyperlaneMessage {
// We do not write version to the DB.
version: 0,
version: 3,
origin: message.origin as u32,
destination: message.destination as u32,
nonce: message.nonce as u32,
Expand Down
2 changes: 2 additions & 0 deletions rust/chains/hyperlane-cosmos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cargo-features = ["workspace-inheritance"]

[package]
name = "hyperlane-cosmos"
documentation = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion rust/chains/hyperlane-cosmos/src/libs/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct CosmosAddress {

impl CosmosAddress {
/// Returns a Bitcoin style address: RIPEMD160(SHA256(pubkey))
/// Source: https://github.com/cosmos/cosmos-sdk/blob/177e7f45959215b0b4e85babb7c8264eaceae052/crypto/keys/secp256k1/secp256k1.go#L154
/// Source: `<https://github.com/cosmos/cosmos-sdk/blob/177e7f45959215b0b4e85babb7c8264eaceae052/crypto/keys/secp256k1/secp256k1.go#L154>`
pub fn from_pubkey(pubkey: PublicKey, prefix: &str) -> ChainResult<Self> {
// Get the inner type
let tendermint_pubkey = TendermintPublicKey::from(pubkey);
Expand Down
2 changes: 1 addition & 1 deletion rust/chains/hyperlane-cosmos/src/providers/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub struct WasmGrpcProvider {
/// Signer for transactions.
signer: Option<Signer>,
/// GRPC Channel that can be cheaply cloned.
/// See https://docs.rs/tonic/latest/tonic/transport/struct.Channel.html#multiplexing-requests
/// See `<https://docs.rs/tonic/latest/tonic/transport/struct.Channel.html#multiplexing-requests>`
channel: Channel,
gas_price: CosmosAmount,
}
Expand Down
2 changes: 1 addition & 1 deletion rust/chains/hyperlane-ethereum/tests/signer_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use hyperlane_core::{
pub fn output_message() {
let hyperlane_message = HyperlaneMessage {
nonce: 0,
version: 0,
version: 3,
origin: 1000,
sender: H256::from(H160::from_str("0x1111111111111111111111111111111111111111").unwrap()),
destination: 2000,
Expand Down
2 changes: 1 addition & 1 deletion rust/chains/hyperlane-sealevel/src/mailbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ impl SealevelMailboxIndexer {
impl SequenceIndexer<HyperlaneMessage> for SealevelMailboxIndexer {
#[instrument(err, skip(self))]
async fn sequence_and_tip(&self) -> ChainResult<(Option<u32>, u32)> {
let tip = Indexer::<HyperlaneMessage>::get_finalized_block_number(self as _).await?;
let tip = Indexer::<HyperlaneMessage>::get_finalized_block_number(self).await?;
// TODO: need to make sure the call and tip are at the same height?
let count = Mailbox::count(&self.mailbox, None).await?;
Ok((Some(count), tip))
Expand Down
27 changes: 20 additions & 7 deletions rust/chains/hyperlane-sealevel/src/merkle_tree_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ use async_trait::async_trait;
use derive_new::new;
use hyperlane_core::{
accumulator::incremental::IncrementalMerkle, ChainCommunicationError, ChainResult, Checkpoint,
HyperlaneChain, Indexer, LogMeta, MerkleTreeHook, MerkleTreeInsertion, SequenceIndexer,
HyperlaneChain, HyperlaneMessage, Indexer, LogMeta, MerkleTreeHook, MerkleTreeInsertion,
SequenceIndexer,
};
use hyperlane_sealevel_mailbox::accounts::OutboxAccount;
use solana_sdk::commitment_config::CommitmentConfig;
use tracing::instrument;

use crate::SealevelMailbox;
use crate::{SealevelMailbox, SealevelMailboxIndexer};

#[async_trait]
impl MerkleTreeHook for SealevelMailbox {
Expand Down Expand Up @@ -76,26 +77,38 @@ impl MerkleTreeHook for SealevelMailbox {
}

/// Struct that retrieves event data for a Sealevel merkle tree hook contract
/// For now it's just a wrapper around the SealevelMailboxIndexer
#[derive(Debug, new)]
pub struct SealevelMerkleTreeHookIndexer {}
pub struct SealevelMerkleTreeHookIndexer(SealevelMailboxIndexer);

#[async_trait]
impl Indexer<MerkleTreeInsertion> for SealevelMerkleTreeHookIndexer {
async fn fetch_logs(
&self,
_range: RangeInclusive<u32>,
range: RangeInclusive<u32>,
) -> ChainResult<Vec<(MerkleTreeInsertion, LogMeta)>> {
Ok(vec![])
let messages = Indexer::<HyperlaneMessage>::fetch_logs(&self.0, range).await?;
let merkle_tree_insertions = messages
.into_iter()
.map(|(m, meta)| (message_to_merkle_tree_insertion(&m), meta))
.collect();
Ok(merkle_tree_insertions)
}

async fn get_finalized_block_number(&self) -> ChainResult<u32> {
Ok(0)
Indexer::<HyperlaneMessage>::get_finalized_block_number(&self.0).await
}
}

#[async_trait]
impl SequenceIndexer<MerkleTreeInsertion> for SealevelMerkleTreeHookIndexer {
async fn sequence_and_tip(&self) -> ChainResult<(Option<u32>, u32)> {
Ok((None, 0))
SequenceIndexer::<HyperlaneMessage>::sequence_and_tip(&self.0).await
}
}

fn message_to_merkle_tree_insertion(message: &HyperlaneMessage) -> MerkleTreeInsertion {
let leaf_index = message.nonce;
let message_id = message.id();
MerkleTreeInsertion::new(leaf_index, message_id)
}
13 changes: 13 additions & 0 deletions rust/config/test-sealevel-keys/test_deployer-account.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"pubkey": "E9VrvAdGRvCguN2XgXsgu9PNmMM3vZsU8LSUrM68j8ty",
"account": {
"lamports": 500000000000000000,
"data": [
"",
"base64"
],
"owner": "11111111111111111111111111111111",
"executable": false,
"rentEpoch": 0
}
}
1 change: 1 addition & 0 deletions rust/config/test-sealevel-keys/test_deployer-keypair.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[137,43,246,148,154,244,35,62,98,248,84,203,54,24,188,26,62,227,52,29,199,26,218,8,196,213,222,202,35,154,207,79,195,85,53,151,7,182,83,94,59,5,131,252,40,75,87,11,243,118,71,59,195,222,212,148,179,233,253,121,97,210,114,98]
Loading

0 comments on commit 08c3d9a

Please sign in to comment.