Skip to content

Commit

Permalink
Add support for ConsensusParametersVersion::V2 (#2188)
Browse files Browse the repository at this point in the history
Partial implementation of
#2133.

## Linked Issues/PRs
(FuelLabs/fuel-vm#821)

## Description
It adds handling for the updated data struct `ConsensusParameters` (new
field: `block_transaction_size_limit`). No additional logic around this
new parameter is implemented in this PR, it's just a stub for further
work.

The new parameter is exposed via GraphQL, example:

Request snippet:
```graphql
  consensusParameters(version: 0) {
    blockGasLimit
    blockTransactionSizeLimit
  }
```

Response snippet:
```json
  "consensusParameters": {
    "blockGasLimit": "30000000",
    "blockTransactionSizeLimit": "129024"
  }
```

## Checklist
- [ ] Breaking changes are clearly marked as such in the PR description
and changelog
- [ ] New behavior is reflected in tests
- [ ] [The specification](https://github.com/FuelLabs/fuel-specs/)
matches the implemented behavior (link update PR if changes are needed)

### Before requesting review
- [ ] I have reviewed the code myself
- [ ] I have created follow-up issues caused by this PR and linked them
here

### After merging, notify other teams

[Add or remove entries as needed]

- [ ] [Rust SDK](https://github.com/FuelLabs/fuels-rs/)
- [ ] [Sway compiler](https://github.com/FuelLabs/sway/)
- [ ] [Platform
documentation](https://github.com/FuelLabs/devrel-requests/issues/new?assignees=&labels=new+request&projects=&template=NEW-REQUEST.yml&title=%5BRequest%5D%3A+)
(for out-of-organization contributors, the person merging the PR will do
this)
- [ ] Someone else?

---------

Co-authored-by: green <[email protected]>
Co-authored-by: Hannes Karppila <[email protected]>
  • Loading branch information
3 people authored Sep 17, 2024
1 parent d71d375 commit 0ae006e
Show file tree
Hide file tree
Showing 14 changed files with 179 additions and 62 deletions.
2 changes: 2 additions & 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 All @@ -23,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [2155](https://github.com/FuelLabs/fuel-core/pull/2155): Added trait declaration for block committer data
- [2142](https://github.com/FuelLabs/fuel-core/pull/2142): Added benchmarks for varied forms of db lookups to assist in optimizations.
- [2158](https://github.com/FuelLabs/fuel-core/pull/2158): Log the public address of the signing key, if it is specified
- [2188](https://github.com/FuelLabs/fuel-core/pull/2188): Upgraded the `fuel-vm` to `0.57.0`. More information in the [release](https://github.com/FuelLabs/fuel-vm/releases/tag/v0.57.0).

## [Version 0.35.0]

Expand Down
180 changes: 148 additions & 32 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fuel-core-xtask = { version = "0.0.0", path = "./xtask" }
fuel-gas-price-algorithm = { version = "0.35.0", path = "crates/fuel-gas-price-algorithm" }

# Fuel dependencies
fuel-vm-private = { version = "0.56.0", package = "fuel-vm", default-features = false }
fuel-vm-private = { version = "0.57.0", package = "fuel-vm", default-features = false }

# Common dependencies
anyhow = "1.0"
Expand Down
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.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ expression: json
{
"chain_name": "local_testnet",
"consensus_parameters": {
"V1": {
"V2": {
"tx_params": {
"V1": {
"max_inputs": 255,
Expand Down Expand Up @@ -297,6 +297,7 @@ expression: json
},
"base_asset_id": "0000000000000000000000000000000000000000000000000000000000000000",
"block_gas_limit": 100000000,
"block_transaction_size_limit": 129024,
"privileged_address": "0000000000000000000000000000000000000000000000000000000000000000"
}
},
Expand Down
1 change: 1 addition & 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 Down
6 changes: 5 additions & 1 deletion 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 Down Expand Up @@ -479,14 +480,17 @@ impl TryFrom<ConsensusParameters> for fuel_core_types::fuel_tx::ConsensusParamet
fn try_from(params: ConsensusParameters) -> Result<Self, Self::Error> {
match params.version {
ConsensusParametersVersion::V1 => Ok(
fuel_core_types::fuel_tx::consensus_parameters::ConsensusParametersV1 {
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(),
Expand Down
Loading

0 comments on commit 0ae006e

Please sign in to comment.