Skip to content

refactor: add BzzAddress to ChainConfig and remove LookupERC20Address#5476

Open
martinconic wants to merge 4 commits into
masterfrom
refactor/bzz-address-config-5475
Open

refactor: add BzzAddress to ChainConfig and remove LookupERC20Address#5476
martinconic wants to merge 4 commits into
masterfrom
refactor/bzz-address-config-5475

Conversation

@martinconic
Copy link
Copy Markdown
Contributor

@martinconic martinconic commented May 25, 2026

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

Follow-up to #5468 and the review comment there. Resolves the long-standing TODO in pkg/config/chain.go to source the BZZ token address from static config instead of looking it up on-chain at runtime.

The address is deterministic per chain but was resolved on-chain twice during node bootstrap:

  • chequebookFactory.ERC20Address(ctx) → feeds erc20Service (and the /wallet endpoint), and
  • postagecontract.LookupERC20Address → feeds the postage stamp and staking contracts.

Changes:

  • Add BzzAddress to ChainConfig, populated for mainnet and testnet from the go-storage-incentives-abi constants (same source already used for the staking/postage addresses).
  • Add a --bzz-token-address override for custom chains.
  • Resolve the address once and reuse it for erc20Service and the postage/staking contracts; remove postagecontract.LookupERC20Address and its test.
  • Add a startup guard rejecting swap-enable=true with the chain backend disabled. Removing the factory ERC20Address call also removed the implicit fail-fast it provided for that misconfiguration; the guard restores it with a clearer message instead of a later nil panic on swap endpoints.

Fixes #5457

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

Related Issue (Optional)

Screenshots (if appropriate):

AI Disclosure

  • This PR contains code that has been generated by an LLM.
  • I have reviewed the AI generated code thoroughly.
  • I possess the technical expertise to responsibly review the code generated in this PR.

@martinconic martinconic self-assigned this May 25, 2026
@martinconic martinconic added this to the 2026 milestone May 25, 2026
@martinconic martinconic requested review from acud, akrem-chabchoub, gacevicljubisa, janos and sbackend123 and removed request for acud May 25, 2026 15:06
Comment thread cmd/bee/cmd/cmd.go Outdated
akrem-chabchoub

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

@akrem-chabchoub akrem-chabchoub left a comment

Choose a reason for hiding this comment

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

Maybe you can just add the bzz-token-address to the docker-compose.yml file ?

Also the beekeeper integration test is failing, not sure if its related to this pr ?

Per @gacevicljubisa's review: surface the new flag through the docker
packaging so operators using the docker-compose setup can configure it
without dropping to a config file. Adds the env-var declaration in
docker-compose.yml and a documented (commented) entry in env, both
alphabetically placed between BEE_BOOTNODE_MODE and BEE_CACHE_CAPACITY.
@martinconic martinconic force-pushed the refactor/bzz-address-config-5475 branch from c77e9fe to f6e6847 Compare May 27, 2026 11:51
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.

refactor: add BzzAddress to ChainConfig and remove postagecontract.LookupERC20Address

3 participants