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

chore: pass network option to Drive ABCI #2037

Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions packages/dashmate/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ services:
- TOKIO_CONSOLE_RETENTION_SECS=${PLATFORM_DRIVE_ABCI_TOKIO_CONSOLE_RETENTION:?err}
- GROVEDB_VISUALIZER_ENABLED=${PLATFORM_DRIVE_ABCI_GROVEDB_VISUALIZER_ENABLED:?err}
- GROVEDB_VISUALIZER_ADDRESS=0.0.0.0:${PLATFORM_DRIVE_ABCI_GROVEDB_VISUALIZER_PORT:?err}
- NETWORK=${NETWORK:?err}
stop_grace_period: 30s
expose:
- 26658
Expand Down
2 changes: 2 additions & 0 deletions packages/rs-drive-abci/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ TOKIO_CONSOLE_RETENTION_SECS=180

GROVEDB_VISUALIZER_ENABLED=false
GROVEDB_VISUALIZER_ADDRESS=127.0.0.1:8083

NETWORK=regtest
2 changes: 2 additions & 0 deletions packages/rs-drive-abci/.env.mainnet
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ TOKIO_CONSOLE_RETENTION_SECS=180

GROVEDB_VISUALIZER_ENABLED=false
GROVEDB_VISUALIZER_ADDRESS=127.0.0.1:8083

NETWORK=mainnet
2 changes: 2 additions & 0 deletions packages/rs-drive-abci/.env.testnet
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ TOKIO_CONSOLE_RETENTION_SECS=180

GROVEDB_VISUALIZER_ENABLED=false
GROVEDB_VISUALIZER_ADDRESS=127.0.0.1:8083

NETWORK=testnet
22 changes: 17 additions & 5 deletions packages/rs-drive-abci/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use bincode::{Decode, Encode};
use dashcore_rpc::json::QuorumType;
use std::path::PathBuf;

use crate::logging::LogConfigs;
use crate::{abci::config::AbciConfig, error::Error};
use bincode::{Decode, Encode};
use dashcore_rpc::json::QuorumType;
use dpp::dashcore::Network;
use dpp::util::deserializer::ProtocolVersion;
use dpp::version::INITIAL_PROTOCOL_VERSION;
use drive::config::DriveConfig;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::path::PathBuf;
use std::str::FromStr;

/// Configuration for Dash Core RPC client used in consensus logic
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
Expand Down Expand Up @@ -145,7 +145,10 @@ where
// https://github.com/softprops/envy/issues/61 and https://github.com/softprops/envy/pull/69
pub struct PlatformConfig {
/// The network type
#[serde(default = "PlatformConfig::default_network")]
#[serde(
default = "PlatformConfig::default_network",
deserialize_with = "from_str_to_network_with_aliases"
)]
pub network: Network,
/// Drive configuration
#[serde(flatten)]
Expand Down Expand Up @@ -224,6 +227,14 @@ pub struct PlatformConfig {
pub tokio_console_retention_secs: u64,
}

fn from_str_to_network_with_aliases(network_name: &str) -> Network {
match network_name {
"mainnet" => Network::Dash,
"local" => Network::Regtest,
_ => Network::from_str(network_name).expect("failed to parse network name"),
}
}

/// A config suitable for a quorum configuration
pub trait QuorumLikeConfig: Sized {
/// Quorum type
Expand Down Expand Up @@ -556,6 +567,7 @@ impl PlatformConfig {

fn default_network() -> Network {
Network::Regtest //todo: Do not leave this as regtest
// TODO: Yes, must be mainnet
}

fn default_tokio_console_address() -> String {
Expand Down
Loading