Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f4691f8
do not recycle presignatures
volovyks Mar 12, 2026
24874e3
Merge branch 'develop' into serhii/do-not-recycle-presignatures
volovyks Mar 12, 2026
59808b8
add .vscode to gitignore
volovyks Mar 12, 2026
feb9b13
clippy
volovyks Mar 12, 2026
33a4e10
Merge branch 'develop' into serhii/do-not-recycle-presignatures
volovyks Mar 12, 2026
568fa99
merge develop
volovyks Mar 12, 2026
9b7091b
Merge branch 'develop' into serhii/do-not-recycle-presignatures
volovyks Mar 16, 2026
7a8815b
extend comment
volovyks Mar 17, 2026
dba03ff
Merge branch 'develop' into serhii/do-not-recycle-presignatures
volovyks Mar 19, 2026
d5eb909
Merge branch 'develop' into serhii/do-not-recycle-presignatures
volovyks Mar 19, 2026
860e90f
Merge branch 'develop' into serhii/do-not-recycle-presignatures
volovyks Mar 19, 2026
c355c10
Merge branch 'develop' into serhii/do-not-recycle-presignatures
volovyks Mar 19, 2026
662ba66
Merge branch 'develop' into serhii/do-not-recycle-presignatures
volovyks Apr 1, 2026
95268db
replace reserved and used with using and generating
volovyks Apr 2, 2026
ac06acb
fix dropper
volovyks Apr 2, 2026
1295a8f
add checks to artifact creation
volovyks Apr 2, 2026
744020c
clippy
volovyks Apr 2, 2026
c6244a2
check ownership before pruning
volovyks Apr 2, 2026
30b70ec
remove redundant store bool flag
volovyks Apr 2, 2026
3413740
use MissedTickBehavior::Skip when stockpiling
volovyks Apr 2, 2026
6a091c6
remove redundant drops
volovyks Apr 2, 2026
f66cd74
merge using and generating into a single lock
volovyks Apr 2, 2026
e74624d
Merge branch 'develop' into serhii/simplify-reserveed
volovyks Apr 2, 2026
4f65cc2
fix storage tests
volovyks Apr 3, 2026
258fa46
add test_sync_when_peer_generating
volovyks Apr 3, 2026
dcd19af
add test_sync_when_owner_generating and fixes
volovyks Apr 5, 2026
20008f0
add matrix sync test, distinguish owned using
volovyks Apr 6, 2026
62d3456
keep me in storage
volovyks Apr 6, 2026
a48fabb
move state sync tests into a separate file
volovyks Apr 6, 2026
671ccb2
fix: check for reserved, not only generating
volovyks Apr 6, 2026
6dbaa54
Merge branch 'develop' into serhii/simplify-reserveed
volovyks Apr 8, 2026
e5691e3
address comments
volovyks Apr 8, 2026
0d78c0d
develop
volovyks Apr 10, 2026
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
6 changes: 6 additions & 0 deletions chain-signatures/node/src/protocol/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ impl<G: Governance> ConsensusProtocol<G> for StartedState {
);

