Skip to content

Commit

Permalink
Make generated block proposals cancel each other out (#3249)
Browse files Browse the repository at this point in the history
## Motivation

The block proposals are supposed to rotate and cancel each other out, but there's currently a bug in how we do it.

## Proposal

Fix the bug

## Test Plan

CI + ran locally

## Release Plan

- Nothing to do / These changes follow the usual release cycle.
  • Loading branch information
ndr-ds authored Feb 6, 2025
1 parent 06f2807 commit 3581c16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 8 additions & 4 deletions linera-client/src/client_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,21 +845,25 @@ where
fungible_application_id: Option<ApplicationId>,
) -> Vec<RpcMessage> {
let mut proposals = Vec::new();
let mut next_recipient = self.wallet.last_chain().unwrap().chain_id;
let mut previous_chain_id = *key_pairs
.iter()
.last()
.expect("There should be a last element")
.0;
let amount = Amount::from(1);
for (&chain_id, key_pair) in key_pairs {
let public_key = key_pair.public();
let operation = match fungible_application_id {
Some(application_id) => Self::fungible_transfer(
application_id,
next_recipient,
previous_chain_id,
public_key,
public_key,
amount,
),
None => Operation::System(SystemOperation::Transfer {
owner: None,
recipient: Recipient::chain(next_recipient),
recipient: Recipient::chain(previous_chain_id),
amount,
}),
};
Expand All @@ -884,7 +888,7 @@ where
key_pair,
);
proposals.push(RpcMessage::BlockProposal(Box::new(proposal)));
next_recipient = chain.chain_id;
previous_chain_id = chain.chain_id;
}
proposals
}
Expand Down
5 changes: 5 additions & 0 deletions linera-service/src/linera/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,11 @@ impl Runnable for Job {
transactions_per_block,
fungible_application_id,
} => {
assert!(num_chains > 0, "Number of chains must be greater than 0");
assert!(
transactions_per_block > 0,
"Number of transactions per block must be greater than 0"
);
let start = Instant::now();
// Below all block proposals are supposed to succeed without retries, we
// must make sure that all incoming payments have been accepted on-chain
Expand Down

0 comments on commit 3581c16

Please sign in to comment.