You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Did you search for an existing issue or pull request?
Description
Hello,
When indexing blocks that only contain native transfers, subquery is only indexing logs, therefore those native transfers are ignored. This behaviour was introduced in this PR.
There is a comment about it here
The reason is in the function isFullBlock, which is excluding blocks that don't contain logs (events)
export function isFullBlock(block: BlockContent): block is EthereumBlock {
// Light etherum block just contains transaction hashes for transactions.
// If the block has no transactions then both types would be the same
if (block.transactions.length && block.logs.length) {
return typeof (block as EthereumBlock).transactions[0] !== 'string';
}
return false;
}
Then it only parses logs in this else condition, as a result native transfers are ignored if this kind of blocks
if (isFullBlock(block)) {
await this.indexBlockContent(block, dataSources, getVM);
for (const tx of block.transactions) {
await this.indexTransaction(tx, dataSources, getVM);
for (const log of tx.logs ?? []) {
await this.indexEvent(log, dataSources, getVM);
}
}
} else {
for (const log of block.logs ?? []) {
await this.indexEvent(log, dataSources, getVM);
}
}
Details
These details can help to reproduce the environment the issue is occurring
Local Environment: @subql/cli/5.2.8 Query Version: I don't know Indexer Version: I don't know Network Details:
any EVM, but it's easier to reproduce with anvil or hardhat
Steps to Reproduce
run anvil with anvil --host 0.0.0.0 --slots-in-an-epoch 1 --block-time 5
run subquery with a simple native transaction handler like this one
project.ts
{
kind: EthereumHandlerKind.Call,
handler: "handleNativeTransaction",
filter: {
function: null, // This picks up native token transfers
},
},
mappingHandlers.ts
export async function handleNativeTransaction(tx: EthereumTransaction): Promise<void> {
logger.info('handleNativeTransaction')
logger.info(serialize(tx))
}
You should have no logs.
Now as a test, if you always return true in node_modules/@subql/node-ethereum/dist/ethereum/block.ethereum.js
function isFullBlock(block) {
return true;
// Light etherum block just contains transaction hashes for transactions.
// If the block has no transactions then both types would be the same
if (block.transactions.length && block.logs.length) {
return typeof block.transactions[0] !== 'string';
}
return false;
}
Restart subquery and send a new native transfer, the log will appear
The text was updated successfully, but these errors were encountered:
mvanmeerbeck
changed the title
Ethereum transactions not indexed when block only contain natives transfers
Ethereum transactions not indexed when block only contain native transfers
Oct 21, 2024
Prerequisites
Description
Hello,
When indexing blocks that only contain native transfers, subquery is only indexing logs, therefore those native transfers are ignored. This behaviour was introduced in this PR.
There is a comment about it here
The reason is in the function isFullBlock, which is excluding blocks that don't contain logs (events)
Then it only parses logs in this
else
condition, as a result native transfers are ignored if this kind of blocksDetails
These details can help to reproduce the environment the issue is occurring
Local Environment: @subql/cli/5.2.8
Query Version: I don't know
Indexer Version: I don't know
Network Details:
Steps to Reproduce
anvil --host 0.0.0.0 --slots-in-an-epoch 1 --block-time 5
project.ts
mappingHandlers.ts
run subquery node
submit a native tx on anvil
cast send --private-key $PRIVATE_KEY --rpc-url $RPC_URL $TO --value $VALUE
You should have no logs.
Now as a test, if you always return true in
node_modules/@subql/node-ethereum/dist/ethereum/block.ethereum.js
Restart subquery and send a new native transfer, the log will appear
The text was updated successfully, but these errors were encountered: