Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/bee/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const (
optionReserveCapacityDoubling = "reserve-capacity-doubling"
optionSkipPostageSnapshot = "skip-postage-snapshot"
optionNameMinimumGasTipCap = "minimum-gas-tip-cap"
optionNameGasLimitFallback = "gas-limit-fallback"

@akrem-chabchoub akrem-chabchoub Apr 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This flag should be added to docker-compose and env files

optionNameP2PWSSEnable = "p2p-wss-enable"
optionP2PWSSAddr = "p2p-wss-addr"
optionNATWSSAddr = "nat-wss-addr"
Expand Down Expand Up @@ -299,6 +300,7 @@ func (c *command) setAllFlags(cmd *cobra.Command) {
cmd.Flags().Int(optionReserveCapacityDoubling, 0, "reserve capacity doubling")
cmd.Flags().Bool(optionSkipPostageSnapshot, false, "skip postage snapshot")
cmd.Flags().Uint64(optionNameMinimumGasTipCap, 0, "minimum gas tip cap in wei for transactions, 0 means use suggested gas tip cap")
cmd.Flags().Uint64(optionNameGasLimitFallback, 500_000, "gas limit fallback when estimation fails for contract transactions")
cmd.Flags().Bool(optionNameP2PWSSEnable, false, "Enable Secure WebSocket P2P connections")
cmd.Flags().String(optionP2PWSSAddr, ":1635", "p2p wss address")
cmd.Flags().String(optionNATWSSAddr, "", "WSS NAT exposed address")
Expand Down
1 change: 1 addition & 0 deletions cmd/bee/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (c *command) initDeployCmd() error {
blocktime,
true,
c.config.GetUint64(optionNameMinimumGasTipCap),
c.config.GetUint64(optionNameGasLimitFallback),
)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions cmd/bee/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ func buildBeeNode(ctx context.Context, c *command, cmd *cobra.Command, logger lo
FullNodeMode: fullNode,
Logger: logger,
MinimumGasTipCap: c.config.GetUint64(optionNameMinimumGasTipCap),
GasLimitFallback: c.config.GetUint64(optionNameGasLimitFallback),
MinimumStorageRadius: c.config.GetUint(optionMinimumStorageRadius),
MutexProfile: c.config.GetBool(optionNamePProfMutex),
NATAddr: c.config.GetString(optionNameNATAddr),
Expand Down
3 changes: 2 additions & 1 deletion pkg/node/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func InitChain(
pollingInterval time.Duration,
chainEnabled bool,
minimumGasTipCap uint64,
fallbackGasLimit uint64,
) (transaction.Backend, common.Address, int64, transaction.Monitor, transaction.Service, error) {
backend := backendnoop.New(chainID)

Expand Down Expand Up @@ -91,7 +92,7 @@ func InitChain(

transactionMonitor := transaction.NewMonitor(logger, backend, overlayEthAddress, pollingInterval, cancellationDepth)

transactionService, err := transaction.NewService(logger, overlayEthAddress, backend, signer, stateStore, backendChainID, transactionMonitor)
transactionService, err := transaction.NewService(logger, overlayEthAddress, backend, signer, stateStore, backendChainID, transactionMonitor, fallbackGasLimit)
if err != nil {
return nil, common.Address{}, 0, nil, nil, fmt.Errorf("transaction service: %w", err)
}
Expand Down
15 changes: 12 additions & 3 deletions pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ type Options struct {
AutoTLSDomain string
AutoTLSRegistrationEndpoint string
FullNodeMode bool
GasLimitFallback uint64
Logger log.Logger
MinimumGasTipCap uint64
MinimumStorageRadius uint
Expand Down Expand Up @@ -410,6 +411,7 @@ func NewBee(
o.BlockTime,
chainEnabled,
o.MinimumGasTipCap,
o.GasLimitFallback,
)
if err != nil {
return nil, fmt.Errorf("init chain: %w", err)
Expand Down Expand Up @@ -724,6 +726,13 @@ func NewBee(
return nil, fmt.Errorf("lookup erc20 postage address: %w", err)
}

// Compute gas limit for contract transactions: when TrxDebugMode is enabled,
// gas estimation is skipped and DefaultGasLimit is used for all contract calls.
var contractGasLimit uint64
if o.TrxDebugMode {
contractGasLimit = transaction.DefaultGasLimit
}

postageStampContractService = postagecontract.New(
overlayEthAddress,
postageStampContractAddress,
Expand All @@ -733,7 +742,7 @@ func NewBee(
post,
batchStore,
chainEnabled,
o.TrxDebugMode,
contractGasLimit,
)

eventListener = listener.New(b.syncingStopped, logger, chainBackend, postageStampContractAddress, postageStampContractABI, o.BlockTime, postageSyncingStallingTimeout, postageSyncingBackoffTimeout)
Expand Down Expand Up @@ -1114,7 +1123,7 @@ func NewBee(
stakingContractAddress = common.HexToAddress(o.StakingContractAddress)
}

stakingContract := staking.New(overlayEthAddress, stakingContractAddress, abiutil.MustParseABI(chainCfg.StakingABI), bzzTokenAddress, transactionService, common.BytesToHash(nonce), o.TrxDebugMode, uint8(o.ReserveCapacityDoubling))
stakingContract := staking.New(overlayEthAddress, stakingContractAddress, abiutil.MustParseABI(chainCfg.StakingABI), bzzTokenAddress, transactionService, common.BytesToHash(nonce), contractGasLimit, uint8(o.ReserveCapacityDoubling))

if chainEnabled {

Expand Down Expand Up @@ -1204,7 +1213,7 @@ func NewBee(
redistributionContractAddress = common.HexToAddress(o.RedistributionContractAddress)
}

redistributionContract := redistribution.New(swarmAddress, overlayEthAddress, logger, transactionService, redistributionContractAddress, abiutil.MustParseABI(chainCfg.RedistributionABI), o.TrxDebugMode)
redistributionContract := redistribution.New(swarmAddress, overlayEthAddress, logger, transactionService, redistributionContractAddress, abiutil.MustParseABI(chainCfg.RedistributionABI), contractGasLimit)

isFullySynced := func() bool {
reserveThreshold := reserveCapacity * 5 / 10
Expand Down
7 changes: 1 addition & 6 deletions pkg/postage/postagecontract/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,12 @@ func New(
postageService postage.Service,
postageStorer postage.Storer,
chainEnabled bool,
setGasLimit bool,
gasLimit uint64,
) Interface {
if !chainEnabled {
return new(noOpPostageContract)
}

var gasLimit uint64
if setGasLimit {
gasLimit = transaction.DefaultGasLimit
}

return &postageContract{
owner: owner,
postageStampContractAddress: postageStampContractAddress,
Expand Down
34 changes: 17 additions & 17 deletions pkg/postage/postagecontract/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func TestCreateBatch(t *testing.T) {
postageMock,
postagestoreMock.New(),
true,
false,
0,
)

_, returnedID, err := contract.CreateBatch(ctx, initialBalance, depth, false, label)
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestCreateBatch(t *testing.T) {
postageMock.New(),
postagestoreMock.New(),
true,
false,
0,
)

_, _, err := contract.CreateBatch(ctx, initialBalance, depth, false, label)
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestCreateBatch(t *testing.T) {
postageMock.New(),
postagestoreMock.New(),
true,
false,
0,
)

_, _, err := contract.CreateBatch(ctx, initialBalance, depth, false, label)
Expand Down Expand Up @@ -249,7 +249,7 @@ func TestCreateBatch(t *testing.T) {
postageMock.New(),
postagestoreMock.New(),
true,
false,
0,
)

_, _, err = contract.CreateBatch(ctx, initialBalance, depth, false, label)
Expand Down Expand Up @@ -360,7 +360,7 @@ func TestTopUpBatch(t *testing.T) {
postageMock,
batchStoreMock,
true,
false,
0,
)

_, err = contract.TopUpBatch(ctx, batch.ID, topupBalance)
Expand Down Expand Up @@ -389,7 +389,7 @@ func TestTopUpBatch(t *testing.T) {
postageMock.New(),
postagestoreMock.New(postagestoreMock.WithGetErr(errNotFound, 0)),
true,
false,
0,
)

_, err := contract.TopUpBatch(ctx, postagetesting.MustNewID(), topupBalance)
Expand Down Expand Up @@ -419,7 +419,7 @@ func TestTopUpBatch(t *testing.T) {
postageMock.New(),
batchStoreMock,
true,
false,
0,
)

_, err := contract.TopUpBatch(ctx, batch.ID, topupBalance)
Expand Down Expand Up @@ -549,7 +549,7 @@ func TestDiluteBatch(t *testing.T) {
postageMock,
batchStoreMock,
true,
false,
0,
)

_, err = contract.DiluteBatch(ctx, batch.ID, newDepth)
Expand Down Expand Up @@ -578,7 +578,7 @@ func TestDiluteBatch(t *testing.T) {
postageMock.New(),
postagestoreMock.New(postagestoreMock.WithGetErr(errNotFound, 0)),
true,
false,
0,
)

_, err := contract.DiluteBatch(ctx, postagetesting.MustNewID(), uint8(17))
Expand All @@ -601,7 +601,7 @@ func TestDiluteBatch(t *testing.T) {
postageMock.New(),
batchStoreMock,
true,
false,
0,
)

_, err := contract.DiluteBatch(ctx, batch.ID, batch.Depth-1)
Expand Down Expand Up @@ -678,7 +678,7 @@ func TestBatchExpirer(t *testing.T) {
postageMock,
postagestoreMock.New(),
true,
false,
0,
)

err = contract.ExpireBatches(ctx)
Expand Down Expand Up @@ -712,7 +712,7 @@ func TestBatchExpirer(t *testing.T) {
postageMock,
postagestoreMock.New(),
true,
false,
0,
)

err = contract.ExpireBatches(ctx)
Expand Down Expand Up @@ -746,7 +746,7 @@ func TestBatchExpirer(t *testing.T) {
postageMock,
postagestoreMock.New(),
true,
false,
0,
)

err = contract.ExpireBatches(ctx)
Expand Down Expand Up @@ -823,7 +823,7 @@ func TestBatchExpirer(t *testing.T) {
postageMock,
postagestoreMock.New(),
true,
false,
0,
)

err = contract.ExpireBatches(ctx)
Expand Down Expand Up @@ -858,7 +858,7 @@ func TestBatchExpirer(t *testing.T) {
postageMock,
postagestoreMock.New(),
true,
false,
0,
)

err = contract.ExpireBatches(ctx)
Expand Down Expand Up @@ -895,7 +895,7 @@ func TestBatchExpirer(t *testing.T) {
postageMock,
postagestoreMock.New(),
true,
false,
0,
)

err = contract.ExpireBatches(ctx)
Expand Down Expand Up @@ -945,7 +945,7 @@ func TestBatchExpirer(t *testing.T) {
postageMock,
postagestoreMock.New(),
true,
false,
0,
)

err = contract.ExpireBatches(ctx)
Expand Down
7 changes: 1 addition & 6 deletions pkg/storageincentives/redistribution/redistribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,8 @@ func New(
txService transaction.Service,
incentivesContractAddress common.Address,
incentivesContractABI abi.ABI,
setGasLimit bool,
gasLimit uint64,
) Contract {
var gasLimit uint64
if setGasLimit {
gasLimit = transaction.DefaultGasLimit
}

return &contract{
overlay: overlay,
owner: owner,
Expand Down
22 changes: 11 additions & 11 deletions pkg/storageincentives/redistribution/redistribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestRedistribution(t *testing.T) {
),
redistributionContractAddress,
redistributionContractABI,
false,
0,
)

isPlaying, err := contract.IsPlaying(ctx, depth)
Expand Down Expand Up @@ -120,7 +120,7 @@ func TestRedistribution(t *testing.T) {
),
redistributionContractAddress,
redistributionContractABI,
false,
0,
)

isPlaying, err := contract.IsPlaying(ctx, depth)
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestRedistribution(t *testing.T) {
),
redistributionContractAddress,
redistributionContractABI,
false,
0,
)

isWinner, err := contract.IsWinner(ctx)
Expand All @@ -177,7 +177,7 @@ func TestRedistribution(t *testing.T) {
),
redistributionContractAddress,
redistributionContractABI,
false,
0,
)

isWinner, err := contract.IsWinner(ctx)
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestRedistribution(t *testing.T) {
),
redistributionContractAddress,
redistributionContractABI,
false,
0,
)

_, err = contract.Claim(ctx, proofs)
Expand Down Expand Up @@ -265,7 +265,7 @@ func TestRedistribution(t *testing.T) {
),
redistributionContractAddress,
redistributionContractABI,
false,
0,
)

_, err = contract.Claim(ctx, proofs)
Expand Down Expand Up @@ -308,7 +308,7 @@ func TestRedistribution(t *testing.T) {
),
redistributionContractAddress,
redistributionContractABI,
false,
0,
)

_, err = contract.Commit(ctx, testobfus, 0)
Expand Down Expand Up @@ -353,7 +353,7 @@ func TestRedistribution(t *testing.T) {
),
redistributionContractAddress,
redistributionContractABI,
false,
0,
)

_, err = contract.Reveal(ctx, depth, common.Hex2Bytes("hash"), common.Hex2Bytes("nonce"))
Expand All @@ -380,7 +380,7 @@ func TestRedistribution(t *testing.T) {
),
redistributionContractAddress,
redistributionContractABI,
false,
0,
)

salt, err := contract.ReserveSalt(ctx)
Expand Down Expand Up @@ -410,7 +410,7 @@ func TestRedistribution(t *testing.T) {
),
redistributionContractAddress,
redistributionContractABI,
false,
0,
)

_, err := contract.IsPlaying(ctx, depth)
Expand Down Expand Up @@ -443,7 +443,7 @@ func TestRedistribution(t *testing.T) {
),
redistributionContractAddress,
redistributionContractABI,
false,
0,
)

_, err = contract.Commit(ctx, common.Hex2Bytes("hash"), 0)
Expand Down
Loading
Loading