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

Use cached header for latest eth_getBlockByNumber #5292

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
- Upgrade RocksDB version from 7.7.3 to 8.0.0. Besu Team [contributed](https://github.com/facebook/rocksdb/pull/11099) to this release to make disabling checksum verification work.

### Bug Fixes
- Fix eth_getBlockByNumber cache error for latest block when called during syncing [#5292](https://github.com/hyperledger/besu/pull/5292)
- Fix QBFT and IBFT unable to propose blocks on London when zeroBaseFee is used [#5276](https://github.com/hyperledger/besu/pull/5276)

- Make QBFT validator smart contract mode work with london fork [#5249](https://github.com/hyperledger/besu/issues/5249)

### Download Links
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResult;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFactory;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Synchronizer;

Expand Down Expand Up @@ -80,8 +79,7 @@ protected Object resultByBlockNumber(
protected Object latestResult(final JsonRpcRequestContext request) {

final long headBlockNumber = blockchainQueriesSupplier.get().headBlockNumber();
Blockchain chain = blockchainQueriesSupplier.get().getBlockchain();
BlockHeader headHeader = chain.getBlockHeader(headBlockNumber).orElse(null);
BlockHeader headHeader = blockchainQueriesSupplier.get().headBlockHeader();

Hash block = headHeader.getHash();
Hash stateRoot = headHeader.getStateRoot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1063,10 +1063,7 @@ public void getBlockByNumberForLatest() throws Exception {
final BlockWithMetadata<TransactionWithMetadata, Hash> blockWithMetadata =
blockWithMetadata(block);
when(blockchainQueries.headBlockNumber()).thenReturn(0L);
when(blockchainQueries.blockByNumber(eq(0L))).thenReturn(Optional.of(blockWithMetadata));
when(blockchainQueries.getBlockchain()).thenReturn(blockchain);
when(blockchain.getBlockHeader(blockchainQueries.headBlockNumber()))
.thenReturn(Optional.of(block.getHeader()));
when(blockchainQueries.headBlockHeader()).thenReturn(block.getHeader());
WorldStateArchive state = mock(WorldStateArchive.class);
when(state.isWorldStateAvailable(any(Hash.class), any(Hash.class))).thenReturn(true);
when(blockchainQueries.getWorldStateArchive()).thenReturn(state);
Expand Down Expand Up @@ -1097,11 +1094,8 @@ public void getBlockByNumberForPending() throws Exception {
final Block block = gen.genesisBlock();
final BlockWithMetadata<TransactionWithMetadata, Hash> blockWithMetadata =
blockWithMetadata(block);
when(blockchainQueries.headBlockNumber()).thenReturn(0L);
when(blockchainQueries.blockByNumber(eq(0L))).thenReturn(Optional.of(blockWithMetadata));
when(blockchainQueries.getBlockchain()).thenReturn(blockchain);
when(blockchain.getBlockHeader(blockchainQueries.headBlockNumber()))
.thenReturn(Optional.of(block.getHeader()));
when(blockchainQueries.headBlockHeader()).thenReturn(block.getHeader());
WorldStateArchive state = mock(WorldStateArchive.class);
when(state.isWorldStateAvailable(any(Hash.class), any(Hash.class))).thenReturn(true);
when(blockchainQueries.getWorldStateArchive()).thenReturn(state);
Expand Down