Skip to content

Commit 0d29b1c

Browse files
authored
Merge branch 'main' into cuprated-config
2 parents 5906e7d + 63216ae commit 0d29b1c

File tree

51 files changed

+504
-260
lines changed

Some content is hidden

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

51 files changed

+504
-260
lines changed

Cargo.lock

Lines changed: 22 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ members = [
55
"binaries/cuprated",
66
"constants",
77
"consensus",
8+
"consensus/context",
89
"consensus/fast-sync",
910
"consensus/rules",
1011
"cryptonight",
@@ -49,6 +50,35 @@ opt-level = 1
4950
opt-level = 3
5051

5152
[workspace.dependencies]
53+
# Cuprate members
54+
cuprate-fast-sync = { path = "consensus/fast-sync" ,default-features = false}
55+
cuprate-consensus-rules = { path = "consensus/rules" ,default-features = false}
56+
cuprate-constants = { path = "constants" ,default-features = false}
57+
cuprate-consensus = { path = "consensus" ,default-features = false}
58+
cuprate-consensus-context = { path = "consensus/context" ,default-features = false}
59+
cuprate-cryptonight = { path = "cryptonight" ,default-features = false}
60+
cuprate-helper = { path = "helper" ,default-features = false}
61+
cuprate-epee-encoding = { path = "net/epee-encoding" ,default-features = false}
62+
cuprate-fixed-bytes = { path = "net/fixed-bytes" ,default-features = false}
63+
cuprate-levin = { path = "net/levin" ,default-features = false}
64+
cuprate-wire = { path = "net/wire" ,default-features = false}
65+
cuprate-p2p = { path = "p2p/p2p" ,default-features = false}
66+
cuprate-p2p-core = { path = "p2p/p2p-core" ,default-features = false}
67+
cuprate-dandelion-tower = { path = "p2p/dandelion-tower" ,default-features = false}
68+
cuprate-async-buffer = { path = "p2p/async-buffer" ,default-features = false}
69+
cuprate-address-book = { path = "p2p/address-book" ,default-features = false}
70+
cuprate-blockchain = { path = "storage/blockchain" ,default-features = false}
71+
cuprate-database = { path = "storage/database" ,default-features = false}
72+
cuprate-database-service = { path = "storage/service" ,default-features = false}
73+
cuprate-txpool = { path = "storage/txpool" ,default-features = false}
74+
cuprate-pruning = { path = "pruning" ,default-features = false}
75+
cuprate-test-utils = { path = "test-utils" ,default-features = false}
76+
cuprate-types = { path = "types" ,default-features = false}
77+
cuprate-json-rpc = { path = "rpc/json-rpc" ,default-features = false}
78+
cuprate-rpc-types = { path = "rpc/types" ,default-features = false}
79+
cuprate-rpc-interface = { path = "rpc/interface" ,default-features = false}
80+
81+
# External dependencies
5282
anyhow = { version = "1.0.89", default-features = false }
5383
async-trait = { version = "0.1.82", default-features = false }
5484
bitflags = { version = "2.6.0", default-features = false }
@@ -322,4 +352,4 @@ non_camel_case_types = "deny"
322352
# unused_results = "deny"
323353
# non_exhaustive_omitted_patterns = "deny"
324354
# missing_docs = "deny"
325-
# missing_copy_implementations = "deny"
355+
# missing_copy_implementations = "deny"

binaries/cuprated/Cargo.toml

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,31 @@ repository = "https://github.com/Cuprate/cuprate/tree/main/binaries/cuprated"
99

1010
[dependencies]
1111
# TODO: after v1.0.0, remove unneeded dependencies.
12-
cuprate-consensus = { path = "../../consensus" }
13-
cuprate-fast-sync = { path = "../../consensus/fast-sync" }
14-
cuprate-consensus-rules = { path = "../../consensus/rules" }
15-
cuprate-cryptonight = { path = "../../cryptonight" }
16-
cuprate-helper = { path = "../../helper", features = ["serde"] }
17-
cuprate-epee-encoding = { path = "../../net/epee-encoding" }
18-
cuprate-fixed-bytes = { path = "../../net/fixed-bytes" }
19-
cuprate-levin = { path = "../../net/levin" }
20-
cuprate-wire = { path = "../../net/wire" }
21-
cuprate-p2p = { path = "../../p2p/p2p", features = ["serde"] }
22-
cuprate-p2p-core = { path = "../../p2p/p2p-core", features = ["serde"] }
23-
cuprate-dandelion-tower = { path = "../../p2p/dandelion-tower" }
24-
cuprate-async-buffer = { path = "../../p2p/async-buffer" }
25-
cuprate-address-book = { path = "../../p2p/address-book", features = ["serde_config"] }
26-
cuprate-blockchain = { path = "../../storage/blockchain", features = ["service"] }
27-
cuprate-database-service = { path = "../../storage/service", features = ["serde"] }
28-
cuprate-txpool = { path = "../../storage/txpool" }
29-
cuprate-database = { path = "../../storage/database", features = ["serde"] }
30-
cuprate-pruning = { path = "../../pruning" }
31-
cuprate-test-utils = { path = "../../test-utils" }
32-
cuprate-types = { path = "../../types" }
33-
cuprate-json-rpc = { path = "../../rpc/json-rpc" }
34-
cuprate-rpc-interface = { path = "../../rpc/interface" }
35-
cuprate-rpc-types = { path = "../../rpc/types" }
12+
cuprate-consensus = { workspace = true }
13+
cuprate-fast-sync = { workspace = true }
14+
cuprate-consensus-context = { workspace = true }
15+
cuprate-consensus-rules = { workspace = true }
16+
cuprate-cryptonight = { workspace = true }
17+
cuprate-helper = { workspace = true, features = ["serde"] }
18+
cuprate-epee-encoding = { workspace = true }
19+
cuprate-fixed-bytes = { workspace = true }
20+
cuprate-levin = { workspace = true }
21+
cuprate-wire = { workspace = true }
22+
cuprate-p2p = { workspace = true, features = ["serde"] }
23+
cuprate-p2p-core = { workspace = true, features = ["serde"] }
24+
cuprate-dandelion-tower = { workspace = true }
25+
cuprate-async-buffer = { workspace = true }
26+
cuprate-address-book = { workspace = true, features = ["serde_config"] }
27+
cuprate-blockchain = { workspace = true, features = ["service"] }
28+
cuprate-database-service = { workspace = true, features = ["serde"] }
29+
cuprate-txpool = { workspace = true }
30+
cuprate-database = { workspace = true, features = ["serde"] }
31+
cuprate-pruning = { workspace = true }
32+
cuprate-test-utils = { workspace = true }
33+
cuprate-types = { workspace = true }
34+
cuprate-json-rpc = { workspace = true }
35+
cuprate-rpc-interface = { workspace = true }
36+
cuprate-rpc-types = { workspace = true }
3637

3738
# TODO: after v1.0.0, remove unneeded dependencies.
3839
anyhow = { workspace = true }

binaries/cuprated/src/blockchain/manager.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ use tracing::error;
88

99
use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle};
1010
use cuprate_consensus::{
11-
context::RawBlockChainContext, BlockChainContextRequest, BlockChainContextResponse,
12-
BlockChainContextService, BlockVerifierService, ExtendedConsensusError, TxVerifierService,
13-
VerifyBlockRequest, VerifyBlockResponse, VerifyTxRequest, VerifyTxResponse,
11+
BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService,
12+
BlockVerifierService, ExtendedConsensusError, TxVerifierService, VerifyBlockRequest,
13+
VerifyBlockResponse, VerifyTxRequest, VerifyTxResponse,
1414
};
15+
use cuprate_consensus_context::RawBlockChainContext;
1516
use cuprate_p2p::{
1617
block_downloader::{BlockBatch, BlockDownloaderConfig},
1718
BroadcastSvc, NetworkInterface,

binaries/cuprated/src/blockchain/manager/handler.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ use tracing::info;
1010

1111
use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle};
1212
use cuprate_consensus::{
13-
block::PreparedBlock, context::NewBlockData, transactions::new_tx_verification_data,
14-
BlockChainContextRequest, BlockChainContextResponse, BlockVerifierService,
15-
ExtendedConsensusError, VerifyBlockRequest, VerifyBlockResponse, VerifyTxRequest,
16-
VerifyTxResponse,
13+
block::PreparedBlock, transactions::new_tx_verification_data, BlockChainContextRequest,
14+
BlockChainContextResponse, BlockVerifierService, ExtendedConsensusError, VerifyBlockRequest,
15+
VerifyBlockResponse, VerifyTxRequest, VerifyTxResponse,
1716
};
17+
use cuprate_consensus_context::NewBlockData;
1818
use cuprate_helper::cast::usize_to_u64;
1919
use cuprate_p2p::{block_downloader::BlockBatch, constants::LONG_BAN, BroadcastRequest};
2020
use cuprate_types::{

binaries/cuprated/src/rpc/request/blockchain_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::convert::Infallible;
55
use anyhow::Error;
66
use tower::{Service, ServiceExt};
77

8-
use cuprate_consensus::context::{
8+
use cuprate_consensus_context::{
99
BlockChainContext, BlockChainContextRequest, BlockChainContextResponse,
1010
BlockChainContextService,
1111
};

books/architecture/src/appendix/crates.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ cargo doc --open --package cuprate-blockchain
1616
| Crate | In-tree path | Purpose |
1717
|-------|--------------|---------|
1818
| [`cuprate-consensus`](https://doc.cuprate.org/cuprate_consensus) | [`consensus/`](https://github.com/Cuprate/cuprate/tree/main/consensus) | TODO
19-
| [`cuprate-consensus-rules`](https://doc.cuprate.org/cuprate_consensus_rules) | [`consensus/rules/`](https://github.com/Cuprate/cuprate/tree/main/consensus-rules) | TODO
19+
| [`cuprate-consensus-context`](https://doc.cuprate.org/cuprate_consensus_context) | [`consensus/context/`](https://github.com/Cuprate/cuprate/tree/main/consensus/context) | TODO
20+
| [`cuprate-consensus-rules`](https://doc.cuprate.org/cuprate_consensus_rules) | [`consensus/rules/`](https://github.com/Cuprate/cuprate/tree/main/consensus/rules) | TODO
2021
| [`cuprate-fast-sync`](https://doc.cuprate.org/cuprate_fast_sync) | [`consensus/fast-sync/`](https://github.com/Cuprate/cuprate/tree/main/consensus/fast-sync) | Fast block synchronization
2122

2223
## Networking

consensus/Cargo.toml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,28 @@ authors = ["Boog900"]
88
repository = "https://github.com/Cuprate/cuprate/tree/main/consensus"
99

1010
[dependencies]
11-
cuprate-helper = { path = "../helper", default-features = false, features = ["std", "asynch", "num"] }
12-
cuprate-consensus-rules = { path = "./rules", features = ["rayon"] }
13-
cuprate-types = { path = "../types" }
11+
cuprate-helper = { workspace = true, default-features = false, features = ["std", "asynch", "num"] }
12+
cuprate-consensus-rules = { workspace = true, features = ["rayon"] }
13+
cuprate-types = { workspace = true }
14+
cuprate-consensus-context = { workspace = true }
1415

1516
cfg-if = { workspace = true }
1617
thiserror = { workspace = true }
1718
tower = { workspace = true, features = ["util"] }
1819
tracing = { workspace = true, features = ["std", "attributes"] }
1920
futures = { workspace = true, features = ["std", "async-await"] }
2021

21-
randomx-rs = { workspace = true }
2222
monero-serai = { workspace = true, features = ["std"] }
2323

2424
rayon = { workspace = true }
2525
thread_local = { workspace = true }
26-
tokio = { workspace = true, features = ["rt"] }
27-
tokio-util = { workspace = true }
2826

2927
hex = { workspace = true }
3028
rand = { workspace = true }
3129

3230
[dev-dependencies]
33-
cuprate-test-utils = { path = "../test-utils" }
34-
cuprate-consensus-rules = {path = "./rules", features = ["proptest"]}
31+
cuprate-test-utils = { workspace = true }
32+
cuprate-consensus-rules = { workspace = true, features = ["proptest"]}
3533

3634
hex-literal = { workspace = true }
3735
curve25519-dalek = { workspace = true }
@@ -42,4 +40,4 @@ proptest = { workspace = true }
4240
proptest-derive = { workspace = true }
4341

4442
[lints]
45-
workspace = true
43+
workspace = true

consensus/context/Cargo.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[package]
2+
name = "cuprate-consensus-context"
3+
version = "0.1.0"
4+
edition = "2021"
5+
license = "MIT"
6+
authors = ["SyntheticBird","Boog900"]
7+
8+
[dependencies]
9+
cuprate-consensus-rules = { workspace = true, features = ["proptest"]}
10+
cuprate-helper = { workspace = true, default-features = false, features = ["std", "cast", "num", "asynch"] }
11+
cuprate-types = { workspace = true, default-features = false, features = ["blockchain"] }
12+
13+
futures = { workspace = true, features = ["std", "async-await"] }
14+
tokio = { workspace = true, features = ["rt-multi-thread", "macros"]}
15+
tokio-util = { workspace = true }
16+
tower = { workspace = true, features = ["util"] }
17+
tracing = { workspace = true, features = ["std", "attributes"] }
18+
thiserror = { workspace = true }
19+
20+
monero-serai = { workspace = true, features = ["std"] }
21+
randomx-rs = { workspace = true }
22+
rayon = { workspace = true }
23+
thread_local = { workspace = true }
24+
hex = { workspace = true }
25+
26+
[lints]
27+
workspace = true

consensus/src/context/alt_chains.rs renamed to consensus/context/src/alt_chains.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ use cuprate_types::{
99
};
1010

1111
use crate::{
12-
ExtendedConsensusError,
13-
__private::Database,
14-
context::{difficulty::DifficultyCache, rx_vms::RandomXVm, weight::BlockWeightsCache},
12+
ContextCacheError, __private::Database, difficulty::DifficultyCache, rx_vms::RandomXVm,
13+
weight::BlockWeightsCache,
1514
};
1615

1716
pub(crate) mod sealed {
@@ -38,7 +37,7 @@ pub struct AltChainContextCache {
3837
pub chain_height: usize,
3938
/// The top hash of the alt chain.
4039
pub top_hash: [u8; 32],
41-
/// The [`ChainID`] of the alt chain.
40+
/// The [`ChainId`] of the alt chain.
4241
pub chain_id: Option<ChainId>,
4342
/// The parent [`Chain`] of this alt chain.
4443
pub parent_chain: Chain,
@@ -98,7 +97,7 @@ impl AltChainMap {
9897
&mut self,
9998
prev_id: [u8; 32],
10099
database: D,
101-
) -> Result<Box<AltChainContextCache>, ExtendedConsensusError> {
100+
) -> Result<Box<AltChainContextCache>, ContextCacheError> {
102101
if let Some(cache) = self.alt_cache_map.remove(&prev_id) {
103102
return Ok(cache);
104103
}
@@ -133,7 +132,7 @@ pub(crate) async fn get_alt_chain_difficulty_cache<D: Database + Clone>(
133132
prev_id: [u8; 32],
134133
main_chain_difficulty_cache: &DifficultyCache,
135134
mut database: D,
136-
) -> Result<DifficultyCache, ExtendedConsensusError> {
135+
) -> Result<DifficultyCache, ContextCacheError> {
137136
// find the block with hash == prev_id.
138137
let BlockchainResponse::FindBlock(res) = database
139138
.ready()
@@ -180,7 +179,7 @@ pub(crate) async fn get_alt_chain_weight_cache<D: Database + Clone>(
180179
prev_id: [u8; 32],
181180
main_chain_weight_cache: &BlockWeightsCache,
182181
mut database: D,
183-
) -> Result<BlockWeightsCache, ExtendedConsensusError> {
182+
) -> Result<BlockWeightsCache, ContextCacheError> {
184183
// find the block with hash == prev_id.
185184
let BlockchainResponse::FindBlock(res) = database
186185
.ready()

0 commit comments

Comments
 (0)