Skip to content

Commit

Permalink
feat: support take_checkpoint from ceseal after completing the fi…
Browse files Browse the repository at this point in the history
…rst block synchronization in `cifrost` (#340)
  • Loading branch information
0xbillw authored May 8, 2024
1 parent 0fec88f commit c44be73
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scripts/run/cifrost.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ ceseal_port=$((${CESEAL_PORT:-8000} + $inst_seq))
pub_port=$((${PUB_PORT:-19999} + $inst_seq))
mnemonic=${MNEMONIC:-//Ferdie}
inject_key=$(printf %064d $(($inst_seq + 1)))
snapshot="--take-checkpoint"
if [[ -z "${SNAPSHOT}" ]]; then
snapshot=
fi

bin="../cess/target/debug/cifrost"
log_file="./target/cifrost-$inst_seq.log"
Expand All @@ -26,5 +30,6 @@ $bin \
--mnemonic $mnemonic \
--attestation-provider none \
--longevity 16 \
$snapshot \
--operator cXjHGCWMUM8gM9YFJUK2rqq2tiFWB4huBKWdQPkWdcXcZHhHA |&
tee $log_file
6 changes: 6 additions & 0 deletions standalone/teeworker/cifrost/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,11 @@ async fn bridge(
handover_worker_key(&mut cc, &mut next_pr).await?;
}

if !flags.checkpoint_taked && args.take_checkpoint {
cc.take_checkpoint(()).await?;
flags.checkpoint_taked = true;
}

sleep(Duration::from_millis(args.dev_wait_block_ms)).await;
continue;
}
Expand Down Expand Up @@ -846,6 +851,7 @@ pub async fn run() {
endpoint_registered: false,
master_key_apply_sent: false,
restart_failure_count: 0,
checkpoint_taked: false,
};

loop {
Expand Down
5 changes: 5 additions & 0 deletions standalone/teeworker/cifrost/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ pub struct Args {
/// Load handover proof after blocks synced.
#[arg(long)]
pub load_handover_proof: bool,

/// Take checkpoint from Ceseal after completing the first block synchronization in Cifrost
#[arg(long)]
pub take_checkpoint: bool,
}

#[derive(clap::ValueEnum, Clone, Copy, Debug)]
Expand All @@ -212,6 +216,7 @@ pub struct RunningFlags {
pub endpoint_registered: bool,
pub master_key_apply_sent: bool,
pub restart_failure_count: u32,
pub checkpoint_taked: bool,
}

pub struct BlockSyncState {
Expand Down

0 comments on commit c44be73

Please sign in to comment.