Skip to content

Commit 2c0e2b8

Browse files
fix(transaction): improve gas estimation reliability and error handling (#5344)
1 parent ce36b8f commit 2c0e2b8

24 files changed

Lines changed: 743 additions & 165 deletions

File tree

cmd/bee/cmd/cmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const (
8282
optionReserveCapacityDoubling = "reserve-capacity-doubling"
8383
optionSkipPostageSnapshot = "skip-postage-snapshot"
8484
optionNameMinimumGasTipCap = "minimum-gas-tip-cap"
85+
optionNameGasLimitFallback = "gas-limit-fallback"
8586
optionNameP2PWSSEnable = "p2p-wss-enable"
8687
optionP2PWSSAddr = "p2p-wss-addr"
8788
optionNATWSSAddr = "nat-wss-addr"
@@ -297,6 +298,7 @@ func (c *command) setAllFlags(cmd *cobra.Command) {
297298
cmd.Flags().Int(optionReserveCapacityDoubling, 0, "reserve capacity doubling")
298299
cmd.Flags().Bool(optionSkipPostageSnapshot, false, "skip postage snapshot")
299300
cmd.Flags().Uint64(optionNameMinimumGasTipCap, 0, "minimum gas tip cap in wei for transactions, 0 means use suggested gas tip cap")
301+
cmd.Flags().Uint64(optionNameGasLimitFallback, 500_000, "gas limit fallback when estimation fails for contract transactions")
300302
cmd.Flags().Bool(optionNameP2PWSSEnable, false, "Enable Secure WebSocket P2P connections")
301303
cmd.Flags().String(optionP2PWSSAddr, ":1635", "p2p wss address")
302304
cmd.Flags().String(optionNATWSSAddr, "", "WSS NAT exposed address")

cmd/bee/cmd/deploy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func (c *command) initDeployCmd() error {
6060
blocktime,
6161
true,
6262
c.config.GetUint64(optionNameMinimumGasTipCap),
63+
c.config.GetUint64(optionNameGasLimitFallback),
6364
)
6465
if err != nil {
6566
return err

cmd/bee/cmd/start.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ func buildBeeNode(ctx context.Context, c *command, cmd *cobra.Command, logger lo
303303
FullNodeMode: fullNode,
304304
Logger: logger,
305305
MinimumGasTipCap: c.config.GetUint64(optionNameMinimumGasTipCap),
306+
GasLimitFallback: c.config.GetUint64(optionNameGasLimitFallback),
306307
MinimumStorageRadius: c.config.GetUint(optionMinimumStorageRadius),
307308
MutexProfile: c.config.GetBool(optionNamePProfMutex),
308309
NATAddr: c.config.GetString(optionNameNATAddr),

packaging/bee.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ password-file: "/var/lib/bee/password"
108108
# tracing-port: ""
109109
## service name identifier for tracing
110110
# tracing-service-name: bee
111+
## gas limit fallback when estimation fails for contract transactions (default 500000)
112+
# gas-limit-fallback: 500000
111113
## skips the gas estimate step for contract transactions
112114
# transaction-debug-mode: false
113115
## log verbosity level 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=trace

packaging/docker/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ services:
3939
- BEE_TRACING_ENABLE
4040
- BEE_TRACING_ENDPOINT
4141
- BEE_TRACING_SERVICE_NAME
42+
- BEE_GAS_LIMIT_FALLBACK
4243
- BEE_TRANSACTION
4344
- BEE_VERBOSITY
4445
- BEE_WELCOME_MESSAGE

packaging/docker/env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@
119119
# BEE_TRACING_PORT=
120120
## service name identifier for tracing
121121
# BEE_TRACING_SERVICE_NAME=
122+
## gas limit fallback when estimation fails for contract transactions (default 500000)
123+
# BEE_GAS_LIMIT_FALLBACK=500000
122124
## skips the gas estimate step for contract transactions
123125
# BEE_TRANSACTION_DEBUG_MODE=false
124126
## bootstrap node using postage snapshot from the network

packaging/homebrew-amd64/bee.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ password-file: "/usr/local/var/lib/swarm-bee/password"
108108
# tracing-port: ""
109109
## service name identifier for tracing
110110
# tracing-service-name: bee
111+
## gas limit fallback when estimation fails for contract transactions (default 500000)
112+
# gas-limit-fallback: 500000
111113
## skips the gas estimate step for contract transactions
112114
# transaction-debug-mode: false
113115
## log verbosity level 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=trace

packaging/homebrew-arm64/bee.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ password-file: "/opt/homebrew/var/lib/swarm-bee/password"
108108
# tracing-port: ""
109109
## service name identifier for tracing
110110
# tracing-service-name: bee
111+
## gas limit fallback when estimation fails for contract transactions (default 500000)
112+
# gas-limit-fallback: 500000
111113
## skips the gas estimate step for contract transactions
112114
# transaction-debug-mode: false
113115
## log verbosity level 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=trace

packaging/scoop/bee.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ password-file: "./password"
108108
# tracing-port: ""
109109
## service name identifier for tracing
110110
# tracing-service-name: bee
111+
## gas limit fallback when estimation fails for contract transactions (default 500000)
112+
# gas-limit-fallback: 500000
111113
## skips the gas estimate step for contract transactions
112114
# transaction-debug-mode: false
113115
## log verbosity level 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=trace

pkg/node/chain.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func InitChain(
5151
pollingInterval time.Duration,
5252
chainEnabled bool,
5353
minimumGasTipCap uint64,
54+
fallbackGasLimit uint64,
5455
) (transaction.Backend, common.Address, int64, transaction.Monitor, transaction.Service, error) {
5556
backend := backendnoop.New(chainID)
5657

@@ -91,7 +92,7 @@ func InitChain(
9192

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

94-
transactionService, err := transaction.NewService(logger, overlayEthAddress, backend, signer, stateStore, backendChainID, transactionMonitor)
95+
transactionService, err := transaction.NewService(logger, overlayEthAddress, backend, signer, stateStore, backendChainID, transactionMonitor, fallbackGasLimit)
9596
if err != nil {
9697
return nil, common.Address{}, 0, nil, nil, fmt.Errorf("transaction service: %w", err)
9798
}

0 commit comments

Comments
 (0)