mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-05-31 07:11:01 +00:00
User Managed Nodes (#189)
* Allow for genesis to be exported by the tool * Allow for substrate-based nodes to be managed by the user * Rename the commandline argument * Rename the commandline argument * Move existing rpc option to revive-dev-node * Remove unneeded test * Remove un-required function in cached compiler * Change the default concurrency limit * Update the default number of threads * Update readme * Remove accidentally comitted dir * Update the readme * Update the readme
This commit is contained in:
+121
-26
@@ -34,6 +34,9 @@ pub enum Context {
|
||||
|
||||
/// Exports the JSON schema of the MatterLabs test format used by the tool.
|
||||
ExportJsonSchema,
|
||||
|
||||
/// Exports the genesis file of the desired platform.
|
||||
ExportGenesis(Box<ExportGenesisContext>),
|
||||
}
|
||||
|
||||
impl Context {
|
||||
@@ -51,7 +54,7 @@ impl AsRef<WorkingDirectoryConfiguration> for Context {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(context) => context.as_ref().as_ref(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
Self::ExportJsonSchema | Self::ExportGenesis(..) => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,7 +64,7 @@ impl AsRef<CorpusConfiguration> for Context {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(context) => context.as_ref().as_ref(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
Self::ExportJsonSchema | Self::ExportGenesis(..) => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,7 +74,7 @@ impl AsRef<SolcConfiguration> for Context {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(context) => context.as_ref().as_ref(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
Self::ExportJsonSchema | Self::ExportGenesis(..) => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,7 +84,7 @@ impl AsRef<ResolcConfiguration> for Context {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(context) => context.as_ref().as_ref(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
Self::ExportJsonSchema | Self::ExportGenesis(..) => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,6 +94,7 @@ impl AsRef<GethConfiguration> for Context {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(context) => context.as_ref().as_ref(),
|
||||
Self::ExportGenesis(context) => context.as_ref().as_ref(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
}
|
||||
}
|
||||
@@ -101,6 +105,7 @@ impl AsRef<KurtosisConfiguration> for Context {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(context) => context.as_ref().as_ref(),
|
||||
Self::ExportGenesis(context) => context.as_ref().as_ref(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
}
|
||||
}
|
||||
@@ -111,6 +116,7 @@ impl AsRef<PolkadotParachainConfiguration> for Context {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(context) => context.as_ref().as_ref(),
|
||||
Self::ExportGenesis(context) => context.as_ref().as_ref(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
}
|
||||
}
|
||||
@@ -121,6 +127,7 @@ impl AsRef<KitchensinkConfiguration> for Context {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(context) => context.as_ref().as_ref(),
|
||||
Self::ExportGenesis(context) => context.as_ref().as_ref(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
}
|
||||
}
|
||||
@@ -131,6 +138,7 @@ impl AsRef<ReviveDevNodeConfiguration> for Context {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(context) => context.as_ref().as_ref(),
|
||||
Self::ExportGenesis(context) => context.as_ref().as_ref(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
}
|
||||
}
|
||||
@@ -141,7 +149,7 @@ impl AsRef<EthRpcConfiguration> for Context {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(context) => context.as_ref().as_ref(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
Self::ExportJsonSchema | Self::ExportGenesis(..) => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -150,7 +158,7 @@ impl AsRef<GenesisConfiguration> for Context {
|
||||
fn as_ref(&self) -> &GenesisConfiguration {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(..) => {
|
||||
Self::Benchmark(..) | Self::ExportGenesis(..) => {
|
||||
static GENESIS: LazyLock<GenesisConfiguration> = LazyLock::new(Default::default);
|
||||
&GENESIS
|
||||
}
|
||||
@@ -164,6 +172,7 @@ impl AsRef<WalletConfiguration> for Context {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(context) => context.as_ref().as_ref(),
|
||||
Self::ExportGenesis(context) => context.as_ref().as_ref(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
}
|
||||
}
|
||||
@@ -174,7 +183,7 @@ impl AsRef<ConcurrencyConfiguration> for Context {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(context) => context.as_ref().as_ref(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
Self::ExportJsonSchema | Self::ExportGenesis(..) => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,7 +193,7 @@ impl AsRef<CompilationConfiguration> for Context {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(context) => context.as_ref().as_ref(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
Self::ExportJsonSchema | Self::ExportGenesis(..) => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,7 +203,7 @@ impl AsRef<ReportConfiguration> for Context {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(context) => context.as_ref().as_ref(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
Self::ExportJsonSchema | Self::ExportGenesis(..) => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,7 +213,7 @@ impl AsRef<IgnoreSuccessConfiguration> for Context {
|
||||
match self {
|
||||
Self::Test(context) => context.as_ref().as_ref(),
|
||||
Self::Benchmark(..) => unreachable!(),
|
||||
Self::ExportJsonSchema => unreachable!(),
|
||||
Self::ExportJsonSchema | Self::ExportGenesis(..) => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -378,6 +387,36 @@ pub struct BenchmarkingContext {
|
||||
pub report_configuration: ReportConfiguration,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Parser, Serialize, Deserialize)]
|
||||
pub struct ExportGenesisContext {
|
||||
/// The platform of choice to export the genesis for.
|
||||
pub platform: PlatformIdentifier,
|
||||
|
||||
/// Configuration parameters for the geth node.
|
||||
#[clap(flatten, next_help_heading = "Geth Configuration")]
|
||||
pub geth_configuration: GethConfiguration,
|
||||
|
||||
/// Configuration parameters for the lighthouse node.
|
||||
#[clap(flatten, next_help_heading = "Lighthouse Configuration")]
|
||||
pub lighthouse_configuration: KurtosisConfiguration,
|
||||
|
||||
/// Configuration parameters for the Kitchensink.
|
||||
#[clap(flatten, next_help_heading = "Kitchensink Configuration")]
|
||||
pub kitchensink_configuration: KitchensinkConfiguration,
|
||||
|
||||
/// Configuration parameters for the Polkadot Parachain.
|
||||
#[clap(flatten, next_help_heading = "Polkadot Parachain Configuration")]
|
||||
pub polkadot_parachain_configuration: PolkadotParachainConfiguration,
|
||||
|
||||
/// Configuration parameters for the Revive Dev Node.
|
||||
#[clap(flatten, next_help_heading = "Revive Dev Node Configuration")]
|
||||
pub revive_dev_node_configuration: ReviveDevNodeConfiguration,
|
||||
|
||||
/// Configuration parameters for the wallet.
|
||||
#[clap(flatten, next_help_heading = "Wallet Configuration")]
|
||||
pub wallet_configuration: WalletConfiguration,
|
||||
}
|
||||
|
||||
impl Default for TestExecutionContext {
|
||||
fn default() -> Self {
|
||||
Self::parse_from(["execution-context"])
|
||||
@@ -482,7 +521,7 @@ impl AsRef<IgnoreSuccessConfiguration> for TestExecutionContext {
|
||||
|
||||
impl Default for BenchmarkingContext {
|
||||
fn default() -> Self {
|
||||
Self::parse_from(["execution-context"])
|
||||
Self::parse_from(["benchmarking-context"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,6 +609,48 @@ impl AsRef<ReportConfiguration> for BenchmarkingContext {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ExportGenesisContext {
|
||||
fn default() -> Self {
|
||||
Self::parse_from(["export-genesis-context"])
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<GethConfiguration> for ExportGenesisContext {
|
||||
fn as_ref(&self) -> &GethConfiguration {
|
||||
&self.geth_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<KurtosisConfiguration> for ExportGenesisContext {
|
||||
fn as_ref(&self) -> &KurtosisConfiguration {
|
||||
&self.lighthouse_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<KitchensinkConfiguration> for ExportGenesisContext {
|
||||
fn as_ref(&self) -> &KitchensinkConfiguration {
|
||||
&self.kitchensink_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<PolkadotParachainConfiguration> for ExportGenesisContext {
|
||||
fn as_ref(&self) -> &PolkadotParachainConfiguration {
|
||||
&self.polkadot_parachain_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<ReviveDevNodeConfiguration> for ExportGenesisContext {
|
||||
fn as_ref(&self) -> &ReviveDevNodeConfiguration {
|
||||
&self.revive_dev_node_configuration
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<WalletConfiguration> for ExportGenesisContext {
|
||||
fn as_ref(&self) -> &WalletConfiguration {
|
||||
&self.wallet_configuration
|
||||
}
|
||||
}
|
||||
|
||||
/// A set of configuration parameters for the corpus files to use for the execution.
|
||||
#[derive(Clone, Debug, Parser, Serialize, Deserialize)]
|
||||
pub struct CorpusConfiguration {
|
||||
@@ -711,6 +792,24 @@ pub struct ReviveDevNodeConfiguration {
|
||||
default_value = "instant-seal"
|
||||
)]
|
||||
pub consensus: String,
|
||||
|
||||
/// Specifies the connection string of an existing node that's not managed by the framework.
|
||||
///
|
||||
/// If this argument is specified then the framework will not spawn certain nodes itself but
|
||||
/// rather it will opt to using the existing node's through their provided connection strings.
|
||||
///
|
||||
/// This means that if `ConcurrencyConfiguration.number_of_nodes` is 10 and we only specify the
|
||||
/// connection strings of 2 nodes here, then nodes 0 and 1 will use the provided connection
|
||||
/// strings and nodes 2 through 10 (exclusive) will all be spawned and managed by the framework.
|
||||
///
|
||||
/// Thus, if you want all of the transactions and tests to happen against the node that you
|
||||
/// spawned and manage then you need to specify a `ConcurrencyConfiguration.number_of_nodes` of
|
||||
/// 1.
|
||||
#[clap(
|
||||
id = "revive-dev-node.existing-rpc-url",
|
||||
long = "revive-dev-node.existing-rpc-url"
|
||||
)]
|
||||
pub existing_rpc_url: Vec<String>,
|
||||
}
|
||||
|
||||
/// A set of configuration parameters for the ETH RPC.
|
||||
@@ -827,30 +926,26 @@ pub struct ConcurrencyConfiguration {
|
||||
#[arg(
|
||||
long = "concurrency.number-of-threads",
|
||||
default_value_t = std::thread::available_parallelism()
|
||||
.map(|n| n.get())
|
||||
.map(|n| n.get() * 4 / 6)
|
||||
.unwrap_or(1)
|
||||
)]
|
||||
pub number_of_threads: usize,
|
||||
|
||||
/// Determines the amount of concurrent tasks that will be spawned to run tests.
|
||||
/// Determines the amount of concurrent tasks that will be spawned to run tests. This means that
|
||||
/// at any given time there is `concurrency.number-of-concurrent-tasks` tests concurrently
|
||||
/// executing.
|
||||
///
|
||||
/// Defaults to 10 x the number of nodes.
|
||||
#[arg(long = "concurrency.number-of-concurrent-tasks")]
|
||||
number_concurrent_tasks: Option<usize>,
|
||||
|
||||
/// Determines if the concurrency limit should be ignored or not.
|
||||
#[arg(long = "concurrency.ignore-concurrency-limit")]
|
||||
ignore_concurrency_limit: bool,
|
||||
/// Note that a task limit of `0` means no limit on the number of concurrent tasks.
|
||||
#[arg(long = "concurrency.number-of-concurrent-tasks", default_value_t = 500)]
|
||||
number_concurrent_tasks: usize,
|
||||
}
|
||||
|
||||
impl ConcurrencyConfiguration {
|
||||
pub fn concurrency_limit(&self) -> Option<usize> {
|
||||
match self.ignore_concurrency_limit {
|
||||
true => None,
|
||||
false => Some(
|
||||
self.number_concurrent_tasks
|
||||
.unwrap_or(20 * self.number_of_nodes),
|
||||
),
|
||||
if self.number_concurrent_tasks == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(self.number_concurrent_tasks)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user