Skip to content

Commit f9878d7

Browse files
Fix README.md and disallow mining on mainnet (#171)
* Fix README.md and disallow mining on mainnet * minor edits --------- Co-authored-by: Michael Sutton <msutton@cs.huji.ac.il>
1 parent 412f921 commit f9878d7

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Kaspa on Rust
22

3-
Work in progress to implement the Kaspa full-node and related libraries in the Rust programming language.
3+
This repository contains the implementation of the Kaspa full-node and related libraries in the Rust programming language. This is an Alpha version at the initial testing phase, however the node is expected to be fully functional and capable as a drop-in replacement for the Kaspa golang node.
44

55
## Getting started
66

@@ -23,24 +23,35 @@ $ git clone https://github.com/kaspanet/rusty-kaspa
2323
$ cd rusty-kaspa
2424
```
2525

26-
## Experimenting with the node
26+
## Running the node
2727

28-
The `kaspad` rust executable is currently at the initial stage where a devnet consensus instance can be built and mined locally through the RPC interface. The P2P network is not supported yet. To see it in action, perform the following:
28+
Run the node through the following command:
2929

3030
```bash
31-
$ cargo run --bin kaspad --release -- --devnet
31+
$ (cargo run --release --bin kaspad) 2>&1 | tee ~/rusty-kaspa.log
3232
```
3333

34+
And if you want to setup a test node, run the following command instead:
35+
36+
```bash
37+
$ (cargo run --release --bin kaspad -- --testnet) 2>&1 | tee ~/rusty-kaspa-testnet.log
38+
```
39+
40+
## Mining
41+
Mining is currently supported only on testnet, so once you've setup a test node, follow these instructions:
42+
3443
- Download and unzip the latest binaries bundle of [kaspanet/kaspad](https://github.com/kaspanet/kaspad/releases).
3544

3645
- In a separate terminal run the kaspanet/kaspad miner:
3746

3847
```bash
39-
$ kaspaminer --rpcserver 127.0.0.1:16610 --devnet --miningaddr kaspadev:qrcqat6l9zcjsu7swnaztqzrv0s7hu04skpaezxk43y4etj8ncwfkuhy0zmax
48+
$ kaspaminer --testnet --miningaddr kaspatest:qrcqat6l9zcjsu7swnaztqzrv0s7hu04skpaezxk43y4etj8ncwfk308jlcew
4049
```
4150

4251
- This will create and feed a DAG with the miner getting block templates from the node and submitting them back when mined. The node processes and stores the blocks while applying all currently implemented logic. Execution can be stopped and resumed, the data is persisted in a database.
4352

53+
- You can replace the above mining address with your own address by creating one as described [here](https://github.com/kaspanet/docs/blob/main/Getting%20Started/Full%20Node%20Installation.md#creating-a-wallet-optional).
54+
4455
## Simulation framework (Simpa)
4556

4657
Additionally, the current codebase supports a full in-process network simulation, building an actual DAG over virtual time with virtual delay and benchmarking validation time (following the simulation generation). Execute
@@ -58,7 +69,7 @@ $ cargo run --release --bin simpa -- -t=200 -d=2 -b=8 -n=1000
5869
Logging in `kaspad` and `simpa` can be [filtered](https://docs.rs/env_logger/0.10.0/env_logger/#filtering-results) either by defining the environment variable `RUST_LOG` and/or by adding a `--loglevel` argument to the command, ie.:
5970

6071
```bash
61-
$ cargo run --bin kaspad -- --loglevel info,kaspa_rpc_core=trace,kaspa_grpc_core=trace,consensus=trace,kaspa_core=trace
72+
$ (cargo run --bin kaspad -- --loglevel info,kaspa_rpc_core=trace,kaspa_grpc_core=trace,consensus=trace,kaspa_core=trace) 2>&1 | tee ~/rusty-kaspa.log
6273
```
6374

6475

consensus/core/src/networktype.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub enum NetworkTypeError {
1010
InvalidNetworkType(String),
1111
}
1212

13-
#[derive(Clone, Copy, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize, BorshSchema)]
13+
#[derive(Clone, Copy, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize, BorshSchema, PartialEq, Eq)]
1414
#[serde(rename_all = "lowercase")]
1515
pub enum NetworkType {
1616
Mainnet,

rpc/service/src/service.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use kaspa_consensus_core::{
88
coinbase::MinerData,
99
config::Config,
1010
constants::MAX_SOMPI,
11+
networktype::NetworkType,
1112
tx::{Transaction, COINBASE_TRANSACTION_INDEX},
1213
};
1314
use kaspa_consensus_notify::{
@@ -190,6 +191,10 @@ impl RpcApi<ChannelConnection> for RpcCoreService {
190191
async fn get_block_template_call(&self, request: GetBlockTemplateRequest) -> RpcResult<GetBlockTemplateResponse> {
191192
trace!("incoming GetBlockTemplate request");
192193

194+
if self.config.net == NetworkType::Mainnet {
195+
return Err(RpcError::General("Mining on mainnet is not supported for the Rust Alpha version".to_owned()));
196+
}
197+
193198
// Make sure the pay address prefix matches the config network type
194199
if request.pay_address.prefix != self.config.prefix() {
195200
return Err(kaspa_addresses::AddressError::InvalidPrefix(request.pay_address.prefix.to_string()))?;

0 commit comments

Comments
 (0)