From e38e9e32e3356af1ef3611d8dcc8eae9348c74d6 Mon Sep 17 00:00:00 2001 From: igor-casper Date: Mon, 21 Oct 2024 14:42:44 +0200 Subject: [PATCH 1/3] remove max-dep chainspec --- node/src/utils/chain_specification.rs | 1 - resources/local/chainspec.toml.in | 2 -- resources/production/chainspec.toml | 2 -- .../transaction_config/deploy_config.rs | 9 ----- types/src/transaction/deploy.rs | 34 +++++++++---------- 5 files changed, 16 insertions(+), 32 deletions(-) diff --git a/node/src/utils/chain_specification.rs b/node/src/utils/chain_specification.rs index b87f079672..899eaa0212 100644 --- a/node/src/utils/chain_specification.rs +++ b/node/src/utils/chain_specification.rs @@ -629,7 +629,6 @@ mod tests { spec.transaction_config.max_ttl, TimeDiff::from_seconds(26_300_160) ); - assert_eq!(spec.transaction_config.deploy_config.max_dependencies, 11); assert_eq!(spec.transaction_config.max_block_size, 12); assert_eq!( spec.transaction_config diff --git a/resources/local/chainspec.toml.in b/resources/local/chainspec.toml.in index dba1042329..4ec02b4ed3 100644 --- a/resources/local/chainspec.toml.in +++ b/resources/local/chainspec.toml.in @@ -205,8 +205,6 @@ wasm_lanes = [[3, 344_064, 1024, 500_000_000_000, 3], [4, 172_032, 1024, 50_000_ [transactions.deploy] # The maximum number of Motes allowed to be spent during payment. 0 means unlimited. max_payment_cost = '0' -# The maximum number of other deploys a deploy can depend on (require to have been executed before it can execute). -max_dependencies = 10 # The limit of length of serialized payment code arguments. payment_args_max_length = 1024 # The limit of length of serialized session code arguments. diff --git a/resources/production/chainspec.toml b/resources/production/chainspec.toml index b06df0aa05..2de2b7134f 100644 --- a/resources/production/chainspec.toml +++ b/resources/production/chainspec.toml @@ -213,8 +213,6 @@ wasm_lanes = [[3, 344_064, 1024, 500_000_000_000, 3], [4, 172_032, 1024, 50_000_ [transactions.deploy] # The maximum number of Motes allowed to be spent during payment. 0 means unlimited. max_payment_cost = '0' -# The maximum number of other deploys a deploy can depend on (require to have been executed before it can execute). -max_dependencies = 10 # The limit of length of serialized payment code arguments. payment_args_max_length = 1024 # The limit of length of serialized session code arguments. diff --git a/types/src/chainspec/transaction_config/deploy_config.rs b/types/src/chainspec/transaction_config/deploy_config.rs index b1aeadcfdc..2a03d28081 100644 --- a/types/src/chainspec/transaction_config/deploy_config.rs +++ b/types/src/chainspec/transaction_config/deploy_config.rs @@ -22,8 +22,6 @@ pub const DEFAULT_MAX_PAYMENT_MOTES: u64 = 2_500_000_000; pub struct DeployConfig { /// Maximum amount any deploy can pay. pub max_payment_cost: Motes, - /// Maximum time to live any deploy can specify. - pub max_dependencies: u8, /// Maximum length in bytes of payment args per deploy. pub payment_args_max_length: u32, /// Maximum length in bytes of session args per deploy. @@ -35,13 +33,11 @@ impl DeployConfig { /// Generates a random instance using a `TestRng`. pub fn random(rng: &mut TestRng) -> Self { let max_payment_cost = Motes::new(rng.gen_range(1_000_000..1_000_000_000)); - let max_dependencies = 0; let payment_args_max_length = rng.gen(); let session_args_max_length = rng.gen(); DeployConfig { max_payment_cost, - max_dependencies, payment_args_max_length, session_args_max_length, } @@ -53,7 +49,6 @@ impl Default for DeployConfig { fn default() -> Self { DeployConfig { max_payment_cost: Motes::new(DEFAULT_MAX_PAYMENT_MOTES), - max_dependencies: 0, payment_args_max_length: 1024, session_args_max_length: 1024, } @@ -63,7 +58,6 @@ impl Default for DeployConfig { impl ToBytes for DeployConfig { fn write_bytes(&self, writer: &mut Vec) -> Result<(), bytesrepr::Error> { self.max_payment_cost.write_bytes(writer)?; - self.max_dependencies.write_bytes(writer)?; self.payment_args_max_length.write_bytes(writer)?; self.session_args_max_length.write_bytes(writer) } @@ -76,7 +70,6 @@ impl ToBytes for DeployConfig { fn serialized_length(&self) -> usize { self.max_payment_cost.value().serialized_length() - + self.max_dependencies.serialized_length() + self.payment_args_max_length.serialized_length() + self.session_args_max_length.serialized_length() } @@ -85,12 +78,10 @@ impl ToBytes for DeployConfig { impl FromBytes for DeployConfig { fn from_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), bytesrepr::Error> { let (max_payment_cost, remainder) = Motes::from_bytes(bytes)?; - let (max_dependencies, remainder) = u8::from_bytes(remainder)?; let (payment_args_max_length, remainder) = u32::from_bytes(remainder)?; let (session_args_max_length, remainder) = u32::from_bytes(remainder)?; let config = DeployConfig { max_payment_cost, - max_dependencies, payment_args_max_length, session_args_max_length, }; diff --git a/types/src/transaction/deploy.rs b/types/src/transaction/deploy.rs index 3177dfa052..519988acc0 100644 --- a/types/src/transaction/deploy.rs +++ b/types/src/transaction/deploy.rs @@ -1755,7 +1755,7 @@ mod tests { let deploy = create_deploy( &mut rng, config.max_ttl, - config.deploy_config.max_dependencies.into(), + 0, &chain_name, GAS_PRICE_TOLERANCE as u64, ); @@ -1780,7 +1780,7 @@ mod tests { let deploy = create_deploy( &mut rng, config.max_ttl, - config.deploy_config.max_dependencies.into(), + 0, &wrong_chain_name, GAS_PRICE_TOLERANCE as u64, ); @@ -1812,12 +1812,10 @@ mod tests { chainspec.with_chain_name(chain_name.to_string()); let config = chainspec.transaction_config.clone(); - let dependency_count = usize::from(config.deploy_config.max_dependencies + 1); - let deploy = create_deploy( &mut rng, config.max_ttl, - dependency_count, + 1, chain_name, GAS_PRICE_TOLERANCE as u64, ); @@ -1851,7 +1849,7 @@ mod tests { let deploy = create_deploy( &mut rng, ttl, - config.deploy_config.max_dependencies.into(), + 0, chain_name, GAS_PRICE_TOLERANCE as u64, ); @@ -1887,7 +1885,7 @@ mod tests { let deploy = create_deploy( &mut rng, config.max_ttl, - config.deploy_config.max_dependencies.into(), + 0, chain_name, GAS_PRICE_TOLERANCE as u64, ); @@ -1924,7 +1922,7 @@ mod tests { let deploy = create_deploy( &mut rng, config.max_ttl, - config.deploy_config.max_dependencies.into(), + 0, chain_name, GAS_PRICE_TOLERANCE as u64, ); @@ -1962,7 +1960,7 @@ mod tests { let mut deploy = create_deploy( &mut rng, config.max_ttl, - config.deploy_config.max_dependencies.into(), + 0, chain_name, GAS_PRICE_TOLERANCE as u64, ); @@ -2011,7 +2009,7 @@ mod tests { let mut deploy = create_deploy( &mut rng, config.max_ttl, - config.deploy_config.max_dependencies.into(), + 0, chain_name, GAS_PRICE_TOLERANCE as u64, ); @@ -2061,7 +2059,7 @@ mod tests { let mut deploy = create_deploy( &mut rng, config.max_ttl, - config.deploy_config.max_dependencies.into(), + 0, chain_name, GAS_PRICE_TOLERANCE as u64, ); @@ -2147,7 +2145,7 @@ mod tests { let deploy = create_deploy( &mut rng, config.max_ttl, - config.deploy_config.max_dependencies as usize, + 0, chain_name, GAS_PRICE_TOLERANCE as u64, ); @@ -2178,7 +2176,7 @@ mod tests { let mut deploy = create_deploy( &mut rng, config.max_ttl, - config.deploy_config.max_dependencies as usize, + 0, chain_name, GAS_PRICE_TOLERANCE as u64, ); @@ -2209,7 +2207,7 @@ mod tests { let mut deploy = create_deploy( &mut rng, config.max_ttl, - config.deploy_config.max_dependencies as usize, + 0, chain_name, GAS_PRICE_TOLERANCE as u64, ); @@ -2244,7 +2242,7 @@ mod tests { let deploy = create_deploy( &mut rng, config.max_ttl, - config.deploy_config.max_dependencies as usize, + 0, chain_name, GAS_PRICE_TOLERANCE as u64, ); @@ -2274,7 +2272,7 @@ mod tests { let mut deploy = create_deploy( &mut rng, config.max_ttl, - config.deploy_config.max_dependencies as usize, + 0, chain_name, GAS_PRICE_TOLERANCE as u64, ); @@ -2334,7 +2332,7 @@ mod tests { let mut deploy = create_deploy( &mut rng, config.max_ttl, - config.deploy_config.max_dependencies.into(), + 0, chain_name, GAS_PRICE_TOLERANCE as u64, ); @@ -2395,7 +2393,7 @@ mod tests { let mut deploy = create_deploy( &mut rng, config.max_ttl, - config.deploy_config.max_dependencies.into(), + 0, chain_name, GAS_PRICE_TOLERANCE as u64, ); From 08b287684e0473f7bff3ed4dd209b69906aa02f0 Mon Sep 17 00:00:00 2001 From: igor-casper Date: Mon, 21 Oct 2024 15:08:49 +0200 Subject: [PATCH 2/3] format and lints --- types/src/transaction/deploy.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/types/src/transaction/deploy.rs b/types/src/transaction/deploy.rs index 519988acc0..fb73765ce0 100644 --- a/types/src/transaction/deploy.rs +++ b/types/src/transaction/deploy.rs @@ -1846,13 +1846,7 @@ mod tests { let ttl = config.max_ttl + TimeDiff::from(Duration::from_secs(1)); - let deploy = create_deploy( - &mut rng, - ttl, - 0, - chain_name, - GAS_PRICE_TOLERANCE as u64, - ); + let deploy = create_deploy(&mut rng, ttl, 0, chain_name, GAS_PRICE_TOLERANCE as u64); let expected_error = InvalidDeploy::ExcessiveTimeToLive { max_ttl: config.max_ttl, From b46df047574d371cd13517bc40051eea72904507 Mon Sep 17 00:00:00 2001 From: igor-casper Date: Tue, 22 Oct 2024 14:11:46 +0200 Subject: [PATCH 3/3] fix a broken rng test --- binary_port/src/response_type.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binary_port/src/response_type.rs b/binary_port/src/response_type.rs index 6be59c9b3e..3ae438e095 100644 --- a/binary_port/src/response_type.rs +++ b/binary_port/src/response_type.rs @@ -145,7 +145,7 @@ impl ResponseType { #[cfg(test)] pub(crate) fn random(rng: &mut TestRng) -> Self { - Self::try_from(rng.gen_range(0..45)).unwrap() + Self::try_from(rng.gen_range(0..=43)).unwrap() } }