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

Final polishing for KarlsenHashv2 mainnet #9

Merged
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
500 changes: 306 additions & 194 deletions .github/workflows/deploy.yaml

Large diffs are not rendered by default.

114 changes: 57 additions & 57 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ members = [

[workspace.package]
rust-version = "1.78.0"
version = "0.1.0"
version = "2.0.0"
authors = ["Karlsen developers"]
license = "ISC"
repository = "https://github.com/karlsen-network/rusty-karlsen"
@@ -79,62 +79,62 @@ include = [
]

[workspace.dependencies]
# karlsen-testing-integration = { version = "0.1.0", path = "testing/integration" }
karlsen-addresses = { version = "0.1.0", path = "crypto/addresses" }
karlsen-addressmanager = { version = "0.1.0", path = "components/addressmanager" }
karlsen-bip32 = { version = "0.1.0", path = "wallet/bip32" }
karlsen-resolver = { version = "0.1.0", path = "rpr/wrpc/resolver" }
karlsen-cli = { version = "0.1.0", path = "cli" }
karlsen-connectionmanager = { version = "0.1.0", path = "components/connectionmanager" }
karlsen-consensus = { version = "0.1.0", path = "consensus" }
karlsen-consensus-core = { version = "0.1.0", path = "consensus/core" }
karlsen-consensus-client = { version = "0.1.0", path = "consensus/client" }
karlsen-consensus-notify = { version = "0.1.0", path = "consensus/notify" }
karlsen-consensus-wasm = { version = "0.1.0", path = "consensus/wasm" }
karlsen-consensusmanager = { version = "0.1.0", path = "components/consensusmanager" }
karlsen-core = { version = "0.1.0", path = "core" }
karlsen-daemon = { version = "0.1.0", path = "daemon" }
karlsen-database = { version = "0.1.0", path = "database" }
karlsen-grpc-client = { version = "0.1.0", path = "rpc/grpc/client" }
karlsen-grpc-core = { version = "0.1.0", path = "rpc/grpc/core" }
karlsen-grpc-server = { version = "0.1.0", path = "rpc/grpc/server" }
karlsen-hashes = { version = "0.1.0", path = "crypto/hashes" }
karlsen-index-core = { version = "0.1.0", path = "indexes/core" }
karlsen-index-processor = { version = "0.1.0", path = "indexes/processor" }
karlsen-math = { version = "0.1.0", path = "math" }
karlsen-merkle = { version = "0.1.0", path = "crypto/merkle" }
karlsen-metrics-core = { version = "0.1.0", path = "metrics/core" }
karlsen-mining = { version = "0.1.0", path = "mining" }
karlsen-mining-errors = { version = "0.1.0", path = "mining/errors" }
karlsen-muhash = { version = "0.1.0", path = "crypto/muhash" }
karlsen-notify = { version = "0.1.0", path = "notify" }
karlsen-p2p-flows = { version = "0.1.0", path = "protocol/flows" }
karlsen-p2p-lib = { version = "0.1.0", path = "protocol/p2p" }
karlsen-perf-monitor = { version = "0.1.0", path = "metrics/perf_monitor" }
karlsen-pow = { version = "0.1.0", path = "consensus/pow" }
karlsen-rpc-core = { version = "0.1.0", path = "rpc/core" }
karlsen-rpc-macros = { version = "0.1.0", path = "rpc/macros" }
karlsen-rpc-service = { version = "0.1.0", path = "rpc/service" }
karlsen-txscript = { version = "0.1.0", path = "crypto/txscript" }
karlsen-txscript-errors = { version = "0.1.0", path = "crypto/txscript/errors" }
karlsen-utils = { version = "0.1.0", path = "utils" }
karlsen-utils-tower = { version = "0.1.0", path = "utils/tower" }
karlsen-utxoindex = { version = "0.1.0", path = "indexes/utxoindex" }
karlsen-wallet = { version = "0.1.0", path = "wallet/native" }
karlsen-wallet-cli-wasm = { version = "0.1.0", path = "wallet/wasm" }
karlsen-wallet-keys = { version = "0.1.0", path = "wallet/keys" }
karlsen-wallet-core = { version = "0.1.0", path = "wallet/core" }
karlsen-wallet-macros = { version = "0.1.0", path = "wallet/macros" }
karlsen-wasm = { version = "0.1.0", path = "wasm" }
karlsen-wasm-core = { version = "0.1.0", path = "wasm/core" }
karlsen-wrpc-client = { version = "0.1.0", path = "rpc/wrpc/client" }
karlsen-wrpc-core = { version = "0.1.0", path = "rpc/wrpc/core" }
karlsen-wrpc-proxy = { version = "0.1.0", path = "rpc/wrpc/proxy" }
karlsen-wrpc-server = { version = "0.1.0", path = "rpc/wrpc/server" }
karlsen-wrpc-wasm = { version = "0.1.0", path = "rpc/wrpc/wasm" }
karlsen-wrpc-example-subscriber = { version = "0.1.0", path = "rpc/wrpc/examples/subscriber" }
karlsend = { version = "0.1.0", path = "karlsend" }
karlsen-alloc = { version = "0.1.0", path = "utils/alloc" }
# karlsen-testing-integration = { version = "2.0.0", path = "testing/integration" }
karlsen-addresses = { version = "2.0.0", path = "crypto/addresses" }
karlsen-addressmanager = { version = "2.0.0", path = "components/addressmanager" }
karlsen-bip32 = { version = "2.0.0", path = "wallet/bip32" }
karlsen-resolver = { version = "2.0.0", path = "rpr/wrpc/resolver" }
karlsen-cli = { version = "2.0.0", path = "cli" }
karlsen-connectionmanager = { version = "2.0.0", path = "components/connectionmanager" }
karlsen-consensus = { version = "2.0.0", path = "consensus" }
karlsen-consensus-core = { version = "2.0.0", path = "consensus/core" }
karlsen-consensus-client = { version = "2.0.0", path = "consensus/client" }
karlsen-consensus-notify = { version = "2.0.0", path = "consensus/notify" }
karlsen-consensus-wasm = { version = "2.0.0", path = "consensus/wasm" }
karlsen-consensusmanager = { version = "2.0.0", path = "components/consensusmanager" }
karlsen-core = { version = "2.0.0", path = "core" }
karlsen-daemon = { version = "2.0.0", path = "daemon" }
karlsen-database = { version = "2.0.0", path = "database" }
karlsen-grpc-client = { version = "2.0.0", path = "rpc/grpc/client" }
karlsen-grpc-core = { version = "2.0.0", path = "rpc/grpc/core" }
karlsen-grpc-server = { version = "2.0.0", path = "rpc/grpc/server" }
karlsen-hashes = { version = "2.0.0", path = "crypto/hashes" }
karlsen-index-core = { version = "2.0.0", path = "indexes/core" }
karlsen-index-processor = { version = "2.0.0", path = "indexes/processor" }
karlsen-math = { version = "2.0.0", path = "math" }
karlsen-merkle = { version = "2.0.0", path = "crypto/merkle" }
karlsen-metrics-core = { version = "2.0.0", path = "metrics/core" }
karlsen-mining = { version = "2.0.0", path = "mining" }
karlsen-mining-errors = { version = "2.0.0", path = "mining/errors" }
karlsen-muhash = { version = "2.0.0", path = "crypto/muhash" }
karlsen-notify = { version = "2.0.0", path = "notify" }
karlsen-p2p-flows = { version = "2.0.0", path = "protocol/flows" }
karlsen-p2p-lib = { version = "2.0.0", path = "protocol/p2p" }
karlsen-perf-monitor = { version = "2.0.0", path = "metrics/perf_monitor" }
karlsen-pow = { version = "2.0.0", path = "consensus/pow" }
karlsen-rpc-core = { version = "2.0.0", path = "rpc/core" }
karlsen-rpc-macros = { version = "2.0.0", path = "rpc/macros" }
karlsen-rpc-service = { version = "2.0.0", path = "rpc/service" }
karlsen-txscript = { version = "2.0.0", path = "crypto/txscript" }
karlsen-txscript-errors = { version = "2.0.0", path = "crypto/txscript/errors" }
karlsen-utils = { version = "2.0.0", path = "utils" }
karlsen-utils-tower = { version = "2.0.0", path = "utils/tower" }
karlsen-utxoindex = { version = "2.0.0", path = "indexes/utxoindex" }
karlsen-wallet = { version = "2.0.0", path = "wallet/native" }
karlsen-wallet-cli-wasm = { version = "2.0.0", path = "wallet/wasm" }
karlsen-wallet-keys = { version = "2.0.0", path = "wallet/keys" }
karlsen-wallet-core = { version = "2.0.0", path = "wallet/core" }
karlsen-wallet-macros = { version = "2.0.0", path = "wallet/macros" }
karlsen-wasm = { version = "2.0.0", path = "wasm" }
karlsen-wasm-core = { version = "2.0.0", path = "wasm/core" }
karlsen-wrpc-client = { version = "2.0.0", path = "rpc/wrpc/client" }
karlsen-wrpc-core = { version = "2.0.0", path = "rpc/wrpc/core" }
karlsen-wrpc-proxy = { version = "2.0.0", path = "rpc/wrpc/proxy" }
karlsen-wrpc-server = { version = "2.0.0", path = "rpc/wrpc/server" }
karlsen-wrpc-wasm = { version = "2.0.0", path = "rpc/wrpc/wasm" }
karlsen-wrpc-example-subscriber = { version = "2.0.0", path = "rpc/wrpc/examples/subscriber" }
karlsend = { version = "2.0.0", path = "karlsend" }
karlsen-alloc = { version = "2.0.0", path = "utils/alloc" }

# external
aes = "0.8.3"
661 changes: 369 additions & 292 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -45,7 +45,9 @@ impl HeaderProcessor {
header.version,
constants::BLOCK_VERSION_KHASHV2,
));
} else if header.daa_score < hf_daa_score && header.version != constants::BLOCK_VERSION_KHASHV1 {
} else if header.daa_score < hf_daa_score
&& header.version != constants::BLOCK_VERSION_KHASHV1
{
return Err(RuleError::WrongBlockVersion(
header.version,
constants::BLOCK_VERSION_KHASHV1,
2 changes: 1 addition & 1 deletion karlsend/src/daemon.rs
Original file line number Diff line number Diff line change
@@ -415,7 +415,7 @@ do you confirm? (answer y/n or pass --yes to the Karlsend command line to confir

let grpc_server_addr = args
.rpclisten
.unwrap_or(ContextualNetAddress::loopback())
.unwrap_or(ContextualNetAddress::unspecified())
.normalize(config.default_rpc_port());

let core = Arc::new(Core::new());
2 changes: 1 addition & 1 deletion rpc/wrpc/server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ workflow-core.workspace = true
workflow-log.workspace = true
workflow-rpc.workspace = true

[target.x86_64-unknown-linux-gnu.dependencies]
[target.'cfg(unix)'.dependencies]
# Adding explicitely the openssl dependency here is needed for a successful build with zigbuild
# as used in the release deployment in GitHub CI
# see: https://github.com/rust-cross/cargo-zigbuild/issues/127
46 changes: 45 additions & 1 deletion rpc/wrpc/server/src/address.rs
Original file line number Diff line number Diff line change
@@ -33,7 +33,17 @@ impl WrpcNetAddress {
};
format!("0.0.0.0:{port}").parse().unwrap()
}
WrpcNetAddress::Custom(address) => *address,
WrpcNetAddress::Custom(address) => {
if address.port_not_specified() {
let port = match encoding {
WrpcEncoding::Borsh => network_type.default_borsh_rpc_port(),
WrpcEncoding::SerdeJson => network_type.default_json_rpc_port(),
};
address.with_port(port)
} else {
*address
}
}
}
}
}
@@ -67,3 +77,37 @@ impl TryFrom<String> for WrpcNetAddress {
WrpcNetAddress::from_str(&s)
}
}

