Skip to content

Commit ada0d22

Browse files
authored
refactor: add BzzAddress to ChainConfig and remove LookupERC20Address (#5476)
1 parent 09d97bb commit ada0d22

14 files changed

Lines changed: 132 additions & 104 deletions

File tree

.github/workflows/beekeeper.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ on:
77
paths-ignore:
88
- packaging/**
99
- openapi/**
10-
- '**/*.md'
11-
- '.github/ISSUE_TEMPLATE/**'
10+
- "**/*.md"
11+
- ".github/ISSUE_TEMPLATE/**"
1212
branches:
1313
- "**"
1414

cmd/bee/cmd/cmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const (
5050
optionNamePaymentEarly = "payment-early-percent"
5151
optionNameResolverEndpoints = "resolver-options"
5252
optionNameBootnodeMode = "bootnode-mode"
53+
optionNameBzzTokenAddress = "bzz-token-address"
5354
optionNameSwapFactoryAddress = "swap-factory-address"
5455
optionNameSwapInitialDeposit = "swap-initial-deposit"
5556
optionNameSwapEnable = "swap-enable"
@@ -301,6 +302,7 @@ func (c *command) setAllFlags(cmd *cobra.Command) {
301302
cmd.Flags().Duration(optionNameBlockchainRpcIdleTimeout, 90*time.Second, "blockchain rpc idle connection timeout")
302303
cmd.Flags().Duration(optionNameBlockchainRpcKeepalive, 30*time.Second, "blockchain rpc TCP keepalive interval")
303304
cmd.Flags().String(optionNameSwapFactoryAddress, "", "swap factory addresses")
305+
cmd.Flags().String(optionNameBzzTokenAddress, "", "bzz token contract address")
304306
cmd.Flags().String(optionNameSwapInitialDeposit, "0", "initial deposit if deploying a new chequebook")
305307
cmd.Flags().Bool(optionNameSwapEnable, false, "enable swap")
306308
cmd.Flags().Bool(optionNameChequebookEnable, true, "enable chequebook")

cmd/bee/cmd/start.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"syscall"
2222
"time"
2323

24+
"github.com/ethereum/go-ethereum/common"
2425
"github.com/ethersphere/bee/v2"
2526
"github.com/ethersphere/bee/v2/pkg/accesscontrol"
2627
"github.com/ethersphere/bee/v2/pkg/bmt"
@@ -285,6 +286,14 @@ func buildBeeNode(ctx context.Context, c *command, cmd *cobra.Command, logger lo
285286
logger.Info("SIMD hashing enabled", "batch_width", keccak.BatchWidth(), "avx512", keccak.HasAVX512())
286287
}
287288

289+
var bzzTokenAddress common.Address
290+
if a := c.config.GetString(optionNameBzzTokenAddress); a != "" {
291+
if !common.IsHexAddress(a) {
292+
return nil, errors.New("malformed bzz token address")
293+
}
294+
bzzTokenAddress = common.HexToAddress(a)
295+
}
296+
288297
b, err := node.NewBee(ctx, c.config.GetString(optionNameP2PAddr), signerConfig.publicKey, signerConfig.signer, networkID, logger, signerConfig.libp2pPrivateKey, signerConfig.pssPrivateKey, signerConfig.session, &node.Options{
289298
Addr: c.config.GetString(optionNameP2PAddr),
290299
AllowPrivateCIDRs: c.config.GetBool(optionNameAllowPrivateCIDRs),
@@ -297,6 +306,7 @@ func buildBeeNode(ctx context.Context, c *command, cmd *cobra.Command, logger lo
297306
BlockchainRpcTLSTimeout: c.config.GetDuration(configKeyBlockchainRpcTLSTimeout),
298307
BlockchainRpcIdleTimeout: c.config.GetDuration(configKeyBlockchainRpcIdleTimeout),
299308
BlockchainRpcKeepalive: c.config.GetDuration(configKeyBlockchainRpcKeepalive),
309+
BzzTokenAddress: bzzTokenAddress,
300310
BlockProfile: c.config.GetBool(optionNamePProfBlock),
301311
BlockTime: networkConfig.blockTime,
302312
BlockSyncInterval: c.config.GetUint64(optionNameBlockSyncInterval),

packaging/bee.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
# bootnode: ["/dnsaddr/mainnet.ethswarm.org"]
2020
## cause the node to always accept incoming connections
2121
# bootnode-mode: false
22+
## bzz token contract address
23+
# bzz-token-address: ""
2224
## cache capacity in chunks, multiply by 4096 to get approximate capacity in bytes
2325
# cache-capacity: "1000000"
2426
## enable forwarded content caching

packaging/docker/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ services:
1919
- BEE_BLOCKCHAIN_RPC_TLS_TIMEOUT
2020
- BEE_BOOTNODE
2121
- BEE_BOOTNODE_MODE
22+
- BEE_BZZ_TOKEN_ADDRESS
2223
- BEE_CACHE_CAPACITY
2324
- BEE_CACHE_RETRIEVAL
2425
- BEE_CHEQUEBOOK_ENABLE

packaging/docker/env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
# BEE_BOOTNODE=[/dnsaddr/mainnet.ethswarm.org]
3232
## cause the node to always accept incoming connections (default false)
3333
# BEE_BOOTNODE_MODE=false
34+
## bzz token contract address
35+
# BEE_BZZ_TOKEN_ADDRESS=
3436
## cache capacity in chunks, multiply by 4096 to get approximate capacity in bytes (default 1000000)
3537
# BEE_CACHE_CAPACITY=1000000
3638
## enable forwarded content caching (default true)

packaging/homebrew-amd64/bee.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
# bootnode: ["/dnsaddr/mainnet.ethswarm.org"]
2020
## cause the node to always accept incoming connections
2121
# bootnode-mode: false
22+
## bzz token contract address
23+
# bzz-token-address: ""
2224
## cache capacity in chunks, multiply by 4096 to get approximate capacity in bytes
2325
# cache-capacity: "1000000"
2426
## enable forwarded content caching

packaging/homebrew-arm64/bee.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
# bootnode: ["/dnsaddr/mainnet.ethswarm.org"]
2020
## cause the node to always accept incoming connections
2121
# bootnode-mode: false
22+
## bzz token contract address
23+
# bzz-token-address: ""
2224
## cache capacity in chunks, multiply by 4096 to get approximate capacity in bytes
2325
# cache-capacity: "1000000"
2426
## enable forwarded content caching

packaging/scoop/bee.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
# bootnode: ["/dnsaddr/mainnet.ethswarm.org"]
2020
## cause the node to always accept incoming connections
2121
# bootnode-mode: false
22+
## bzz token contract address
23+
# bzz-token-address: ""
2224
## cache capacity in chunks, multiply by 4096 to get approximate capacity in bytes
2325
# cache-capacity: "1000000"
2426
## enable forwarded content caching

pkg/config/chain.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import (
1212
"github.com/ethersphere/go-storage-incentives-abi/abi"
1313
)
1414

15-
// TODO: consider adding BzzAddress (also as a cmd param) to the ChainConfig and remove the postagecontract.LookupERC20Address function.
16-
1715
type ChainConfig struct {
1816
// General.
1917
ChainID int64
@@ -28,6 +26,7 @@ type ChainConfig struct {
2826
RedistributionAddress common.Address
2927
SwapPriceOracleAddress common.Address // Swap swear and swindle (S3) Contracts
3028
CurrentFactoryAddress common.Address
29+
TokenContractAddress common.Address
3130

3231
// ABIs.
3332
StakingABI string
@@ -65,6 +64,7 @@ var (
6564
RedistributionAddress: common.HexToAddress(abi.TestnetRedistributionAddress),
6665
SwapPriceOracleAddress: common.HexToAddress("0x1814e9b3951Df0CB8e12b2bB99c5594514588936"),
6766
CurrentFactoryAddress: common.HexToAddress("0x0fF044F6bB4F684a5A149B46D7eC03ea659F98A1"),
67+
TokenContractAddress: common.HexToAddress(abi.TestnetBzzTokenAddress),
6868

6969
StakingABI: abi.TestnetStakingABI,
7070
PostageStampABI: abi.TestnetPostageStampABI,
@@ -87,6 +87,7 @@ var (
8787
RedistributionAddress: common.HexToAddress(abi.MainnetRedistributionAddress),
8888
SwapPriceOracleAddress: common.HexToAddress("0xA57A50a831B31c904A770edBCb706E03afCdbd94"),
8989
CurrentFactoryAddress: common.HexToAddress("0xc2d5a532cf69aa9a1378737d8ccdef884b6e7420"),
90+
TokenContractAddress: common.HexToAddress(abi.MainnetBzzTokenAddress),
9091

9192
StakingABI: abi.MainnetStakingABI,
9293
PostageStampABI: abi.MainnetPostageStampABI,

0 commit comments

Comments
 (0)