Skip to content

Commit

Permalink
Merge branch 'testnet3' into feat/rest_rate_limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
howardwu authored Dec 27, 2023
2 parents 48f54c2 + 664fdb2 commit c1d8d5f
Show file tree
Hide file tree
Showing 23 changed files with 171 additions and 94 deletions.
3 changes: 2 additions & 1 deletion .integration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ mod tests {
// Perform the sync.
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
let completed_height = sync_ledger_with_cdn(TEST_BASE_URL, ledger.clone()).await.unwrap();
let completed_height =
sync_ledger_with_cdn(TEST_BASE_URL, ledger.clone(), Default::default()).await.unwrap();
assert_eq!(completed_height, ledger.latest_height());
});
}
Expand Down
60 changes: 30 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jemalloc = [ "tikv-jemallocator" ]
metrics = [ "snarkos-node-metrics", "snarkos-node/metrics" ]

[dependencies.anyhow]
version = "1.0.75"
version = "1.0.76"

[dependencies.clap]
version = "4.4"
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ The following are **minimum** requirements to run an Aleo node:
- Provers: CUDA-enabled GPU (optional)
- Validators: Not required at this time

Please note to run an Aleo Prover that is **competitive**, the machine will require more than these requirements.
Please note that in order to run an Aleo Prover that is **competitive**, the machine will need more than these requirements.

### 2.2 Installation

