forked from cerc-io/laconicd-deprecated
rpc: eth_feeHistory (#734)
* Problem: missing json rpc of eth_feeHistory #685 add oracle backend space ready structure ok refactoring return feehistory data flow ok basefee set gas used ratio computing reward add testing add gas used prepare data fill reward increase coin fixing api add mac add launch gas used ratio ok print element reward workes reward working fix panic value correct remove debugging log tidy up tidy up remove oracle tidy up fix handler crash add unit test tidy up add limit check reformat fix lint fix lint fix lint fix lint Update rpc/ethereum/backend/feebackend.go thanks Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Update rpc/ethereum/backend/feebackend.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Update rpc/ethereum/backend/feebackend.go thanks Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Update rpc/ethereum/backend/feebackend.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> fix compile error split lines remove temporary string conversion return error if gaslimit is 0 move OneFeeHistory to types add comment only err check Update rpc/ethereum/backend/feebackend.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Update rpc/ethereum/backend/feebackend.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> tidy up add feehistory-cap * Apply suggestions from code review * changelog Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Federico Kunze Küllmer <federico.kunze94@gmail.com>
This commit is contained in:
co-authored by
Federico Kunze Küllmer
Federico Kunze Küllmer
parent
b7e8dd8216
commit
392d1dd8cf
+26
-16
@@ -32,6 +32,8 @@ const (
|
||||
|
||||
DefaultFilterCap int32 = 200
|
||||
|
||||
DefaultFeeHistoryCap int32 = 100
|
||||
|
||||
DefaultEVMTimeout = 5 * time.Second
|
||||
// default 1.0 eth
|
||||
DefaultTxFeeCap float64 = 1.0
|
||||
@@ -72,6 +74,8 @@ type JSONRPCConfig struct {
|
||||
TxFeeCap float64 `mapstructure:"txfee-cap"`
|
||||
// FilterCap is the global cap for total number of filters that can be created.
|
||||
FilterCap int32 `mapstructure:"filter-cap"`
|
||||
// FeeHistoryCap is the global cap for total number of blocks that can be fetched
|
||||
FeeHistoryCap int32 `mapstructure:"feehistory-cap"`
|
||||
// Enable defines if the EVM RPC server should be enabled.
|
||||
Enable bool `mapstructure:"enable"`
|
||||
}
|
||||
@@ -153,14 +157,15 @@ func GetDefaultAPINamespaces() []string {
|
||||
// DefaultJSONRPCConfig returns an EVM config with the JSON-RPC API enabled by default
|
||||
func DefaultJSONRPCConfig() *JSONRPCConfig {
|
||||
return &JSONRPCConfig{
|
||||
Enable: true,
|
||||
API: GetDefaultAPINamespaces(),
|
||||
Address: DefaultJSONRPCAddress,
|
||||
WsAddress: DefaultJSONRPCWsAddress,
|
||||
GasCap: DefaultGasCap,
|
||||
EVMTimeout: DefaultEVMTimeout,
|
||||
TxFeeCap: DefaultTxFeeCap,
|
||||
FilterCap: DefaultFilterCap,
|
||||
Enable: true,
|
||||
API: GetDefaultAPINamespaces(),
|
||||
Address: DefaultJSONRPCAddress,
|
||||
WsAddress: DefaultJSONRPCWsAddress,
|
||||
GasCap: DefaultGasCap,
|
||||
EVMTimeout: DefaultEVMTimeout,
|
||||
TxFeeCap: DefaultTxFeeCap,
|
||||
FilterCap: DefaultFilterCap,
|
||||
FeeHistoryCap: DefaultFeeHistoryCap,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +179,10 @@ func (c JSONRPCConfig) Validate() error {
|
||||
return errors.New("JSON-RPC filter-cap cannot be negative")
|
||||
}
|
||||
|
||||
if c.FeeHistoryCap <= 0 {
|
||||
return errors.New("JSON-RPC feehistory-cap cannot be negative or 0")
|
||||
}
|
||||
|
||||
if c.TxFeeCap < 0 {
|
||||
return errors.New("JSON-RPC tx fee cap cannot be negative")
|
||||
}
|
||||
@@ -230,14 +239,15 @@ func GetConfig(v *viper.Viper) Config {
|
||||
Tracer: v.GetString("evm.tracer"),
|
||||
},
|
||||
JSONRPC: JSONRPCConfig{
|
||||
Enable: v.GetBool("json-rpc.enable"),
|
||||
API: v.GetStringSlice("json-rpc.api"),
|
||||
Address: v.GetString("json-rpc.address"),
|
||||
WsAddress: v.GetString("json-rpc.ws-address"),
|
||||
GasCap: v.GetUint64("json-rpc.gas-cap"),
|
||||
FilterCap: v.GetInt32("json-rpc.filter-cap"),
|
||||
TxFeeCap: v.GetFloat64("json-rpc.txfee-cap"),
|
||||
EVMTimeout: v.GetDuration("json-rpc.evm-timeout"),
|
||||
Enable: v.GetBool("json-rpc.enable"),
|
||||
API: v.GetStringSlice("json-rpc.api"),
|
||||
Address: v.GetString("json-rpc.address"),
|
||||
WsAddress: v.GetString("json-rpc.ws-address"),
|
||||
GasCap: v.GetUint64("json-rpc.gas-cap"),
|
||||
FilterCap: v.GetInt32("json-rpc.filter-cap"),
|
||||
FeeHistoryCap: v.GetInt32("json-rpc.feehistory-cap"),
|
||||
TxFeeCap: v.GetFloat64("json-rpc.txfee-cap"),
|
||||
EVMTimeout: v.GetDuration("json-rpc.evm-timeout"),
|
||||
},
|
||||
TLS: TLSConfig{
|
||||
CertificatePath: v.GetString("tls.certificate-path"),
|
||||
|
||||
@@ -44,6 +44,10 @@ txfee-cap = {{ .JSONRPC.TxFeeCap }}
|
||||
# FilterCap sets the global cap for total number of filters that can be created
|
||||
filter-cap = {{ .JSONRPC.FilterCap }}
|
||||
|
||||
# FeeHistoryCap sets the global cap for total number of blocks that can be fetched
|
||||
feehistory-cap = {{ .JSONRPC.FeeHistoryCap }}
|
||||
|
||||
|
||||
###############################################################################
|
||||
### TLS Configuration ###
|
||||
###############################################################################
|
||||
|
||||
@@ -26,14 +26,15 @@ const (
|
||||
|
||||
// JSON-RPC flags
|
||||
const (
|
||||
JSONRPCEnable = "json-rpc.enable"
|
||||
JSONRPCAPI = "json-rpc.api"
|
||||
JSONRPCAddress = "json-rpc.address"
|
||||
JSONWsAddress = "json-rpc.ws-address"
|
||||
JSONRPCGasCap = "json-rpc.gas-cap"
|
||||
JSONRPCEVMTimeout = "json-rpc.evm-timeout"
|
||||
JSONRPCTxFeeCap = "json-rpc.txfee-cap"
|
||||
JSONRPCFilterCap = "json-rpc.filter-cap"
|
||||
JSONRPCEnable = "json-rpc.enable"
|
||||
JSONRPCAPI = "json-rpc.api"
|
||||
JSONRPCAddress = "json-rpc.address"
|
||||
JSONWsAddress = "json-rpc.ws-address"
|
||||
JSONRPCGasCap = "json-rpc.gas-cap"
|
||||
JSONRPCEVMTimeout = "json-rpc.evm-timeout"
|
||||
JSONRPCTxFeeCap = "json-rpc.txfee-cap"
|
||||
JSONRPCFilterCap = "json-rpc.filter-cap"
|
||||
JSONRPFeeHistoryCap = "json-rpc.feehistory-cap"
|
||||
)
|
||||
|
||||
// EVM flags
|
||||
|
||||
Reference in New Issue
Block a user