Skip to content

block header cache not initialized before used#7601

Merged
macfarla merged 3 commits intobesu-eth:mainfrom
lu-pinto:reorder-DefaultBlockchain-init
Sep 10, 2024
Merged

block header cache not initialized before used#7601
macfarla merged 3 commits intobesu-eth:mainfrom
lu-pinto:reorder-DefaultBlockchain-init

Conversation

@lu-pinto
Copy link
Copy Markdown
Contributor

PR description

After this commit the block headers cache is being used before it's initialized which creates an NPE while setting up the metrics:

Caused by: java.lang.NullPointerException: Cannot invoke \"java.util.Optional.map(java.util.function.Function)\" because \"this.blockHeadersCache\" is null
    at org.hyperledger.besu.ethereum.chain.DefaultBlockchain.getBlockHeader(DefaultBlockchain.java:328)
    at java.base/java.util.Optional.flatMap(Optional.java:289)
    at org.hyperledger.besu.ethereum.chain.DefaultBlockchain.getFinalizedBlockNumber(DefaultBlockchain.java:775)
    at org.hyperledger.besu.plugin.services.MetricsSystem.lambda$createLongGauge$1(MetricsSystem.java:160)
    at org.hyperledger.besu.metrics.prometheus.CurrentValueCollector.collect(CurrentValueCollector.java:55)
    ...

Fixed Issue(s)

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests

Signed-off-by: Luis Pinto <luis.pinto@consensys.net>
@lu-pinto lu-pinto force-pushed the reorder-DefaultBlockchain-init branch from 44ec697 to 2a9d85b Compare September 10, 2024 22:59
Copy link
Copy Markdown
Contributor

@garyschulte garyschulte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@macfarla macfarla enabled auto-merge (squash) September 10, 2024 23:01
Signed-off-by: Luis Pinto <luis.pinto@consensys.net>
auto-merge was automatically disabled September 10, 2024 23:13

Head branch was pushed to by a user without write access

@macfarla macfarla enabled auto-merge (squash) September 10, 2024 23:17
@macfarla macfarla merged commit 46636c7 into besu-eth:main Sep 10, 2024
@lu-pinto lu-pinto deleted the reorder-DefaultBlockchain-init branch September 11, 2024 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants