Skip to content

Commit

Permalink
fix:update ra first time will crash if not register
Browse files Browse the repository at this point in the history
  • Loading branch information
democ98 committed Jul 29, 2024
1 parent d7d5687 commit af9e207
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
26 changes: 11 additions & 15 deletions standalone/teeworker/cifrost/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ async fn try_update_worker_ra_report(
.await?
.into_inner();
if let Some(attestation) = info.attestation {
info!("Registering worker...");
tx::update_worker_ra_report(
chain_client,
info.encoded_runtime_info,
Expand Down Expand Up @@ -374,17 +373,6 @@ async fn bridge(
}
}

//anyway update ceseal ra report even though not register
try_update_worker_ra_report(
&mut cc,
&chain_api,
&mut signer,
operator.clone(),
args.longevity,
args.tip,
)
.await?;

if args.no_sync {
let worker_pubkey = hex::decode(
info.public_key()
Expand Down Expand Up @@ -417,6 +405,7 @@ async fn bridge(

block_subscribe::spawn_subscriber(&chain_api, cc.clone()).await?;

info!("Start updating ceseal's ra report task...");
tokio::spawn(schedule_updates_ra_report(
cc.clone(),
chain_api.clone(),
Expand Down Expand Up @@ -885,18 +874,25 @@ async fn schedule_updates_ra_report(
longevity: u64,
tip: u128,
) -> Result<()> {
let mut interval = tokio::time::interval(tokio::time::Duration::from_secs(86400));
let mut interval = tokio::time::interval(tokio::time::Duration::from_secs(/*86400*/300));
let mut signer = SrSigner::new(pair.clone());
loop {
interval.tick().await;
try_update_worker_ra_report(
match try_update_worker_ra_report(
&mut cc.clone(),
&chain_api,
&mut signer,
operator.clone(),
longevity,
tip,
)
.await?;
.await{
Ok(result) =>{
info!("Scheduled update ceseal ra report successfully!")
},
Err(error) => {
info!("can't update ceseal ra report because :{:?}",error.to_string())
},
};
}
}
2 changes: 1 addition & 1 deletion standalone/teeworker/cifrost/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub struct Args {
pub tip: u128,

#[arg(
default_value = "4",
default_value = "16",
long,
help = "The transaction longevity, should be a power of two between 4 and 65536. unit: block"
)]
Expand Down

0 comments on commit af9e207

Please sign in to comment.