Skip to content

Commit

Permalink
refactor: no fees on duplicate payment report
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Hill <[email protected]>
  • Loading branch information
gregdhill committed Jul 14, 2021
1 parent b03d4d9 commit 0bab75b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 3 additions & 1 deletion crates/relay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ pub mod pallet {
ext::security::ensure_parachain_status_not_shutdown::<T>()?;
let signer = ensure_signed(origin)?;

// transactions must be unique
ensure!(raw_txs.0 != raw_txs.1, Error::<T>::DuplicateTransaction);

let parse_and_verify = |raw_tx, raw_proof| -> Result<Transaction, DispatchError> {
Expand Down Expand Up @@ -325,7 +326,8 @@ pub mod pallet {
ext::sla::event_update_vault_sla::<T>(&signer, ext::sla::Action::TheftReport)?;
Self::deposit_event(<Event<T>>::VaultDoublePayment(vault_id, left_tx_id, right_tx_id));

Ok(().into())
// don't take tx fees on success
Ok(Pays::No.into())
}
_ => Err(Error::<T>::InvalidTransaction.into()),
}
Expand Down
4 changes: 1 addition & 3 deletions crates/relay/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,8 @@ fn build_dummy_transaction_from_input_with_output_and_op_return(
let mut builder = TransactionBuilder::new();
builder.with_version(1).add_input(
TransactionInputBuilder::new()
.with_coinbase(false)
.with_source(TransactionInputSource::FromOutput(prev_hash, 1))
.with_sequence(4294967295)
.with_previous_index(1)
.with_previous_hash(prev_hash)
.with_p2pkh(public_key, vec![1u8; 32])
.build(),
);
Expand Down

0 comments on commit 0bab75b

Please sign in to comment.