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

refactor: increase type safety of block lifecycle #5140

Merged
merged 1 commit into from
Oct 11, 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
10 changes: 4 additions & 6 deletions crates/iroha/examples/register_1000_triggers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn generate_genesis(
chain_id: ChainId,
genesis_key_pair: &KeyPair,
topology: Vec<PeerId>,
) -> Result<GenesisBlock, Box<dyn std::error::Error>> {
) -> GenesisBlock {
let builder = GenesisBuilder::default()
.append_instruction(SetParameter::new(Parameter::Executor(
SmartContractParameter::Fuel(NonZeroU64::MAX),
Expand Down Expand Up @@ -61,10 +61,10 @@ fn generate_genesis(
.fold(builder, GenesisBuilder::append_instruction);

let executor = Executor::new(load_sample_wasm("default_executor"));
Ok(builder.build_and_sign(chain_id, executor, topology, genesis_key_pair))
builder.build_and_sign(chain_id, executor, topology, genesis_key_pair)
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
fn main() {
let mut peer: TestPeer = <TestPeer>::new().expect("Failed to create peer");

let chain_id = get_chain_id();
Expand All @@ -77,7 +77,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
genesis_key_pair.public_key(),
);

let genesis = generate_genesis(1_000_u32, chain_id, &genesis_key_pair, topology)?;
let genesis = generate_genesis(1_000_u32, chain_id, &genesis_key_pair, topology);

let builder = PeerBuilder::new()
.with_genesis(genesis)
Expand All @@ -88,6 +88,4 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
rt.block_on(builder.start_with_peer(&mut peer));

wait_for_genesis_committed_with_max_retries(&vec![test_client.clone()], 0, 600);

Ok(())
}
1 change: 0 additions & 1 deletion crates/iroha/tests/integration/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use iroha_test_samples::{gen_account_in, load_sample_wasm, ALICE_ID};
use nonzero_ext::nonzero;

#[test]
#[expect(clippy::too_many_lines)]
fn mutlisig() -> Result<()> {
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(11_400).start_with_runtime();
wait_for_genesis_committed(&vec![test_client.clone()], 0);
Expand Down
2 changes: 2 additions & 0 deletions crates/iroha_core/benches/blocks/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ pub fn create_block(
.chain(0, state)
.sign(peer_private_key)
.unpack(|_| {})
.categorize(state)
.unpack(|_| {})
.commit(topology)
.unpack(|_| {})
.unwrap();
Expand Down
2 changes: 2 additions & 0 deletions crates/iroha_core/benches/kura.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ async fn measure_block_size_for_n_executors(n_executors: u32) {
.chain(0, &mut state_block)
.sign(&peer_private_key)
.unpack(|_| {})
.categorize(&mut state_block)
.unpack(|_| {})
};

let key_pair = KeyPair::random();
Expand Down
2 changes: 1 addition & 1 deletion crates/iroha_core/benches/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fn sign_blocks(criterion: &mut Criterion) {
b.iter_batched(
|| block.clone(),
|block| {
let _: ValidBlock = block.sign(&peer_private_key).unpack(|_| {});
let _: NewBlock = block.sign(&peer_private_key).unpack(|_| {});
count += 1;
},
BatchSize::SmallInput,
Expand Down
Loading
Loading