-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
100 changed files
with
1,825 additions
and
1,324 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ on: | |
|
||
permissions: | ||
issues: write | ||
pull-requests: read | ||
|
||
jobs: | ||
monthly-issue-metrics: | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
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
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,28 @@ | ||
use near_primitives::hash::CryptoHash; | ||
use rand::seq::SliceRandom; | ||
use rand::SeedableRng; | ||
use rand_chacha::ChaCha20Rng; | ||
|
||
pub fn shuffle_receipt_proofs<ReceiptProofType>( | ||
receipt_proofs: &mut Vec<ReceiptProofType>, | ||
block_hash: &CryptoHash, | ||
) { | ||
let mut slice = [0u8; 32]; | ||
slice.copy_from_slice(block_hash.as_ref()); | ||
let mut rng: ChaCha20Rng = SeedableRng::from_seed(slice); | ||
receipt_proofs.shuffle(&mut rng); | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::sharding::shuffle_receipt_proofs; | ||
use near_primitives::hash::CryptoHash; | ||
|
||
#[test] | ||
pub fn receipt_randomness_reproducibility() { | ||
// Sanity check that the receipt shuffling implementation does not change. | ||
let mut receipt_proofs = vec![0, 1, 2, 3, 4, 5, 6]; | ||
shuffle_receipt_proofs(&mut receipt_proofs, &CryptoHash::hash_bytes(&[1, 2, 3, 4, 5])); | ||
assert_eq!(receipt_proofs, vec![2, 3, 1, 4, 0, 5, 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
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
Oops, something went wrong.