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

Standardize 'txpool' namespace #353

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ methodFiles.forEach(file => {
];
});

methodsBase = "src/txpool/";
methodFiles = fs.readdirSync(methodsBase);
methodFiles.forEach(file => {
console.log(file);
let raw = fs.readFileSync(methodsBase + file);
let parsed = yaml.load(raw);
methods = [
...methods,
...parsed,
];
});

let schemas = {};
let schemasBase = "src/schemas/"
let schemaFiles = fs.readdirSync(schemasBase);
Expand Down
10 changes: 10 additions & 0 deletions src/schemas/filter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,13 @@ FilterTopic:
type: array
items:
$ref: '#/components/schemas/bytes32'
FilterOperators:
title: operator
type: object
properties:
eq:
$ref: '#/components/schemas/uint'
gt:
$ref: '#/components/schemas/uint'
lt:
$ref: '#/components/schemas/uint'
50 changes: 50 additions & 0 deletions src/schemas/txpool.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
TxPoolFilter:
title: txpool filter
type: object
properties:
from:
title: from address
$ref: '#/components/schemas/address'
to:
title: to address
$ref: '#/components/schemas/address'
gas:
title: gas limit
$ref: '#/components/schemas/FilterOperators'
gasPrice:
wslyvh marked this conversation as resolved.
Show resolved Hide resolved
title: gas price
$ref: '#/components/schemas/FilterOperators'
value:
title: value
$ref: '#/components/schemas/FilterOperators'
nonce:
Copy link
Member

Choose a reason for hiding this comment

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

is there a use for being able to filter by nonce?

Copy link
Member Author

Choose a reason for hiding this comment

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

It might not be used that much, but I can imagine if you have multiple txs pending (or stuck), it could be helpful to be able to filter. But this might be more with the idea that while we're at it we might as well include these

title: nonce
$ref: '#/components/schemas/FilterOperators'
TxPoolTransactions:
wslyvh marked this conversation as resolved.
Show resolved Hide resolved
title: transactions
type: object
properties:
pending:
title: pending
type: array
items:
$ref: '#/components/schemas/GenericTransaction'
queued:
title: queued
type: array
items:
$ref: '#/components/schemas/GenericTransaction'
TxPoolStatistics:
wslyvh marked this conversation as resolved.
Show resolved Hide resolved
title: statistics
type: object
properties:
maxSize:
Copy link
Member

Choose a reason for hiding this comment

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

Is this useful? I lean towards omitting it.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's meant to show the configured maximum amount of txs on the pool.
E.g. txpool.globalslots value or tx-pool-max-size

Which would give some indication of how full / utilized the node's pool is compared to pending/queued txs.

No strong opinion here tho.

title: max size
$ref: '#/components/schemas/uint'
pending:
title: pending
$ref: '#/components/schemas/uint'
queued:
title: queued
$ref: '#/components/schemas/uint'

19 changes: 19 additions & 0 deletions src/txpool/getters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- name: txpool_transactions
summary: Returns a list of all transactions that match the supplied filter conditions that are either pending for inclusion in the next block(s) or scheduled for future execution.
params:
- name: Filter
schema:
$ref: '#/components/schemas/TxPoolFilter'
result:
name: Result
schema:
title: Result
schema:
$ref: '#/components/schemas/TxPoolTransactions'
- name: txpool_statistics
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- name: txpool_statistics
- name: txpool_stats

Copy link
Member Author

Choose a reason for hiding this comment

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

I think introducing txpool_stats next to the existing txpool_status might cause confusion and potential typos/errors.
txpool_statistics would avoid that

But again, no strong opinion

summary: Returns statistics about the node's transaction pool.
params: []
result:
name: Statistics
schema:
$ref: '#/components/schemas/TxPoolStatistics'
2 changes: 2 additions & 0 deletions tests/txpool_statistics/get-statistics.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":31,"method":"txpool_statistics"}
<< {"jsonrpc":"2.0","id":31,"result":{"maxSize":"0x1","pending":"0x1","queued":"0x1"}}
2 changes: 2 additions & 0 deletions tests/txpool_transactions/get-default-transactions.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":31,"method":"txpool_transactions"}
Copy link
Member

Choose a reason for hiding this comment

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

So I think what we should here for the tests is have two eth_sendRawTransactions before txpool_transactions so it actually seeds the pool with the txs. This way we can still use these tests in hive to verify the response of each client. You can do this by defining the interaction as a test generator here: https://github.com/lightclient/rpctestgen/blob/main/testgen/generators.go

<< {"jsonrpc":"2.0","id":31,"result":{"pending":[{"blockHash":null,"blockNumber":null,"from":"0x658bdf435d810c91414ec09147daa6db62406379","gas":"0x5208","gasPrice":"0x342770c1","hash":"0x74e41d593675913d6d5521f46523f1bd396dff1891bdb35f59be47c7e5e0b34b","input":"0x","nonce":"0x0","to":"0x658bdf435d810c91414ec09147daa6db62406379","transactionIndex":"0x0","value":"0x3e8","type":"0x0","chainId":"0x539","v":"0xa95","r":"0xaf5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60","s":"0x201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b"}],"queued":[{"blockHash":null,"blockNumber":null,"from":"0x658bdf435d810c91414ec09147daa6db62406379","gas":"0x5208","gasPrice":"0x342770c1","hash":"0x74e41d593675913d6d5521f46523f1bd396dff1891bdb35f59be47c7e5e0b34b","input":"0x","nonce":"0x0","to":"0x658bdf435d810c91414ec09147daa6db62406379","transactionIndex":"0x0","value":"0x3e8","type":"0x0","chainId":"0x539","v":"0xa95","r":"0xaf5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60","s":"0x201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b"}]}}
2 changes: 2 additions & 0 deletions tests/txpool_transactions/get-empty-transactions-list.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":31,"method":"txpool_transactions"}
<< {"jsonrpc":"2.0","id":31,"result":{"pending":[],"queued":[]}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":31,"method":"txpool_transactions","params":[{"from":"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"}]}
<< {"jsonrpc":"2.0","id":31,"result":{"pending":[{"blockHash":null,"blockNumber":null,"from":"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73","gas":"0x5208","gasPrice":"0x342770c1","hash":"0x74e41d593675913d6d5521f46523f1bd396dff1891bdb35f59be47c7e5e0b34b","input":"0x","nonce":"0x0","to":"0x658bdf435d810c91414ec09147daa6db62406379","transactionIndex":"0x0","value":"0x3e8","type":"0x0","chainId":"0x539","v":"0xa95","r":"0xaf5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60","s":"0x201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b"}],"queued":[{"blockHash":null,"blockNumber":null,"from":"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73","gas":"0x5208","gasPrice":"0x342770c1","hash":"0x74e41d593675913d6d5521f46523f1bd396dff1891bdb35f59be47c7e5e0b34b","input":"0x","nonce":"0x0","to":"0x658bdf435d810c91414ec09147daa6db62406379","transactionIndex":"0x0","value":"0x3e8","type":"0x0","chainId":"0x539","v":"0xa95","r":"0xaf5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60","s":"0x201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b"}]}}
2 changes: 2 additions & 0 deletions tests/txpool_transactions/get-filtered-transactions-gt-gas.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":31,"method":"txpool_transactions","params":[{"gas":{"lt":"0x0"}}]}
<< {"jsonrpc":"2.0","id":31,"result":{"pending":[{"blockHash":null,"blockNumber":null,"from":"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73","gas":"0x5208","gasPrice":"0x342770c1","hash":"0x74e41d593675913d6d5521f46523f1bd396dff1891bdb35f59be47c7e5e0b34b","input":"0x","nonce":"0x0","to":"0x658bdf435d810c91414ec09147daa6db62406379","transactionIndex":"0x0","value":"0x3e8","type":"0x0","chainId":"0x539","v":"0xa95","r":"0xaf5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60","s":"0x201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b"}],"queued":[{"blockHash":null,"blockNumber":null,"from":"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73","gas":"0x5208","gasPrice":"0x342770c1","hash":"0x74e41d593675913d6d5521f46523f1bd396dff1891bdb35f59be47c7e5e0b34b","input":"0x","nonce":"0x0","to":"0x658bdf435d810c91414ec09147daa6db62406379","transactionIndex":"0x0","value":"0x3e8","type":"0x0","chainId":"0x539","v":"0xa95","r":"0xaf5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60","s":"0x201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b"}]}}
5 changes: 5 additions & 0 deletions wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,8 @@ graphql
gwei
withdrawalv
DocToc
txpool
TxPool
eq
lt
gt