|
|
@ -105,6 +105,21 @@ impl BaseAgent for Validator { |
|
|
|
async fn run(&self) -> Instrumented<JoinHandle<Result<()>>> { |
|
|
|
async fn run(&self) -> Instrumented<JoinHandle<Result<()>>> { |
|
|
|
self.announce().await.expect("Failed to announce validator"); |
|
|
|
self.announce().await.expect("Failed to announce validator"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let reorg_period = NonZeroU64::new(self.reorg_period); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ensure that the mailbox has count > 0 before we begin indexing
|
|
|
|
|
|
|
|
// messages or submitting checkpoints.
|
|
|
|
|
|
|
|
while self |
|
|
|
|
|
|
|
.mailbox |
|
|
|
|
|
|
|
.count(reorg_period) |
|
|
|
|
|
|
|
.await |
|
|
|
|
|
|
|
.expect("Failed to get count of mailbox") |
|
|
|
|
|
|
|
== 0 |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
info!("Waiting for first message to mailbox"); |
|
|
|
|
|
|
|
sleep(self.interval).await; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let mut tasks = vec![]; |
|
|
|
let mut tasks = vec![]; |
|
|
|
|
|
|
|
|
|
|
|
tasks.push(self.run_message_sync().await); |
|
|
|
tasks.push(self.run_message_sync().await); |
|
|
@ -146,19 +161,19 @@ impl Validator { |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
let empty_tree = IncrementalMerkle::default(); |
|
|
|
let empty_tree = IncrementalMerkle::default(); |
|
|
|
let lag = NonZeroU64::new(self.reorg_period); |
|
|
|
let reorg_period = NonZeroU64::new(self.reorg_period); |
|
|
|
let tip_tree = self |
|
|
|
let tip_tree = self |
|
|
|
.mailbox |
|
|
|
.mailbox |
|
|
|
.tree(lag) |
|
|
|
.tree(reorg_period) |
|
|
|
.await |
|
|
|
.await |
|
|
|
.expect("failed to get mailbox tree"); |
|
|
|
.expect("failed to get mailbox tree"); |
|
|
|
let mut tasks = vec![]; |
|
|
|
assert!(tip_tree.count() > 0, "mailbox tree is empty"); |
|
|
|
|
|
|
|
let backfill_target = submitter.checkpoint(&tip_tree); |
|
|
|
|
|
|
|
|
|
|
|
let legacy_submitter = submitter.clone(); |
|
|
|
let legacy_submitter = submitter.clone(); |
|
|
|
|
|
|
|
|
|
|
|
if tip_tree.count() > 0 { |
|
|
|
|
|
|
|
let backfill_target = submitter.checkpoint(&tip_tree); |
|
|
|
|
|
|
|
let backfill_submitter = submitter.clone(); |
|
|
|
let backfill_submitter = submitter.clone(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut tasks = vec![]; |
|
|
|
tasks.push( |
|
|
|
tasks.push( |
|
|
|
tokio::spawn(async move { |
|
|
|
tokio::spawn(async move { |
|
|
|
backfill_submitter |
|
|
|
backfill_submitter |
|
|
@ -167,7 +182,6 @@ impl Validator { |
|
|
|
}) |
|
|
|
}) |
|
|
|
.instrument(info_span!("BackfillCheckpointSubmitter")), |
|
|
|
.instrument(info_span!("BackfillCheckpointSubmitter")), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tasks.push( |
|
|
|
tasks.push( |
|
|
|
tokio::spawn(async move { submitter.checkpoint_submitter(tip_tree, None).await }) |
|
|
|
tokio::spawn(async move { submitter.checkpoint_submitter(tip_tree, None).await }) |
|
|
@ -222,6 +236,7 @@ impl Validator { |
|
|
|
validator_address=?announcement.validator, |
|
|
|
validator_address=?announcement.validator, |
|
|
|
"Please send tokens to the validator address to announce", |
|
|
|
"Please send tokens to the validator address to announce", |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
sleep(self.interval).await; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
let outcome = self |
|
|
|
let outcome = self |
|
|
|
.validator_announce |
|
|
|
.validator_announce |
|
|
@ -235,7 +250,6 @@ impl Validator { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
sleep(self.interval).await; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|