Before beginning, please ensure your machine has `Rust v1.66+` installed. Instructions to [install Rust can be found here.](https://www.rust-lang.org/tools/install)

Start by cloning this Github repository:
Start by cloning this GitHub repository:
```
git clone https://github.com/AleoHQ/snarkOS.git --depth 1
```
Expand Down Expand Up @@ -150,11 +150,11 @@ APrivateKey1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
### 3. I can't generate a new address ###

- Before running the command above (`snarkos account new`) try `source ~/.bashrc`
- Also double-check the spelling of `snarkos`. Note the directory is `/snarkOS`, the command is `snarkos`
- Also double-check the spelling of `snarkos`. Note the directory is `/snarkOS`, and the command is `snarkos`

## 5. Command Line Interface

To run a node with custom settings, refer to the full list of options and flags available in the `snarkOS` CLI.
To run a node with custom settings, refer to the options and flags available in the `snarkOS` CLI.

The full list of CLI flags and options can be viewed with `snarkos --help`:
```
Expand Down Expand Up @@ -225,7 +225,7 @@ In the fourth terminal, start the fourth validator by running:
cargo run --release -- start --nodisplay --dev 3 --validator
```

From here, this procedure can be used to further start up provers and clients.
From here, this procedure can be used to further start-up provers and clients.

### 6.2 Operations

Expand Down Expand Up @@ -434,7 +434,7 @@ Thank you for helping make snarkOS better!

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!

## 8. License

Expand Down
2 changes: 1 addition & 1 deletion account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ license = "Apache-2.0"
edition = "2021"

[dependencies.anyhow]
version = "1.0.75"
version = "1.0.76"

[dependencies.colored]
version = "2"
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ default-features = false
version = "1"

[dependencies.anyhow]
version = "1.0.75"
version = "1.0.76"

[dependencies.bincode]
version = "1.0"
Expand Down
50 changes: 33 additions & 17 deletions cli/src/commands/developer/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,25 +252,41 @@ impl Scan {
// Construct the runtime.
let rt = tokio::runtime::Runtime::new()?;

// Create a placeholder shutdown flag.
let _shutdown = Default::default();

// Scan the blocks via the CDN.
rt.block_on(async move {
let _ = snarkos_node_cdn::load_blocks(&cdn, cdn_request_start, Some(cdn_request_end), move |block| {
// Check if the block is within the requested range.
if block.height() < start_height || block.height() > end_height {
return Ok(());
}

// Log the progress.
let percentage_complete =
block.height().saturating_sub(start_height) as f64 * 100.0 / total_blocks as f64;
print!("\rScanning {total_blocks} blocks for records ({percentage_complete:.2}% complete)...");
stdout().flush()?;

// Scan the block for records.
Self::scan_block(&block, &endpoint, private_key, &view_key, &address_x_coordinate, records.clone())?;

Ok(())
})
let _ = snarkos_node_cdn::load_blocks(
&cdn,
cdn_request_start,
Some(cdn_request_end),
_shutdown,
move |block| {
// Check if the block is within the requested range.
if block.height() < start_height || block.height() > end_height {
return Ok(());
}

// Log the progress.
let percentage_complete =
block.height().saturating_sub(start_height) as f64 * 100.0 / total_blocks as f64;
print!("\rScanning {total_blocks} blocks for records ({percentage_complete:.2}% complete)...");
stdout().flush()?;

// Scan the block for records.
Self::scan_block(
&block,
&endpoint,
private_key,
&view_key,
&address_x_coordinate,
records.clone(),
)?;

Ok(())
},
)
.await;
});

Expand Down
2 changes: 1 addition & 1 deletion display/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ license = "Apache-2.0"
edition = "2021"

[dependencies.anyhow]
version = "1.0.75"
version = "1.0.76"

[dependencies.crossterm]
version = "0.27"
Expand Down
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ version = "0.1.18"
default-features = false

[dependencies.anyhow]
version = "1.0.75"
version = "1.0.76"

[dependencies.async-trait]
version = "0.1"
Expand Down
6 changes: 3 additions & 3 deletions node/bft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ default = [ ]
metrics = [ "dep:metrics", "snarkos-node-bft-events/metrics" ]

[dependencies.anyhow]
version = "1.0.70"
version = "1.0.76"

[dependencies.async-recursion]
version = "1.0"
Expand All @@ -36,7 +36,7 @@ version = "1"
version = "2"

[dependencies.futures]
version = "0.3.29"
version = "0.3.30"
features = [ "thread-pool" ]

[dependencies.indexmap]
Expand Down Expand Up @@ -177,4 +177,4 @@ features = [ "env-filter" ]
version = "0.1"

[dev-dependencies.mockall]
version = "0.12.0"
version = "0.12.1"
19 changes: 16 additions & 3 deletions node/bft/ledger-service/src/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,27 @@ use snarkvm::{
};

use indexmap::IndexMap;
use std::{fmt, ops::Range, sync::Arc};
use std::{
fmt,
ops::Range,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
};

/// A core ledger service.
pub struct CoreLedgerService<N: Network, C: ConsensusStorage<N>> {
ledger: Ledger<N, C>,
coinbase_verifying_key: Arc<CoinbaseVerifyingKey<N>>,
shutdown: Arc<AtomicBool>,
}

impl<N: Network, C: ConsensusStorage<N>> CoreLedgerService<N, C> {
/// Initializes a new core ledger service.
pub fn new(ledger: Ledger<N, C>) -> Self {
pub fn new(ledger: Ledger<N, C>, shutdown: Arc<AtomicBool>) -> Self {
let coinbase_verifying_key = Arc::new(ledger.coinbase_puzzle().coinbase_verifying_key().clone());
Self { ledger, coinbase_verifying_key }
Self { ledger, coinbase_verifying_key, shutdown }
}
}

Expand Down Expand Up @@ -283,6 +291,11 @@ impl<N: Network, C: ConsensusStorage<N>> LedgerService<N> for CoreLedgerService<
/// Adds the given block as the next block in the ledger.
#[cfg(feature = "ledger-write")]
fn advance_to_next_block(&self, block: &Block<N>) -> Result<()> {
// If the Ctrl-C handler registered the signal, then skip advancing to the next block.
if self.shutdown.load(Ordering::Relaxed) {
bail!("Skipping advancing to block {} - The node is shutting down", block.height());
}
// Advance to the next block.
self.ledger.advance_to_next_block(block)?;
tracing::info!("\n\nAdvanced to block {} at round {} - {}\n", block.height(), block.round(), block.hash());
Ok(())
Expand Down
Loading

0 comments on commit c1d8d5f

Please sign in to comment.