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

Make ConsensusParameters Serialize/Derserialize again #526

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading