-
Notifications
You must be signed in to change notification settings - Fork 4
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
Dictionary V2 Ethereum #225
Conversation
poc with indexing tidy up
…r.ts Co-authored-by: Scott Twiname <[email protected]>
Coverage reportCaution Test run failed
Test suite run failedFailed tests: 1/73. Failed suites: 2/14.
Report generated by 🧪jest coverage report action from 09973bd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good starting point but could evolve to be more flexible.
If we think about the future there are a few scenarios we could prepare for now:
- V2 Dictionaries may have a block range that isn't the whole network, so there might be more than one dictionary for a network.
- We can use this to build other data sources, e.g Space and Time or KYVE
Considering these future use cases i think this can be updated to support these cases:
- If there is an interface
IDictionary
that has a functiongetData
to get block content/block numbers for a block range given the current datasources - V1, V2 dictionaries can implement
IDictionary
- The dictionary service can also implement
IDictionary
but control a collection of otherIDictionary
it can then route calls ofgetData
to the appropriateIDictionary
in the collection. This would behave similar to how we support multiple endpoints
Maybe we should look at renaming from Dictionary
to DataProvider
to better explain the purpose of this part of the code.
f2228dd
to
72168b9
Compare
packages/node-core/src/indexer/dictionary/dictionary.service.ts
Outdated
Show resolved
Hide resolved
packages/node-core/src/indexer/dictionary/dictionary.service.ts
Outdated
Show resolved
Hide resolved
const startBlock = heightsBlocks[0]; | ||
const endBlock = heightsBlocks[heightsBlocks.length - 1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just be cautious about heightsBlocks
being empty, enqueueBlocks could be called like so enqueueBlocks([])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, from line 93-95 we did an assertion for heightsBlocks.length, this ensure heights blocks at least have 1 block. I can made a change to enqueueBlocks input, ensure latestBufferHeight never to be undefined.
packages/node-core/src/indexer/blockDispatcher/worker-block-dispatcher.ts
Outdated
Show resolved
Hide resolved
packages/node-core/src/indexer/blockDispatcher/worker-block-dispatcher.ts
Outdated
Show resolved
Hide resolved
packages/node-core/src/indexer/dictionary/dictionary.service.ts
Outdated
Show resolved
Hide resolved
…spatcher.ts Co-authored-by: Scott Twiname <[email protected]>
…spatcher.ts Co-authored-by: Scott Twiname <[email protected]>
packages/node-core/src/indexer/dictionary/dictionary.service.ts
Outdated
Show resolved
Hide resolved
} | ||
|
||
async initDictionaries() { | ||
if (this.nodeConfig.networkDictionaries) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be the project.network.dictionary
instead. It doesn't take into account the manifest dictionary like it used to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will leave this with //TODO, this require update in type-core too, can do this when rebase with main
return ( | ||
typeof (block as EthereumBlock).transactions[0] !== 'string' || | ||
!( | ||
!(block as EthereumBlock).transactions.length && | ||
(block as EthereumBlock).logs.length | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have tests for this.
packages/node/src/indexer/blockDispatcher/block-dispatcher.service.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Scott Twiname <[email protected]>
…' into dictionary-v2-poc-generalization
protected getBlockHeight(block: BlockContent): number { | ||
return block.number; | ||
} | ||
|
||
protected async indexBlock( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be saved for another PR. But this service has nothing specific to ethereum, it would be good if this could now live purely in node-core. I think only substrate would need a specific version because of specVersions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have a lot more tests here to cover some various use cases similar to the v1 tests.
I'm particularly interested in handling contract creation filters where the to field is null
logConditions[field] = []; | ||
} | ||
if (topic === '!null') { | ||
logConditions[field] = []; // TODO, check if !null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a test
Co-authored-by: Scott Twiname <[email protected]>
Co-authored-by: Scott Twiname <[email protected]>
…' into dictionary-v2-poc-generalization
packages/node/src/indexer/dictionary/v2/ethDictionaryV2.spec.ts
Outdated
Show resolved
Hide resolved
packages/node/src/indexer/dictionary/v2/ethDictionaryV2.spec.ts
Outdated
Show resolved
Hide resolved
if ( | ||
filter.from !== undefined || | ||
filter.to !== undefined || | ||
filter.function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filter.function | |
filter.function !== undefined |
The same changes i mentioned earlier for functions should be applied here.
Because this code is very similar for v1 and v2 it could probably be generalised
} catch (e) { | ||
logger.error( | ||
e, | ||
`Failed to handle block response ${JSON.stringify(data)}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a large amount of data to log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed ${JSON.stringify(data)
, I think from error msg from rawBlockToEthBlock
is very detailed should be sufficent
|
||
export function rawBlockToEthBlock(block: RawEthBlock): IBlock<EthereumBlock> { | ||
try { | ||
const formatter = new Formatter(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to worry about it for now because we don't have receipts. But we should apply the formatter changes from here https://github.com/subquery/subql-ethereum/blob/main/packages/node/src/ethereum/ethers/op/op-provider.ts#L19 to this formatter/ have a global formatter
@stwiname
does this mean only writing index with blocks, which have transactions and logs? |
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
Checklist