Comments (2)
Thanks for the bug report! I can reproduce your observation that the receipts root for block 22982400 does not match the merkle root calculated from the receipts that are returned via RPC.
Block 22982400 is an epoch block and it looks like this mismatch happens for all epoch blocks and all other blocks are fine. Epoch blocks have special epoch transactions to distribute the epoch rewards rewards (e.g. rewards for block 22982400). These won't show up as normal transactions in the RPC. I assume that the epoch transactions are the reason for the mismatch, although I have not yet looked up how receipts for them are handled.
from celo-blockchain.
When events are emitted by the block processing outside of user transaction (e.g. epoch rewards), then one "block receipt" is added to the block. This receipt can't be fetched with eth_getTransactionReceipt
but with the Celo-specific eth_getBlockReceipt
.
Combining these receipts makes the receiptsRoot match again:
import { ethers } from "ethers";
import { BaseTrie as Tree } from 'merkle-patricia-tree';
import { Receipt } from 'eth-object';
import { encode } from 'eth-util-lite';
const provider = new ethers.JsonRpcProvider('https://forno.celo.org');
const block = '0x' + (22982400).toString(16);
const rpcBlock = await provider.send('eth_getBlockByNumber', [block, false]);
const transactionReceipts = (
await Promise.all(
rpcBlock.transactions
.map(async (siblingTxHash) => {
return provider.send('eth_getTransactionReceipt', [siblingTxHash]);
})
)
)
const blockReceipt = (
await Promise.all(
[rpcBlock.hash]
.map(async (siblingTxHash) => {
return provider.send('eth_getBlockReceipt', [siblingTxHash]);
})
)
)
const receipts = transactionReceipts.concat(blockReceipt);
const tree = new Tree();
await Promise.all(
receipts.map((siblingReceipt, index) => {
const siblingPath = encode(index);
let serializedReceipt = Receipt.fromRpc(siblingReceipt).serialize();
if (siblingReceipt.type && siblingReceipt.type != '0x0') {
serializedReceipt = Buffer.concat([Buffer.from([siblingReceipt.type]), serializedReceipt]);
}
return tree.put(siblingPath, serializedReceipt);
}),
);
const receiptsRoot = '0x' + tree.root.toString('hex');
if (receiptsRoot !== rpcBlock.receiptsRoot) {
console.error(receipts, {
receiptsRoot,
blockReceiptsRoot: rpcBlock.receiptsRoot,
});
throw new Error('receiptsRoot mismatch');
}
I admit that this situation is currently under-documented.
from celo-blockchain.
Related Issues (20)
- Shanghai hardfork not supported, invalid opcodes in solidity 0.8.20+ generated code HOT 2
- Bad indexed data for block gas limit HOT 1
- Support eth_call, eth_gasEstimate state override set HOT 1
- Celo rosetta node issue HOT 5
- Dependency Dashboard
- Move gh pages publishing out of celo-blockchain
- miner.TestMiner is flakey
- Get epoch rewards for a block from node. HOT 7
- Add tx type metrics to txpool
- Asymmetry in mechanisms to skip calling debitGasFees & creditGasFees
- Flaky/Flakey tests
- isBlockReceipt incorrectly called on non derived logs HOT 2
- eth_getBlockReceipts is broken, because it does not take into account the celo block receipt
- go: github.com/celo-org/celo-blockchain@latest (v1.13.0) requires github.com/celo-org/[email protected]: parsing go.mod: module declares its path as: github.com/ethereum/go-ethereum but was required as: github.com/celo-org/celo-blockchain HOT 1
- Ensure we deep copy the difficulty field in types.CopyHeader
- Execution Clients - Erigon and Reth
- Validator experiencing a panic
- Baklava node synchronisation failing
- Node stop syncing with BAD BLOCK HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from celo-blockchain.