let threshold = contract_state.threshold;
// Initialize identity for storage; this is an entry point into Running.
ctx.triple_storage.set_me(me);
ctx.presignature_storage.set_me(me);
let triple_task = TripleSpawnerTask::run(me, threshold, epoch, ctx);
let presign_task = PresignatureSpawnerTask::run(
me,
Expand Down Expand Up @@ -399,6 +402,9 @@ impl<G: Governance> ConsensusProtocol<G> for WaitingForConsensusState {
return NodeState::WaitingForConsensus(self);
};

// Initialize identity for storage; this is an entry point into Running.
ctx.triple_storage.set_me(me);
ctx.presignature_storage.set_me(me);
let triple_task = TripleSpawnerTask::run(me, self.threshold, self.epoch, ctx);
let presign_task = PresignatureSpawnerTask::run(
me,
Expand Down
12 changes: 5 additions & 7 deletions chain-signatures/node/src/protocol/presignature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,6 @@ impl PresignatureSpawner {
self.ongoing.contains_key(&id)
}

pub async fn contains_used(&self, id: PresignatureId) -> bool {
self.presignatures.contains_used(id).await
}

/// Returns the number of unspent presignatures available in the manager.
pub async fn len_generated(&self) -> usize {
self.presignatures.len_generated().await
Expand Down Expand Up @@ -480,7 +476,7 @@ impl PresignatureSpawner {
// to use the same triple as any other node.
// TODO: have all this part be a separate task such that finding a pair of triples is done in parallel instead
// of waiting for storage to respond here.
let Some(triples) = self.triples.take_mine(self.me).await else {
let Some(triples) = self.triples.take_mine().await else {
return;
};

Expand Down Expand Up @@ -566,9 +562,10 @@ impl PresignatureSpawner {
"starting protocol to generate a new presignature",
);

let Some(slot) = self.presignatures.reserve(id.id).await else {
let Some(slot) = self.presignatures.create_slot(id.id, owner).await else {
return Err(InitializationError::BadParameters(format!(
"id collision: presignature_id={id:?}"
"presignature {} is already generating, in use, or stored",
id.id
)));
};

Expand Down Expand Up @@ -696,6 +693,7 @@ impl PresignatureSpawner {
) {
let mut last_active_warn: Option<Instant> = None;
let mut stockpile_interval = time::interval(Duration::from_millis(100));
stockpile_interval.set_missed_tick_behavior(time::MissedTickBehavior::Skip);
let mut expiration_interval = tokio::time::interval(Duration::from_secs(1));
let mut posits = self.msg.subscribe_presignature_posit().await;

Expand Down
2 changes: 1 addition & 1 deletion chain-signatures/node/src/protocol/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ impl SignOrganizer {
let remaining = state.budget.remaining();
let fetch = tokio::time::timeout(remaining, async {
loop {
if let Some(taken) = ctx.presignatures.take_mine(ctx.me).await {
if let Some(taken) = ctx.presignatures.take_mine().await {
let Some(holders) = taken.artifact.holders() else {
tracing::error!(
id = taken.artifact.id,
Expand Down
12 changes: 5 additions & 7 deletions chain-signatures/node/src/protocol/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl SyncTask {
match handle.await {
Ok(responses) => {
// Process sync responses: update artifact participants based on not_found data
if let Err(err) = self.process_sync_responses(responses, me, threshold).await {
if let Err(err) = self.process_sync_responses(responses, threshold).await {
tracing::warn!(?err, "failed to process sync responses");
}
tracing::debug!(elapsed = ?start.elapsed(), "processed broadcast");
Expand All @@ -236,9 +236,8 @@ impl SyncTask {
}
}

// TODO: use reserved values instead. Note that we cannot fetch our own triples via reserved
async fn new_update(&self, me: Participant) -> Option<SyncUpdate> {
let triples = match self.triples.fetch_owned(me).await {
let triples = match self.triples.fetch_owned_with_reserved().await {
Ok(ids) => ids,
Err(err) => {
tracing::warn!(
Expand All @@ -248,7 +247,7 @@ impl SyncTask {
return None;
}
};
let presignatures = match self.presignatures.fetch_owned(me).await {
let presignatures = match self.presignatures.fetch_owned_with_reserved().await {
Ok(ids) => ids,
Err(err) => {
tracing::warn!(
Expand All @@ -272,7 +271,6 @@ impl SyncTask {
async fn process_sync_responses(
&self,
responses: Vec<(Participant, SyncPeerResponse)>,
me: Participant,
threshold: usize,
) -> Result<(), String> {
for (peer, result) in responses {
Expand All @@ -294,13 +292,13 @@ impl SyncTask {
// Batch remove peer from all triples and prune
let triple_res = self
.triples
.remove_holder_and_prune(me, peer, threshold, &response.triples)
.remove_holder_and_prune(peer, threshold, &response.triples)
.await;

// Batch remove peer from all presignatures and prune
let presig_res = self
.presignatures
.remove_holder_and_prune(me, peer, threshold, &response.presignatures)
.remove_holder_and_prune(peer, threshold, &response.presignatures)
.await;

match (triple_res, presig_res) {
Expand Down
9 changes: 3 additions & 6 deletions chain-signatures/node/src/protocol/triple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,6 @@ impl TripleSpawner {
self.ongoing.contains_key(&id)
}

pub async fn contains_used(&self, id: TripleId) -> bool {
self.triple_storage.contains_used(id).await
}

/// Returns the number of unspent triples assigned to this node.
pub async fn len_mine(&self) -> usize {
self.triple_storage.len_by_owner(self.me).await
Expand Down Expand Up @@ -528,9 +524,9 @@ impl TripleSpawner {
timeout: Duration,
) -> Result<(), InitializationError> {
// Check if the `id` is already in the system. Error out and have the next cycle try again.
let Some(slot) = self.triple_storage.reserve(id).await else {
let Some(slot) = self.triple_storage.create_slot(id, proposer).await else {
return Err(InitializationError::BadParameters(format!(
"id collision: pair_id={id}"
"triple {id} is already generating, in use, or stored"
)));
};

Expand Down Expand Up @@ -581,6 +577,7 @@ impl TripleSpawner {
ongoing_gen_tx: watch::Sender<usize>,
) {
let mut stockpile_interval = tokio::time::interval(Duration::from_millis(100));
stockpile_interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
let mut expiration_interval = tokio::time::interval(Duration::from_secs(1));
let mut posits = self.msg.subscribe_triple_posit().await;

Expand Down
Loading
Loading