Skip to content

Commit

Permalink
[forge] Ability to set onchain config in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ibalajiarun committed Oct 24, 2023
1 parent b870fb9 commit a757f20
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions crates/aptos-genesis/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use aptos_types::{
account_address::{AccountAddress, AccountAddressWithChecks},
chain_id::ChainId,
network_address::{DnsName, NetworkAddress, Protocol},
on_chain_config::OnChainConsensusConfig,
transaction::authenticator::AuthenticationKey,
};
use aptos_vm_genesis::{AccountBalance, EmployeePool, Validator, ValidatorWithCommissionRate};
Expand Down Expand Up @@ -66,6 +67,9 @@ pub struct Layout {
pub employee_vesting_start: Option<u64>,
/// Duration of each vesting period (in seconds).
pub employee_vesting_period_duration: Option<u64>,
/// Onchain Consensus Config
#[serde(default)]
pub on_chain_consensus_config: OnChainConsensusConfig,
}

impl Layout {
Expand Down Expand Up @@ -103,6 +107,7 @@ impl Default for Layout {
total_supply: None,
employee_vesting_start: Some(1663456089),
employee_vesting_period_duration: Some(5 * 60), // 5 minutes
on_chain_consensus_config: OnChainConsensusConfig::default(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/aptos-genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use aptos_vm_genesis::Validator;
use std::convert::TryInto;

/// Holder object for all pieces needed to generate a genesis transaction
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct GenesisInfo {
/// ChainId for identifying the network
chain_id: ChainId,
Expand Down
3 changes: 2 additions & 1 deletion crates/aptos/src/genesis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl CliCommand<Vec<PathBuf>> for GenerateGenesis {
(genesis_bytes, mainnet_genesis.generate_waypoint()?)
} else {
let mut test_genesis = fetch_genesis_info(self.git_options)?;
info!("Using Genesis Info: {:?}", test_genesis);
let genesis_bytes = bcs::to_bytes(test_genesis.clone().get_genesis())
.map_err(|e| CliError::BCS(GENESIS_FILE, e))?;
(genesis_bytes, test_genesis.generate_waypoint()?)
Expand Down Expand Up @@ -294,7 +295,7 @@ pub fn fetch_genesis_info(git_options: GitOptions) -> CliTypedResult<GenesisInfo
voting_power_increase_limit: layout.voting_power_increase_limit,
employee_vesting_start: layout.employee_vesting_start,
employee_vesting_period_duration: layout.employee_vesting_period_duration,
consensus_config: OnChainConsensusConfig::default(),
consensus_config: layout.on_chain_consensus_config,
execution_config: OnChainExecutionConfig::default_for_genesis(),
gas_schedule: default_gas_schedule(),
},
Expand Down
3 changes: 3 additions & 0 deletions terraform/helm/genesis/templates/genesis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ data:
rewards_apy_percentage: {{ .Values.chain.rewards_apy_percentage | int }}
voting_duration_secs: {{ .Values.chain.voting_duration_secs | int }}
voting_power_increase_limit: {{ .Values.chain.voting_power_increase_limit | int }}
{{- if len .Values.chain.on_chain_consensus_config > 1}}
on_chain_consensus_config: {{ .Values.chain.on_chain_consensus_config | mustToJson | quote }}
{{- end}}
---

Expand Down
2 changes: 2 additions & 0 deletions terraform/helm/genesis/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ chain:
rewards_apy_percentage: 10
# -- Minimum price per gas unit
min_price_per_gas_unit: 1
# -- Onchain Consensus Config
on_chain_consensus_config:

# -- Default image tag to use for all tools images
imageTag: testnet
Expand Down
7 changes: 6 additions & 1 deletion testsuite/forge-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ use aptos_forge::{
};
use aptos_logger::{info, Level};
use aptos_rest_client::Client as RestClient;
use aptos_sdk::{move_types::account_address::AccountAddress, transaction_builder::aptos_stdlib};
use aptos_sdk::{
move_types::account_address::AccountAddress, transaction_builder::aptos_stdlib,
types::on_chain_config::OnChainConsensusConfig,
};
use aptos_testcases::{
compatibility_test::SimpleValidatorUpgrade,
consensus_reliability_tests::ChangingWorkingQuorumTest,
Expand Down Expand Up @@ -1775,6 +1778,8 @@ fn realistic_env_max_load_test(
// Have single epoch change in land blocking, and a few on long-running
helm_values["chain"]["epoch_duration_secs"] =
(if long_running { 600 } else { 300 }).into();
helm_values["chain"]["on_chain_consensus_config"] =
OnChainConsensusConfig::default().into();
}))
// First start higher gas-fee traffic, to not cause issues with TxnEmitter setup - account creation
.with_emit_job(
Expand Down

0 comments on commit a757f20

Please sign in to comment.