From 143b8bd44a121cc1b611855bb460d62f8f0bb76c Mon Sep 17 00:00:00 2001 From: Dimitris Lamprinos Date: Mon, 4 Dec 2023 20:25:00 +0200 Subject: [PATCH] Rename branches to proofs --- feeder/src/prover/consensus.rs | 28 ++++++++++++++-------------- feeder/src/prover/mod.rs | 19 ++++++++++--------- types/src/lightclient.rs | 2 +- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/feeder/src/prover/consensus.rs b/feeder/src/prover/consensus.rs index 22439fb2..0e0f48d9 100644 --- a/feeder/src/prover/consensus.rs +++ b/feeder/src/prover/consensus.rs @@ -14,7 +14,7 @@ const CAPELLA_FORK_SLOT: u64 = CAPELLA_FORK_EPOCH * SLOTS_PER_EPOCH; /** * Generates a merkle proof from the transaction to the beacon block root. */ -pub async fn generate_transaction_branch( +pub async fn generate_transaction_proof( state_prover: &dyn StateProverAPI, block_id: &String, tx_index: u64, @@ -35,7 +35,7 @@ pub async fn generate_transaction_branch( /** * Generates a merkle proof from the receipts_root to the beacon block root. */ -pub async fn generate_receipts_root_branch( +pub async fn generate_receipts_root_proof( state_prover: &dyn StateProverAPI, block_id: &String, ) -> Result { @@ -116,7 +116,7 @@ pub async fn prove_ancestry_with_block_roots( Ok(ancestry_proof) } -async fn prove_historical_summaries_branch( +async fn prove_historical_summaries_proof( state_prover: &dyn StateProverAPI, target_block_slot: &u64, recent_block_state_id: &String, @@ -170,8 +170,8 @@ pub async fn prove_ancestry_with_historical_summaries( "Target block epoch is less than CAPELLA_FORK_EPOCH" )); } - let historical_summaries_branch = - prove_historical_summaries_branch(state_prover, target_block_slot, recent_block_state_id) + let historical_summaries_proof = + prove_historical_summaries_proof(state_prover, target_block_slot, recent_block_state_id) .await?; let block_root_to_block_summary_root = @@ -179,9 +179,9 @@ pub async fn prove_ancestry_with_historical_summaries( let res = AncestryProof::HistoricalRoots { block_root_proof: block_root_to_block_summary_root, - block_summary_root_proof: historical_summaries_branch.witnesses, - block_summary_root: historical_summaries_branch.leaf, - block_summary_root_gindex: historical_summaries_branch.gindex as usize, + block_summary_root_proof: historical_summaries_proof.witnesses, + block_summary_root: historical_summaries_proof.leaf, + block_summary_root_gindex: historical_summaries_proof.gindex as usize, }; Ok(res) @@ -191,8 +191,8 @@ pub async fn prove_ancestry_with_historical_summaries( mod tests { use crate::eth::consensus::EthBeaconAPI; use crate::prover::consensus::{ - generate_receipts_root_branch, generate_transaction_branch, - prove_ancestry_with_block_roots, prove_ancestry_with_historical_summaries, + generate_receipts_root_proof, generate_transaction_proof, prove_ancestry_with_block_roots, + prove_ancestry_with_historical_summaries, }; use crate::prover::mocks::mock_consensus_rpc::MockConsensusRPC; use crate::prover::mocks::mock_state_prover::MockStateProver; @@ -209,7 +209,7 @@ mod tests { * TESTS BELOW REQUIRE NETWORK REQUESTS */ #[tokio_test] - async fn test_transactions_branch() { + async fn test_transactions_proof() { let consensus = &MockConsensusRPC::new(); let state_prover = MockStateProver::new(); let mut block = consensus.get_beacon_block(7807119).await.unwrap(); @@ -220,7 +220,7 @@ mod tests { let node = transaction.hash_tree_root().unwrap(); let proof = - generate_transaction_branch(&state_prover, &block_root.to_string(), tx_index as u64) + generate_transaction_proof(&state_prover, &block_root.to_string(), tx_index as u64) .await .unwrap(); @@ -235,13 +235,13 @@ mod tests { } #[tokio_test] - async fn test_receipts_root_branch() { + async fn test_receipts_root_proof() { let consensus = &MockConsensusRPC::new(); let state_prover = MockStateProver::new(); let mut block = consensus.get_beacon_block(7807119).await.unwrap(); let block_root = block.hash_tree_root().unwrap(); - let proof = generate_receipts_root_branch(&state_prover, &block_root.to_string()) + let proof = generate_receipts_root_proof(&state_prover, &block_root.to_string()) .await .unwrap(); diff --git a/feeder/src/prover/mod.rs b/feeder/src/prover/mod.rs index 292b7477..0d4a6e99 100644 --- a/feeder/src/prover/mod.rs +++ b/feeder/src/prover/mod.rs @@ -12,7 +12,7 @@ use crate::{ utils::calc_slot_from_timestamp, }, prover::{ - consensus::{generate_receipts_root_branch, generate_transaction_branch, prove_ancestry}, + consensus::{generate_receipts_root_proof, generate_transaction_proof, prove_ancestry}, execution::{generate_receipt_proof, get_tx_index}, }, types::InternalMessage, @@ -85,12 +85,13 @@ impl Prover { println!("Got receipts proof"); // Consensus Proofs - let transaction_branch = - generate_transaction_branch(&self.state_prover, &block_id, tx_index).await?; - println!("Got transactions branch"); + let transaction_proof = + generate_transaction_proof(&self.state_prover, &block_id, tx_index).await?; + println!("Got transactions proof"); - let receipts_branch = generate_receipts_root_branch(&self.state_prover, &block_id).await?; - println!("Got receipts branch"); + let receipts_root_proof = + generate_receipts_root_proof(&self.state_prover, &block_id).await?; + println!("Got receipts root proof"); let ancestry_proof = prove_ancestry( &self.consensus_rpc, @@ -108,13 +109,13 @@ impl Prover { ancestry_proof, transaction_proof: TransactionProof { transaction_index: tx_index, - transaction_gindex: transaction_branch.gindex, - transaction_branch: transaction_branch.witnesses, + transaction_gindex: transaction_proof.gindex, + transaction_proof: transaction_proof.witnesses, transaction, }, receipt_proof: ReceiptProof { receipt_proof, - receipts_root_proof: receipts_branch.witnesses, + receipts_root_proof: receipts_root_proof.witnesses, receipts_root: Node::from_bytes(target_block.receipts_root.as_bytes().try_into()?), }, }) diff --git a/types/src/lightclient.rs b/types/src/lightclient.rs index 5938d6ff..d9008653 100644 --- a/types/src/lightclient.rs +++ b/types/src/lightclient.rs @@ -75,7 +75,7 @@ pub struct TransactionProof { // Generalized index of transaction in target block pub transaction_gindex: u64, // Proof from target block to transaction - pub transaction_branch: Vec, + pub transaction_proof: Vec, // Actual transaction to keccak and test against tx_hash of message pub transaction: Transaction, }