@@ -91,21 +91,16 @@ func (args *TransactionArgs) data() []byte {
91
91
return nil
92
92
}
93
93
94
- // setDefaultConfig defines the options for deriving missing fields of transactions.
95
- type setDefaultConfig struct {
94
+ // sidecarConfig defines the options for deriving missing fields of transactions.
95
+ type sidecarConfig struct {
96
96
// This configures whether blobs are allowed to be passed and
97
97
// the associated sidecar version should be attached.
98
98
blobSidecarAllowed bool
99
99
blobSidecarVersion byte
100
-
101
- // skipGasEstimation is the flag whether the gas estimation is skipped.
102
- // this flag should only be used in the scenarios that a precise gas limit
103
- // is not critical, e.g., in non-transaction calls.
104
- skipGasEstimation bool
105
100
}
106
101
107
102
// setDefaults fills in default values for unspecified tx fields.
108
- func (args * TransactionArgs ) setDefaults (ctx context.Context , b Backend , config setDefaultConfig ) error {
103
+ func (args * TransactionArgs ) setDefaults (ctx context.Context , b Backend , config sidecarConfig ) error {
109
104
if err := args .setBlobTxSidecar (ctx , config ); err != nil {
110
105
return err
111
106
}
@@ -146,36 +141,28 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend, config
146
141
}
147
142
148
143
if args .Gas == nil {
149
- if config .skipGasEstimation {
150
- gas := hexutil .Uint64 (b .RPCGasCap ())
151
- if gas == 0 {
152
- gas = hexutil .Uint64 (math .MaxUint64 / 2 )
153
- }
154
- args .Gas = & gas
155
- } else {
156
- // These fields are immutable during the estimation, safe to
157
- // pass the pointer directly.
158
- data := args .data ()
159
- callArgs := TransactionArgs {
160
- From : args .From ,
161
- To : args .To ,
162
- GasPrice : args .GasPrice ,
163
- MaxFeePerGas : args .MaxFeePerGas ,
164
- MaxPriorityFeePerGas : args .MaxPriorityFeePerGas ,
165
- Value : args .Value ,
166
- Data : (* hexutil .Bytes )(& data ),
167
- AccessList : args .AccessList ,
168
- BlobFeeCap : args .BlobFeeCap ,
169
- BlobHashes : args .BlobHashes ,
170
- }
171
- latestBlockNr := rpc .BlockNumberOrHashWithNumber (rpc .LatestBlockNumber )
172
- estimated , err := DoEstimateGas (ctx , b , callArgs , latestBlockNr , nil , nil , b .RPCGasCap ())
173
- if err != nil {
174
- return err
175
- }
176
- args .Gas = & estimated
177
- log .Trace ("Estimate gas usage automatically" , "gas" , args .Gas )
144
+ // These fields are immutable during the estimation, safe to
145
+ // pass the pointer directly.
146
+ data := args .data ()
147
+ callArgs := TransactionArgs {
148
+ From : args .From ,
149
+ To : args .To ,
150
+ GasPrice : args .GasPrice ,
151
+ MaxFeePerGas : args .MaxFeePerGas ,
152
+ MaxPriorityFeePerGas : args .MaxPriorityFeePerGas ,
153
+ Value : args .Value ,
154
+ Data : (* hexutil .Bytes )(& data ),
155
+ AccessList : args .AccessList ,
156
+ BlobFeeCap : args .BlobFeeCap ,
157
+ BlobHashes : args .BlobHashes ,
158
+ }
159
+ latestBlockNr := rpc .BlockNumberOrHashWithNumber (rpc .LatestBlockNumber )
160
+ estimated , err := DoEstimateGas (ctx , b , callArgs , latestBlockNr , nil , nil , b .RPCGasCap ())
161
+ if err != nil {
162
+ return err
178
163
}
164
+ args .Gas = & estimated
165
+ log .Trace ("Estimate gas usage automatically" , "gas" , args .Gas )
179
166
}
180
167
181
168
// If chain id is provided, ensure it matches the local chain id. Otherwise, set the local
@@ -292,7 +279,7 @@ func (args *TransactionArgs) setLondonFeeDefaults(ctx context.Context, head *typ
292
279
}
293
280
294
281
// setBlobTxSidecar adds the blob tx
295
- func (args * TransactionArgs ) setBlobTxSidecar (ctx context.Context , config setDefaultConfig ) error {
282
+ func (args * TransactionArgs ) setBlobTxSidecar (ctx context.Context , config sidecarConfig ) error {
296
283
// No blobs, we're done.
297
284
if args .Blobs == nil {
298
285
return nil
@@ -311,7 +298,7 @@ func (args *TransactionArgs) setBlobTxSidecar(ctx context.Context, config setDef
311
298
return errors .New (`blob commitments provided while proofs were not` )
312
299
}
313
300
314
- // len(blobs) == len(commitments) == len(proofs) == len( hashes)
301
+ // len(blobs) == len(commitments) == len(hashes)
315
302
n := len (args .Blobs )
316
303
if args .BlobHashes != nil && len (args .BlobHashes ) != n {
317
304
return fmt .Errorf ("number of blobs and hashes mismatch (have=%d, want=%d)" , len (args .BlobHashes ), n )
0 commit comments