Skip to content

Commit

Permalink
feat(consensus): validate BlockInfo (#3979)
Browse files Browse the repository at this point in the history
  • Loading branch information
asmaastarkware authored Feb 6, 2025
1 parent daf4118 commit 97feeec
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 45 deletions.
10 changes: 10 additions & 0 deletions config/papyrus/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,21 @@
"privacy": "Public",
"value": 100
},
"context.block_timestamp_window": {
"description": "Maximum allowed deviation (seconds) of a proposed block's timestamp from the current time.",
"privacy": "Public",
"value": 1
},
"context.chain_id": {
"description": "The chain id of the Starknet chain.",
"pointer_target": "chain_id",
"privacy": "Public"
},
"context.l1_da_mode": {
"description": "The data availability mode, true: Blob, false: Calldata.",
"privacy": "Public",
"value": true
},
"context.num_validators": {
"description": "The number of validators.",
"privacy": "Public",
Expand Down
10 changes: 10 additions & 0 deletions config/sequencer/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -784,11 +784,21 @@
"privacy": "Public",
"value": 100
},
"consensus_manager_config.context_config.block_timestamp_window": {
"description": "Maximum allowed deviation (seconds) of a proposed block's timestamp from the current time.",
"privacy": "Public",
"value": 1
},
"consensus_manager_config.context_config.chain_id": {
"description": "The chain id of the Starknet chain.",
"pointer_target": "chain_id",
"privacy": "Public"
},
"consensus_manager_config.context_config.l1_da_mode": {
"description": "The data availability mode, true: Blob, false: Calldata.",
"privacy": "Public",
"value": true
},
"consensus_manager_config.context_config.num_validators": {
"description": "The number of validators.",
"privacy": "Public",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
source: crates/papyrus_node/src/config/config_test.rs
expression: dumped_default_config
snapshot_kind: text
---
{
"base_layer.node_url": {
Expand Down Expand Up @@ -163,11 +162,23 @@ snapshot_kind: text
},
"privacy": "Public"
},
"context.block_timestamp_window": {
"description": "Maximum allowed deviation (seconds) of a proposed block's timestamp from the current time.",
"value": {
"$serde_json::private::Number": "1"
},
"privacy": "Public"
},
"context.chain_id": {
"description": "The chain id of the Starknet chain.",
"value": "SN_MAIN",
"privacy": "Public"
},
"context.l1_da_mode": {
"description": "The data availability mode, true: Blob, false: Calldata.",
"value": true,
"privacy": "Public"
},
"context.num_validators": {
"description": "The number of validators.",
"value": {
Expand Down
25 changes: 24 additions & 1 deletion crates/starknet_consensus/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ pub struct ContextConfig {
pub num_validators: u64,
/// The chain id of the Starknet chain.
pub chain_id: ChainId,
/// Maximum allowed deviation (seconds) of a proposed block's timestamp from the current time.
pub block_timestamp_window: u64,
/// The data availability mode, true: Blob, false: Calldata.
pub l1_da_mode: bool,
}

impl SerializeConfig for ContextConfig {
Expand All @@ -63,13 +67,32 @@ impl SerializeConfig for ContextConfig {
"The chain id of the Starknet chain.",
ParamPrivacyInput::Public,
),
ser_param(
"block_timestamp_window",
&self.block_timestamp_window,
"Maximum allowed deviation (seconds) of a proposed block's timestamp from the \
current time.",
ParamPrivacyInput::Public,
),
ser_param(
"l1_da_mode",
&self.l1_da_mode,
"The data availability mode, true: Blob, false: Calldata.",
ParamPrivacyInput::Public,
),
])
}
}

impl Default for ContextConfig {
fn default() -> Self {
Self { batcher_build_buffer: 100, num_validators: 1, chain_id: ChainId::Mainnet }
Self {
batcher_build_buffer: 100,
num_validators: 1,
chain_id: ChainId::Mainnet,
block_timestamp_window: 1,
l1_da_mode: true,
}
}
}

Expand Down
Loading

0 comments on commit 97feeec

Please sign in to comment.