# Dev notes - w/c 14 April 2025
Kick off ephemery-prysm
- [x] ephemery-prysm branch
- [x] add `--ephemery` flag
- [x] run prysm with `--ephemery` flag locally
## MONDAY
Done:
- Cloned Prysm, created ephemery branch, added `ephemery` flag to config
- Installed [Bazel for Mac](https://bazel.build/install/os-x)
- Resolved Bazel path issue; ran `bazel build /...`
Example usage:
1. Run `bazel build /...` if changes to packages. Beware building everything takes a while!
3. Run EL client
`./geth --ephemery --http --http.api eth,net,engine,admin --authrpc.jwtsecret=<PATH_TO_JWT_FILE>`
4. Run a beacon node
`./prysm.sh beacon-chain --execution-endpoint=http://localhost:8551 --ephemery --jwt-secret=<PATH_TO_JWT_FILE> --checkpoint-sync-url=https://checkpointz.bordel.wtf/ --genesis-beacon-api-url=https://checkpointz.bordel.wtf/`
TODO:
- Fix build errors



- Run network locally, resolve any network config issues
## TUESDAY
Done:
- Added ephemery testfile
- We can't use `"@ephemery_testnet//:configs",` in`config/BUILD.bazel` in the same way as other networks; not including this to see if can build
- Tried to resolve bazel cross-compiling error
- Ran `bazel sync --configure` to fix darwin_x86_64 issue on MacOS, still doesn't build
- 
- Checked that I have full XCode as per [stackoverflow](https://stackoverflow.com/questions/72380159/bazel-build-failed-for-does-not-contain-a-toolchain-for-cpu-darwin-arm64) - I do
- Ran `bazel clean --expunge`
- Updated macOS (prerequisite for latest Xcode version)
- Tried again - not building yet
## WEDNESDAY
Done:
- Checked xcode latest version `/usr/bin/xcodebuild -version`
- More debugging - [stackoverflow](https://stackoverflow.com/questions/21272479/how-can-i-find-out-if-i-have-xcode-commandline-tools-installed)
- Removed commandline tools and reinstalled them - [stackoverflow](https://stackoverflow.com/questions/42538171/how-to-update-xcode-command-line-tools)
- Found [offchain labs issue](https://github.com/OffchainLabs/prysm/issues/14157) and ran `bazel build -- //... -//tools/...` as recommended by james-prysm => build success!

- Installed gpg `brew install gpg`
- Tried `./prysm.sh beacon-chain --execution-endpoint=http://localhost:8551 --ephemery` without running EL client, to see if commandline arguments recognised...

- Ran `bazel run gazelle -- fix` as per [prysm docs](https://www.offchainlabs.com/prysm/docs/reading/bazel/)
- Flag still not found. Debugging `config/params/BUILD.bazel` and `WORKSPACE`

- Bazel [rules on http_archive](https://bazel.build/rules/lib/repo/http#http_archive)
- Set url to latest release (standardized testnet layout) `url=https://github.com/ephemery-testnet/ephemery-genesis/releases/download/ephemery-145/network-config.tar.gz`
- Local path `/private/var/tmp/_bazel_hollyatkinson/344d529f6264b45d54bed4eed9b68be0/external/ephemery_testnet`
Including the url for the latest release enables build but flag is still not defined :-/

Tried `bazel build //cmd/beacon-chain --config=release` - flag not defined
## THURSDAY
Done:
- Installed cmake and reinstalled Bazel
- Viewed subcommands and tried using flag directly in bazel-bin `bazel build --subcommands //cmd/beacon-chain:beacon-chain `
- `bazel-bin/cmd/beacon-chain/beacon-chain_/beacon-chain --execution-endpoint=http://localhost:8551 --ephemery`
- I needed to update the ephemery config because I had not yet updated the fork versions so there were conflicts with hoodi during build
Two different issues occuring:
1. The first error from bazel-bin shows that the --ephemery flag is working, but there's a database conflict. The database has a different deposit contract address than what's configured for Ephemery.
Either:
Clear the existing database with --clear-db
Or use a different data directory with --datadir
Full command:
`bazel-bin/cmd/beacon-chain/beacon-chain_/beacon-chain --execution-endpoint=http://localhost:8551 --ephemery --clear-db`
2. The second error from `prysm.sh` shows that the --ephemery flag isn't being recognized when running through the shell script.
The `prysm.sh` script is downloading a pre-built binary from Prysmatic Labs. The bazel-bin version is built from local source code.
Two options:
Use the bazel-bin version that's working:
`bazel-bin/cmd/beacon-chain/beacon-chain_/beacon-chain --execution-endpoint=http://localhost:8551 --ephemery`
Or build and use the local version through the script:
`bazel build //cmd/beacon-chain`
`./prysm.sh beacon-chain --execution-endpoint=http://localhost:8551 --ephemery` => doesn't work (?)
Managed to get ephemery to run:
`bazel-bin/cmd/beacon-chain/beacon-chain_/beacon-chain --execution-endpoint=http://localhost:8551 --genesis-beacon-api-url=https://checkpointz.bordel.wtf/ --ephemery --clear-db`
(Also works without `--clear-db`)

Testing - not sure how to test / which tests are applicable to ephemery;
FAILS: `bazel test //testing/endtoend:go_default_test --test_arg="-test.run=TestEndToEnd_MinimalConfig" --test_env=ETH_NETWORK=ephemery`
FAILS: `bazel test //testing/endtoend:go_builder_test --test_arg="-test.run=TestEndToEnd_MinimalConfig_WithBuilder" --test_env=ETH_NETWORK=ephemery`
PASSES: `bazel test //testing/endtoend:go_mainnet_test --test_arg="-test.run=TestEndToEnd_MultiScenarioRun_Multiclient" --test_env=ETH_NETWORK=ephemery`

TODO:
- Now that I've figured out how to run the ephemery flag using iteration 145, my next step is to remove the hardcoded ephemery-145 references and download the latest ephemery config for the latest MONTHLY release, and the iteration calculation should be VERIFIED against some initial values
- Figure out how to build and use the local version of ephemery through the script
- Reach out to prysm, write github issue, ask about test scenarios
- Peer review
## Resources
[Hoodi PR](https://github.com/OffchainLabs/prysm/pull/15057)
[Holesky PR](https://github.com/OffchainLabs/prysm/pull/12821)
[Prysm docs - install](https://www.offchainlabs.com/prysm/docs/install/install-with-script/)
[Prysm docs - bazel build](https://www.offchainlabs.com/prysm/docs/reading/bazel/#building-production-releases)
[Prysm docs - install with bazel](https://www.offchainlabs.com/prysm/docs/install/install-with-bazel)
[epf.wiki](https://epf.wiki/#/wiki/protocol/architecture)
https://stackoverflow.com/questions/34617452/how-to-update-xcode-from-command-line
https://stackoverflow.com/questions/52801868/what-does-the-symbol-mean-in-bazel
[Holesky issue](https://github.com/OffchainLabs/prysm/issues/12724)