Skip to content

Commit

Permalink
Merge branch 'mainnet-staging' into unique-transmissions
Browse files Browse the repository at this point in the history
  • Loading branch information
howardwu authored Mar 22, 2024
2 parents da996bd + 689ce48 commit 915ae93
Show file tree
Hide file tree
Showing 9 changed files with 547 additions and 762 deletions.
116 changes: 58 additions & 58 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ default-features = false

[workspace.dependencies.snarkvm]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "01c8b09"
rev = "eefd27d"
#version = "=0.16.18"
features = [ "circuit", "console", "rocks" ]

Expand Down
2 changes: 1 addition & 1 deletion devnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ for client_index in "${client_indices[@]}"; do
tmux new-window -t "devnet:$window_index" -n "window-$window_index"

# Send the command to start the validator to the new window and capture output to the log file
tmux send-keys -t "devnet:window-$window_index" "snarkos start --nodisplay --dev $window_index --client --logfile $log_file" C-m
tmux send-keys -t "devnet:window-$window_index" "snarkos start --nodisplay --dev $window_index --dev-num-validators $total_validators --client --logfile $log_file" C-m
done

# Attach to the tmux session to view and interact with the windows
Expand Down
5 changes: 4 additions & 1 deletion node/bft/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,12 @@ mod tests {

#[tokio::test]
async fn test_max_redundant_requests() {
const NUM_NODES: u16 = Committee::<CurrentNetwork>::MAX_COMMITTEE_SIZE;

let rng = &mut TestRng::default();
// Sample a committee.
let committee = snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_size(0, 100, rng);
let committee =
snarkvm::ledger::committee::test_helpers::sample_committee_for_round_and_size(0, NUM_NODES, rng);
let committee_clone = committee.clone();
// Setup the mock ledger.
let mut mock_ledger = MockLedger::default();
Expand Down
6 changes: 4 additions & 2 deletions node/bft/tests/common/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use snarkvm::{
console::{
account::{Address, PrivateKey},
algorithms::{Hash, BHP256},
network::Network,
},
ledger::{
block::Block,
Expand Down Expand Up @@ -137,8 +138,9 @@ impl TestNetwork {
.map(|(address, (amount, _))| (*address, (*address, *address, *amount)))
.collect();
let gen_key = *accounts[0].private_key();
let public_balance_per_validator =
(1_500_000_000_000_000 - (config.num_nodes as u64) * 1_000_000_000_000) / (config.num_nodes as u64);
let public_balance_per_validator = (CurrentNetwork::STARTING_SUPPLY
- (config.num_nodes as u64) * MIN_VALIDATOR_STAKE)
/ (config.num_nodes as u64);
let mut balances = IndexMap::<Address<CurrentNetwork>, u64>::new();
for account in accounts.iter() {
balances.insert(account.address(), public_balance_per_validator);
Expand Down
4 changes: 2 additions & 2 deletions node/bft/tests/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use snarkos_node_bft_ledger_service::LedgerService;
use snarkos_node_bft_storage_service::BFTMemoryService;
use snarkvm::{
console::{account::Address, network::Network},
ledger::{narwhal::BatchHeader, store::helpers::memory::ConsensusMemory},
ledger::{committee::MIN_VALIDATOR_STAKE, narwhal::BatchHeader, store::helpers::memory::ConsensusMemory},
prelude::TestRng,
};

Expand All @@ -42,7 +42,7 @@ pub fn sample_ledger(
committee.members().iter().map(|(address, (amount, _))| (*address, (*address, *address, *amount))).collect();
let gen_key = *accounts[0].private_key();
let public_balance_per_validator =
(1_500_000_000_000_000 - (num_nodes as u64) * 1_000_000_000_000) / (num_nodes as u64);
(CurrentNetwork::STARTING_SUPPLY - (num_nodes as u64) * MIN_VALIDATOR_STAKE) / (num_nodes as u64);
let mut balances = IndexMap::<Address<CurrentNetwork>, u64>::new();
for account in accounts.iter() {
balances.insert(account.address(), public_balance_per_validator);
Expand Down
6 changes: 3 additions & 3 deletions node/bft/tests/components/pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::components::sample_ledger;
use crate::{common::CurrentNetwork, components::sample_ledger};
use snarkos_node_bft::helpers::max_redundant_requests;
use snarkvm::prelude::TestRng;
use snarkvm::{ledger::committee::Committee, prelude::TestRng};

#[test]
fn test_max_redundant_requests() {
const NUM_NODES: u16 = 100;
const NUM_NODES: u16 = Committee::<CurrentNetwork>::MAX_COMMITTEE_SIZE;

// Initialize the RNG.
let rng = &mut TestRng::default();
Expand Down
12 changes: 8 additions & 4 deletions node/bft/tests/components/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
};
use snarkos_node_bft::helpers::max_redundant_requests;
use snarkvm::{
ledger::narwhal::TransmissionID,
ledger::{committee::Committee, narwhal::TransmissionID},
prelude::{Network, TestRng},
};

Expand All @@ -27,7 +27,7 @@ use std::net::SocketAddr;
#[tokio::test]
#[rustfmt::skip]
async fn test_resend_transmission_request() {
const NUM_NODES: u16 = 100;
const NUM_NODES: u16 = Committee::<CurrentNetwork>::MAX_COMMITTEE_SIZE;

// Initialize the RNG.
let rng = &mut TestRng::default();
Expand All @@ -36,6 +36,10 @@ async fn test_resend_transmission_request() {
// Sample a worker.
let worker = sample_worker(0, ledger.clone());

// Determine the maximum number of redundant requests.
let max_redundancy = max_redundant_requests(ledger.clone(), 0);
assert_eq!(max_redundancy, 34, "Update me if the formula changes");

// Prepare a dummy transmission ID.
let peer_ip = SocketAddr::from(([127, 0, 0, 1], 1234));
let transmission_id = TransmissionID::Transaction(<CurrentNetwork as Network>::TransactionID::default());
Expand Down Expand Up @@ -75,14 +79,14 @@ async fn test_resend_transmission_request() {
// Ensure the number of callbacks is correct.
assert_eq!(pending.num_callbacks(transmission_id), 1 + i, "Incorrect number of callbacks for transmission");
// Ensure the number of sent requests is correct.
assert_eq!(pending.num_sent_requests(transmission_id), 1 + i, "Incorrect number of sent requests for transmission");
assert_eq!(pending.num_sent_requests(transmission_id), (1 + i).min(max_redundancy), "Incorrect number of sent requests for transmission");
}
}

#[tokio::test]
#[rustfmt::skip]
async fn test_flood_transmission_requests() {
const NUM_NODES: u16 = 100;
const NUM_NODES: u16 = Committee::<CurrentNetwork>::MAX_COMMITTEE_SIZE;

// Initialize the RNG.
let rng = &mut TestRng::default();
Expand Down
Loading

0 comments on commit 915ae93

Please sign in to comment.