Skip to content

Commit a576fb4

Browse files
committed
Revert "Merge pull request #3847 from ProvableHQ/fix/revert-pending-blocks"
This reverts commit de856fd, reversing changes made to 647f6f3.
1 parent 06685ac commit a576fb4

File tree

17 files changed

+437
-419
lines changed

17 files changed

+437
-419
lines changed

Cargo.lock

Lines changed: 61 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ default-features = false
4848
#path = "../snarkVM"
4949
git = "https://github.com/ProvableHQ/snarkVM.git"
5050
#rev = "e873e69b458"
51-
branch = "feat/track-error"
51+
branch = "fix/restore-pending-blocks"
5252
#version = "=4.2.1"
5353
default-features = false
5454

cli/src/helpers/logger.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ fn parse_log_filter(filter_str: &str) -> Result<EnvFilter> {
107107
}
108108

109109
/// Sets the log filter based on the given verbosity level.
110+
/// Initializes the logger with the specified verbosity level, where 0 is the lowest verbosity and 6 the highest.
110111
///
112+
/// The following shows what messages are enabled at each level.
111113
/// ```ignore
112114
/// 0 => info
113115
/// 1 => info, debug

node/bft/ledger-service/src/ledger.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ use snarkos_utilities::Stoppable;
1919

2020
use snarkvm::{
2121
ledger::{
22+
Block,
2223
Ledger,
23-
block::{Block, Transaction},
24+
PendingBlock,
25+
Transaction,
2426
committee::Committee,
2527
narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID},
2628
puzzle::{Solution, SolutionID},
@@ -346,6 +348,14 @@ impl<N: Network, C: ConsensusStorage<N>> LedgerService<N> for CoreLedgerService<
346348
spawn_blocking!(ledger.check_transaction_basic(&transaction, None, &mut rand::thread_rng()))
347349
}
348350

351+
fn check_block_subdag(&self, block: Block<N>, prefix: &[PendingBlock<N>]) -> Result<PendingBlock<N>> {
352+
self.ledger.check_block_subdag(block, prefix)
353+
}
354+
355+
fn check_block_content(&self, block: PendingBlock<N>) -> Result<Block<N>> {
356+
self.ledger.check_block_content(block, &mut rand::thread_rng())
357+
}
358+
349359
/// Checks the given block is valid next block.
350360
fn check_next_block(&self, block: &Block<N>) -> Result<()> {
351361
self.ledger.check_next_block(block, &mut rand::thread_rng())

node/bft/ledger-service/src/mock.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
use crate::{LedgerService, fmt_id};
1717
use snarkvm::{
1818
ledger::{
19-
block::{Block, Transaction},
19+
Block,
20+
PendingBlock,
21+
Transaction,
2022
committee::Committee,
2123
narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID},
2224
puzzle::{Solution, SolutionID},
@@ -211,6 +213,14 @@ impl<N: Network> LedgerService<N> for MockLedgerService<N> {
211213
Ok(())
212214
}
213215

216+
fn check_block_subdag(&self, _block: Block<N>, _prefix: &[PendingBlock<N>]) -> Result<PendingBlock<N>> {
217+
unimplemented!();
218+
}
219+
220+
fn check_block_content(&self, _block: PendingBlock<N>) -> Result<Block<N>> {
221+
unimplemented!();
222+
}
223+
214224
/// Checks the given block is valid next block.
215225
fn check_next_block(&self, _block: &Block<N>) -> Result<()> {
216226
Ok(())

node/bft/ledger-service/src/prover.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
use crate::LedgerService;
1717
use snarkvm::{
1818
ledger::{
19-
block::{Block, Transaction},
19+
Block,
20+
PendingBlock,
21+
Transaction,
2022
committee::Committee,
2123
narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID},
2224
puzzle::{Solution, SolutionID},
@@ -166,6 +168,14 @@ impl<N: Network> LedgerService<N> for ProverLedgerService<N> {
166168
Ok(())
167169
}
168170

171+
fn check_block_subdag(&self, _block: Block<N>, _prefix: &[PendingBlock<N>]) -> Result<PendingBlock<N>> {
172+
bail!("Cannot check block subDAG in prover")
173+
}
174+
175+
fn check_block_content(&self, _pending_block: PendingBlock<N>) -> Result<Block<N>> {
176+
bail!("Cannot check block content in prover")
177+
}
178+
169179
/// Checks the given block is valid next block.
170180
fn check_next_block(&self, _block: &Block<N>) -> Result<()> {
171181
Ok(())

node/bft/ledger-service/src/traits.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
use snarkvm::{
1717
ledger::{
18-
block::{Block, Transaction},
18+
Block,
19+
PendingBlock,
20+
Transaction,
1921
committee::Committee,
2022
narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID},
2123
puzzle::{Solution, SolutionID},
@@ -106,6 +108,12 @@ pub trait LedgerService<N: Network>: Debug + Send + Sync {
106108
transaction: Transaction<N>,
107109
) -> Result<()>;
108110

111+
/// Checks that the subDAG in a given block is valid, but does not fully verify the block.
112+
fn check_block_subdag(&self, block: Block<N>, prefix: &[PendingBlock<N>]) -> Result<PendingBlock<N>>;
113+
114+
/// Takes a pending block and performs the remaining checks to full verify it.
115+
fn check_block_content(&self, _block: PendingBlock<N>) -> Result<Block<N>>;
116+
109117
/// Checks the given block is valid next block.
110118
fn check_next_block(&self, block: &Block<N>) -> Result<()>;
111119

node/bft/ledger-service/src/translucent.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ use snarkos_utilities::Stoppable;
1919

2020
use snarkvm::{
2121
ledger::{
22+
Block,
2223
Ledger,
23-
block::{Block, Transaction},
24+
PendingBlock,
25+
Transaction,
2426
committee::Committee,
2527
narwhal::{Data, Subdag, Transmission, TransmissionID},
2628
puzzle::{Solution, SolutionID},
@@ -177,6 +179,14 @@ impl<N: Network, C: ConsensusStorage<N>> LedgerService<N> for TranslucentLedgerS
177179
Ok(())
178180
}
179181

182+
fn check_block_subdag(&self, _block: Block<N>, _prefix: &[PendingBlock<N>]) -> Result<PendingBlock<N>> {
183+
unimplemented!();
184+
}
185+
186+
fn check_block_content(&self, _block: PendingBlock<N>) -> Result<Block<N>> {
187+
unimplemented!();
188+
}
189+
180190
/// Always succeeds.
181191
fn check_next_block(&self, _block: &Block<N>) -> Result<()> {
182192
Ok(())

0 commit comments

Comments
 (0)