Skip to content

Commit

Permalink
Merge pull request #2503 from ProvableHQ/feat/update-target
Browse files Browse the repository at this point in the history
[Feature] Update targets
  • Loading branch information
apruden2008 committed Jun 26, 2024
2 parents d1dbad4 + bb98e68 commit d170a9f
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 13 deletions.
4 changes: 2 additions & 2 deletions console/network/src/canary_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ impl Network for CanaryV0 {
/// The network edition.
const EDITION: u16 = 0;
/// The genesis block coinbase target.
const GENESIS_COINBASE_TARGET: u64 = (1u64 << 10).saturating_sub(1);
const GENESIS_COINBASE_TARGET: u64 = (1u64 << 29).saturating_sub(1);
/// The genesis block proof target.
const GENESIS_PROOF_TARGET: u64 = 1u64 << 8;
const GENESIS_PROOF_TARGET: u64 = 1u64 << 27;
/// The fixed timestamp of the genesis block.
const GENESIS_TIMESTAMP: i64 = 1715776496 /* 2024-05-15 12:34:56 UTC */;
/// The network ID.
Expand Down
4 changes: 2 additions & 2 deletions console/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ pub trait Network:
const GENESIS_TIMESTAMP: i64;
/// The genesis block coinbase target.
#[cfg(not(feature = "test"))]
const GENESIS_COINBASE_TARGET: u64 = (1u64 << 10).saturating_sub(1);
const GENESIS_COINBASE_TARGET: u64 = (1u64 << 29).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;
const GENESIS_PROOF_TARGET: u64 = 1u64 << 27;
/// The genesis block proof target.
/// This is deliberately set to a low value (8) for testing purposes only.
#[cfg(feature = "test")]
Expand Down
14 changes: 14 additions & 0 deletions console/network/src/mainnet_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ impl Network for MainnetV0 {

/// The network edition.
const EDITION: u16 = 0;
/// The genesis block coinbase target.
#[cfg(not(feature = "test"))]
const GENESIS_COINBASE_TARGET: u64 = (1u64 << 29).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 << 27;
/// The genesis block proof target.
/// This is deliberately set to a low value (8) for testing purposes only.
#[cfg(feature = "test")]
const GENESIS_PROOF_TARGET: u64 = 1u64 << 3;
/// The fixed timestamp of the genesis block.
const GENESIS_TIMESTAMP: i64 = 1696118400 /* 2023-10-01 00:00:00 UTC */;
/// The network ID.
Expand Down
4 changes: 2 additions & 2 deletions console/network/src/testnet_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ impl Network for TestnetV0 {
/// The network edition.
const EDITION: u16 = 0;
/// The genesis block coinbase target.
const GENESIS_COINBASE_TARGET: u64 = (1u64 << 10).saturating_sub(1);
const GENESIS_COINBASE_TARGET: u64 = (1u64 << 29).saturating_sub(1);
/// The genesis block proof target.
const GENESIS_PROOF_TARGET: u64 = 1u64 << 8;
const GENESIS_PROOF_TARGET: u64 = 1u64 << 27;
/// The fixed timestamp of the genesis block.
const GENESIS_TIMESTAMP: i64 = 1715776496 /* 2024-05-15 12:34:56 UTC */;
/// The network ID.
Expand Down
2 changes: 1 addition & 1 deletion parameters/src/canary/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ mod tests {
#[test]
fn test_genesis_block() {
let bytes = GenesisBytes::load_bytes();
assert_eq!(14947, bytes.len() as u64, "Update me if serialization has changed");
assert_eq!(20083, bytes.len() as u64, "Update me if serialization has changed");
}
}
Binary file modified parameters/src/canary/resources/block.genesis
Binary file not shown.
2 changes: 1 addition & 1 deletion parameters/src/mainnet/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ mod tests {
#[test]
fn test_genesis_block() {
let bytes = GenesisBytes::load_bytes();
assert_eq!(14955, bytes.len() as u64, "Update me if serialization has changed");
assert_eq!(20083, bytes.len() as u64, "Update me if serialization has changed");
}
}
Binary file modified parameters/src/mainnet/resources/block.genesis
Binary file not shown.
2 changes: 1 addition & 1 deletion parameters/src/testnet/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ mod tests {
#[test]
fn test_genesis_block() {
let bytes = GenesisBytes::load_bytes();
assert_eq!(14943, bytes.len() as u64, "Update me if serialization has changed");
assert_eq!(20083, bytes.len() as u64, "Update me if serialization has changed");
}
}
Binary file modified parameters/src/testnet/resources/block.genesis
Binary file not shown.
4 changes: 4 additions & 0 deletions synthesizer/src/vm/finalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,10 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {
*amount >= MIN_DELEGATOR_STAKE,
"Ratify::Genesis(..) the delegator {address} must stake at least {MIN_DELEGATOR_STAKE}",
);
// If the corresponding validator is not a committee member yet, then continue.
if !committee.is_committee_member(*validator_address) {
continue;
}
// If the address is a delegator, check that the corresponding validator is open.
ensure!(
committee.is_committee_member_open(*validator_address),
Expand Down
9 changes: 6 additions & 3 deletions synthesizer/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,17 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {
bonded_balances: IndexMap<Address<N>, (Address<N>, Address<N>, u64)>,
rng: &mut R,
) -> Result<Block<N>> {
// Retrieve the total stake.
let total_stake = committee.total_stake();
// Retrieve the total bonded balance.
let total_bonded_amount = bonded_balances
.values()
.try_fold(0u64, |acc, (_, _, x)| acc.checked_add(*x).ok_or(anyhow!("Invalid bonded amount")))?;
// Compute the account supply.
let account_supply = public_balances
.values()
.try_fold(0u64, |acc, x| acc.checked_add(*x).ok_or(anyhow!("Invalid account supply")))?;
// Compute the total supply.
let total_supply = total_stake.checked_add(account_supply).ok_or_else(|| anyhow!("Invalid total supply"))?;
let total_supply =
total_bonded_amount.checked_add(account_supply).ok_or_else(|| anyhow!("Invalid total supply"))?;
// Ensure the total supply matches.
ensure!(
total_supply == N::STARTING_SUPPLY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ outputs:
test_rand.aleo/rand_chacha_check:
outputs:
- '{"type":"future","id":"3094014759641313043901697261267946468626327163450942596641947962222295207390field","value":"{\n program_id: test_rand.aleo,\n function_name: rand_chacha_check,\n arguments: [\n 0field,\n false\n ]\n}"}'
speculate: the execution was accepted
speculate: the execution was rejected
add_next_block: succeeded.
- verified: true
execute:
Expand Down

0 comments on commit d170a9f

Please sign in to comment.