thor
thor copied to clipboard
enhancement: logdb - include optional tx and log indexes in responses
Description
Includes log and TX indexes in the logDB sequence entries and optionally return them in response bodies.
This will break existing nodes, as a fully sync would be required. (On top of maindb v4 if we want to include it)
NOTE: IMO it would be better to revert the sequence changes and store the tx index the same way as we do for clause index
Type of change
Please delete options that are not relevant.
- [x] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
How Has This Been Tested?
- [ ] Unit tests
- [ ] E2E tests
- [x] Manually:
- Test case:
indexes
omitted from request body
Request:
curl --request POST \
--url http://127.0.0.1:8669/logs/transfer \
--header 'Accept: application/json, text/plain' \
--header 'Content-Type: application/json' \
--data '{
"range": {
"from": 100,
"to": 17289864
},
"options": {
"offset": 0,
"limit": 1
},
"criteriaSet": []
}' | jq
Response:
[
{
"sender": "0x137053dfbe6c0a43f915ad2efefefdcc2708e975",
"recipient": "0x1e3a0ef75b142c1fcd54609ce6352a8b5d3b898d",
"amount": "0xad78ebc5ac6200000",
"meta": {
"blockID": "0x000093d16b04addea4e2051edc427607dc25c7241c9c0bbcc5cf4098e204aa4c",
"blockNumber": 37841,
"blockTimestamp": 1530695350,
"txID": "0xfc996d321a96702d0468a60e17b032fe5fa9e3f6edb6a55858eb2e2d5580af8d",
"txOrigin": "0x137053dfbe6c0a43f915ad2efefefdcc2708e975",
"clauseIndex": 0
}
}
]
- Test case:
"indexes": true
Request:
curl --request POST \
--url http://127.0.0.1:8669/logs/transfer \
--header 'Accept: application/json, text/plain' \
--header 'Content-Type: application/json' \
--data '{
"range": {
"from": 100,
"to": 17289864
},
"options": {
"offset": 0,
"limit": 1
},
"criteriaSet": [],
"indexes": true
}' | jq
Respons:
[
{
"sender": "0x137053dfbe6c0a43f915ad2efefefdcc2708e975",
"recipient": "0x1e3a0ef75b142c1fcd54609ce6352a8b5d3b898d",
"amount": "0xad78ebc5ac6200000",
"meta": {
"blockID": "0x000093d16b04addea4e2051edc427607dc25c7241c9c0bbcc5cf4098e204aa4c",
"blockNumber": 37841,
"blockTimestamp": 1530695350,
"txID": "0xfc996d321a96702d0468a60e17b032fe5fa9e3f6edb6a55858eb2e2d5580af8d",
"txOrigin": "0x137053dfbe6c0a43f915ad2efefefdcc2708e975",
"clauseIndex": 0,
"logIndex": 0,
"txIndex": 0
}
}
]
- Test case:
"indexes": false
Request:
curl --request POST \
--url http://127.0.0.1:8669/logs/transfer \
--header 'Accept: application/json, text/plain' \
--header 'Content-Type: application/json' \
--data '{
"range": {
"from": 100,
"to": 17289864
},
"options": {
"offset": 0,
"limit": 1
},
"criteriaSet": [],
"indexes": false
}' | jq
Respons:
[
{
"sender": "0x137053dfbe6c0a43f915ad2efefefdcc2708e975",
"recipient": "0x1e3a0ef75b142c1fcd54609ce6352a8b5d3b898d",
"amount": "0xad78ebc5ac6200000",
"meta": {
"blockID": "0x000093d16b04addea4e2051edc427607dc25c7241c9c0bbcc5cf4098e204aa4c",
"blockNumber": 37841,
"blockTimestamp": 1530695350,
"txID": "0xfc996d321a96702d0468a60e17b032fe5fa9e3f6edb6a55858eb2e2d5580af8d",
"txOrigin": "0x137053dfbe6c0a43f915ad2efefefdcc2708e975",
"clauseIndex": 0
}
}
]
Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [x] New and existing E2E tests pass locally with my changes
- [x] Any dependent changes have been merged and published in downstream modules
- [x] I have not added any vulnerable dependencies to my code