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

[Feature] Updates the puzzle integration for development and testing #2401

Merged
merged 1 commit into from Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 31 additions & 10 deletions .circleci/config.yml
Expand Up @@ -493,32 +493,33 @@ jobs:
workspace_member: ledger
cache_key: snarkvm-ledger-with-rocksdb-cache

ledger-authority:
ledger-with-valid-solutions:
docker:
- image: cimg/rust:1.72.1
resource_class: 2xlarge
steps:
- run_serial:
workspace_member: ledger/authority
cache_key: snarkvm-ledger-authority-cache
flags: valid_solutions --features=test
workspace_member: ledger
cache_key: snarkvm-ledger-with-valid-solutions-cache

ledger-block:
ledger-authority:
docker:
- image: cimg/rust:1.72.1
resource_class: 2xlarge
steps:
- run_serial:
workspace_member: ledger/block
cache_key: snarkvm-ledger-block-cache
workspace_member: ledger/authority
cache_key: snarkvm-ledger-authority-cache

ledger-coinbase:
ledger-block:
docker:
- image: cimg/rust:1.72.1
resource_class: 2xlarge
steps:
- run_serial:
workspace_member: ledger/coinbase
cache_key: snarkvm-ledger-coinbase-cache
workspace_member: ledger/block
cache_key: snarkvm-ledger-block-cache

ledger-committee:
docker:
Expand Down Expand Up @@ -592,6 +593,24 @@ jobs:
workspace_member: ledger/narwhal/transmission-id
cache_key: snarkvm-ledger-narwhal-transmission-id-cache

ledger-puzzle:
docker:
- image: cimg/rust:1.72.1
resource_class: 2xlarge
steps:
- run_serial:
workspace_member: ledger/puzzle
cache_key: snarkvm-ledger-puzzle-cache

ledger-puzzle-epoch:
docker:
- image: cimg/rust:1.72.1
resource_class: 2xlarge
steps:
- run_serial:
workspace_member: ledger/puzzle/epoch
cache_key: snarkvm-ledger-puzzle-epoch-cache

ledger-query:
docker:
- image: cimg/rust:1.72.1
Expand Down Expand Up @@ -869,9 +888,9 @@ workflows:
- ledger
# TODO (howardwu) - Implement `open_testing` on all storage, update to `CurrentConsensusStore::open_testing`, then re-enable.
# - ledger-with-rocksdb
- ledger-with-valid-solutions
- ledger-authority
- ledger-block
- ledger-coinbase
- ledger-committee
- ledger-narwhal
- ledger-narwhal-batch-certificate
Expand All @@ -880,6 +899,8 @@ workflows:
- ledger-narwhal-subdag
- ledger-narwhal-transmission
- ledger-narwhal-transmission-id
- ledger-puzzle
- ledger-puzzle-epoch
- ledger-query
- ledger-store
- ledger-test-helpers
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yml
Expand Up @@ -84,7 +84,7 @@ jobs:
- name: Benchmark ledger/coinbase
run: |
cd ledger/coinbase
cargo bench --bench coinbase_puzzle --features "setup" -- --output-format bencher | tee -a ../../output.txt
cargo bench --bench puzzle --features "setup" -- --output-format bencher | tee -a ../../output.txt
cd ../..

# Clean benchmark output to remove unnecessary lines
Expand Down
77 changes: 46 additions & 31 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Expand Up @@ -64,7 +64,6 @@ members = [
"ledger",
"ledger/authority",
"ledger/block",
"ledger/coinbase",
"ledger/committee",
"ledger/narwhal",
"ledger/narwhal/batch-certificate",
Expand All @@ -73,6 +72,8 @@ members = [
"ledger/narwhal/subdag",
"ledger/narwhal/transmission",
"ledger/narwhal/transmission-id",
"ledger/puzzle",
"ledger/puzzle/epoch",
"ledger/query",
"ledger/store",
"ledger/test-helpers",
Expand Down
4 changes: 4 additions & 0 deletions algorithms/src/snark/varuna/data_structures/proof.rs
Expand Up @@ -255,6 +255,10 @@ impl<E: PairingEngine> Proof<E> {
Ok(Self { batch_sizes, commitments, evaluations, third_msg, fourth_msg, pc_proof })
}

pub fn is_hiding(&self) -> bool {
self.pc_proof.is_hiding()
}

pub fn batch_sizes(&self) -> &[usize] {
&self.batch_sizes
}
Expand Down
1 change: 1 addition & 0 deletions circuit/environment/src/environment.rs
Expand Up @@ -18,6 +18,7 @@ use snarkvm_fields::traits::*;

use core::{fmt, hash};

/// Attention: Do not use `Send + Sync` on this trait, as it is not thread-safe.
pub trait Environment: 'static + Copy + Clone + fmt::Debug + fmt::Display + Eq + PartialEq + hash::Hash {
type Network: console::Network<Affine = Self::Affine, Field = Self::BaseField, Scalar = Self::ScalarField>;

Expand Down
1 change: 1 addition & 0 deletions circuit/network/src/lib.rs
Expand Up @@ -21,6 +21,7 @@ pub use v0::*;
use snarkvm_circuit_collections::merkle_tree::MerklePath;
use snarkvm_circuit_types::{environment::Environment, Boolean, Field, Group, Scalar};

/// Attention: Do not use `Send + Sync` on this trait, as it is not thread-safe.
pub trait Aleo: Environment {
/// The maximum number of field elements in data (must not exceed u16::MAX).
const MAX_DATA_SIZE_IN_FIELDS: u32 = <Self::Network as console::Network>::MAX_DATA_SIZE_IN_FIELDS;
Expand Down
1 change: 1 addition & 0 deletions console/Cargo.toml
Expand Up @@ -48,6 +48,7 @@ default = [
wasm = [ "snarkvm-console-network/wasm" ]
test = [
"snarkvm-console-account/test",
"snarkvm-console-network/test",
"snarkvm-console-program/test"
]
account = [ "network", "snarkvm-console-account" ]
Expand Down
1 change: 1 addition & 0 deletions console/network/Cargo.toml
Expand Up @@ -12,6 +12,7 @@ wasm = [
"snarkvm-algorithms/polycommit_wasm",
"snarkvm-parameters/wasm"
]
test = []

[dependencies.snarkvm-algorithms]
path = "../../algorithms"
Expand Down
1 change: 1 addition & 0 deletions console/network/environment/src/lib.rs
Expand Up @@ -66,6 +66,7 @@ pub mod prelude {
cfg_into_iter,
cfg_iter,
cfg_iter_mut,
cfg_keys,
cfg_reduce,
cfg_values,
error,
Expand Down
22 changes: 16 additions & 6 deletions console/network/src/lib.rs
Expand Up @@ -90,9 +90,23 @@ pub trait Network:
/// The fixed timestamp of the genesis block.
const GENESIS_TIMESTAMP: i64 = 1696118400; // 2023-10-01 00:00:00 UTC
/// The genesis block coinbase target.
const GENESIS_COINBASE_TARGET: u64 = (1u64 << 32).saturating_sub(1);
#[cfg(not(feature = "test"))]
const GENESIS_COINBASE_TARGET: u64 = (1u64 << 10).saturating_sub(1);
/// The genesis block coinbase target.
/// This is deliberately set to a low value (32) for testing purposes only.
#[cfg(feature = "test")]
const GENESIS_COINBASE_TARGET: u64 = (1u64 << 5).saturating_sub(1);
/// The genesis block proof target.
#[cfg(not(feature = "test"))]
const GENESIS_PROOF_TARGET: u64 = 1u64 << 8;
/// The genesis block proof target.
const GENESIS_PROOF_TARGET: u64 = 1u64 << 25;
/// This is deliberately set to a low value (8) for testing purposes only.
#[cfg(feature = "test")]
const GENESIS_PROOF_TARGET: u64 = 1u64 << 3;
/// The maximum number of solutions that can be included per block as a power of 2.
const MAX_SOLUTIONS_AS_POWER_OF_TWO: u8 = 2; // 4 solutions
/// The maximum number of solutions that can be included per block.
const MAX_SOLUTIONS: usize = 1 << Self::MAX_SOLUTIONS_AS_POWER_OF_TWO; // 4 solutions

/// The starting supply of Aleo credits.
const STARTING_SUPPLY: u64 = 1_500_000_000_000_000; // 1.5B credits
Expand All @@ -113,10 +127,6 @@ pub trait Network:
const ANCHOR_TIME: u16 = 25;
/// The expected time per block in seconds.
const BLOCK_TIME: u16 = 10;
/// The coinbase puzzle degree.
const COINBASE_PUZZLE_DEGREE: u32 = (1 << 13) - 1; // 8,191
/// The maximum number of solutions that can be included per block.
const MAX_SOLUTIONS: usize = 1 << 8; // 256 solutions
/// The number of blocks per epoch.
const NUM_BLOCKS_PER_EPOCH: u32 = 3600 / Self::BLOCK_TIME as u32; // 360 blocks == ~1 hour

Expand Down
14 changes: 7 additions & 7 deletions ledger/Cargo.toml
Expand Up @@ -39,14 +39,14 @@ serial = [
"console/serial",
"ledger-authority/serial",
"ledger-block/serial",
"ledger-coinbase/serial",
"ledger-committee/serial",
"ledger-narwhal/serial",
"ledger-puzzle/serial",
"ledger-query/serial",
"ledger-store/serial",
"synthesizer/serial"
]
test = [ "ledger-block/test", "ledger-store/test" ]
test = [ "console/test", "ledger-block/test", "ledger-store/test" ]
test-helpers = [
"ledger-test-helpers",
"ledger-committee/test-helpers",
Expand All @@ -69,11 +69,6 @@ package = "snarkvm-ledger-block"
path = "./block"
version = "=0.16.19"

[dependencies.ledger-coinbase]
package = "snarkvm-ledger-coinbase"
path = "./coinbase"
version = "=0.16.19"

[dependencies.ledger-committee]
package = "snarkvm-ledger-committee"
path = "./committee"
Expand All @@ -84,6 +79,11 @@ package = "snarkvm-ledger-narwhal"
path = "./narwhal"
version = "=0.16.19"

[dependencies.ledger-puzzle]
package = "snarkvm-ledger-puzzle"
path = "puzzle"
version = "=0.16.19"

[dependencies.ledger-query]
package = "snarkvm-ledger-query"
path = "./query"
Expand Down