Skip to content

Commit

Permalink
Make ConsensusParameters Serialize/Derserialize again (#526)
Browse files Browse the repository at this point in the history
* Make `ConsensusParameters` Serialize/Derserialize again

* Update CHANGELOG
  • Loading branch information
MitchTurner authored Jul 25, 2023
1 parent e278038 commit 98019fd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

Description of the upcoming release here.
- [#514](https://github.com/FuelLabs/fuel-vm/pull/514/): Add `ClientId` and `GasCosts` to `ConsensusParameters`.
Break down `ConsensusParameters` into sub-structs to match usage. Change signatures of functions to ask for
necessary fields only.

## [Version 0.35.1]

Expand Down
10 changes: 9 additions & 1 deletion fuel-tx/src/transaction/consensus_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ pub use gas::{
const MAX_GAS: u64 = 100_000_000;

/// A collection of parameters for convenience
#[derive(Debug, Clone)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(default))]
pub struct ConsensusParameters {
pub tx_params: TxParameters,
pub predicate_params: PredicateParameters,
Expand All @@ -28,6 +30,12 @@ pub struct ConsensusParameters {
pub gas_costs: GasCosts,
}

impl Default for ConsensusParameters {
fn default() -> Self {
Self::standard(ChainId::default())
}
}

impl ConsensusParameters {
/// Constructor for the `ConsensusParameters` with Standard values
pub fn standard(chain_id: ChainId) -> Self {
Expand Down
6 changes: 3 additions & 3 deletions fuel-tx/src/transaction/consensus_parameters/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl GasUnit {
}
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
/// Gas costings for every op.
/// The inner values are wrapped in an [`Arc`]
Expand Down Expand Up @@ -173,7 +173,7 @@ impl Default for GasCostsValues {
}

#[allow(missing_docs)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(default = "GasCostsValues::unit"))]
/// Gas costs for every op.
Expand Down Expand Up @@ -289,7 +289,7 @@ pub struct GasCostsValues {
pub srwq: DependentCost,
}

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
/// Dependent cost is a cost that depends on the number of units.
/// The cost starts at the base and grows by `dep_per_unit` for every unit.
Expand Down

0 comments on commit 98019fd

Please sign in to comment.