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 block_transaction_size_limit to ConsensusParameters #821

Merged
merged 13 commits into from
Sep 16, 2024

Conversation

rafal-ch
Copy link
Contributor

@rafal-ch rafal-ch commented Sep 11, 2024

Partial implementation of FuelLabs/fuel-core#2133.

This PR adds a new version (V2) of the ConsensusParameters which includes the block_transaction_size_limit parameter.

Linked Issues/PRs

FuelLabs/fuel-core#2188

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • The specification 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]

Comment on lines 52 to 56
#[cfg(feature = "test-helpers")]
/// Constructor for the `ConsensusParameters` with Standard values.
pub fn standard_v2() -> Self {
ConsensusParametersV2::standard().into()
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can just use only standard=)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in a1ddd07

CHANGELOG.md Outdated Show resolved Hide resolved
@@ -273,6 +332,63 @@ impl From<ConsensusParametersV1> for ConsensusParameters {
}
}

/// A collection of parameters for convenience
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice to mention what is the difference between V1 and V2 here=) You can check how we do it for GasCosts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update in 65087ba

Comment on lines 162 to 165
Self::V1(params) => params
.block_gas_limit
.checked_div(self.fee_params().gas_per_byte())
.unwrap_or(Self::DEFAULT_BLOCK_TRANSACTION_SIZE_LIMIT),
Copy link
Collaborator

Choose a reason for hiding this comment

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

After thinking a little bit more about it, I think we need to return u64::MAX for backward compatibility reasons. Because in the past it was not limited

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in 7b8c998

pub gas_costs: GasCosts,
pub base_asset_id: AssetId,
pub block_gas_limit: u64,
pub block_transaction_size_limit: u64,
Copy link
Contributor

@acerone85 acerone85 Sep 12, 2024

Choose a reason for hiding this comment

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

This is not related to this PR only, but in general I think we should strive to have as much documentation as possible, including individual fields of structs.

For example in this case it is not 100% clear if block_transaction_size_limit refers to the number of transactions in a block, or the number of bytes in a transaction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we could enforce this with missing_docs lint, but it'll cause a swarm of warnings.

Also, I see an indication that it is already on our radar.

xgreenx
xgreenx previously approved these changes Sep 12, 2024
Copy link
Member

@rymnc rymnc left a comment

Choose a reason for hiding this comment

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

LGTM, a test which asserts SettingBlockTransactionSizeLimitNotSupported is thrown would be nice :)

@rafal-ch
Copy link
Contributor Author

LGTM, a test which asserts SettingBlockTransactionSizeLimitNotSupported is thrown would be nice :)

Test added in d07fbc3

@acerone85
Copy link
Contributor

Checked the code again, LGTM.

@rafal-ch rafal-ch added this pull request to the merge queue Sep 16, 2024
Merged via the queue into master with commit 2999f40 Sep 16, 2024
39 checks passed
@rafal-ch rafal-ch deleted the 2133_block_size_consensus_parameter branch September 16, 2024 12:49
@xgreenx xgreenx mentioned this pull request Sep 17, 2024
Dentosal added a commit to FuelLabs/fuel-core that referenced this pull request Sep 17, 2024
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 <xgreenx9999@gmail.com>
Co-authored-by: Hannes Karppila <2204863+Dentosal@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants