Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Mitigate payment-free verification #2428

Merged
merged 11 commits into from
Apr 19, 2024

Conversation

raychu86
Copy link
Contributor

@raychu86 raychu86 commented Apr 8, 2024

Motivation

This PR adds a few rules to mitigate the case where malicious parties can force validators to perform transaction verification without having to pay transaction fees (due to transaction aborts).

Example cases:

In both of these cases, the validators will perform verification on all transactions, but only the first transaction will be accepted. All others will be aborted.

  1. Send multiple transactions with the same private fee record.
  2. Send multiple transactions with the same public fee payer. However only have enough balance to pay for the first transaction.

The mitigating factors in this PR are:

  1. To perform duplicate/spent checks (input ID, output ID, tpks, etc) and abort colliding transactions prior to transaction verification in VM::prepare_for_speculate.
    • This check is done in VM::atomic_speculate, but now we also perform it prior to tx verification.
  2. Add only process 1 deployment per block per public payer.
    • Abort all subsequent deployments.

Note that these checks are added prior to verification, so it may be aggressive in aborting transactions. For example given transactions A and B who have the same fee record. If A is aborted for a separate reason (for example, invalid finalize operation):
1. This PR will abort both A and B.
2. The previous logic will only abort A and accept B.

Possible future mitigations:

  1. Possibly process deployment finalize before executions.
    • Deployments are more expensive to verify than executions, so processing them first will reduce wasted verification work.
  2. Add slashing for malicious validators who inject aborted transactions to proposals.

Test Plan

Tests have been added to ensure that there can only be 1 deployment per block per public fee payer. In addition, more checks have been added to existing tests to ensure that the aborted transactions do not incur verification costs.

Note

This could break existing testnets, and will require a chain reset.

@raychu86 raychu86 requested review from vicsn and d0cd April 8, 2024 16:53
Copy link
Collaborator

@vicsn vicsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some comment nits.

synthesizer/src/vm/finalize.rs Outdated Show resolved Hide resolved
synthesizer/src/vm/finalize.rs Outdated Show resolved Hide resolved
synthesizer/src/vm/finalize.rs Outdated Show resolved Hide resolved
@vicsn
Copy link
Collaborator

vicsn commented Apr 9, 2024

I'll also rerun consensus test 8.- Load-Batch-Proposal-Attack.

/// - The transaction is producing a duplicate output
/// - The transaction is producing a duplicate transition public key
/// - The transaction is another deployment in the block from the same public fee payer.
fn should_abort_transaction(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As there are other reasons and locations where a transaction may be aborted, perhaps a more descriptive name would be: check_transaction_uniqueness_in_block

@howardwu
Copy link
Member

@vicsn @onetrickwolf can you guys run this branch with CI validation and consensus burn-in / test criteria checks?

@raychu86 raychu86 changed the title Mitigate payment-free verification [Feature] Mitigate payment-free verification Apr 12, 2024
@vicsn
Copy link
Collaborator

vicsn commented Apr 13, 2024

Long-running e2e test passed, consensus test 8 passed as well and clearly logs many Speculation safely aborted a transaction - Another deployment in the block from the same public fee.

@howardwu howardwu merged commit 33bf3c3 into mainnet-staging Apr 19, 2024
80 checks passed
@howardwu howardwu deleted the mitigate-free-verification branch April 19, 2024 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants