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

Add support for ConsensusParametersVersion::V2 #2188

Merged
Show file tree
Hide file tree
Changes from 9 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- [2135](https://github.com/FuelLabs/fuel-core/pull/2135): Added metrics logging for number of blocks served over the p2p req/res protocol.
- [2151](https://github.com/FuelLabs/fuel-core/pull/2151): Added limitations on gas used during dry_run in API.
- [2188](https://github.com/FuelLabs/fuel-core/pull/2188): Added the new variant `V2` for the `ConsensusParameters` which contains the new `block_transaction_size_limit` parameter.
- [2163](https://github.com/FuelLabs/fuel-core/pull/2163): Added runnable task for fetching block committer data.

### Changed
Expand Down
32 changes: 12 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,6 @@ itertools = { version = "0.12", default-features = false }
insta = "1.8"
tempfile = "3.4"
tikv-jemallocator = "0.5"

[patch.crates-io]
fuel-vm-private = { git = 'https://github.com/FuelLabs/fuel-vm.git', package = "fuel-vm", branch = "2133_block_size_consensus_parameter" }
3 changes: 2 additions & 1 deletion bin/fuel-core/chainspec/local-testnet/chain_config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"chain_name": "Local testnet",
"consensus_parameters": {
"V1": {
"V2": {
"tx_params": {
"V1": {
"max_inputs": 255,
Expand Down Expand Up @@ -293,6 +293,7 @@
},
"base_asset_id": "f8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07",
"block_gas_limit": 30000000,
"block_transaction_size_limit": 129024,
"privileged_address": "9f0e19d6c2a6283a3222426ab2630d35516b1799b503f37b02105bebe1b8a3e9"
}
},
Expand Down
Binary file not shown.
2 changes: 2 additions & 0 deletions crates/client/assets/schema.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ type ConsensusParameters {
feeParams: FeeParameters!
baseAssetId: AssetId!
blockGasLimit: U64!
blockTransactionSizeLimit: U64!
Copy link
Contributor

Choose a reason for hiding this comment

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

When I first read it, I understood that it was the maximum size for a transaction. I think I misunderstood because the word transaction is singular. IMO, it should be plural.

Copy link
Contributor Author

@rafal-ch rafal-ch Sep 17, 2024

Choose a reason for hiding this comment

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

Yes, the name could indeed be slightly improved. However, it's already merged in fuel-vm here.

In the follow-up PR to fuel-core I'll make sure that this is comprehensively documented.

chainId: U64!
gasCosts: GasCosts!
privilegedAddress: Address!
Expand All @@ -210,6 +211,7 @@ type ConsensusParametersPurpose {

enum ConsensusParametersVersion {
V1
V2
}

type Contract {
Expand Down
20 changes: 20 additions & 0 deletions crates/client/src/client/schema/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct ConsensusParameters {
pub fee_params: FeeParameters,
pub base_asset_id: AssetId,
pub block_gas_limit: U64,
pub block_transaction_size_limit: U64,
pub chain_id: U64,
pub gas_costs: GasCosts,
pub privileged_address: Address,
Expand All @@ -29,6 +30,7 @@ pub struct ConsensusParameters {
#[cynic(schema_path = "./assets/schema.sdl")]
pub enum ConsensusParametersVersion {
V1,
V2,
}

#[derive(cynic::QueryFragment, Clone, Debug)]
Expand Down Expand Up @@ -493,6 +495,24 @@ impl TryFrom<ConsensusParameters> for fuel_core_types::fuel_tx::ConsensusParamet
}
.into(),
),
ConsensusParametersVersion::V2 => Ok(
fuel_core_types::fuel_tx::consensus_parameters::ConsensusParametersV2 {
tx_params: params.tx_params.try_into()?,
predicate_params: params.predicate_params.try_into()?,
script_params: params.script_params.try_into()?,
contract_params: params.contract_params.try_into()?,
fee_params: params.fee_params.try_into()?,
base_asset_id: params.base_asset_id.into(),
block_gas_limit: params.block_gas_limit.into(),
block_transaction_size_limit: params
.block_transaction_size_limit
.into(),
chain_id: params.chain_id.0.into(),
gas_costs: params.gas_costs.try_into()?,
privileged_address: params.privileged_address.into(),
}
.into(),
),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ query {
}
baseAssetId
blockGasLimit
blockTransactionSizeLimit
chainId
gasCosts {
version
Expand Down
7 changes: 3 additions & 4 deletions crates/fuel-core/src/query/message/test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::ops::Deref;

use fuel_core_txpool::types::ContractId;
use fuel_core_types::{
blockchain::header::{
ApplicationHeader,
Expand All @@ -8,13 +9,11 @@ use fuel_core_types::{
},
entities::relayer::message::MerkleProof,
fuel_tx::{
AssetId,
Script,
Transaction,
},
fuel_types::{
BlockHeight,
*,
},
fuel_types::BlockHeight,
tai64::Tai64,
};

Expand Down
7 changes: 7 additions & 0 deletions crates/fuel-core/src/schema/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub enum TxParametersVersion {
#[derive(Clone, Copy, Debug, Enum, Eq, PartialEq)]
pub enum ConsensusParametersVersion {
V1,
V2,
}

#[derive(Union)]
Expand Down Expand Up @@ -118,6 +119,7 @@ impl ConsensusParameters {
async fn version(&self) -> ConsensusParametersVersion {
match self.0.as_ref() {
fuel_tx::ConsensusParameters::V1(_) => ConsensusParametersVersion::V1,
fuel_tx::ConsensusParameters::V2(_) => ConsensusParametersVersion::V2,
}
}

Expand Down Expand Up @@ -156,6 +158,11 @@ impl ConsensusParameters {
self.0.block_gas_limit().into()
}

#[graphql(complexity = "QUERY_COSTS.storage_read")]
async fn block_transaction_size_limit(&self) -> U64 {
self.0.block_transaction_size_limit().into()
}

async fn chain_id(&self) -> U64 {
(*self.0.chain_id()).into()
}
Expand Down
6 changes: 3 additions & 3 deletions crates/fuel-core/src/schema/tx/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl From<&fuel_tx::Input> for Input {
tx_pointer: TxPointer(*tx_pointer),
witness_index: Default::default(),
predicate_gas_used: (*predicate_gas_used).into(),
predicate: HexString(predicate.clone()),
predicate: HexString(predicate.to_vec()),
predicate_data: HexString(predicate_data.clone()),
}),
fuel_tx::Input::Contract(contract) => Input::Contract(contract.into()),
Expand Down Expand Up @@ -239,7 +239,7 @@ impl From<&fuel_tx::Input> for Input {
witness_index: Default::default(),
predicate_gas_used: (*predicate_gas_used).into(),
data: HexString(Default::default()),
predicate: HexString(predicate.clone()),
predicate: HexString(predicate.to_vec()),
predicate_data: HexString(predicate_data.clone()),
}),
fuel_tx::Input::MessageDataSigned(
Expand Down Expand Up @@ -283,7 +283,7 @@ impl From<&fuel_tx::Input> for Input {
witness_index: Default::default(),
predicate_gas_used: (*predicate_gas_used).into(),
data: HexString(data.clone()),
predicate: HexString(predicate.clone()),
predicate: HexString(predicate.to_vec()),
predicate_data: HexString(predicate_data.clone()),
}),
}
Expand Down
1 change: 1 addition & 0 deletions crates/services/consensus_module/poa/src/service_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ fn test_signing_key() -> Secret<SecretKeyWrapper> {
}

#[derive(Debug, PartialEq)]
#[allow(clippy::large_enum_variant)]
enum FakeProducedBlock {
Predefined(Block),
New(BlockHeight, Tai64),
Expand Down
1 change: 1 addition & 0 deletions crates/services/executor/src/ports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use alloc::{
};

/// The wrapper around either `Transaction` or `CheckedTransaction`.
#[allow(clippy::large_enum_variant)]
pub enum MaybeCheckedTransaction {
CheckedTransaction(CheckedTransaction, ConsensusParametersVersion),
Transaction(fuel_tx::Transaction),
Expand Down
Loading