Skip to content

Commit

Permalink
Merge branch 'feat/zksync-signer-strategy' into feat/zksync-support
Browse files Browse the repository at this point in the history
  • Loading branch information
ljankovic-txfusion committed Dec 12, 2024
2 parents 56b9c02 + b6fc019 commit 1bcbdc4
Show file tree
Hide file tree
Showing 14 changed files with 168 additions and 97 deletions.
1 change: 1 addition & 0 deletions rust/main/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/main/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ sha256 = "1.1.4"
sha3 = "0.10"
solana-account-decoder = "=1.14.13"
solana-client = "=1.14.13"
solana-program = "=1.14.13"
solana-sdk = "=1.14.13"
solana-transaction-status = "=1.14.13"
static_assertions = "1.1"
Expand Down
19 changes: 12 additions & 7 deletions rust/main/agents/relayer/src/msg/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,29 @@ impl ForwardBackwardIterator {
loop {
let high_nonce_message_status = self.high_nonce_iter.try_get_next_nonce(metrics)?;
let low_nonce_message_status = self.low_nonce_iter.try_get_next_nonce(metrics)?;
// Always prioritize the high nonce message

match (high_nonce_message_status, low_nonce_message_status) {
// Keep iterating if only processed messages are found
// Always prioritize advancing the the high nonce iterator, as
// we have a preference for higher nonces
(MessageStatus::Processed, _) => {
self.high_nonce_iter.iterate();
}
(_, MessageStatus::Processed) => {
self.low_nonce_iter.iterate();
}
// Otherwise return - either a processable message or nothing to process
(MessageStatus::Processable(high_nonce_message), _) => {
self.high_nonce_iter.iterate();
return Ok(Some(high_nonce_message));
}

// Low nonce messages are only processed if the high nonce iterator
// can't make any progress
(_, MessageStatus::Processed) => {
self.low_nonce_iter.iterate();
}
(_, MessageStatus::Processable(low_nonce_message)) => {
self.low_nonce_iter.iterate();
return Ok(Some(low_nonce_message));
}

// If both iterators give us unindexed messages, there are no messages at the moment
(MessageStatus::Unindexed, MessageStatus::Unindexed) => return Ok(None),
}
// This loop may iterate through millions of processed messages, blocking the runtime.
Expand Down Expand Up @@ -157,7 +162,7 @@ impl DirectionalNonceIterator {
}

fn try_get_next_nonce(
&mut self,
&self,
metrics: &MessageProcessorMetrics,
) -> Result<MessageStatus<HyperlaneMessage>> {
if let Some(message) = self.indexed_message_with_nonce()? {
Expand Down
24 changes: 15 additions & 9 deletions rust/main/agents/relayer/src/server/message_retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ mod tests {
let (addr, mut rx) = setup_test_server();

let client = reqwest::Client::new();
let mut message = HyperlaneMessage::default();
// Use a random destination domain
message.destination = 42;
let message = HyperlaneMessage {
// Use a random destination domain
destination: 42,
..Default::default()
};
let pending_operation = MockPendingOperation::with_message_data(message.clone());
let matching_list_body = json!([
{
Expand Down Expand Up @@ -127,9 +129,11 @@ mod tests {
let (addr, mut rx) = setup_test_server();

let client = reqwest::Client::new();
let mut message = HyperlaneMessage::default();
// Use a random origin domain
message.origin = 42;
let message = HyperlaneMessage {
// Use a random origin domain
origin: 42,
..Default::default()
};
let pending_operation = MockPendingOperation::with_message_data(message.clone());
let matching_list_body = json!([
{
Expand Down Expand Up @@ -216,9 +220,11 @@ mod tests {
let (addr, mut rx) = setup_test_server();

let client = reqwest::Client::new();
let mut message = HyperlaneMessage::default();
// Use a random origin domain
message.origin = 42;
let message = HyperlaneMessage {
// Use a random origin domain
origin: 42,
..Default::default()
};
let pending_operation = MockPendingOperation::with_message_data(message.clone());
let matching_list_body = json!([
{
Expand Down
12 changes: 5 additions & 7 deletions rust/main/agents/validator/src/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ mod test {
let unix_timestamp = chrono::Utc::now().timestamp() as u64;
let expected_reorg_period = 12;

let pre_reorg_merke_insertions = vec![
let pre_reorg_merke_insertions = [
MerkleTreeInsertion::new(0, H256::random()),
MerkleTreeInsertion::new(1, H256::random()),
MerkleTreeInsertion::new(2, H256::random()),
Expand All @@ -570,9 +570,9 @@ mod test {
}

// the last leaf is different post-reorg
let post_reorg_merkle_insertions = vec![
pre_reorg_merke_insertions[0].clone(),
pre_reorg_merke_insertions[1].clone(),
let post_reorg_merkle_insertions = [
pre_reorg_merke_insertions[0],
pre_reorg_merke_insertions[1],
MerkleTreeInsertion::new(2, H256::random()),
];
let mut mock_onchain_merkle_tree = IncrementalMerkle::default();
Expand All @@ -589,9 +589,7 @@ mod test {
// the db returns the pre-reorg merkle tree insertions
let mut db = MockDb::new();
db.expect_retrieve_merkle_tree_insertion_by_leaf_index()
.returning(move |sequence| {
Ok(Some(pre_reorg_merke_insertions[*sequence as usize].clone()))
});
.returning(move |sequence| Ok(Some(pre_reorg_merke_insertions[*sequence as usize])));

// boilerplate mocks
let mut mock_merkle_tree_hook = MockMerkleTreeHook::new();
Expand Down
8 changes: 4 additions & 4 deletions rust/main/chains/hyperlane-cosmos/src/libs/account/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ fn test_ethereum_style() {
fn compressed_public_key() -> PublicKey {
let hex = hex::decode(COMPRESSED_PUBLIC_KEY).unwrap();
let tendermint = tendermint::PublicKey::from_raw_secp256k1(&hex).unwrap();
let pub_key = PublicKey::from(tendermint);
pub_key

PublicKey::from(tendermint)
}

fn decompressed_public_key() -> PublicKey {
let hex = hex::decode(COMPRESSED_PUBLIC_KEY).unwrap();
let decompressed = decompress_public_key(&hex).unwrap();
let tendermint = tendermint::PublicKey::from_raw_secp256k1(&decompressed).unwrap();
let pub_key = PublicKey::from(tendermint);
pub_key

PublicKey::from(tendermint)
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ mod tests {

fn encode_proto(msg: &MsgRecvPacket) -> Any {
let mut buf = Vec::with_capacity(msg.encoded_len());
MsgRecvPacket::encode(&msg, &mut buf).unwrap();
MsgRecvPacket::encode(msg, &mut buf).unwrap();

Any {
type_url: "".to_string(),
Expand Down
1 change: 1 addition & 0 deletions rust/main/chains/hyperlane-sealevel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ serde.workspace = true
serde_json.workspace = true
solana-account-decoder.workspace = true
solana-client.workspace = true
solana-program.workspace = true
solana-sdk.workspace = true
solana-transaction-status.workspace = true
thiserror.workspace = true
Expand Down
Loading

0 comments on commit 1bcbdc4

Please sign in to comment.