-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3313 from dusk-network/mainnet-dryrun-20250103
rusk: include changes from `rusk-release-1.0.0` branch
- Loading branch information
Showing
8 changed files
with
2,043 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
base_state = "https://nodes.dusk.network/genesis-state" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
�j�<$m��U]@����$s!ԕ��3ꠅ�EZH�� ��Y�'먎�+i!�/6�Y�^�,�2^'�Gs{�x�Rh8�~hڀEY�^t������� | ||
��k}�95��A�:�v�>�8��������k"�D������s�<6�9��)M�kfIO�����)1E����1������a�>6ء/�$� |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) DUSK NETWORK. All rights reserved. | ||
|
||
use std::path::Path; | ||
use std::sync::mpsc::{self, Receiver, Sender}; | ||
|
||
use dusk_core::dusk; | ||
use dusk_core::stake::{StakeData, StakeKeys, STAKE_CONTRACT}; | ||
use dusk_core::transfer::moonlight::AccountData; | ||
use dusk_core::transfer::phoenix::NoteLeaf; | ||
use dusk_core::transfer::TRANSFER_CONTRACT; | ||
use rusk::{Result, Rusk}; | ||
use tempfile::tempdir; | ||
|
||
use crate::common::logger; | ||
use crate::common::state::new_state; | ||
|
||
const GENESIS_BALANCE: u64 = dusk(500_000_000.0); | ||
|
||
// Creates the Rusk initial state for the tests below | ||
fn initial_state<P: AsRef<Path>>(dir: P) -> Result<Rusk> { | ||
let snapshot = toml::from_str(include_str!( | ||
"../../../rusk-recovery/config/mainnet.toml" | ||
)) | ||
.expect("Cannot deserialize config"); | ||
|
||
new_state(dir, &snapshot, u64::MAX) | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
pub async fn mainnet_genesis() -> Result<()> { | ||
// Setup the logger | ||
logger(); | ||
|
||
let tmp = tempdir().expect("Should be able to create temporary directory"); | ||
let rusk = initial_state(&tmp)?; | ||
let mut total_amount = 0u64; | ||
|
||
let (sender, receiver): (Sender<Vec<u8>>, Receiver<Vec<u8>>) = | ||
mpsc::channel(); | ||
rusk.feeder_query(STAKE_CONTRACT, "stakes", &(), sender, None)?; | ||
for bytes in receiver.into_iter() { | ||
let (_, data) = rkyv::from_bytes::<(StakeKeys, StakeData)>(&bytes) | ||
.expect( | ||
"The contract should only return (StakeKeys, StakeData) tuples", | ||
); | ||
total_amount += data.amount.unwrap_or_default().total_funds(); | ||
} | ||
|
||
let skate_balance: u64 = rusk | ||
.query(TRANSFER_CONTRACT, "contract_balance", &STAKE_CONTRACT) | ||
.expect("Query to succeed"); | ||
assert_eq!( | ||
total_amount, skate_balance, | ||
"Total stake amount should match" | ||
); | ||
|
||
let sync_range = (0u64, u64::MAX); | ||
let (sender, receiver): (Sender<Vec<u8>>, Receiver<Vec<u8>>) = | ||
std::sync::mpsc::channel(); | ||
rusk.feeder_query( | ||
TRANSFER_CONTRACT, | ||
"sync_accounts", | ||
&sync_range, | ||
sender, | ||
None, | ||
)?; | ||
for bytes in receiver.into_iter() { | ||
let (data, _) = rkyv::from_bytes::<(AccountData, [u8; 193])>(&bytes) | ||
.expect( | ||
"The contract should only return (AccountData, [u8; 193]) tuples", | ||
); | ||
total_amount += data.balance; | ||
} | ||
|
||
let (sender, receiver): (Sender<Vec<u8>>, Receiver<Vec<u8>>) = | ||
std::sync::mpsc::channel(); | ||
rusk.feeder_query(TRANSFER_CONTRACT, "sync", &sync_range, sender, None)?; | ||
for bytes in receiver.into_iter() { | ||
let leaf: NoteLeaf = rkyv::from_bytes(&bytes) | ||
.expect("The contract should only return NoteLeaf"); | ||
|
||
total_amount += leaf.note.value(None).expect("Transparent note"); | ||
} | ||
|
||
assert_eq!(total_amount, GENESIS_BALANCE, "Total amount should match"); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters