Skip to content

Commit

Permalink
Merge branch 'master' into dento/gm-base-asset-id
Browse files Browse the repository at this point in the history
  • Loading branch information
Dentosal authored Mar 25, 2024
2 parents 896fdae + 88158d5 commit 6bf7acc
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
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

- [#705](https://github.com/FuelLabs/fuel-vm/pull/705): Added `privileged_address` to the `ConsensusParameters` for permissioned operations(like upgrade of the network).
- [#648](https://github.com/FuelLabs/fuel-vm/pull/648): Added support for generating proofs for Sparse Merkle Trees (SMTs) and proof verification. Proofs can be used to attest to the inclusion or exclusion of data from the set.

### Changed
Expand Down
1 change: 1 addition & 0 deletions fuel-tx/src/tests/valid_cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub fn test_params() -> ConsensusParameters {
Default::default(),
Default::default(),
Default::default(),
Default::default(),
)
}

Expand Down
33 changes: 22 additions & 11 deletions fuel-tx/src/transaction/consensus_parameters.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use fuel_types::{
bytes::WORD_SIZE,
Address,
AssetId,
Bytes32,
ChainId,
Expand Down Expand Up @@ -53,6 +54,7 @@ impl ConsensusParameters {
gas_costs: GasCosts,
base_asset_id: AssetId,
block_gas_limit: u64,
privileged_address: Address,
) -> Self {
Self::V1(ConsensusParametersV1 {
tx_params,
Expand All @@ -64,6 +66,7 @@ impl ConsensusParameters {
gas_costs,
base_asset_id,
block_gas_limit,
privileged_address,
})
}

Expand Down Expand Up @@ -129,6 +132,13 @@ impl ConsensusParameters {
Self::V1(params) => params.block_gas_limit,
}
}

/// Get the privileged address
pub const fn privileged_address(&self) -> &Address {
match self {
Self::V1(params) => &params.privileged_address,
}
}
}

#[cfg(feature = "builder")]
Expand Down Expand Up @@ -195,6 +205,13 @@ impl ConsensusParameters {
Self::V1(params) => params.block_gas_limit = block_gas_limit,
}
}

/// Set the privileged address.
pub fn set_privileged_address(&mut self, privileged_address: Address) {
match self {
Self::V1(params) => params.privileged_address = privileged_address,
}
}
}

/// A collection of parameters for convenience
Expand All @@ -211,22 +228,15 @@ pub struct ConsensusParametersV1 {
pub gas_costs: GasCosts,
pub base_asset_id: AssetId,
pub block_gas_limit: u64,
/// The privileged address(user or predicate) that can perform permissioned
/// operations(like upgrading the network).
pub privileged_address: Address,
}

impl ConsensusParametersV1 {
/// Constructor for the `ConsensusParameters` with Standard values.
pub fn standard() -> Self {
Self {
tx_params: TxParameters::DEFAULT,
predicate_params: PredicateParameters::DEFAULT,
script_params: ScriptParameters::DEFAULT,
contract_params: ContractParameters::DEFAULT,
fee_params: FeeParameters::DEFAULT,
chain_id: ChainId::default(),
gas_costs: GasCosts::default(),
base_asset_id: Default::default(),
block_gas_limit: TxParameters::DEFAULT.max_gas_per_tx,
}
Self::standard_with_id(ChainId::default())
}

/// Constructor for the `ConsensusParameters` with Standard values around `ChainId`.
Expand All @@ -241,6 +251,7 @@ impl ConsensusParametersV1 {
gas_costs: GasCosts::default(),
base_asset_id: Default::default(),
block_gas_limit: TxParameters::DEFAULT.max_gas_per_tx,
privileged_address: Default::default(),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions fuel-vm/src/checked_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ mod tests {
Default::default(),
Default::default(),
Default::default(),
Default::default(),
)
}

Expand Down
1 change: 1 addition & 0 deletions fuel-vm/src/tests/outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ fn correct_change_is_provided_for_coin_outputs_create() {
context.get_gas_costs().to_owned(),
*context.get_base_asset_id(),
context.get_block_gas_limit(),
*context.get_privileged_address(),
);
let create = create
.into_checked_basic(context.get_block_height(), &consensus_params)
Expand Down
4 changes: 4 additions & 0 deletions fuel-vm/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ pub mod test_helpers {
self.consensus_params.block_gas_limit()
}

pub fn get_privileged_address(&self) -> &Address {
self.consensus_params.privileged_address()
}

pub fn get_chain_id(&self) -> ChainId {
self.consensus_params.chain_id()
}
Expand Down

0 comments on commit 6bf7acc

Please sign in to comment.