Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support take_checkpoint from ceseal after completing the first block synchronization in cifrost #340

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading