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

Enforce the block size limit #2195

Merged
merged 53 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
fa1288b
Add support for `ConsensusParametersVersion::V2`
rafal-ch Sep 11, 2024
0c65bbe
Update `CHANGELOG.md`
rafal-ch Sep 11, 2024
25432d2
Remove the temporary comment
rafal-ch Sep 12, 2024
0a0b6c2
Fix imports in tests
rafal-ch Sep 12, 2024
3068d2f
`#[allow(clippy::large_enum_variant)]` for `enum FakeProducedBlock` a…
rafal-ch Sep 12, 2024
0656491
Update expected GraphQL schema
rafal-ch Sep 12, 2024
a1ea188
Update `state_transition_bytecode.wasm`
rafal-ch Sep 12, 2024
345a03f
Thread the `block_transaction_size_limit` parameter across the system
rafal-ch Sep 12, 2024
256dfb7
Add `used_size` to `ExecutionData`
rafal-ch Sep 13, 2024
960745c
Remove stray comment
rafal-ch Sep 13, 2024
ecb57d8
Transaction selector respects block size limit
rafal-ch Sep 13, 2024
a75d865
`select_transactions()` does not need to `collect()`
rafal-ch Sep 13, 2024
6e2bf19
Split test cases using `rstest`
rafal-ch Sep 13, 2024
7c14352
Merge remote-tracking branch 'upstream/master' into 2133_block_size_c…
rafal-ch Sep 13, 2024
c002c0c
Applying several breaking changes to the WASM interface from backlog
xgreenx Sep 15, 2024
2cfcaa5
Make CI happy
xgreenx Sep 15, 2024
af91864
Merge branch 'master' into feature/wasm-interface-breaking-changes
xgreenx Sep 15, 2024
8032b7a
Remove timeout error because bytecode is not compiled
xgreenx Sep 15, 2024
94851b8
Use always compiled WASM bytecode for local testnet
xgreenx Sep 15, 2024
b7d8da6
Merge branch 'feature/wasm-interface-breaking-changes' into 2133_bloc…
rafal-ch Sep 16, 2024
96b4c7c
Merge branch '2133_block_size_consensus_parameter' into 2133_enforce_…
rafal-ch Sep 16, 2024
c85879b
Update patch for `fuel-vm` to `master` branch
rafal-ch Sep 16, 2024
309d1af
Merge branch '2133_block_size_consensus_parameter' into 2133_enforce_…
rafal-ch Sep 16, 2024
03004ac
Add integration test verifying the block size limit enforcement
rafal-ch Sep 17, 2024
7851fb1
Add more integration tests for block transaction size limit
rafal-ch Sep 17, 2024
445a51c
Merge remote-tracking branch 'upstream/master' into 2133_enforce_the_…
rafal-ch Sep 18, 2024
7e27fd6
Update CHANGELOG.md
rafal-ch Sep 18, 2024
b408669
Updates after the master merge
rafal-ch Sep 18, 2024
a8263fd
Simplify creation of transactions in tests
rafal-ch Sep 18, 2024
d01dcff
Revert changes to `state_transition_bytecode.wasm`
rafal-ch Sep 18, 2024
0b7633b
Merge branch 'master' into 2133_enforce_the_block_size_limit
xgreenx Sep 18, 2024
99099e6
Merge remote-tracking branch 'upstream/master' into 2133_enforce_the_…
rafal-ch Sep 20, 2024
70dbe06
Remove patch to `fuel-vm` from `Cargo.toml`
rafal-ch Sep 20, 2024
e7e3102
Merge remote-tracking branch 'upstream/2133_enforce_the_block_size_li…
rafal-ch Sep 20, 2024
f62fa43
Fix formatting
rafal-ch Sep 20, 2024
af8164c
Add missing comment
rafal-ch Sep 20, 2024
82949df
Set block transaction size limit in E2E tests to large value
rafal-ch Sep 20, 2024
474a81d
Update `too_many_transactions_are_split_in_blocks()` test to not fail…
rafal-ch Sep 20, 2024
9fdf1f7
Do not re-introduce `V2` in the `ConsensusParametersVersion` schema
rafal-ch Sep 20, 2024
f9b95c1
Update comment
rafal-ch Sep 20, 2024
010baf9
Merge branch 'master' into 2133_enforce_the_block_size_limit
xgreenx Sep 20, 2024
9bdea6d
Revert changes to `Cargo.lock`
rafal-ch Sep 21, 2024
36ab508
Simplify code of `select_transactions()` by using `saturating_add()`
rafal-ch Sep 21, 2024
15a2cf7
Remove superfluous calls to `tokio::time::sleep` in tests
rafal-ch Sep 21, 2024
26fd531
Merge remote-tracking branch 'upstream/2133_enforce_the_block_size_li…
rafal-ch Sep 21, 2024
251c01d
Merge branch 'master' into 2133_enforce_the_block_size_limit
xgreenx Sep 24, 2024
be29818
Merge branch 'master' into 2133_enforce_the_block_size_limit
xgreenx Sep 25, 2024
92da3b0
Merge remote-tracking branch 'upstream/master' into 2133_enforce_the_…
rafal-ch Sep 25, 2024
70e9178
Merge remote-tracking branch 'upstream/2133_enforce_the_block_size_li…
rafal-ch Sep 25, 2024
ef22a3b
Merge branch 'master' into 2133_enforce_the_block_size_limit
xgreenx Sep 25, 2024
e748837
Change `block_transaction_size_limit` to be `u32` instead of `u64`
rafal-ch Sep 26, 2024
0872751
Merge remote-tracking branch 'upstream/2133_enforce_the_block_size_li…
rafal-ch Sep 26, 2024
c226aee
Merge branch 'master' into 2133_enforce_the_block_size_limit
rafal-ch Sep 26, 2024
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.

### 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!
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
8 changes: 6 additions & 2 deletions crates/fuel-core/src/service/adapters/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ use fuel_core_types::{
};

impl fuel_core_executor::ports::TransactionsSource for TransactionsSource {
fn next(&self, gas_limit: u64) -> Vec<MaybeCheckedTransaction> {
fn next(
&self,
gas_limit: u64,
block_transaction_size_limit: u64,
) -> Vec<MaybeCheckedTransaction> {
self.txpool
.select_transactions(gas_limit)
.select_transactions(gas_limit, block_transaction_size_limit)
.into_iter()
.map(|tx| {
MaybeCheckedTransaction::CheckedTransaction(
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
Loading
Loading