From 1f73d8ae01e77b286d5168b0e228a0ebec694e9d Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 24 Oct 2022 09:51:43 +0100 Subject: [PATCH 1/7] add remaining logic to build on ConsensusConstants grpc interface --- applications/tari_app_grpc/proto/types.proto | 79 +++++++++++++++- .../src/conversions/consensus_constants.rs | 93 ++++++++++++++++++- .../src/grpc/base_node_grpc_server.rs | 5 +- 3 files changed, 173 insertions(+), 4 deletions(-) diff --git a/applications/tari_app_grpc/proto/types.proto b/applications/tari_app_grpc/proto/types.proto index a353891e41..350503fc0e 100644 --- a/applications/tari_app_grpc/proto/types.proto +++ b/applications/tari_app_grpc/proto/types.proto @@ -41,6 +41,59 @@ message ComSignature { bytes signature_v = 3; } +/// PoW Algorithm constants +message PowAlgorithmConstants { + uint64 max_target_time = 1; + uint64 min_difficulty = 2; + uint64 max_difficulty = 3; + uint64 target_time = 4; +} + +/// Weight params +message WeightParams { + uint64 kernel_weight = 1; + uint64 input_weight = 2; + uint64 output_weight = 3; + uint64 metadata_bytes_per_gram = 4; +} + +/// Transaction input version +enum TransactionInputVersion { + TRANSACTION_INPUT_V0 = 0; + TRANSACTION_INPUT_V1 = 1; +} + +/// Transaction output version +enum TransactionOutputVersion { + TRANSACTION_OUTPUT_V0 = 0; + TRANSACTION_OUTPUT_V1 = 1; +} + +/// Output features version +enum OutputFeaturesVersion { + OUTPUT_FEATURES_V0 = 0; + OUTPUT_FEATURES_V1 = 1; +} + +/// Output version +message OutputsVersion { + repeated TransactionOutputVersion outputs = 1; + repeated OutputFeaturesVersion features = 2; +} + +/// Kernel version +enum KernelVersion { + KERNEL_V0 = 0; +} + +/// Output types +enum OutputType { + STANDARD = 0; + COINBASE = 1; + BURN = 2; + VALIDATOR_NODE_REGISTRATION = 3; + CODE_TEMPLATE_REGISTRATION = 4; +} /// Consensus Constants response message ConsensusConstants { @@ -48,7 +101,7 @@ message ConsensusConstants { uint64 coinbase_lock_height = 1; /// Current version of the blockchain uint32 blockchain_version = 2; - /// The Future Time Limit (FTL) of the blockchain in seconds. This is the max allowable timestamp that is excepted. + /// The Future Time Limit (FTL) of the blockchain in seconds. Thfis is the max allowable timestamp that is excepted. /// We use TxN/20 where T = target time = 60 seconds, and N = block_window = 150 uint64 future_time_limit = 3; @@ -76,4 +129,28 @@ message ConsensusConstants { uint64 block_weight_outputs = 15; /// Block weight for kernels uint64 block_weight_kernels = 16; + /// This is to keep track of the value inside of the genesis block + uint64 faucet_value = 17; + /// Maximum byte size of TariScript + uint64 max_script_byte_size = 18; + /// How long does it take to timeout validator node registration + uint64 validator_node_timeout = 19; + /// The height at which these constants become effective + uint64 effective_from_height = 20; + /// Current version of the blockchain + repeated uint64 valid_blockchain_version_range = 21; + /// This is the maximum age a monero merge mined seed can be reused + uint64 max_randomx_seed_height = 22; + /// This keeps track of the block split targets and which algo is accepted + repeated PowAlgorithmConstants proof_of_work = 23; + /// Transaction Weight params + WeightParams transaction_weight = 24; + /// Range of valid transaction input versions + repeated TransactionInputVersion input_version_range = 26; + /// Range of valid transaction output (and features) versions + OutputsVersion output_version_range = 27; + /// Range of valid transaction kernel versions + repeated KernelVersion kernel_version_range = 28; + /// An allowlist of output types + repeated OutputType permitted_output_types = 29; } diff --git a/applications/tari_app_grpc/src/conversions/consensus_constants.rs b/applications/tari_app_grpc/src/conversions/consensus_constants.rs index be0b45e28a..be14f14eca 100644 --- a/applications/tari_app_grpc/src/conversions/consensus_constants.rs +++ b/applications/tari_app_grpc/src/conversions/consensus_constants.rs @@ -22,7 +22,10 @@ use std::convert::TryFrom; -use tari_core::{consensus::ConsensusConstants, proof_of_work::PowAlgorithm}; +use tari_core::{ + consensus::ConsensusConstants, + proof_of_work::PowAlgorithm, +}; use crate::tari_rpc as grpc; @@ -30,6 +33,82 @@ impl From for grpc::ConsensusConstants { fn from(cc: ConsensusConstants) -> Self { let (emission_initial, emission_decay, emission_tail) = cc.emission_amounts(); let weight_params = cc.transaction_weight().params(); + let input_version_range = cc.input_version_range().clone().into_inner(); + let input_version_range = if input_version_range.0 != input_version_range.1 { + vec![ + input_version_range.0.as_u8() as i32, + input_version_range.1.as_u8() as i32, + ] + } else { + vec![input_version_range.0.as_u8() as i32] + }; + let kernel_version_range = cc.kernel_version_range().clone().into_inner(); + let kernel_version_range = if kernel_version_range.0 != kernel_version_range.1 { + vec![ + kernel_version_range.0.as_u8() as i32, + kernel_version_range.1.as_u8() as i32, + ] + } else { + vec![kernel_version_range.0.as_u8() as i32] + }; + let valid_blockchain_version_range = cc.valid_blockchain_version_range().clone().into_inner(); + let valid_blockchain_version_range = if valid_blockchain_version_range.0 != valid_blockchain_version_range.1 { + vec![ + valid_blockchain_version_range.0 as u64, + valid_blockchain_version_range.1 as u64, + ] + } else { + vec![valid_blockchain_version_range.0 as u64] + }; + let transaction_weight = cc.transaction_weight(); + let metadata_bytes_per_gram = if let Some(val) = transaction_weight.params().metadata_bytes_per_gram { + u64::from(val) + } else { + 0u64 + }; + let transaction_weight = grpc::WeightParams { + kernel_weight: cc.transaction_weight().params().kernel_weight, + input_weight: cc.transaction_weight().params().input_weight, + output_weight: cc.transaction_weight().params().output_weight, + metadata_bytes_per_gram, + }; + let output_version_range = cc.output_version_range(); + let outputs = vec![ + output_version_range.outputs.start().as_u8() as i32, + output_version_range.outputs.end().as_u8() as i32, + ]; + let features = vec![ + output_version_range.features.start().as_u8() as i32, + output_version_range.features.end().as_u8() as i32, + ]; + + let output_version_range = grpc::OutputsVersion { outputs, features }; + + let permitted_output_types = cc.permitted_output_types(); + let permitted_output_types = permitted_output_types + .iter() + .map(|ot| ot.as_byte() as i32) + .collect::>(); + + let monero_pow = PowAlgorithm::Monero; + let sha3_pow = PowAlgorithm::Sha3; + + let monero_pow = grpc::PowAlgorithmConstants { + max_target_time: cc.get_difficulty_max_block_interval(monero_pow), + max_difficulty: cc.max_pow_difficulty(monero_pow).as_u64(), + min_difficulty: cc.min_pow_difficulty(monero_pow).as_u64(), + target_time: cc.get_diff_target_block_interval(monero_pow), + }; + + let sha3_pow = grpc::PowAlgorithmConstants { + max_target_time: cc.get_difficulty_max_block_interval(sha3_pow), + max_difficulty: cc.max_pow_difficulty(sha3_pow).as_u64(), + min_difficulty: cc.min_pow_difficulty(sha3_pow).as_u64(), + target_time: cc.get_diff_target_block_interval(sha3_pow), + }; + + let proof_of_work = vec![monero_pow, sha3_pow]; + Self { coinbase_lock_height: cc.coinbase_lock_height(), blockchain_version: cc.blockchain_version().into(), @@ -46,6 +125,18 @@ impl From for grpc::ConsensusConstants { block_weight_inputs: weight_params.input_weight, block_weight_outputs: weight_params.output_weight, block_weight_kernels: weight_params.kernel_weight, + validator_node_timeout: cc.validator_node_timeout(), + max_script_byte_size: cc.get_max_script_byte_size() as u64, + faucet_value: cc.faucet_value().as_u64(), + effective_from_height: cc.effective_from_height(), + input_version_range, + kernel_version_range, + valid_blockchain_version_range, + proof_of_work, + transaction_weight: Some(transaction_weight), + max_randomx_seed_height: cc.max_randomx_seed_height(), + output_version_range: Some(output_version_range), + permitted_output_types, } } } diff --git a/applications/tari_base_node/src/grpc/base_node_grpc_server.rs b/applications/tari_base_node/src/grpc/base_node_grpc_server.rs index e82ca58d9c..adb59026cc 100644 --- a/applications/tari_base_node/src/grpc/base_node_grpc_server.rs +++ b/applications/tari_base_node/src/grpc/base_node_grpc_server.rs @@ -1675,9 +1675,10 @@ impl tari_rpc::base_node_server::BaseNode for BaseNodeGrpcServer { let sidechain_outputs = utxos .into_iter() .filter(|u| u.features.output_type.is_sidechain_type()) - .collect::>(); + .map(TryInto::try_into) + .collect::, _>>(); - match sidechain_outputs.into_iter().map(TryInto::try_into).collect() { + match sidechain_outputs { Ok(outputs) => { let resp = tari_rpc::GetSideChainUtxosResponse { block_info: Some(tari_rpc::BlockInfo { From b0555c696973a99d45ca6e3b8314827dfe7b0d54 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 24 Oct 2022 10:35:18 +0100 Subject: [PATCH 2/7] address some PR comments --- applications/tari_app_grpc/proto/types.proto | 12 ++++-- .../src/conversions/consensus_constants.rs | 38 +++++++++---------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/applications/tari_app_grpc/proto/types.proto b/applications/tari_app_grpc/proto/types.proto index 350503fc0e..c3cb8b2a16 100644 --- a/applications/tari_app_grpc/proto/types.proto +++ b/applications/tari_app_grpc/proto/types.proto @@ -23,6 +23,12 @@ syntax = "proto3"; package tari.rpc; +/// A range interface to more accurately represent Rust native Range's +message Range { + uint64 min = 1; + uint64 max = 2; +} + /// An Empty placeholder for endpoints without request parameters message Empty {} @@ -77,8 +83,8 @@ enum OutputFeaturesVersion { /// Output version message OutputsVersion { - repeated TransactionOutputVersion outputs = 1; - repeated OutputFeaturesVersion features = 2; + Range outputs = 1; + Range features = 2; } /// Kernel version @@ -138,7 +144,7 @@ message ConsensusConstants { /// The height at which these constants become effective uint64 effective_from_height = 20; /// Current version of the blockchain - repeated uint64 valid_blockchain_version_range = 21; + Range valid_blockchain_version_range = 21; /// This is the maximum age a monero merge mined seed can be reused uint64 max_randomx_seed_height = 22; /// This keeps track of the block split targets and which algo is accepted diff --git a/applications/tari_app_grpc/src/conversions/consensus_constants.rs b/applications/tari_app_grpc/src/conversions/consensus_constants.rs index be14f14eca..6bed30444d 100644 --- a/applications/tari_app_grpc/src/conversions/consensus_constants.rs +++ b/applications/tari_app_grpc/src/conversions/consensus_constants.rs @@ -22,10 +22,7 @@ use std::convert::TryFrom; -use tari_core::{ - consensus::ConsensusConstants, - proof_of_work::PowAlgorithm, -}; +use tari_core::{consensus::ConsensusConstants, proof_of_work::PowAlgorithm}; use crate::tari_rpc as grpc; @@ -52,13 +49,9 @@ impl From for grpc::ConsensusConstants { vec![kernel_version_range.0.as_u8() as i32] }; let valid_blockchain_version_range = cc.valid_blockchain_version_range().clone().into_inner(); - let valid_blockchain_version_range = if valid_blockchain_version_range.0 != valid_blockchain_version_range.1 { - vec![ - valid_blockchain_version_range.0 as u64, - valid_blockchain_version_range.1 as u64, - ] - } else { - vec![valid_blockchain_version_range.0 as u64] + let valid_blockchain_version_range = grpc::Range { + min: valid_blockchain_version_range.0 as u64, + max: valid_blockchain_version_range.1 as u64, }; let transaction_weight = cc.transaction_weight(); let metadata_bytes_per_gram = if let Some(val) = transaction_weight.params().metadata_bytes_per_gram { @@ -73,16 +66,19 @@ impl From for grpc::ConsensusConstants { metadata_bytes_per_gram, }; let output_version_range = cc.output_version_range(); - let outputs = vec![ - output_version_range.outputs.start().as_u8() as i32, - output_version_range.outputs.end().as_u8() as i32, - ]; - let features = vec![ - output_version_range.features.start().as_u8() as i32, - output_version_range.features.end().as_u8() as i32, - ]; + let outputs = grpc::Range { + min: output_version_range.outputs.start().as_u8() as u64, + max: output_version_range.outputs.end().as_u8() as u64, + }; + let features = grpc::Range { + min: output_version_range.features.start().as_u8() as u64, + max: output_version_range.features.end().as_u8() as u64, + }; - let output_version_range = grpc::OutputsVersion { outputs, features }; + let output_version_range = grpc::OutputsVersion { + outputs: Some(outputs), + features: Some(features), + }; let permitted_output_types = cc.permitted_output_types(); let permitted_output_types = permitted_output_types @@ -131,7 +127,7 @@ impl From for grpc::ConsensusConstants { effective_from_height: cc.effective_from_height(), input_version_range, kernel_version_range, - valid_blockchain_version_range, + valid_blockchain_version_range: Some(valid_blockchain_version_range), proof_of_work, transaction_weight: Some(transaction_weight), max_randomx_seed_height: cc.max_randomx_seed_height(), From dca789abe08d648be113bcc422c957b9447b8494 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 24 Oct 2022 10:36:43 +0100 Subject: [PATCH 3/7] correct grammar error --- applications/tari_app_grpc/proto/types.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/tari_app_grpc/proto/types.proto b/applications/tari_app_grpc/proto/types.proto index c3cb8b2a16..daef4f65b2 100644 --- a/applications/tari_app_grpc/proto/types.proto +++ b/applications/tari_app_grpc/proto/types.proto @@ -107,7 +107,7 @@ message ConsensusConstants { uint64 coinbase_lock_height = 1; /// Current version of the blockchain uint32 blockchain_version = 2; - /// The Future Time Limit (FTL) of the blockchain in seconds. Thfis is the max allowable timestamp that is excepted. + /// The Future Time Limit (FTL) of the blockchain in seconds. This is the max allowable timestamp that is excepted. /// We use TxN/20 where T = target time = 60 seconds, and N = block_window = 150 uint64 future_time_limit = 3; From ef17979fb9c15af35a3cab86c8b2bc1818afc5f7 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 24 Oct 2022 11:05:51 +0100 Subject: [PATCH 4/7] cargo clippy --- .../src/conversions/consensus_constants.rs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/applications/tari_app_grpc/src/conversions/consensus_constants.rs b/applications/tari_app_grpc/src/conversions/consensus_constants.rs index 6bed30444d..0e376699ff 100644 --- a/applications/tari_app_grpc/src/conversions/consensus_constants.rs +++ b/applications/tari_app_grpc/src/conversions/consensus_constants.rs @@ -33,25 +33,25 @@ impl From for grpc::ConsensusConstants { let input_version_range = cc.input_version_range().clone().into_inner(); let input_version_range = if input_version_range.0 != input_version_range.1 { vec![ - input_version_range.0.as_u8() as i32, - input_version_range.1.as_u8() as i32, + i32::from(input_version_range.0.as_u8()), + i32::from(input_version_range.1.as_u8()), ] } else { - vec![input_version_range.0.as_u8() as i32] + vec![i32::from(input_version_range.0.as_u8())] }; let kernel_version_range = cc.kernel_version_range().clone().into_inner(); let kernel_version_range = if kernel_version_range.0 != kernel_version_range.1 { vec![ - kernel_version_range.0.as_u8() as i32, - kernel_version_range.1.as_u8() as i32, + i32::from(kernel_version_range.0.as_u8()), + i32::from(kernel_version_range.1.as_u8()), ] } else { vec![kernel_version_range.0.as_u8() as i32] }; let valid_blockchain_version_range = cc.valid_blockchain_version_range().clone().into_inner(); let valid_blockchain_version_range = grpc::Range { - min: valid_blockchain_version_range.0 as u64, - max: valid_blockchain_version_range.1 as u64, + min: u64::from(valid_blockchain_version_range.0), + max: u64::from(valid_blockchain_version_range.1), }; let transaction_weight = cc.transaction_weight(); let metadata_bytes_per_gram = if let Some(val) = transaction_weight.params().metadata_bytes_per_gram { @@ -67,12 +67,12 @@ impl From for grpc::ConsensusConstants { }; let output_version_range = cc.output_version_range(); let outputs = grpc::Range { - min: output_version_range.outputs.start().as_u8() as u64, - max: output_version_range.outputs.end().as_u8() as u64, + min: u64::from(output_version_range.outputs.start().as_u8()), + max: u64::from(output_version_range.outputs.end().as_u8()), }; let features = grpc::Range { - min: output_version_range.features.start().as_u8() as u64, - max: output_version_range.features.end().as_u8() as u64, + min: u64::from(output_version_range.features.start().as_u8()), + max: u64::from(output_version_range.features.end().as_u8()), }; let output_version_range = grpc::OutputsVersion { @@ -83,7 +83,7 @@ impl From for grpc::ConsensusConstants { let permitted_output_types = cc.permitted_output_types(); let permitted_output_types = permitted_output_types .iter() - .map(|ot| ot.as_byte() as i32) + .map(|ot| i32::from(ot.as_byte())) .collect::>(); let monero_pow = PowAlgorithm::Monero; From 467d6604f8952e13c8a03e87f4c966abbd5f7855 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 24 Oct 2022 11:44:34 +0100 Subject: [PATCH 5/7] further refactoring --- applications/tari_app_grpc/proto/types.proto | 31 +++---------------- .../src/conversions/consensus_constants.rs | 28 ++++++----------- 2 files changed, 14 insertions(+), 45 deletions(-) diff --git a/applications/tari_app_grpc/proto/types.proto b/applications/tari_app_grpc/proto/types.proto index daef4f65b2..da44dda3d4 100644 --- a/applications/tari_app_grpc/proto/types.proto +++ b/applications/tari_app_grpc/proto/types.proto @@ -23,7 +23,7 @@ syntax = "proto3"; package tari.rpc; -/// A range interface to more accurately represent Rust native Range's +/// An unsigned range interface to more accurately represent Rust native Range's message Range { uint64 min = 1; uint64 max = 2; @@ -63,35 +63,12 @@ message WeightParams { uint64 metadata_bytes_per_gram = 4; } -/// Transaction input version -enum TransactionInputVersion { - TRANSACTION_INPUT_V0 = 0; - TRANSACTION_INPUT_V1 = 1; -} - -/// Transaction output version -enum TransactionOutputVersion { - TRANSACTION_OUTPUT_V0 = 0; - TRANSACTION_OUTPUT_V1 = 1; -} - -/// Output features version -enum OutputFeaturesVersion { - OUTPUT_FEATURES_V0 = 0; - OUTPUT_FEATURES_V1 = 1; -} - /// Output version message OutputsVersion { Range outputs = 1; Range features = 2; } -/// Kernel version -enum KernelVersion { - KERNEL_V0 = 0; -} - /// Output types enum OutputType { STANDARD = 0; @@ -148,15 +125,15 @@ message ConsensusConstants { /// This is the maximum age a monero merge mined seed can be reused uint64 max_randomx_seed_height = 22; /// This keeps track of the block split targets and which algo is accepted - repeated PowAlgorithmConstants proof_of_work = 23; + map proof_of_work = 23; /// Transaction Weight params WeightParams transaction_weight = 24; /// Range of valid transaction input versions - repeated TransactionInputVersion input_version_range = 26; + Range input_version_range = 26; /// Range of valid transaction output (and features) versions OutputsVersion output_version_range = 27; /// Range of valid transaction kernel versions - repeated KernelVersion kernel_version_range = 28; + Range kernel_version_range = 28; /// An allowlist of output types repeated OutputType permitted_output_types = 29; } diff --git a/applications/tari_app_grpc/src/conversions/consensus_constants.rs b/applications/tari_app_grpc/src/conversions/consensus_constants.rs index 0e376699ff..e35256a08e 100644 --- a/applications/tari_app_grpc/src/conversions/consensus_constants.rs +++ b/applications/tari_app_grpc/src/conversions/consensus_constants.rs @@ -20,7 +20,7 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use std::convert::TryFrom; +use std::{collections::HashMap, convert::TryFrom, iter::FromIterator}; use tari_core::{consensus::ConsensusConstants, proof_of_work::PowAlgorithm}; @@ -31,22 +31,14 @@ impl From for grpc::ConsensusConstants { let (emission_initial, emission_decay, emission_tail) = cc.emission_amounts(); let weight_params = cc.transaction_weight().params(); let input_version_range = cc.input_version_range().clone().into_inner(); - let input_version_range = if input_version_range.0 != input_version_range.1 { - vec![ - i32::from(input_version_range.0.as_u8()), - i32::from(input_version_range.1.as_u8()), - ] - } else { - vec![i32::from(input_version_range.0.as_u8())] + let input_version_range = grpc::Range { + min: u64::from(input_version_range.0.as_u8()), + max: u64::from(input_version_range.1.as_u8()), }; let kernel_version_range = cc.kernel_version_range().clone().into_inner(); - let kernel_version_range = if kernel_version_range.0 != kernel_version_range.1 { - vec![ - i32::from(kernel_version_range.0.as_u8()), - i32::from(kernel_version_range.1.as_u8()), - ] - } else { - vec![kernel_version_range.0.as_u8() as i32] + let kernel_version_range = grpc::Range { + min: u64::from(kernel_version_range.0.as_u8()), + max: u64::from(kernel_version_range.1.as_u8()), }; let valid_blockchain_version_range = cc.valid_blockchain_version_range().clone().into_inner(); let valid_blockchain_version_range = grpc::Range { @@ -103,7 +95,7 @@ impl From for grpc::ConsensusConstants { target_time: cc.get_diff_target_block_interval(sha3_pow), }; - let proof_of_work = vec![monero_pow, sha3_pow]; + let proof_of_work = HashMap::from_iter([(0u32, monero_pow), (1u32, sha3_pow)]); Self { coinbase_lock_height: cc.coinbase_lock_height(), @@ -125,8 +117,8 @@ impl From for grpc::ConsensusConstants { max_script_byte_size: cc.get_max_script_byte_size() as u64, faucet_value: cc.faucet_value().as_u64(), effective_from_height: cc.effective_from_height(), - input_version_range, - kernel_version_range, + input_version_range: Some(input_version_range), + kernel_version_range: Some(kernel_version_range), valid_blockchain_version_range: Some(valid_blockchain_version_range), proof_of_work, transaction_weight: Some(transaction_weight), From 6159c3b951c1c94e5264d4c76221c4217905ef56 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 24 Oct 2022 11:49:52 +0100 Subject: [PATCH 6/7] add constructor to TransactionOutput type --- base_layer/core/src/transactions/weight.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/base_layer/core/src/transactions/weight.rs b/base_layer/core/src/transactions/weight.rs index aedb0c83c2..9271aa65c5 100644 --- a/base_layer/core/src/transactions/weight.rs +++ b/base_layer/core/src/transactions/weight.rs @@ -52,6 +52,11 @@ impl WeightParams { pub struct TransactionWeight(WeightParams); impl TransactionWeight { + /// Constructor + pub fn new(weight_params: WeightParams) -> Self { + Self(weight_params) + } + /// Creates a new `TransactionWeight` with latest weight params pub fn latest() -> Self { Self(WeightParams::v1()) From 1438a0a95d09fcab3e9fc63266375df418a0986d Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 24 Oct 2022 11:56:02 +0100 Subject: [PATCH 7/7] cargo fmt --- base_layer/core/src/transactions/weight.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base_layer/core/src/transactions/weight.rs b/base_layer/core/src/transactions/weight.rs index 9271aa65c5..9c38dbbbde 100644 --- a/base_layer/core/src/transactions/weight.rs +++ b/base_layer/core/src/transactions/weight.rs @@ -56,7 +56,7 @@ impl TransactionWeight { pub fn new(weight_params: WeightParams) -> Self { Self(weight_params) } - + /// Creates a new `TransactionWeight` with latest weight params pub fn latest() -> Self { Self(WeightParams::v1())