Skip to content

Commit e990929

Browse files
Bo Wuareshand
authored andcommitted
create local network
update the autobootstrap to waypoint version
1 parent ea63add commit e990929

File tree

29 files changed

+307
-130
lines changed

29 files changed

+307
-130
lines changed

Cargo.lock

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/src/config/consensus_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ impl Default for ConsensusConfig {
363363
max_pending_rounds_in_commit_vote_cache: 100,
364364
optimistic_sig_verification: true,
365365
enable_round_timeout_msg: true,
366-
enable_pipeline: true,
366+
enable_pipeline: false,
367367
}
368368
}
369369
}

consensus/consensus-types/src/block.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,11 @@ impl Block {
177177
/// Construct new genesis block for next epoch deterministically from the end-epoch LedgerInfo
178178
/// We carry over most fields except round and block id
179179
pub fn make_genesis_block_from_ledger_info(ledger_info: &LedgerInfo) -> Self {
180-
let block_data = BlockData::new_genesis_from_ledger_info(ledger_info);
180+
let block_data = if ledger_info.ends_epoch() {
181+
BlockData::new_genesis_from_ledger_info(ledger_info)
182+
} else {
183+
BlockData::make_genesis_block_from_any_ledger_info(ledger_info)
184+
};
181185
Block {
182186
id: block_data.hash(),
183187
block_data,

consensus/consensus-types/src/block_data.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,22 @@ impl BlockData {
188188
}
189189
}
190190

191+
pub fn make_genesis_block_from_any_ledger_info(ledger_info: &LedgerInfo) -> Self {
192+
let ancestor = ledger_info.commit_info().to_owned();
193+
194+
// Genesis carries a placeholder quorum certificate to its parent id with LedgerInfo
195+
// carrying information about version from the last LedgerInfo of previous epoch.
196+
let genesis_quorum_cert = QuorumCert::new(
197+
VoteData::new(ancestor.clone(), ancestor.clone()),
198+
LedgerInfoWithSignatures::new(
199+
LedgerInfo::new(ancestor, HashValue::zero()),
200+
AggregateSignature::empty(),
201+
),
202+
);
203+
204+
BlockData::new_starting_block(ledger_info.timestamp_usecs(), genesis_quorum_cert)
205+
}
206+
191207
pub fn new_genesis_from_ledger_info(ledger_info: &LedgerInfo) -> Self {
192208
assert!(ledger_info.ends_epoch());
193209
let ancestor = BlockInfo::new(
@@ -246,9 +262,22 @@ impl BlockData {
246262

247263
#[allow(unexpected_cfgs)]
248264
pub fn new_genesis(timestamp_usecs: u64, quorum_cert: QuorumCert) -> Self {
265+
assume!(quorum_cert.certified_block().epoch() < u64::MAX); // unlikely to be false in this universe
266+
let genesis_epoch = quorum_cert.certified_block().epoch() + 1;
267+
Self {
268+
epoch: genesis_epoch,
269+
round: 0,
270+
timestamp_usecs,
271+
quorum_cert,
272+
block_type: BlockType::Genesis,
273+
}
274+
}
275+
276+
#[allow(unexpected_cfgs)]
277+
pub fn new_starting_block(timestamp_usecs: u64, quorum_cert: QuorumCert) -> Self {
249278
assume!(quorum_cert.certified_block().epoch() < u64::MAX); // unlikely to be false in this universe
250279
Self {
251-
epoch: quorum_cert.certified_block().epoch() + 1,
280+
epoch: quorum_cert.certified_block().epoch(),
252281
round: 0,
253282
timestamp_usecs,
254283
quorum_cert,

consensus/consensus-types/src/pipelined_block.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,15 +571,16 @@ impl PipelinedBlock {
571571
}
572572

573573
pub async fn wait_for_compute_result(&self) -> ExecutorResult<(StateComputeResult, Duration)> {
574-
self.pipeline_futs()
575-
.ok_or(ExecutorError::InternalError {
576-
error: "Pipeline aborted".to_string(),
577-
})?
574+
let pipeline_futs = self.pipeline_futs().ok_or(ExecutorError::InternalError {
575+
error: "Pipeline aborted".to_string(),
576+
})?;
577+
578+
pipeline_futs
578579
.ledger_update_fut
579580
.await
580581
.map(|(compute_result, execution_time, _)| (compute_result, execution_time))
581582
.map_err(|e| ExecutorError::InternalError {
582-
error: e.to_string(),
583+
error: e.to_string()
583584
})
584585
}
585586

consensus/consensus-types/src/quorum_cert.rs

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,31 +82,51 @@ impl QuorumCert {
8282
/// - the accumulator root hash of the LedgerInfo is set to the last executed state of previous
8383
/// epoch.
8484
/// - the map of signatures is empty because genesis block is implicitly agreed.
85+
// TODO(l1-migration): This is for recovery when we lost consensu DB data
86+
// We create this virual block and don't want to add 1 since it is not epoch_ending block
87+
8588
pub fn certificate_for_genesis_from_ledger_info(
8689
ledger_info: &LedgerInfo,
8790
genesis_id: HashValue,
8891
) -> QuorumCert {
89-
let ancestor = BlockInfo::new(
92+
let ancestor_epoch = if ledger_info.ends_epoch() {
9093
ledger_info
9194
.epoch()
9295
.checked_add(1)
93-
.expect("Integer overflow when creating cert for genesis from ledger info"),
94-
0,
95-
genesis_id,
96-
ledger_info.transaction_accumulator_hash(),
97-
ledger_info.version(),
98-
ledger_info.timestamp_usecs(),
99-
None,
100-
);
96+
.expect("Integer overflow when creating cert for genesis from ledger info")
97+
} else {
98+
ledger_info.epoch()
99+
};
100+
101+
let ancestor = if ledger_info.ends_epoch() {
102+
BlockInfo::new(
103+
ancestor_epoch,
104+
0,
105+
genesis_id,
106+
ledger_info.transaction_accumulator_hash(),
107+
ledger_info.version(),
108+
ledger_info.timestamp_usecs(),
109+
None,
110+
)
111+
} else {
112+
BlockInfo::new(
113+
ancestor_epoch,
114+
0,
115+
genesis_id,
116+
ledger_info.transaction_accumulator_hash(),
117+
ledger_info.version(),
118+
ledger_info.timestamp_usecs(),
119+
None,
120+
)
121+
};
101122

102123
let vote_data = VoteData::new(ancestor.clone(), ancestor.clone());
103124
let li = LedgerInfo::new(ancestor, vote_data.hash());
104125

105126
let validator_set_size = ledger_info
106127
.next_epoch_state()
107-
.expect("Next epoch state not found in ledger info")
108-
.verifier
109-
.len();
128+
.map(|epoch_state| epoch_state.verifier.len())
129+
.unwrap_or(1);
110130

111131
QuorumCert::new(
112132
vote_data,

consensus/safety-rules/src/safety_rules.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ impl SafetyRules {
131131
let mut updated = false;
132132
let one_chain = qc.certified_block().round();
133133
let two_chain = qc.parent_block().round();
134+
134135
if one_chain > safety_data.one_chain_round {
135136
safety_data.one_chain_round = one_chain;
136137
trace!(
@@ -260,6 +261,7 @@ impl SafetyRules {
260261
let last_li = proof
261262
.verify(&waypoint)
262263
.map_err(|e| Error::InvalidEpochChangeProof(format!("{}", e)))?;
264+
263265
let ledger_info = last_li.ledger_info();
264266
let epoch_state = ledger_info
265267
.next_epoch_state()

consensus/src/block_storage/block_store.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ impl BlockStore {
311311
let block_to_commit = self
312312
.get_block(block_id_to_commit)
313313
.ok_or_else(|| format_err!("Committed block id not found"))?;
314+
if block_to_commit.block().is_genesis_block() && block_to_commit.round() == 0 {
315+
return Ok(());
316+
}
314317

315318
// First make sure that this commit is new.
316319
ensure!(

consensus/src/epoch_manager.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,9 +1476,10 @@ impl<P: OnChainConfigProvider> EpochManager<P> {
14761476
tokio::spawn(bootstrapper.start(dag_rpc_rx, dag_shutdown_rx));
14771477
}
14781478

1479+
//TODO(l1-migration) turn on quorum store
14791480
fn enable_quorum_store(&mut self, onchain_config: &OnChainConsensusConfig) -> bool {
14801481
fail_point!("consensus::start_new_epoch::disable_qs", |_| false);
1481-
onchain_config.quorum_store_enabled()
1482+
onchain_config.quorum_store_enabled() && false
14821483
}
14831484

14841485
async fn process_message(

consensus/src/execution_pipeline.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ impl ExecutionPipeline {
288288
{
289289
counters::APPLY_LEDGER_WAIT_TIME.observe_duration(command_creation_time.elapsed());
290290
debug!("ledger_apply stage received block {}.", block_id);
291+
291292
let res = async {
292293
let execution_duration = execution_time?;
293294
let executor = executor.clone();

0 commit comments

Comments
 (0)