Skip to content

Conversation

abi87
Copy link
Collaborator

@abi87 abi87 commented Aug 18, 2025

Apparent bera-geth init is not idempotent anymore, so we need to skip it if the beacond home folder is already there.
Note that if you run make start and make start-geth without then feeding any load to the chain, you can safely restart the nodes with no problem.
Instead if some load has been provided to the chain (e.g. deploying PoL) then an error like the following would appear:

INFO [08-18|12:31:43.727] Opened ancient database                  database=/.tmp/eth-home/bera-geth/chaindata/ancient/chain readonly=false
INFO [08-18|12:31:43.727] Opened Era store                         datadir=/.tmp/eth-home/bera-geth/chaindata/ancient/chain/era
INFO [08-18|12:31:43.727] State scheme set to already existing     scheme=path
INFO [08-18|12:31:43.728] Initialising Ethereum protocol           network=80087 dbversion=9
WARN [08-18|12:31:43.728] Sanitizing invalid node buffer size      provided=653.00MiB updated=256.00MiB
INFO [08-18|12:31:43.728] Load database journal from file          path=/.tmp/eth-home/bera-geth/triedb/merkle.journal
INFO [08-18|12:31:43.756] Opened ancient database                  database=/.tmp/eth-home/bera-geth/chaindata/ancient/state readonly=false
CRIT [08-18|12:31:43.756] Failed to truncate extra state histories err="out of range, tail: 0, head: 1, target: 5"

I manually tested that this is not the case for devnet with the proposed PR

@abi87 abi87 self-assigned this Aug 18, 2025
@abi87 abi87 requested a review from a team as a code owner August 18, 2025 13:07
Copy link

codecov bot commented Aug 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.67%. Comparing base (9fb50c1) to head (f9ee48e).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2885      +/-   ##
==========================================
+ Coverage   60.64%   60.67%   +0.03%     
==========================================
  Files         354      354              
  Lines       16673    16673              
==========================================
+ Hits        10111    10117       +6     
+ Misses       5773     5768       -5     
+ Partials      789      788       -1     

see 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@abi87
Copy link
Collaborator Author

abi87 commented Aug 18, 2025

@rabbit review

ghcr.io/berachain/bera-geth:latest init \
--datadir ${ETH_DATA_DIR} \
${ETH_GENESIS_PATH}
@if [ -f .tmp/.dir_was_reset ]; then \
Copy link
Contributor

@fridrik01 fridrik01 Aug 18, 2025

Choose a reason for hiding this comment

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

we could just test for the existence of .tmp/chaindata and only run bera-geth init if that folder does not exist. It would be simpler IMO as we won't need the .dir_was_reset file for that

Something like:

@if [  ! -d .tmp/chaindata ]; then \

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason I went for this solution is that I want ask_reset_dir_func to be the only place where the logic reset or init is decided. Still I understand your concern.
How about we make ask_reset_dir_func return a proper value and implement a conditional on top of it?
No file, but logic in a single place

@abi87
Copy link
Collaborator Author

abi87 commented Aug 18, 2025

Closing since redundant. @calbera already fixed this in berachain/bera-geth#54. The issue showed up in my case due to stale docker image

@abi87 abi87 closed this Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants