Skip to content

Commit

Permalink
Merge #4922
Browse files Browse the repository at this point in the history
4922: Remove max_dependencies from chainspec r=igor-casper a=igor-casper

Addresses #4567 by removing the max_dependencies setting from chainspec.

This was not supported before, and is still not supported in 2.0

Co-authored-by: igor-casper <[email protected]>
Co-authored-by: igor-casper <[email protected]>
  • Loading branch information
3 people authored Oct 22, 2024
2 parents 7971492 + 5e1fe75 commit 9669f5b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 38 deletions.
1 change: 0 additions & 1 deletion node/src/utils/chain_specification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,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
Expand Down
2 changes: 0 additions & 2 deletions resources/local/chainspec.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions resources/production/chainspec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 0 additions & 9 deletions types/src/chainspec/transaction_config/deploy_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
}
Expand All @@ -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,
}
Expand All @@ -63,7 +58,6 @@ impl Default for DeployConfig {
impl ToBytes for DeployConfig {
fn write_bytes(&self, writer: &mut Vec<u8>) -> 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)
}
Expand All @@ -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()
}
Expand All @@ -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,
};
Expand Down
40 changes: 16 additions & 24 deletions types/src/transaction/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand All @@ -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,
);
Expand Down Expand Up @@ -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,
);
Expand Down Expand Up @@ -1848,13 +1846,7 @@ mod tests {

let ttl = config.max_ttl + TimeDiff::from(Duration::from_secs(1));

let deploy = create_deploy(
&mut rng,
ttl,
config.deploy_config.max_dependencies.into(),
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,
Expand Down Expand Up @@ -1887,7 +1879,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,
);
Expand Down Expand Up @@ -1924,7 +1916,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,
);
Expand Down Expand Up @@ -1962,7 +1954,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,
);
Expand Down Expand Up @@ -2011,7 +2003,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,
);
Expand Down Expand Up @@ -2061,7 +2053,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,
);
Expand Down Expand Up @@ -2147,7 +2139,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,
);
Expand Down Expand Up @@ -2178,7 +2170,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,
);
Expand Down Expand Up @@ -2209,7 +2201,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,
);
Expand Down Expand Up @@ -2244,7 +2236,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,
);
Expand Down Expand Up @@ -2274,7 +2266,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,
);
Expand Down Expand Up @@ -2334,7 +2326,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,
);
Expand Down Expand Up @@ -2395,7 +2387,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,
);
Expand Down

0 comments on commit 9669f5b

Please sign in to comment.