mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 04:09:23 +00:00
Implement a fee on every input to prevent prior described economic attacks
Completes #297.
This commit is contained in:
@@ -8,12 +8,16 @@ use dkg::{Participant, tests::clone_without};
|
||||
use messages::{coordinator::PlanMeta, sign::SignId, SubstrateContext};
|
||||
|
||||
use serai_client::{
|
||||
primitives::{BlockHash, crypto::RuntimePublic, PublicKey, SeraiAddress, NetworkId},
|
||||
primitives::{
|
||||
BlockHash, Amount, Balance, crypto::RuntimePublic, PublicKey, SeraiAddress, NetworkId,
|
||||
},
|
||||
in_instructions::primitives::{
|
||||
InInstruction, InInstructionWithBalance, Batch, SignedBatch, batch_message,
|
||||
},
|
||||
};
|
||||
|
||||
use processor::networks::{Network, Bitcoin, Monero};
|
||||
|
||||
use crate::{*, tests::*};
|
||||
|
||||
pub(crate) async fn recv_batch_preprocesses(
|
||||
@@ -247,7 +251,20 @@ fn batch_test() {
|
||||
id: i,
|
||||
block: BlockHash(block_with_tx.unwrap()),
|
||||
instructions: if let Some(instruction) = instruction {
|
||||
vec![InInstructionWithBalance { instruction, balance: balance_sent }]
|
||||
vec![InInstructionWithBalance {
|
||||
instruction,
|
||||
balance: Balance {
|
||||
coin: balance_sent.coin,
|
||||
amount: Amount(
|
||||
balance_sent.amount.0 -
|
||||
(2 * if network == NetworkId::Bitcoin {
|
||||
Bitcoin::COST_TO_AGGREGATE
|
||||
} else {
|
||||
Monero::COST_TO_AGGREGATE
|
||||
}),
|
||||
),
|
||||
},
|
||||
}]
|
||||
} else {
|
||||
// This shouldn't have an instruction as we didn't add any data into the TX we sent
|
||||
// Empty batches remain valuable as they let us achieve consensus on the block and spend
|
||||
|
||||
Reference in New Issue
Block a user