mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 12:49:23 +00:00
Add support for multiple orderings in Provided
Necessary as our Tributary chains needed to agree when a Serai block has occurred, and when a Monero block has occurred. Since those could happen at the same time, some validators may put SeraiBlock before ExternalBlock and vice versa, causing a chain halt. Now they can have distinct ordering queues.
This commit is contained in:
@@ -69,7 +69,7 @@ fn empty_block() {
|
||||
const GENESIS: [u8; 32] = [0xff; 32];
|
||||
const LAST: [u8; 32] = [0x01; 32];
|
||||
Block::<NonceTransaction>::new(LAST, vec![], vec![])
|
||||
.verify(GENESIS, LAST, &[], HashMap::new())
|
||||
.verify(GENESIS, LAST, HashMap::new(), HashMap::new())
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ fn duplicate_nonces() {
|
||||
let res = Block::new(LAST, vec![], mempool).verify(
|
||||
GENESIS,
|
||||
LAST,
|
||||
&[],
|
||||
HashMap::new(),
|
||||
HashMap::from([(<Ristretto as Ciphersuite>::G::identity(), 0)]),
|
||||
);
|
||||
if i == 1 {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::collections::VecDeque;
|
||||
use std::collections::{VecDeque, HashMap};
|
||||
|
||||
use zeroize::Zeroizing;
|
||||
use rand::{RngCore, rngs::OsRng};
|
||||
@@ -187,10 +187,10 @@ fn provided_transaction() {
|
||||
assert_eq!(txs.provide(tx.clone()), Err(ProvidedError::AlreadyProvided));
|
||||
assert_eq!(
|
||||
ProvidedTransactions::<_, ProvidedTransaction>::new(db.clone(), genesis).transactions,
|
||||
VecDeque::from([tx.clone()]),
|
||||
HashMap::from([("provided", VecDeque::from([tx.clone()]))]),
|
||||
);
|
||||
let mut txn = db.txn();
|
||||
txs.complete(&mut txn, tx.hash());
|
||||
txs.complete(&mut txn, "provided", tx.hash());
|
||||
txn.commit();
|
||||
assert!(ProvidedTransactions::<_, ProvidedTransaction>::new(db.clone(), genesis)
|
||||
.transactions
|
||||
|
||||
@@ -47,7 +47,7 @@ impl ReadWrite for ProvidedTransaction {
|
||||
|
||||
impl Transaction for ProvidedTransaction {
|
||||
fn kind(&self) -> TransactionKind<'_> {
|
||||
TransactionKind::Provided
|
||||
TransactionKind::Provided("provided")
|
||||
}
|
||||
|
||||
fn hash(&self) -> [u8; 32] {
|
||||
|
||||
Reference in New Issue
Block a user