diff --git a/docs/config-file/node-config-doc.html b/docs/config-file/node-config-doc.html index 8839d4b587..00015a00a0 100644 --- a/docs/config-file/node-config-doc.html +++ b/docs/config-file/node-config-doc.html @@ -18,7 +18,7 @@
"300ms"
WriteTimeout is the HTTP server write timeout
check net/http.server.WriteTimeout
"1m"
"300ms"
-
MaxRequestsPerIPAndSecond defines how much requests a single IP can
send within a single second
SequencerNodeURI is used allow Non-Sequencer nodes
to relay transactions to the Sequencer node
MaxCumulativeGasUsed is the max gas allowed per batch
Enabled defines if the WebSocket requests are enabled or disabled
Host defines the network adapter that will be used to serve the WS requests
Port defines the port to serve the endpoints via WS
ReadLimit defines the maximum size of a message read from the client (in bytes)
EnableL2SuggestedGasPricePolling enables polling of the L2 gas price to block tx in the RPC with lower gas price.
BatchRequestsEnabled defines if the Batch requests are enabled or disabled
BatchRequestsLimit defines the limit of requests that can be incorporated into each batch request
L2Coinbase defines which address is going to receive the fees
Must contain a minimum of 20
items
Must contain a maximum of 20
items
MaxLogsCount is a configuration to set the max number of logs that can be returned
in a single call to the state, if zero it means no limit
MaxLogsBlockRange is a configuration to set the max range for block number when querying TXs
logs in a single call to the state, if zero it means no limit
MaxNativeBlockHashBlockRange is a configuration to set the max range for block number when querying
native block hashes in a single call to the state, if zero it means no limit
EnableHttpLog allows the user to enable or disable the logs related to the HTTP
requests to be captured by the server.
XLayer config
EnablePendingTransactionFilter enables pending transaction filter that can support query L2 pending transaction
URLs nacos server urls for discovery service of rest api, url is separated by ","
NamespaceId nacos namepace id for discovery service of rest api
ApplicationName rest application name in nacos
ExternalListenAddr Set the rest-server external ip and port, when it is launched by Docker
URLs nacos server urls for discovery service of rest api, url is separated by ","
NamespaceId nacos namepace id for discovery service of rest api
ApplicationName rest application name in nacos
ExternalListenAddr Set the rest-server external ip and port, when it is launched by Docker
GasLimitFactor is used to multiply the suggested gas provided by the network
in order to allow a enough gas to be set for all the transactions default value is 1.
ex:
suggested gas limit: 100
GasLimitFactor: 1
gas limit = 100
suggested gas limit: 100
GasLimitFactor: 1.1
gas limit = 110
DisableAPIs disable some API
Enabled defines if the rate limit is enabled or disabled
RateLimitApis defines the apis that need to be rate limited
RateLimitBurst defines the maximum burst size of requests
RateLimitDuration defines the time window for the rate limit
SpecialApis defines the apis that need to be rate limited with special rate limit
Api defines the api that need to be rate limited
Count defines the maximum burst size of requests
Duration defines the time window for the rate limit
Enabled defines if the dynamic gas price is enabled or disabled
CongestionTxThreshold defines the tx threshold to measure whether there is congestion
CheckBatches defines the number of recent Batches used to sample gas price
SampleTxNumer defines the number of sampled gas prices in each batch
Percentile defines the sampling weight of all sampled gas prices
MaxPrice defines the dynamic gas price upper limit
MinPrice defines the dynamic gas price lower limit
UpdatePeriod defines the time interval for updating dynamic gas price
"1m"
+
MaxRequestsPerIPAndSecond defines how much requests a single IP can
send within a single second
SequencerNodeURI is used allow Non-Sequencer nodes
to relay transactions to the Sequencer node
MaxCumulativeGasUsed is the max gas allowed per batch
Enabled defines if the WebSocket requests are enabled or disabled
Host defines the network adapter that will be used to serve the WS requests
Port defines the port to serve the endpoints via WS
ReadLimit defines the maximum size of a message read from the client (in bytes)
EnableL2SuggestedGasPricePolling enables polling of the L2 gas price to block tx in the RPC with lower gas price.
BatchRequestsEnabled defines if the Batch requests are enabled or disabled
BatchRequestsLimit defines the limit of requests that can be incorporated into each batch request
L2Coinbase defines which address is going to receive the fees
Must contain a minimum of 20
items
Must contain a maximum of 20
items
MaxLogsCount is a configuration to set the max number of logs that can be returned
in a single call to the state, if zero it means no limit
MaxLogsBlockRange is a configuration to set the max range for block number when querying TXs
logs in a single call to the state, if zero it means no limit
MaxNativeBlockHashBlockRange is a configuration to set the max range for block number when querying
native block hashes in a single call to the state, if zero it means no limit
EnableHttpLog allows the user to enable or disable the logs related to the HTTP
requests to be captured by the server.
XLayer config
EnablePendingTransactionFilter enables pending transaction filter that can support query L2 pending transaction
URLs nacos server urls for discovery service of rest api, url is separated by ","
NamespaceId nacos namepace id for discovery service of rest api
ApplicationName rest application name in nacos
ExternalListenAddr Set the rest-server external ip and port, when it is launched by Docker
URLs nacos server urls for discovery service of rest api, url is separated by ","
NamespaceId nacos namepace id for discovery service of rest api
ApplicationName rest application name in nacos
ExternalListenAddr Set the rest-server external ip and port, when it is launched by Docker
GasLimitFactor is used to multiply the suggested gas provided by the network
in order to allow a enough gas to be set for all the transactions default value is 1.
ex:
suggested gas limit: 100
GasLimitFactor: 1
gas limit = 100
suggested gas limit: 100
GasLimitFactor: 1.1
gas limit = 110
DisableAPIs disable some API
Enabled defines if the rate limit is enabled or disabled
RateLimitApis defines the apis that need to be rate limited
RateLimitBurst defines the maximum burst size of requests
RateLimitDuration defines the time window for the rate limit
SpecialApis defines the apis that need to be rate limited with special rate limit
Api defines the api that need to be rate limited
Count defines the maximum burst size of requests
Duration defines the time window for the rate limit
Enabled defines if the dynamic gas price is enabled or disabled
CongestionTxThreshold defines the tx threshold to measure whether there is congestion
CheckBatches defines the number of recent Batches used to sample gas price
SampleTxNumer defines the number of sampled gas prices in each batch
Percentile defines the sampling weight of all sampled gas prices
MaxPrice defines the dynamic gas price upper limit
MinPrice defines the dynamic gas price lower limit
UpdatePeriod defines the time interval for updating dynamic gas price
"1m"
"300ms"
EnableInnerTxCacheDB enables the inner tx cache db
BridgeAddress is the address of the bridge contract
Must contain a minimum of 20
items
Must contain a maximum of 20
items
Enabled defines if the api authentication is enabled
ApiKeys defines the api keys
Name defines the name of the key
Key defines the key
Timeout defines the timeout
SyncInterval is the delay interval between reading new rollup information
"1m"
"300ms"
diff --git a/docs/config-file/node-config-doc.md b/docs/config-file/node-config-doc.md
index 4be852f2af..c2fae0654c 100644
--- a/docs/config-file/node-config-doc.md
+++ b/docs/config-file/node-config-doc.md
@@ -1334,6 +1334,7 @@ FreeGasLimit=0
| - [NacosWs](#RPC_NacosWs ) | No | object | No | - | NacosWs configuration |
| - [GasLimitFactor](#RPC_GasLimitFactor ) | No | number | No | - | GasLimitFactor is used to multiply the suggested gas provided by the network
in order to allow a enough gas to be set for all the transactions default value is 1.
ex:
suggested gas limit: 100
GasLimitFactor: 1
gas limit = 100
suggested gas limit: 100
GasLimitFactor: 1.1
gas limit = 110 |
| - [EnableEstimateGasOpt](#RPC_EnableEstimateGasOpt ) | No | boolean | No | - | - |
+| - [EnableEstimateGasUltraOpt](#RPC_EnableEstimateGasUltraOpt ) | No | boolean | No | - | - |
| - [DisableAPIs](#RPC_DisableAPIs ) | No | array of string | No | - | DisableAPIs disable some API |
| - [RateLimit](#RPC_RateLimit ) | No | object | No | - | RateLimit enable rate limit |
| - [DynamicGP](#RPC_DynamicGP ) | No | object | No | - | DynamicGP defines the config of dynamic gas price |
@@ -1942,7 +1943,19 @@ GasLimitFactor=1
EnableEstimateGasOpt=false
```
-### 8.23. `RPC.DisableAPIs`
+### 8.23. `RPC.EnableEstimateGasUltraOpt`
+
+**Type:** : `boolean`
+
+**Default:** `false`
+
+**Example setting the default value** (false):
+```
+[RPC]
+EnableEstimateGasUltraOpt=false
+```
+
+### 8.24. `RPC.DisableAPIs`
**Type:** : `array of string`
@@ -1956,7 +1969,7 @@ EnableEstimateGasOpt=false
DisableAPIs=[]
```
-### 8.24. `[RPC.RateLimit]`
+### 8.25. `[RPC.RateLimit]`
**Type:** : `object`
**Description:** RateLimit enable rate limit
@@ -1969,7 +1982,7 @@ DisableAPIs=[]
| - [RateLimitDuration](#RPC_RateLimit_RateLimitDuration ) | No | integer | No | - | RateLimitDuration defines the time window for the rate limit |
| - [SpecialApis](#RPC_RateLimit_SpecialApis ) | No | array of object | No | - | SpecialApis defines the apis that need to be rate limited with special rate limit |
-#### 8.24.1. `RPC.RateLimit.Enabled`
+#### 8.25.1. `RPC.RateLimit.Enabled`
**Type:** : `boolean`
@@ -1983,7 +1996,7 @@ DisableAPIs=[]
Enabled=false
```
-#### 8.24.2. `RPC.RateLimit.RateLimitApis`
+#### 8.25.2. `RPC.RateLimit.RateLimitApis`
**Type:** : `array of string`
@@ -1997,7 +2010,7 @@ Enabled=false
RateLimitApis=[]
```
-#### 8.24.3. `RPC.RateLimit.RateLimitCount`
+#### 8.25.3. `RPC.RateLimit.RateLimitCount`
**Type:** : `integer`
@@ -2011,7 +2024,7 @@ RateLimitApis=[]
RateLimitCount=100
```
-#### 8.24.4. `RPC.RateLimit.RateLimitDuration`
+#### 8.25.4. `RPC.RateLimit.RateLimitDuration`
**Type:** : `integer`
@@ -2025,7 +2038,7 @@ RateLimitCount=100
RateLimitDuration=1
```
-#### 8.24.5. `RPC.RateLimit.SpecialApis`
+#### 8.25.5. `RPC.RateLimit.SpecialApis`
**Type:** : `array of object`
@@ -2051,7 +2064,7 @@ SpecialApis=[]
| ----------------------------------------------------- | ---------------------------------------------------------- |
| [SpecialApis items](#RPC_RateLimit_SpecialApis_items) | RateLimitItem defines the special rate limit for some apis |
-##### 8.24.5.1. [RPC.RateLimit.SpecialApis.SpecialApis items]
+##### 8.25.5.1. [RPC.RateLimit.SpecialApis.SpecialApis items]
**Type:** : `object`
**Description:** RateLimitItem defines the special rate limit for some apis
@@ -2062,22 +2075,22 @@ SpecialApis=[]
| - [Count](#RPC_RateLimit_SpecialApis_items_Count ) | No | integer | No | - | Count defines the maximum burst size of requests |
| - [Duration](#RPC_RateLimit_SpecialApis_items_Duration ) | No | integer | No | - | Duration defines the time window for the rate limit |
-##### 8.24.5.1.1. `RPC.RateLimit.SpecialApis.SpecialApis items.Api`
+##### 8.25.5.1.1. `RPC.RateLimit.SpecialApis.SpecialApis items.Api`
**Type:** : `string`
**Description:** Api defines the api that need to be rate limited
-##### 8.24.5.1.2. `RPC.RateLimit.SpecialApis.SpecialApis items.Count`
+##### 8.25.5.1.2. `RPC.RateLimit.SpecialApis.SpecialApis items.Count`
**Type:** : `integer`
**Description:** Count defines the maximum burst size of requests
-##### 8.24.5.1.3. `RPC.RateLimit.SpecialApis.SpecialApis items.Duration`
+##### 8.25.5.1.3. `RPC.RateLimit.SpecialApis.SpecialApis items.Duration`
**Type:** : `integer`
**Description:** Duration defines the time window for the rate limit
-### 8.25. `[RPC.DynamicGP]`
+### 8.26. `[RPC.DynamicGP]`
**Type:** : `object`
**Description:** DynamicGP defines the config of dynamic gas price
@@ -2093,7 +2106,7 @@ SpecialApis=[]
| - [MinPrice](#RPC_DynamicGP_MinPrice ) | No | integer | No | - | MinPrice defines the dynamic gas price lower limit |
| - [UpdatePeriod](#RPC_DynamicGP_UpdatePeriod ) | No | string | No | - | Duration |
-#### 8.25.1. `RPC.DynamicGP.Enabled`
+#### 8.26.1. `RPC.DynamicGP.Enabled`
**Type:** : `boolean`
@@ -2107,7 +2120,7 @@ SpecialApis=[]
Enabled=false
```
-#### 8.25.2. `RPC.DynamicGP.CongestionTxThreshold`
+#### 8.26.2. `RPC.DynamicGP.CongestionTxThreshold`
**Type:** : `integer`
@@ -2121,7 +2134,7 @@ Enabled=false
CongestionTxThreshold=100
```
-#### 8.25.3. `RPC.DynamicGP.CheckBatches`
+#### 8.26.3. `RPC.DynamicGP.CheckBatches`
**Type:** : `integer`
@@ -2135,7 +2148,7 @@ CongestionTxThreshold=100
CheckBatches=5
```
-#### 8.25.4. `RPC.DynamicGP.SampleNumber`
+#### 8.26.4. `RPC.DynamicGP.SampleNumber`
**Type:** : `integer`
@@ -2149,7 +2162,7 @@ CheckBatches=5
SampleNumber=3
```
-#### 8.25.5. `RPC.DynamicGP.Percentile`
+#### 8.26.5. `RPC.DynamicGP.Percentile`
**Type:** : `integer`
@@ -2163,7 +2176,7 @@ SampleNumber=3
Percentile=70
```
-#### 8.25.6. `RPC.DynamicGP.MaxPrice`
+#### 8.26.6. `RPC.DynamicGP.MaxPrice`
**Type:** : `integer`
@@ -2177,7 +2190,7 @@ Percentile=70
MaxPrice=20000000000
```
-#### 8.25.7. `RPC.DynamicGP.MinPrice`
+#### 8.26.7. `RPC.DynamicGP.MinPrice`
**Type:** : `integer`
@@ -2191,7 +2204,7 @@ MaxPrice=20000000000
MinPrice=2000000000
```
-#### 8.25.8. `RPC.DynamicGP.UpdatePeriod`
+#### 8.26.8. `RPC.DynamicGP.UpdatePeriod`
**Title:** Duration
@@ -2217,7 +2230,7 @@ MinPrice=2000000000
UpdatePeriod="10s"
```
-### 8.26. `RPC.EnableInnerTxCacheDB`
+### 8.27. `RPC.EnableInnerTxCacheDB`
**Type:** : `boolean`
@@ -2231,12 +2244,12 @@ UpdatePeriod="10s"
EnableInnerTxCacheDB=false
```
-### 8.27. `RPC.BridgeAddress`
+### 8.28. `RPC.BridgeAddress`
**Type:** : `array of integer`
**Description:** BridgeAddress is the address of the bridge contract
-### 8.28. `[RPC.ApiAuthentication]`
+### 8.29. `[RPC.ApiAuthentication]`
**Type:** : `object`
**Description:** ApiAuthentication defines the authentication configuration for the API
@@ -2246,7 +2259,7 @@ EnableInnerTxCacheDB=false
| - [Enabled](#RPC_ApiAuthentication_Enabled ) | No | boolean | No | - | Enabled defines if the api authentication is enabled |
| - [ApiKeys](#RPC_ApiAuthentication_ApiKeys ) | No | array of object | No | - | ApiKeys defines the api keys |
-#### 8.28.1. `RPC.ApiAuthentication.Enabled`
+#### 8.29.1. `RPC.ApiAuthentication.Enabled`
**Type:** : `boolean`
@@ -2260,7 +2273,7 @@ EnableInnerTxCacheDB=false
Enabled=false
```
-#### 8.28.2. `RPC.ApiAuthentication.ApiKeys`
+#### 8.29.2. `RPC.ApiAuthentication.ApiKeys`
**Type:** : `array of object`
@@ -2286,7 +2299,7 @@ ApiKeys=[]
| ----------------------------------------------------- | --------------------------- |
| [ApiKeys items](#RPC_ApiAuthentication_ApiKeys_items) | KeyItem is the api key item |
-##### 8.28.2.1. [RPC.ApiAuthentication.ApiKeys.ApiKeys items]
+##### 8.29.2.1. [RPC.ApiAuthentication.ApiKeys.ApiKeys items]
**Type:** : `object`
**Description:** KeyItem is the api key item
@@ -2297,22 +2310,22 @@ ApiKeys=[]
| - [Key](#RPC_ApiAuthentication_ApiKeys_items_Key ) | No | string | No | - | Key defines the key |
| - [Timeout](#RPC_ApiAuthentication_ApiKeys_items_Timeout ) | No | string | No | - | Timeout defines the timeout |
-##### 8.28.2.1.1. `RPC.ApiAuthentication.ApiKeys.ApiKeys items.Project`
+##### 8.29.2.1.1. `RPC.ApiAuthentication.ApiKeys.ApiKeys items.Project`
**Type:** : `string`
**Description:** Name defines the name of the key
-##### 8.28.2.1.2. `RPC.ApiAuthentication.ApiKeys.ApiKeys items.Key`
+##### 8.29.2.1.2. `RPC.ApiAuthentication.ApiKeys.ApiKeys items.Key`
**Type:** : `string`
**Description:** Key defines the key
-##### 8.28.2.1.3. `RPC.ApiAuthentication.ApiKeys.ApiKeys items.Timeout`
+##### 8.29.2.1.3. `RPC.ApiAuthentication.ApiKeys.ApiKeys items.Timeout`
**Type:** : `string`
**Description:** Timeout defines the timeout
-### 8.29. `[RPC.ApiRelay]`
+### 8.30. `[RPC.ApiRelay]`
**Type:** : `object`
**Description:** ApiRelay defines the relay configuration for the API
@@ -2323,7 +2336,7 @@ ApiKeys=[]
| - [DestURI](#RPC_ApiRelay_DestURI ) | No | string | No | - | - |
| - [RPCs](#RPC_ApiRelay_RPCs ) | No | array of string | No | - | - |
-#### 8.29.1. `RPC.ApiRelay.Enabled`
+#### 8.30.1. `RPC.ApiRelay.Enabled`
**Type:** : `boolean`
@@ -2335,7 +2348,7 @@ ApiKeys=[]
Enabled=false
```
-#### 8.29.2. `RPC.ApiRelay.DestURI`
+#### 8.30.2. `RPC.ApiRelay.DestURI`
**Type:** : `string`
@@ -2347,7 +2360,7 @@ Enabled=false
DestURI=""
```
-#### 8.29.3. `RPC.ApiRelay.RPCs`
+#### 8.30.3. `RPC.ApiRelay.RPCs`
**Type:** : `array of string`
diff --git a/docs/config-file/node-config-schema.json b/docs/config-file/node-config-schema.json
index bc98359466..1029b0ed18 100644
--- a/docs/config-file/node-config-schema.json
+++ b/docs/config-file/node-config-schema.json
@@ -731,6 +731,10 @@
"type": "boolean",
"default": false
},
+ "EnableEstimateGasUltraOpt": {
+ "type": "boolean",
+ "default": false
+ },
"DisableAPIs": {
"items": {
"type": "string"
diff --git a/jsonrpc/apollo_xlayer.go b/jsonrpc/apollo_xlayer.go
index 156625f98e..b98590c6d4 100644
--- a/jsonrpc/apollo_xlayer.go
+++ b/jsonrpc/apollo_xlayer.go
@@ -8,16 +8,17 @@ import (
// ApolloConfig is the apollo RPC dynamic config
type ApolloConfig struct {
- EnableApollo bool
- BatchRequestsEnabled bool
- BatchRequestsLimit uint
- GasLimitFactor float64
- EnableEstimateGasOpt bool
- DisableAPIs []string
- RateLimit RateLimitConfig
- DynamicGP DynamicGPConfig
- ApiAuthentication ApiAuthConfig
- ApiRelay ApiRelayConfig
+ EnableApollo bool
+ BatchRequestsEnabled bool
+ BatchRequestsLimit uint
+ GasLimitFactor float64
+ EnableEstimateGasOpt bool
+ EnableEstimateGasUltraOpt bool
+ DisableAPIs []string
+ RateLimit RateLimitConfig
+ DynamicGP DynamicGPConfig
+ ApiAuthentication ApiAuthConfig
+ ApiRelay ApiRelayConfig
sync.RWMutex
}
@@ -65,6 +66,7 @@ func UpdateConfig(apolloConfig Config) {
getApolloConfig().BatchRequestsLimit = apolloConfig.BatchRequestsLimit
getApolloConfig().GasLimitFactor = apolloConfig.GasLimitFactor
getApolloConfig().EnableEstimateGasOpt = apolloConfig.EnableEstimateGasOpt
+ getApolloConfig().EnableEstimateGasUltraOpt = apolloConfig.EnableEstimateGasUltraOpt
getApolloConfig().setDisableAPIs(apolloConfig.DisableAPIs)
setRateLimit(apolloConfig.RateLimit)
setApiAuth(apolloConfig.ApiAuthentication)
diff --git a/jsonrpc/config.go b/jsonrpc/config.go
index 53ec1e6053..3d681f2779 100644
--- a/jsonrpc/config.go
+++ b/jsonrpc/config.go
@@ -87,8 +87,9 @@ type Config struct {
// suggested gas limit: 100
// GasLimitFactor: 1.1
// gas limit = 110
- GasLimitFactor float64 `mapstructure:"GasLimitFactor"`
- EnableEstimateGasOpt bool `mapstructure:"EnableEstimateGasOpt"`
+ GasLimitFactor float64 `mapstructure:"GasLimitFactor"`
+ EnableEstimateGasOpt bool `mapstructure:"EnableEstimateGasOpt"`
+ EnableEstimateGasUltraOpt bool `mapstructure:"EnableEstimateGasUltraOpt"`
// DisableAPIs disable some API
DisableAPIs []string `mapstructure:"DisableAPIs"`
diff --git a/jsonrpc/endpoints_eth.go b/jsonrpc/endpoints_eth.go
index fa3f359ef5..c4c8e0e317 100644
--- a/jsonrpc/endpoints_eth.go
+++ b/jsonrpc/endpoints_eth.go
@@ -210,7 +210,7 @@ func (e *EthEndpoints) EstimateGas(arg *types.TxArgs, blockArg *types.BlockNumbe
var gasEstimation uint64
var returnValue []byte
if e.enableEstimateGasOpt() {
- gasEstimation, returnValue, err = e.state.EstimateGasOpt(tx, sender, isGasFreeSender, blockToProcess, dbTx)
+ gasEstimation, returnValue, err = e.state.EstimateGasOpt(tx, sender, isGasFreeSender, blockToProcess, dbTx, e.enableEstimateGasUltraOpt())
} else {
gasEstimation, returnValue, err = e.state.EstimateGas(tx, sender, isGasFreeSender, blockToProcess, dbTx)
}
diff --git a/jsonrpc/endpoints_eth_xlayer.go b/jsonrpc/endpoints_eth_xlayer.go
index 36ca8be500..2ea16b8d59 100644
--- a/jsonrpc/endpoints_eth_xlayer.go
+++ b/jsonrpc/endpoints_eth_xlayer.go
@@ -297,6 +297,19 @@ func (e *EthEndpoints) enableEstimateGasOpt() bool {
return res
}
+func (e *EthEndpoints) enableEstimateGasUltraOpt() bool {
+ res := false
+ if getApolloConfig().Enable() {
+ getApolloConfig().RLock()
+ res = getApolloConfig().EnableEstimateGasUltraOpt
+ getApolloConfig().RUnlock()
+ } else {
+ res = e.cfg.EnableEstimateGasUltraOpt
+ }
+
+ return res
+}
+
// internal
func (e *EthEndpoints) newPendingTransactionFilterXLayer(wsConn *concurrentWsConn) (interface{}, types.Error) {
//XLayer handle
diff --git a/jsonrpc/mocks/mock_state.go b/jsonrpc/mocks/mock_state.go
index 5c93ab7272..3fa357d1dc 100644
--- a/jsonrpc/mocks/mock_state.go
+++ b/jsonrpc/mocks/mock_state.go
@@ -152,7 +152,7 @@ func (_m *StateMock) EstimateGas(transaction *coretypes.Transaction, senderAddre
}
// EstimateGasOpt provides a mock function with given fields: transaction, senderAddress, l2BlockNumber, dbTx
-func (_m *StateMock) EstimateGasOpt(transaction *coretypes.Transaction, senderAddress common.Address, isGasFreeSender bool, l2BlockNumber *uint64, dbTx pgx.Tx) (uint64, []byte, error) {
+func (_m *StateMock) EstimateGasOpt(transaction *coretypes.Transaction, senderAddress common.Address, isGasFreeSender bool, l2BlockNumber *uint64, dbTx pgx.Tx, ultraOpt bool) (uint64, []byte, error) {
return _m.EstimateGas(transaction, senderAddress, isGasFreeSender, l2BlockNumber, dbTx)
}
diff --git a/jsonrpc/types/interfaces.go b/jsonrpc/types/interfaces.go
index f733df5eb2..6478828a7d 100644
--- a/jsonrpc/types/interfaces.go
+++ b/jsonrpc/types/interfaces.go
@@ -39,7 +39,7 @@ type StateInterface interface {
BeginStateTransaction(ctx context.Context) (pgx.Tx, error)
DebugTransaction(ctx context.Context, transactionHash common.Hash, traceConfig state.TraceConfig, dbTx pgx.Tx) (*runtime.ExecutionResult, error)
EstimateGas(transaction *types.Transaction, senderAddress common.Address, isGasFreeSender bool, l2BlockNumber *uint64, dbTx pgx.Tx) (uint64, []byte, error)
- EstimateGasOpt(transaction *types.Transaction, senderAddress common.Address, isGasFreeSender bool, l2BlockNumber *uint64, dbTx pgx.Tx) (uint64, []byte, error)
+ EstimateGasOpt(transaction *types.Transaction, senderAddress common.Address, isGasFreeSender bool, l2BlockNumber *uint64, dbTx pgx.Tx, ultraOpt bool) (uint64, []byte, error)
GetBalance(ctx context.Context, address common.Address, root common.Hash) (*big.Int, error)
GetCode(ctx context.Context, address common.Address, root common.Hash) ([]byte, error)
GetL2BlockByHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*state.L2Block, error)
diff --git a/state/transaction_xlayer.go b/state/transaction_xlayer.go
index 7cc3186eef..589f16d252 100644
--- a/state/transaction_xlayer.go
+++ b/state/transaction_xlayer.go
@@ -15,7 +15,7 @@ import (
)
// EstimateGasOpt for a transaction
-func (s *State) EstimateGasOpt(transaction *types.Transaction, senderAddress common.Address, isGasFreeSender bool, l2BlockNumber *uint64, dbTx pgx.Tx) (uint64, []byte, error) {
+func (s *State) EstimateGasOpt(transaction *types.Transaction, senderAddress common.Address, isGasFreeSender bool, l2BlockNumber *uint64, dbTx pgx.Tx, ultraOpt bool) (uint64, []byte, error) {
const ethTransferGas = 21000
ctx := context.Background()
@@ -106,6 +106,12 @@ func (s *State) EstimateGasOpt(transaction *types.Transaction, senderAddress com
return 0, nil, err
}
+ // xLayer opt
+ if ultraOpt {
+ log.Infof("state-EstimateGas value. UltraOpt:%v, gas:%d", ultraOpt, lowEnd)
+ return lowEnd, nil, nil
+ }
+
// if the intrinsic gas is the same as the constant value for eth transfer
// and the transaction has a receiver address
if lowEnd == ethTransferGas && transaction.To() != nil {
@@ -161,6 +167,7 @@ func (s *State) EstimateGasOpt(transaction *types.Transaction, senderAddress com
log.Infof("state-EstimateGas time. getBlock:%vms, getBatch:%vms, getForkID:%vms, getNonce:%vms, getEnd:%vms, internalGas:%vms",
getBlockTime.Milliseconds(), getBatchTime.Milliseconds(), getForkIDTime.Milliseconds(), getNonceTime.Milliseconds(), getEndTime.Milliseconds(), internalGasTime.Milliseconds())
+ log.Infof("state-EstimateGas value. UltraOpt:%v, IntrinsicGas:%d, finalGas:%d", ultraOpt, lowEnd, estimationResult.gasUsed)
return estimationResult.gasUsed, nil, nil
}