Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: document the config file #194

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import (
"os"
"strings"

"github.com/0xPolygon/cdk/config"
"github.com/urfave/cli/v2"
)

func configCmd(*cli.Context) error {
// String buffer to concatenate all the default config vars
defaultConfig := strings.Builder{}
defaultConfig.WriteString(config.DefaultMandatoryVars)
defaultConfig.WriteString(config.DefaultVars)
defaultConfig.WriteString(config.DefaultValues)

_, err := os.Stdout.WriteString(defaultConfig.String())
if err != nil {
return err
}

return nil
}
6 changes: 6 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ func main() {
Action: start,
Flags: append(flags, &customNetworkFlag),
},
{
Name: "config",
Aliases: []string{},
Usage: "Output a default configuration file",
Action: configCmd,
},
}

err := app.Run(os.Args)
Expand Down
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const (
FlagDisableDefaultConfigVars = "disable-default-config-vars"
// FlagAllowDeprecatedFields is the flag to allow deprecated fields
FlagAllowDeprecatedFields = "allow-deprecated-fields"
// FlagExtendedConfig is the flag to print extended configuration
FlagExtendedConfig = "extended"

deprecatedFieldSyncDB = "Aggregator.Synchronizer.DB is deprecated. Use Aggregator.Synchronizer.SQLDB instead."

Expand Down
1,621 changes: 1,350 additions & 271 deletions config/default.go

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions crates/cdk-config/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ pub struct Aggregator {
pub verify_proof_interval: String,
#[serde(rename = "ProofStatePollingInterval", default)]
pub proof_state_polling_interval: String,
#[serde(rename = "TxProfitabilityCheckerType", default)]
pub tx_profitability_checker_type: String,
#[serde(rename = "TxProfitabilityMinReward", default)]
pub tx_profitability_min_reward: String,
#[serde(rename = "IntervalAfterWhichBatchConsolidateAnyway", default)]
pub interval_after_which_batch_consolidate_anyway: String,
#[serde(rename = "ForkId", default)]
Expand Down
2 changes: 2 additions & 0 deletions crates/cdk/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ pub(crate) enum Commands {
},
/// Output the corresponding versions of the components
Versions,
/// Output the default config template file
Config,
}
26 changes: 26 additions & 0 deletions crates/cdk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ async fn main() -> anyhow::Result<()> {
cli::Commands::Node { config, components } => node(config, components)?,
cli::Commands::Erigon { config, chain } => erigon(config, chain).await?,
cli::Commands::Versions {} => versions::versions(),
cli::Commands::Config {} => config()?,
}

Ok(())
Expand Down Expand Up @@ -182,3 +183,28 @@ async fn get_timestamp(url: Url) -> Result<u64, anyhow::Error> {
struct Batch {
timestamp: String,
}

/// This function simply calls the config subcommand in cdk-node.
pub fn config() -> anyhow::Result<()> {
// This is to find the binary when running in development mode
// otherwise it will use system path
let bin_path = helpers::get_bin_path();

// Run the node passing the config file path as argument
let mut command = Command::new(bin_path.clone());
command.args(&["config"]);

let output_result = command.execute_output();
match output_result {
Ok(output) => output,
Err(e) => {
eprintln!(
"Failed to execute command, trying to find executable in path: {}",
bin_path
);
return Err(e.into());
}
};

Ok(())
}
4 changes: 2 additions & 2 deletions crates/cdk/versions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"agglayer_image": "ghcr.io/agglayer/agglayer:0.2.0-rc.5",
"agglayer_image": "ghcr.io/agglayer/agglayer:0.2.0-rc.12",
"cdk_erigon_node_image": "hermeznetwork/cdk-erigon:v2.1.2",
"cdk_node_image": "ghcr.io/0xpolygon/cdk:0.4.0-beta8",
"cdk_node_image": "ghcr.io/0xpolygon/cdk:0.4.0-beta10",
"cdk_validium_node_image": "0xpolygon/cdk-validium-node:0.7.0-cdk",
"zkevm_bridge_proxy_image": "haproxy:3.0-bookworm",
"zkevm_bridge_service_image": "hermeznetwork/zkevm-bridge-service:v0.6.0-RC1",
Expand Down
2 changes: 0 additions & 2 deletions test/config/test.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ Host = "0.0.0.0"
Port = 50081
RetryTime = "5s"
VerifyProofInterval = "10s"
TxProfitabilityCheckerType = "acceptall"
TxProfitabilityMinReward = "1.1"
ProofStatePollingInterval = "5s"
SenderAddress = "0x3f2963d678442c4af27a797453b64ef6ce9443e9"
CleanupLockedProofsInterval = "2m"
Expand Down
Loading