Skip to content

Commit e1110d5

Browse files
committed
diamond front running resistance: applying the transaction shuffeling for
DMDcoin#89
1 parent fa5f509 commit e1110d5

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

crates/ethcore/src/engines/hbbft/hbbft_engine.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ impl HoneyBadgerBFT {
503503
trace!(target: "consensus", "Batch received for epoch {}, creating new Block.", batch.epoch);
504504

505505
// Decode and de-duplicate transactions
506-
let batch_txns: Vec<_> = batch
506+
let mut batch_txns: Vec<_> = batch
507507
.contributions
508508
.iter()
509509
.flat_map(|(_, c)| &c.transactions)
@@ -564,6 +564,9 @@ impl HoneyBadgerBFT {
564564
.write()
565565
.insert(batch.epoch, random_number);
566566

567+
// Shuffelin transactions deterministically based on the random number.
568+
batch_txns = crate::engines::hbbft::utils::transactions_shuffling::deterministic_transactions_shuffling(batch_txns, random_number);
569+
567570
if let Some(header) = client.create_pending_block_at(batch_txns, timestamp, batch.epoch) {
568571
let block_num = header.number();
569572
let hash = header.bare_hash();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
pub mod bound_contract;
2-
mod transactions_shuffling;
2+
pub mod transactions_shuffling;

crates/ethcore/src/engines/hbbft/utils/transactions_shuffling.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ fn address_xor_u256(address: &Address, seed: U256) -> Address {
2525
}
2626

2727
/// The list of transactions is expected to be free of duplicates.
28-
#[allow(dead_code)]
29-
fn deterministic_transactions_shuffling(
28+
pub fn deterministic_transactions_shuffling(
3029
transactions: Vec<SignedTransaction>,
3130
seed: U256,
3231
) -> Vec<SignedTransaction> {

0 commit comments

Comments
 (0)