#[cfg(test)]
mod tests {
use super::*;
use karlsen_utils::networking::IpAddress;

#[test]
fn test_wrpc_net_address_from_str() {
// Addresses
let port: u16 = 42110;
let addr = format!("1.2.3.4:{port}").parse::<WrpcNetAddress>().unwrap();
let addr_without_port = "1.2.3.4".parse::<WrpcNetAddress>().unwrap();
let ip_addr = "1.2.3.4".parse::<IpAddress>().unwrap();
// Test
for schema in WrpcEncoding::iter() {
for network in NetworkType::iter() {
let expected_port = match schema {
WrpcEncoding::Borsh => Some(network.default_borsh_rpc_port()),
WrpcEncoding::SerdeJson => Some(network.default_json_rpc_port()),
};
// Custom address with port
assert_eq!(
addr.to_address(&network, schema),
ContextualNetAddress::new(ip_addr, Some(port))
);
// Custom address without port
assert_eq!(
addr_without_port.to_address(&network, schema),
ContextualNetAddress::new(ip_addr, expected_port)
)
}
}
}
}
13 changes: 12 additions & 1 deletion utils/src/networking.rs
Original file line number Diff line number Diff line change
@@ -325,7 +325,7 @@ pub struct ContextualNetAddress {
}

impl ContextualNetAddress {
fn new(ip: IpAddress, port: Option<u16>) -> Self {
pub fn new(ip: IpAddress, port: Option<u16>) -> Self {
Self { ip, port }
}

@@ -346,6 +346,17 @@ impl ContextualNetAddress {
port: None,
}
}

pub fn port_not_specified(&self) -> bool {
self.port.is_none()
}

pub fn with_port(&self, port: u16) -> Self {
Self {
ip: self.ip,
port: Some(port),
}
}
}

impl From<NetAddress> for ContextualNetAddress {