Skip to content

Commit

Permalink
nonce -> leaf_index builder.get_proof
Browse files Browse the repository at this point in the history
  • Loading branch information
aroralanuk committed Nov 2, 2023
1 parent 228c698 commit 9751ce5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
23 changes: 8 additions & 15 deletions rust/agents/relayer/src/merkle_tree/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,16 @@ impl MerkleTreeBuilder {
#[instrument(err, skip(self), level="debug", fields(prover_latest_index=self.count()-1))]
pub fn get_proof(
&self,
message_nonce: u32,
leaf_index: u32,
root_index: u32,
) -> Result<Option<Proof>, MerkleTreeBuilderError> {
self.db
.retrieve_message_id_by_nonce(&message_nonce)?
.and_then(|message_id| {
self.db
.retrieve_merkle_leaf_index_by_message_id(&message_id)
.ok()
.flatten()
})
.map(|leaf_index| {
self.prover
.prove_against_previous(leaf_index as usize, root_index as usize)
})
.transpose()
.map_err(Into::into)
match self
.prover
.prove_against_previous(leaf_index as usize, root_index as usize)
{
Ok(proof) => Ok(Some(proof)),
Err(prover_err) => Err(MerkleTreeBuilderError::from(prover_err)),
}
}

pub fn count(&self) -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion rust/agents/relayer/src/msg/metadata/aggregation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl AggregationIsmMetadataBuilder {

let metas_and_gas_count = metas_and_gas.len();
if metas_and_gas_count < threshold {
info!("Could not fetch all metadata: Found {metas_and_gas_count} of the {threshold} required ISM metadata pieces");
info!("Could not fetch all metadata: Found {metas_and_gas_count} of the {threshold} required ISM metadata pieces for message_id {message_id}", metas_and_gas_count=metas_and_gas_count, threshold=threshold, message_id=message.id());
return None;
}
Some(Self::n_cheapest_metas(metas_and_gas, threshold))
Expand Down
8 changes: 6 additions & 2 deletions rust/agents/relayer/src/msg/metadata/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,16 @@ impl BaseMetadataBuilder {
}
}

pub async fn get_proof(&self, nonce: u32, checkpoint: Checkpoint) -> Result<Option<Proof>> {
pub async fn get_proof(
&self,
leaf_index: u32,
checkpoint: Checkpoint,
) -> Result<Option<Proof>> {
const CTX: &str = "When fetching message proof";
let proof = self.origin_prover_sync
.read()
.await
.get_proof(nonce, checkpoint.index)
.get_proof(leaf_index, checkpoint.index)
.context(CTX)?
.and_then(|proof| {
// checkpoint may be fraudulent if the root does not
Expand Down
2 changes: 1 addition & 1 deletion rust/hyperlane-base/src/types/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl MultisigCheckpointSyncer {
// Gracefully handle errors getting the latest_index
match checkpoint_syncer.latest_index().await {
Ok(Some(index)) => {
trace!(?address, ?index, "Validator returned latest index");
debug!(?address, ?index, "Validator returned latest index");
latest_indices.push(index);
}
err => {
Expand Down

0 comments on commit 9751ce5

Please sign in to comment.