Skip to content

Commit 770abb7

Browse files
committed
Merge main
1 parent 7d9df61 commit 770abb7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3105
-205
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.git
2+
target

Cargo.lock

Lines changed: 14 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ rayon = "1.8.0"
225225
regex = "1.10.2"
226226
ripemd = { version = "0.1.3", default-features = false }
227227
rlimit = "0.10.1"
228-
rocksdb = "0.22.0"
228+
rocksdb = "0.24.0"
229229
rv = "0.16.4"
230230
secp256k1 = { version = "0.29.0", features = [
231231
"global-context",

README.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![DeepWiki](https://img.shields.io/badge/DeepWiki-kaspanet%2Frusty--kaspa-blue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAyCAYAAAAnWDnqAAAAAXNSR0IArs4c6QAAA05JREFUaEPtmUtyEzEQhtWTQyQLHNak2AB7ZnyXZMEjXMGeK/AIi+QuHrMnbChYY7MIh8g01fJoopFb0uhhEqqcbWTp06/uv1saEDv4O3n3dV60RfP947Mm9/SQc0ICFQgzfc4CYZoTPAswgSJCCUJUnAAoRHOAUOcATwbmVLWdGoH//PB8mnKqScAhsD0kYP3j/Yt5LPQe2KvcXmGvRHcDnpxfL2zOYJ1mFwrryWTz0advv1Ut4CJgf5uhDuDj5eUcAUoahrdY/56ebRWeraTjMt/00Sh3UDtjgHtQNHwcRGOC98BJEAEymycmYcWwOprTgcB6VZ5JK5TAJ+fXGLBm3FDAmn6oPPjR4rKCAoJCal2eAiQp2x0vxTPB3ALO2CRkwmDy5WohzBDwSEFKRwPbknEggCPB/imwrycgxX2NzoMCHhPkDwqYMr9tRcP5qNrMZHkVnOjRMWwLCcr8ohBVb1OMjxLwGCvjTikrsBOiA6fNyCrm8V1rP93iVPpwaE+gO0SsWmPiXB+jikdf6SizrT5qKasx5j8ABbHpFTx+vFXp9EnYQmLx02h1QTTrl6eDqxLnGjporxl3NL3agEvXdT0WmEost648sQOYAeJS9Q7bfUVoMGnjo4AZdUMQku50McDcMWcBPvr0SzbTAFDfvJqwLzgxwATnCgnp4wDl6Aa+Ax283gghmj+vj7feE2KBBRMW3FzOpLOADl0Isb5587h/U4gGvkt5v60Z1VLG8BhYjbzRwyQZemwAd6cCR5/XFWLYZRIMpX39AR0tjaGGiGzLVyhse5C9RKC6ai42ppWPKiBagOvaYk8lO7DajerabOZP46Lby5wKjw1HCRx7p9sVMOWGzb/vA1hwiWc6jm3MvQDTogQkiqIhJV0nBQBTU+3okKCFDy9WwferkHjtxib7t3xIUQtHxnIwtx4mpg26/HfwVNVDb4oI9RHmx5WGelRVlrtiw43zboCLaxv46AZeB3IlTkwouebTr1y2NjSpHz68WNFjHvupy3q8TFn3Hos2IAk4Ju5dCo8B3wP7VPr/FGaKiG+T+v+TQqIrOqMTL1VdWV1DdmcbO8KXBz6esmYWYKPwDL5b5FA1a0hwapHiom0r/cKaoqr+27/XcrS5UwSMbQAAAABJRU5ErkJggg==)](https://deepwiki.com/kaspanet/rusty-kaspa)
22
<!-- DeepWiki badge generated by https://deepwiki.ryoppippi.com/ -->
3-
<h1>Kaspa On Rust</h1>
3+
<h1>Kaspa on Rust</h1>
44

55
Welcome to the Rust-based implementation of the Kaspa full-node and its ancillary libraries. The contained node release serves as a drop-in replacement to the established <a href="https://github.com/kaspanet/kaspad">Golang node</a> and to date is the recommended node software for the Kaspa network, introducing developers to the possibilities of Rust in the Kaspa network's context.
66

@@ -158,6 +158,52 @@ To build WASM on MacOS you need to install `llvm` from homebrew (at the time of
158158

159159
</details>
160160

161+
<details>
162+
<summary> Building with Docker </summary>
163+
164+
You can build the project using Docker in two ways: a simple single-architecture build, or a multi-architecture build using the provided script.
165+
166+
#### 1. Simple Docker Build
167+
168+
To build for your current architecture (e.g., `linux/amd64`):
169+
170+
```sh
171+
docker build -f docker/Dockerfile.kaspad -t kaspad:latest .
172+
```
173+
174+
Replace `Dockerfile.kaspad` with the appropriate Dockerfile for your target (`kaspad`, `kaspa-wallet`, `rothschild`, or `simpa`).
175+
176+
#### 2. Multi-Architecture Build
177+
178+
To build images for multiple architectures (e.g., `linux/amd64` and `linux/arm64`) and optionally push them to a registry, use the `build-docker-multi-arch.sh` script:
179+
180+
```sh
181+
./build-docker-multi-arch.sh --tag <tag> --artifact <artifact> [--arches "<arches>"] [--push]
182+
```
183+
184+
- `--tag <tag>`: **(required)** The Docker image tag to use.
185+
- `--artifact <artifact>`: The build target/artifact (default: `kaspad`). Must match the Dockerfile name, e.g., `kaspad` for `Dockerfile.kaspad`.
186+
- `--arches "<arches>"`: Space-separated list of architectures (default: `"linux/amd64 linux/arm64"`).
187+
- `--push`: If specified, the built images will be pushed to your Docker registry.
188+
189+
**Examples:**
190+
191+
Build and push a multi-arch image for `kaspad`:
192+
193+
```sh
194+
./build-docker-multi-arch.sh --tag myrepo/kaspad:latest --artifact kaspad --push
195+
```
196+
197+
Build a multi-arch image for `kaspa-wallet` without pushing:
198+
199+
```sh
200+
./build-docker-multi-arch.sh --tag kaspa-wallet:test --artifact kaspa-wallet
201+
```
202+
203+
**Note:**
204+
In order to use `build-docker-multi-arch.sh`, you need Docker with Buildx enabled.
205+
</details>
206+
161207
<details>
162208

163209
<summary>Building WASM32 SDK</summary>
@@ -253,7 +299,7 @@ Start the DevNet node with the following command:
253299
cargo run --bin kaspad -- --devnet --enable-unsynced-mining --rpclisten=127.0.0.1 --rpclisten-borsh=127.0.0.1 --utxoindex
254300
```
255301
* `enable-unsynced-mining` is required when the network isn't synchronized, which is the case on the first launch
256-
* `uxtoindex` is required to broadcast mined blocks on this node
302+
* `uxtoindex` enables the UTXO index, which is necessary for wallet functionality.
257303
* `rpclisten-borsh` and `rpclisten-borsh` are likely to be required by mining softwares
258304

259305
note: it will take a bit of time for difficulty to adjust, so you may need to wait a bit before you see blocks being mined consistently.

build-docker-multi-arch.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# Parse command line arguments for --tag and --repo
6+
ARCHES="linux/amd64 linux/arm64"
7+
ARTIFACT="kaspad"
8+
while [ $# -gt 0 ]; do
9+
case "$1" in
10+
--tag)
11+
shift
12+
TAG="$1"
13+
;;
14+
--arches)
15+
shift
16+
ARCHES="$1"
17+
;;
18+
--push)
19+
PUSH="push"
20+
;;
21+
--artifact)
22+
shift
23+
ARTIFACT="$1"
24+
;;
25+
--help|-h)
26+
echo "Usage: $0 --tag <tag> --artifact <artifact> [--arches <arches>] [--push]"
27+
echo ""
28+
echo " --tag <tag> Docker image tag (required)"
29+
echo " --artifact <name> Build target/artifact (default: \"$ARTIFACT\")"
30+
echo " --arches <arches> Space-separated list of architectures (default: \"$ARCHES\")"
31+
echo " --push Push the built images"
32+
echo " --help, -h Show this help message"
33+
exit 0
34+
;;
35+
*)
36+
break
37+
;;
38+
esac
39+
shift
40+
done
41+
42+
if [ -z "$TAG" ]; then
43+
echo "Error: --tag argument is required"
44+
exit 1
45+
fi
46+
47+
BUILD_DIR="$(dirname $0)"
48+
docker=docker
49+
id -nG $USER | grep -qw docker || docker="sudo $docker"
50+
51+
multi_arch_build() {
52+
echo
53+
echo "===================================================="
54+
echo " Running build for $1"
55+
echo "===================================================="
56+
dockerRepo="${DOCKER_REPO_PREFIX}-$1"
57+
dockerRepoArgs=
58+
59+
if [ "$PUSH" = "push" ]; then
60+
dockerRepoArgs="$dockerRepoArgs --push"
61+
fi
62+
63+
dockerRepoArgs="$dockerRepoArgs --tag $TAG"
64+
dockerRepoArgs="$dockerRepoArgs -f docker/Dockerfile.$1"
65+
66+
$docker buildx build --platform=$(echo $ARCHES | sed 's/ /,/g') $dockerRepoArgs \
67+
--tag $TAG "$BUILD_DIR"
68+
echo "===================================================="
69+
echo " Completed build for $1"
70+
echo "===================================================="
71+
}
72+
73+
echo
74+
echo "===================================================="
75+
echo " Setup multi arch build ($ARCHES)"
76+
echo "===================================================="
77+
$docker buildx create --name mybuilder \
78+
--driver docker-container \
79+
--node mybuilder0 \
80+
--use --bootstrap
81+
$docker buildx create --name=mybuilder --append --node=mybuilder0 --platform=$(echo $ARCHES | sed 's/ /,/g') --bootstrap --use
82+
echo "SUCCESS - doing multi arch build"
83+
multi_arch_build $ARTIFACT

components/consensusmanager/src/session.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ impl ConsensusSessionOwned {
378378
self.clone().spawn_blocking(move |c| c.get_block(hash)).await
379379
}
380380

381+
pub async fn async_get_block_body(&self, hash: Hash) -> ConsensusResult<Arc<Vec<Transaction>>> {
382+
self.clone().spawn_blocking(move |c| c.get_block_body(hash)).await
383+
}
384+
381385
pub async fn async_get_block_even_if_header_only(&self, hash: Hash) -> ConsensusResult<Block> {
382386
self.clone().spawn_blocking(move |c| c.get_block_even_if_header_only(hash)).await
383387
}

consensus/core/src/api/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ pub trait ConsensusApi: Send + Sync {
305305
unimplemented!()
306306
}
307307

308+
fn get_block_body(&self, hash: Hash) -> ConsensusResult<Arc<Vec<Transaction>>> {
309+
unimplemented!()
310+
}
311+
308312
fn get_block_even_if_header_only(&self, hash: Hash) -> ConsensusResult<Block> {
309313
unimplemented!()
310314
}

consensus/core/src/merkle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod tests {
1717

1818
#[test]
1919
fn merkle_root_test() {
20-
let txs = vec![
20+
let txs = [
2121
Transaction::new(
2222
0,
2323
vec![],

consensus/src/consensus/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,17 @@ impl ConsensusApi for Consensus {
10771077
}
10781078
}
10791079

1080+
fn get_block_body(&self, hash: Hash) -> ConsensusResult<Arc<Vec<Transaction>>> {
1081+
if match self.statuses_store.read().get(hash).unwrap_option() {
1082+
Some(status) => !status.has_block_body(),
1083+
None => true,
1084+
} {
1085+
return Err(ConsensusError::BlockNotFound(hash));
1086+
}
1087+
1088+
self.block_transactions_store.get(hash).unwrap_option().ok_or(ConsensusError::BlockNotFound(hash))
1089+
}
1090+
10801091
fn get_block_even_if_header_only(&self, hash: Hash) -> ConsensusResult<Block> {
10811092
let Some(status) = self.statuses_store.read().get(hash).unwrap_option().filter(|&status| status.has_block_header()) else {
10821093
return Err(ConsensusError::HeaderNotFound(hash));

crypto/hashes/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ license.workspace = true
1010
repository.workspace = true
1111

1212
[features]
13+
default = ["keccak?/asm"]
1314
no-asm = ["keccak"]
1415

1516
[dependencies]
@@ -25,7 +26,7 @@ sha2.workspace = true
2526
wasm-bindgen.workspace = true
2627
workflow-wasm.workspace = true
2728

28-
[target.'cfg(any(target_os = "windows", not(target_arch = "x86_64")))'.dependencies]
29+
[target.'cfg(not(target_arch = "x86_64"))'.dependencies]
2930
keccak.workspace = true
3031

3132
[dev-dependencies]

0 commit comments

Comments
 (0)