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

Add fee cap for transactions submitted via RPC. #1137

Merged
merged 1 commit into from
Jun 24, 2020

Conversation

AbdelStark
Copy link
Contributor

@AbdelStark AbdelStark commented Jun 24, 2020

PR description

This PR adds a new CLI option that enables the user to define the maximum fees (gas price) accepted for transactions submitted via RPC(eth_sendRawTransaction).

Changes summary

  • Added --rpc-tx-feecap command line flag.
    • Maximum transaction fees (in Wei) accepted for transaction submitted through RPC.
    • Defaulted to 1 ether.
  • Updated TransactionPool.addLocalTransaction method: performs an additional check to verify if transaction fees don't exceed user defined fee cap (if cap is set to 0 then it is ignored and means no cap).

Testing

Unit tests

Command line

  • BesuCommandTest.transactionPoolTxFeeCap: Assert that specified CLI flag value is used (different from default).
  • BesuCommandTest.invalidTansactionPoolTxFeeCapShouldFail: Assert that invalid value causes an error with proper message.

Transaction pool

  • TransactionPoolTest.shouldIgnoreFeeCapIfSetZero: Assert that no fee cap is applied if set to 0.
  • TransactionPoolTest.shouldRejectLocalTransactionIfFeeCapExceeded: Assert that local transaction is rejected if gasPrice is higher than defined fee cap.

Manual tests

Steps

  • Run Besu with --rpc-tx-feecap=2000000000000000005
  • Submit transaction with nonce set to 1 and gasPrice set to 2000000000000000005
  • Submit transaction with nonce set to 2 and gasPrice set to 2000000000000000006

Results

First transaction is accepted.
Seconds transaction is rejected with response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32000,
    "message": "Transaction fee cap exceeded"
  }
}

Signed-off-by: Abdelhamid Bakhta abdelhamid.bakhta@consensys.net

Changes summary:

- Added `--rpc-tx-feecap` command line flag.
    - Maximum transaction fees (in Wei) accepted for transaction submitted through RPC.
    - Defaulted to 1 ether.
- Updated `TransactionPool.addLocalTransaction` method: performs an additional check to verify if transaction fees don't exceed user defined fee cap (if cap is set to 0 then it is ignored and means no cap).

Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
@AbdelStark AbdelStark added the enhancement New feature or request label Jun 24, 2020
@AbdelStark AbdelStark self-assigned this Jun 24, 2020
Copy link
Contributor

@matkt matkt left a comment

Choose a reason for hiding this comment

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

LGTM
Just read the code on Github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants