Skip to content

Commit

Permalink
Add support for ConsensusParametersVersion::V2
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal-ch committed Sep 11, 2024
1 parent f308bae commit fa1288b
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 24 deletions.
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
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!
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
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
7 changes: 4 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,8 @@ 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()),
// TODO[RC]: Not yet sure why these are needed?
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 +240,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 +284,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

0 comments on commit fa1288b

Please sign in to comment.