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

New Block structure #3101

Merged
merged 30 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bc152a7
Rename Block to Proposal
deuszx Jan 7, 2025
a6080da
New Block structures
deuszx Jan 8, 2025
facb07d
Add a newtype struct for wrapping Vec<CryptoHash>
deuszx Jan 9, 2025
c3ccffa
fix linera-indexer/examples test
deuszx Jan 9, 2025
a61b959
Fix linera-explorer tests
deuszx Jan 9, 2025
5204ea3
Fix hex_game example
deuszx Jan 9, 2025
1ab41d6
Fix cargo clippy
deuszx Jan 9, 2025
93afb26
Cleanup
deuszx Jan 9, 2025
bb50374
Fix test
deuszx Jan 9, 2025
b2c870d
rm comments
deuszx Jan 9, 2025
8d06dac
Fix graphql query in the tests
deuszx Jan 10, 2025
d13da68
Comments on the new types
deuszx Jan 10, 2025
86f300d
block.rs cleanup
deuszx Jan 10, 2025
5fe0425
Testy empty Block size.
deuszx Jan 10, 2025
f71b944
Check hash equality when deserializing Block
deuszx Jan 13, 2025
ab619da
Merge remote-tracking branch 'origin/main' into new-block-structure
deuszx Jan 13, 2025
65a80f6
Address typos and renames
deuszx Jan 13, 2025
19ce2d1
Fix after merge with main.
deuszx Jan 13, 2025
652604e
Custom (de)serializer for BlockHeader.
deuszx Jan 13, 2025
8402eb4
Update EMPTY_BLOCK_SIZE
deuszx Jan 13, 2025
5cbe42e
Improve comment on the Block type a bit
deuszx Jan 13, 2025
42ae6d2
RM (de)serializers for ExecutedBlock
deuszx Jan 13, 2025
db6db25
Derive (De)Serialize for CryptoHashVec
deuszx Jan 14, 2025
0c92ed4
Comment formatting
deuszx Jan 14, 2025
fff9b8b
Merge remote-tracking branch 'origin/main' into new-block-structure
deuszx Jan 14, 2025
dd1147a
Update maximum block size in test
deuszx Jan 14, 2025
89062f6
Address review comments from Andreas
deuszx Jan 17, 2025
5bf891d
Merge remote-tracking branch 'origin/main' into new-block-structure
deuszx Jan 17, 2025
0952a88
one more fix to expected block sizes
deuszx Jan 17, 2025
ac1c97f
Merge branch 'main' into new-block-structure
afck Jan 22, 2025
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
Prev Previous commit
Next Next commit
RM (de)serializers for ExecutedBlock
  • Loading branch information
deuszx committed Jan 13, 2025
commit 42ae6d274604f310f33f4851f90f631ebec1cce2
16 changes: 1 addition & 15 deletions linera-chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,7 @@ static STATE_HASH_COMPUTATION_LATENCY: LazyLock<HistogramVec> = LazyLock::new(||
)
});

/// The BCS-serialized size of an empty [`crate::data_types::ExecutedBlock`].
const EMPTY_EXECUTED_BLOCK_SIZE: usize = 91;

/// The BCS-serialized size of an empty [`Block`].
#[cfg(test)]
const EMPTY_BLOCK_SIZE: usize = 92;

/// An origin, cursor and timestamp of a unskippable bundle in our inbox.
Expand Down Expand Up @@ -707,7 +703,7 @@ where
account: block.authenticated_signer,
};
resource_controller
.track_block_size(EMPTY_EXECUTED_BLOCK_SIZE)
.track_block_size(EMPTY_BLOCK_SIZE)
.and_then(|()| {
resource_controller
.track_executed_block_size_sequence_extension(0, block.incoming_bundles.len())
Expand Down Expand Up @@ -1237,16 +1233,6 @@ where
}
}

#[test]
fn empty_executed_block_size() {
let executed_block = crate::data_types::ExecutedBlock {
proposal: crate::test::make_first_block(ChainId::root(0)),
outcome: crate::data_types::BlockExecutionOutcome::default(),
};
let size = bcs::serialized_size(&executed_block).unwrap();
assert_eq!(size, EMPTY_EXECUTED_BLOCK_SIZE);
}

#[test]
fn empty_block_size() {
let executed_block = crate::data_types::ExecutedBlock {
Expand Down
4 changes: 1 addition & 3 deletions linera-chain/src/data_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,14 +400,12 @@ impl OutgoingMessage {
}

/// A [`Proposal`], together with the outcome from its execution.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, SimpleObject)]
#[derive(Debug, PartialEq, Eq, Hash, Clone, SimpleObject)]
pub struct ExecutedBlock {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe ProposalWithOutcome. Or even inline it, if it's not used in many places anymore?

pub proposal: Proposal,
pub outcome: BlockExecutionOutcome,
}

impl<'de> BcsHashable<'de> for ExecutedBlock {}

/// The messages and the state hash resulting from a [`Proposal`]'s execution.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, SimpleObject)]
#[cfg_attr(with_testing, derive(Default))]
Expand Down
6 changes: 3 additions & 3 deletions linera-chain/src/unit_tests/chain_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use linera_views::{
};

use crate::{
block::ConfirmedBlock,
block::{Block, ConfirmedBlock},
data_types::{IncomingBundle, MessageAction, MessageBundle, Origin},
test::{make_child_block, make_first_block, BlockTestExt, MessageTestExt},
ChainError, ChainExecutionContext, ChainStateView,
Expand Down Expand Up @@ -171,11 +171,11 @@ async fn test_block_size_limit() {

// The valid block is accepted...
let outcome = chain.execute_block(&valid_block, time, None).await.unwrap();
let executed_block = outcome.with(valid_block);
let block: Block = Block::new(valid_block, outcome);
afck marked this conversation as resolved.
Show resolved Hide resolved

// ...because its size is exactly at the allowed limit.
assert_eq!(
bcs::serialized_size(&executed_block).unwrap(),
bcs::serialized_size(&block).unwrap(),
maximum_executed_block_size as usize
);
}
Expand Down