Set default path for eth event db, set it to enabled by default if EnableEthRPC is set
This commit is contained in:
parent
2335bed58a
commit
6601d9031d
@ -293,58 +293,62 @@
|
|||||||
#Tracing = false
|
#Tracing = false
|
||||||
|
|
||||||
|
|
||||||
[ActorEvent]
|
[Events]
|
||||||
# EnableRealTimeFilterAPI enables APIs that can create and query filters for actor events as they are emitted.
|
# EnableEthRPC enables APIs that
|
||||||
|
# DisableRealTimeFilterAPI will disable the RealTimeFilterAPI that can create and query filters for actor events as they are emitted.
|
||||||
|
# The API is enabled when EnableEthRPC is true, but can be disabled selectively with this flag.
|
||||||
#
|
#
|
||||||
# type: bool
|
# type: bool
|
||||||
# env var: LOTUS_ACTOREVENT_ENABLEREALTIMEFILTERAPI
|
# env var: LOTUS_EVENTS_DISABLEREALTIMEFILTERAPI
|
||||||
#EnableRealTimeFilterAPI = false
|
#DisableRealTimeFilterAPI = false
|
||||||
|
|
||||||
# EnableHistoricFilterAPI enables APIs that can create and query filters for actor events that occurred in the past.
|
# DisableHistoricFilterAPI will disable the HistoricFilterAPI that can create and query filters for actor events
|
||||||
# A queryable index of events will be maintained.
|
# that occurred in the past. HistoricFilterAPI maintains a queryable index of events.
|
||||||
|
# The API is enabled when EnableEthRPC is true, but can be disabled selectively with this flag.
|
||||||
#
|
#
|
||||||
# type: bool
|
# type: bool
|
||||||
# env var: LOTUS_ACTOREVENT_ENABLEHISTORICFILTERAPI
|
# env var: LOTUS_EVENTS_DISABLEHISTORICFILTERAPI
|
||||||
#EnableHistoricFilterAPI = false
|
#DisableHistoricFilterAPI = false
|
||||||
|
|
||||||
# FilterTTL specifies the time to live for actor event filters. Filters that haven't been accessed longer than
|
# FilterTTL specifies the time to live for actor event filters. Filters that haven't been accessed longer than
|
||||||
# this time become eligible for automatic deletion.
|
# this time become eligible for automatic deletion.
|
||||||
#
|
#
|
||||||
# type: Duration
|
# type: Duration
|
||||||
# env var: LOTUS_ACTOREVENT_FILTERTTL
|
# env var: LOTUS_EVENTS_FILTERTTL
|
||||||
#FilterTTL = "24h0m0s"
|
#FilterTTL = "0s"
|
||||||
|
|
||||||
# MaxFilters specifies the maximum number of filters that may exist at any one time.
|
# MaxFilters specifies the maximum number of filters that may exist at any one time.
|
||||||
#
|
#
|
||||||
# type: int
|
# type: int
|
||||||
# env var: LOTUS_ACTOREVENT_MAXFILTERS
|
# env var: LOTUS_EVENTS_MAXFILTERS
|
||||||
#MaxFilters = 100
|
#MaxFilters = 0
|
||||||
|
|
||||||
# MaxFilterResults specifies the maximum number of results that can be accumulated by an actor event filter.
|
# MaxFilterResults specifies the maximum number of results that can be accumulated by an actor event filter.
|
||||||
#
|
#
|
||||||
# type: int
|
# type: int
|
||||||
# env var: LOTUS_ACTOREVENT_MAXFILTERRESULTS
|
# env var: LOTUS_EVENTS_MAXFILTERRESULTS
|
||||||
#MaxFilterResults = 10000
|
#MaxFilterResults = 0
|
||||||
|
|
||||||
# MaxFilterHeightRange specifies the maximum range of heights that can be used in a filter (to avoid querying
|
# MaxFilterHeightRange specifies the maximum range of heights that can be used in a filter (to avoid querying
|
||||||
# the entire chain)
|
# the entire chain)
|
||||||
#
|
#
|
||||||
# type: uint64
|
# type: uint64
|
||||||
# env var: LOTUS_ACTOREVENT_MAXFILTERHEIGHTRANGE
|
# env var: LOTUS_EVENTS_MAXFILTERHEIGHTRANGE
|
||||||
#MaxFilterHeightRange = 2880
|
#MaxFilterHeightRange = 0
|
||||||
|
|
||||||
# ActorEventDatabasePath is the full path to a sqlite database that will be used to index actor events to
|
# DatabasePath is the full path to a sqlite database that will be used to index actor events to
|
||||||
# support the historic filter APIs. If the database does not exist it will be created. The directory containing
|
# support the historic filter APIs. If the database does not exist it will be created. The directory containing
|
||||||
# the database must already exist and be writeable. If a relative path is provided here, sqlite treats it as
|
# the database must already exist and be writeable. If a relative path is provided here, sqlite treats it as
|
||||||
# relative to the CWD (current working directory).
|
# relative to the CWD (current working directory).
|
||||||
#
|
#
|
||||||
# type: string
|
# type: string
|
||||||
# env var: LOTUS_ACTOREVENT_ACTOREVENTDATABASEPATH
|
# env var: LOTUS_EVENTS_DATABASEPATH
|
||||||
#ActorEventDatabasePath = ""
|
#DatabasePath = ""
|
||||||
|
|
||||||
|
|
||||||
[Fevm]
|
[Fevm]
|
||||||
# EnableEthRPC enables eth_ rpc, and enables storing a mapping of eth transaction hashes to filecoin message Cids.
|
# EnableEthRPC enables eth_ rpc, and enables storing a mapping of eth transaction hashes to filecoin message Cids.
|
||||||
|
# This will also enable the RealTimeFilterAPI and HistoricFilterAPI by default, but they can be disabled by config options above.
|
||||||
#
|
#
|
||||||
# type: bool
|
# type: bool
|
||||||
# env var: LOTUS_FEVM_ENABLEETHRPC
|
# env var: LOTUS_FEVM_ENABLEETHRPC
|
||||||
@ -357,4 +361,56 @@
|
|||||||
# env var: LOTUS_FEVM_ETHTXHASHMAPPINGLIFETIMEDAYS
|
# env var: LOTUS_FEVM_ETHTXHASHMAPPINGLIFETIMEDAYS
|
||||||
#EthTxHashMappingLifetimeDays = 0
|
#EthTxHashMappingLifetimeDays = 0
|
||||||
|
|
||||||
|
[Fevm.Events]
|
||||||
|
# EnableEthRPC enables APIs that
|
||||||
|
# DisableRealTimeFilterAPI will disable the RealTimeFilterAPI that can create and query filters for actor events as they are emitted.
|
||||||
|
# The API is enabled when EnableEthRPC is true, but can be disabled selectively with this flag.
|
||||||
|
#
|
||||||
|
# type: bool
|
||||||
|
# env var: LOTUS_FEVM_EVENTS_DISABLEREALTIMEFILTERAPI
|
||||||
|
#DisableRealTimeFilterAPI = false
|
||||||
|
|
||||||
|
# DisableHistoricFilterAPI will disable the HistoricFilterAPI that can create and query filters for actor events
|
||||||
|
# that occurred in the past. HistoricFilterAPI maintains a queryable index of events.
|
||||||
|
# The API is enabled when EnableEthRPC is true, but can be disabled selectively with this flag.
|
||||||
|
#
|
||||||
|
# type: bool
|
||||||
|
# env var: LOTUS_FEVM_EVENTS_DISABLEHISTORICFILTERAPI
|
||||||
|
#DisableHistoricFilterAPI = false
|
||||||
|
|
||||||
|
# FilterTTL specifies the time to live for actor event filters. Filters that haven't been accessed longer than
|
||||||
|
# this time become eligible for automatic deletion.
|
||||||
|
#
|
||||||
|
# type: Duration
|
||||||
|
# env var: LOTUS_FEVM_EVENTS_FILTERTTL
|
||||||
|
#FilterTTL = "24h0m0s"
|
||||||
|
|
||||||
|
# MaxFilters specifies the maximum number of filters that may exist at any one time.
|
||||||
|
#
|
||||||
|
# type: int
|
||||||
|
# env var: LOTUS_FEVM_EVENTS_MAXFILTERS
|
||||||
|
#MaxFilters = 100
|
||||||
|
|
||||||
|
# MaxFilterResults specifies the maximum number of results that can be accumulated by an actor event filter.
|
||||||
|
#
|
||||||
|
# type: int
|
||||||
|
# env var: LOTUS_FEVM_EVENTS_MAXFILTERRESULTS
|
||||||
|
#MaxFilterResults = 10000
|
||||||
|
|
||||||
|
# MaxFilterHeightRange specifies the maximum range of heights that can be used in a filter (to avoid querying
|
||||||
|
# the entire chain)
|
||||||
|
#
|
||||||
|
# type: uint64
|
||||||
|
# env var: LOTUS_FEVM_EVENTS_MAXFILTERHEIGHTRANGE
|
||||||
|
#MaxFilterHeightRange = 2880
|
||||||
|
|
||||||
|
# DatabasePath is the full path to a sqlite database that will be used to index actor events to
|
||||||
|
# support the historic filter APIs. If the database does not exist it will be created. The directory containing
|
||||||
|
# the database must already exist and be writeable. If a relative path is provided here, sqlite treats it as
|
||||||
|
# relative to the CWD (current working directory).
|
||||||
|
#
|
||||||
|
# type: string
|
||||||
|
# env var: LOTUS_FEVM_EVENTS_DATABASEPATH
|
||||||
|
#DatabasePath = ""
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
||||||
"github.com/filecoin-project/lotus/itests/kit"
|
"github.com/filecoin-project/lotus/itests/kit"
|
||||||
"github.com/filecoin-project/lotus/node/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestDeployment smoke tests the deployment of a contract via the
|
// TestDeployment smoke tests the deployment of a contract via the
|
||||||
@ -36,11 +35,7 @@ func TestDeployment(t *testing.T) {
|
|||||||
client, _, ens := kit.EnsembleMinimal(
|
client, _, ens := kit.EnsembleMinimal(
|
||||||
t,
|
t,
|
||||||
kit.MockProofs(),
|
kit.MockProofs(),
|
||||||
kit.ThroughRPC(),
|
kit.ThroughRPC())
|
||||||
kit.WithCfgOpt(func(cfg *config.FullNode) error {
|
|
||||||
cfg.ActorEvent.EnableRealTimeFilterAPI = true
|
|
||||||
return nil
|
|
||||||
}))
|
|
||||||
ens.InterconnectAll().BeginMining(blockTime)
|
ens.InterconnectAll().BeginMining(blockTime)
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -30,7 +29,7 @@ func TestEthNewPendingTransactionFilter(t *testing.T) {
|
|||||||
|
|
||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC(), kit.RealTimeFilterAPI())
|
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC(), kit.WithEthRPC())
|
||||||
ens.InterconnectAll().BeginMining(10 * time.Millisecond)
|
ens.InterconnectAll().BeginMining(10 * time.Millisecond)
|
||||||
|
|
||||||
// create a new address where to send funds.
|
// create a new address where to send funds.
|
||||||
@ -124,7 +123,7 @@ func TestEthNewBlockFilter(t *testing.T) {
|
|||||||
|
|
||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC(), kit.RealTimeFilterAPI())
|
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC(), kit.WithEthRPC())
|
||||||
ens.InterconnectAll().BeginMining(10 * time.Millisecond)
|
ens.InterconnectAll().BeginMining(10 * time.Millisecond)
|
||||||
|
|
||||||
// create a new address where to send funds.
|
// create a new address where to send funds.
|
||||||
@ -204,7 +203,7 @@ func TestEthNewFilterCatchAll(t *testing.T) {
|
|||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
blockTime := 100 * time.Millisecond
|
blockTime := 100 * time.Millisecond
|
||||||
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC(), kit.RealTimeFilterAPI())
|
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC(), kit.WithEthRPC())
|
||||||
ens.InterconnectAll().BeginMining(blockTime)
|
ens.InterconnectAll().BeginMining(blockTime)
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||||
@ -569,9 +568,8 @@ func TestEthGetLogsAll(t *testing.T) {
|
|||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
blockTime := 100 * time.Millisecond
|
blockTime := 100 * time.Millisecond
|
||||||
dbpath := filepath.Join(t.TempDir(), "actorevents.db")
|
|
||||||
|
|
||||||
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC(), kit.HistoricFilterAPI(dbpath))
|
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC(), kit.WithEthRPC())
|
||||||
ens.InterconnectAll().BeginMining(blockTime)
|
ens.InterconnectAll().BeginMining(blockTime)
|
||||||
|
|
||||||
ethContractAddr, received := invokeContractAndWaitUntilAllOnChain(t, client, 10)
|
ethContractAddr, received := invokeContractAndWaitUntilAllOnChain(t, client, 10)
|
||||||
@ -632,9 +630,8 @@ func TestEthGetLogsByTopic(t *testing.T) {
|
|||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
blockTime := 100 * time.Millisecond
|
blockTime := 100 * time.Millisecond
|
||||||
dbpath := filepath.Join(t.TempDir(), "actorevents.db")
|
|
||||||
|
|
||||||
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC(), kit.HistoricFilterAPI(dbpath))
|
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC(), kit.WithEthRPC())
|
||||||
ens.InterconnectAll().BeginMining(blockTime)
|
ens.InterconnectAll().BeginMining(blockTime)
|
||||||
|
|
||||||
invocations := 1
|
invocations := 1
|
||||||
@ -696,7 +693,7 @@ func TestEthSubscribeLogs(t *testing.T) {
|
|||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
blockTime := 100 * time.Millisecond
|
blockTime := 100 * time.Millisecond
|
||||||
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC(), kit.RealTimeFilterAPI())
|
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC(), kit.WithEthRPC())
|
||||||
ens.InterconnectAll().BeginMining(blockTime)
|
ens.InterconnectAll().BeginMining(blockTime)
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||||
|
@ -290,18 +290,9 @@ func SplitstoreMessges() NodeOpt {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func RealTimeFilterAPI() NodeOpt {
|
func WithEthRPC() NodeOpt {
|
||||||
return WithCfgOpt(func(cfg *config.FullNode) error {
|
return WithCfgOpt(func(cfg *config.FullNode) error {
|
||||||
cfg.ActorEvent.EnableRealTimeFilterAPI = true
|
cfg.Fevm.EnableEthRPC = true
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func HistoricFilterAPI(dbpath string) NodeOpt {
|
|
||||||
return WithCfgOpt(func(cfg *config.FullNode) error {
|
|
||||||
cfg.ActorEvent.EnableRealTimeFilterAPI = true
|
|
||||||
cfg.ActorEvent.EnableHistoricFilterAPI = true
|
|
||||||
cfg.ActorEvent.ActorEventDatabasePath = dbpath
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ func ConfigFullNode(c interface{}) Option {
|
|||||||
// Actor event filtering support
|
// Actor event filtering support
|
||||||
Override(new(events.EventAPI), From(new(modules.EventAPI))),
|
Override(new(events.EventAPI), From(new(modules.EventAPI))),
|
||||||
// in lite-mode Eth event api is provided by gateway
|
// in lite-mode Eth event api is provided by gateway
|
||||||
ApplyIf(isFullNode, Override(new(full.EthEventAPI), modules.EthEventAPI(cfg.ActorEvent))),
|
ApplyIf(isFullNode, Override(new(full.EthEventAPI), modules.EthEventAPI(cfg.Fevm))),
|
||||||
|
|
||||||
If(cfg.Fevm.EnableEthRPC, Override(new(full.EthModuleAPI), modules.EthModuleAPI(cfg.Fevm))),
|
If(cfg.Fevm.EnableEthRPC, Override(new(full.EthModuleAPI), modules.EthModuleAPI(cfg.Fevm))),
|
||||||
If(!cfg.Fevm.EnableEthRPC, Override(new(full.EthModuleAPI), &full.EthModuleDummy{})),
|
If(!cfg.Fevm.EnableEthRPC, Override(new(full.EthModuleAPI), &full.EthModuleDummy{})),
|
||||||
|
@ -99,17 +99,17 @@ func DefaultFullNode() *FullNode {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Cluster: *DefaultUserRaftConfig(),
|
Cluster: *DefaultUserRaftConfig(),
|
||||||
ActorEvent: ActorEventConfig{
|
|
||||||
EnableRealTimeFilterAPI: false,
|
|
||||||
EnableHistoricFilterAPI: false,
|
|
||||||
FilterTTL: Duration(time.Hour * 24),
|
|
||||||
MaxFilters: 100,
|
|
||||||
MaxFilterResults: 10000,
|
|
||||||
MaxFilterHeightRange: 2880, // conservative limit of one day
|
|
||||||
},
|
|
||||||
Fevm: FevmConfig{
|
Fevm: FevmConfig{
|
||||||
EnableEthRPC: false,
|
EnableEthRPC: false,
|
||||||
EthTxHashMappingLifetimeDays: 0,
|
EthTxHashMappingLifetimeDays: 0,
|
||||||
|
Events: EventsConfig{
|
||||||
|
DisableRealTimeFilterAPI: false,
|
||||||
|
DisableHistoricFilterAPI: false,
|
||||||
|
FilterTTL: Duration(time.Hour * 24),
|
||||||
|
MaxFilters: 100,
|
||||||
|
MaxFilterResults: 10000,
|
||||||
|
MaxFilterHeightRange: 2880, // conservative limit of one day
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,56 +29,6 @@ var Doc = map[string][]DocField{
|
|||||||
Comment: ``,
|
Comment: ``,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"ActorEventConfig": []DocField{
|
|
||||||
{
|
|
||||||
Name: "EnableRealTimeFilterAPI",
|
|
||||||
Type: "bool",
|
|
||||||
|
|
||||||
Comment: `EnableRealTimeFilterAPI enables APIs that can create and query filters for actor events as they are emitted.`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "EnableHistoricFilterAPI",
|
|
||||||
Type: "bool",
|
|
||||||
|
|
||||||
Comment: `EnableHistoricFilterAPI enables APIs that can create and query filters for actor events that occurred in the past.
|
|
||||||
A queryable index of events will be maintained.`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "FilterTTL",
|
|
||||||
Type: "Duration",
|
|
||||||
|
|
||||||
Comment: `FilterTTL specifies the time to live for actor event filters. Filters that haven't been accessed longer than
|
|
||||||
this time become eligible for automatic deletion.`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "MaxFilters",
|
|
||||||
Type: "int",
|
|
||||||
|
|
||||||
Comment: `MaxFilters specifies the maximum number of filters that may exist at any one time.`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "MaxFilterResults",
|
|
||||||
Type: "int",
|
|
||||||
|
|
||||||
Comment: `MaxFilterResults specifies the maximum number of results that can be accumulated by an actor event filter.`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "MaxFilterHeightRange",
|
|
||||||
Type: "uint64",
|
|
||||||
|
|
||||||
Comment: `MaxFilterHeightRange specifies the maximum range of heights that can be used in a filter (to avoid querying
|
|
||||||
the entire chain)`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "ActorEventDatabasePath",
|
|
||||||
Type: "string",
|
|
||||||
|
|
||||||
Comment: `ActorEventDatabasePath is the full path to a sqlite database that will be used to index actor events to
|
|
||||||
support the historic filter APIs. If the database does not exist it will be created. The directory containing
|
|
||||||
the database must already exist and be writeable. If a relative path is provided here, sqlite treats it as
|
|
||||||
relative to the CWD (current working directory).`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"Backup": []DocField{
|
"Backup": []DocField{
|
||||||
{
|
{
|
||||||
Name: "DisableMetadataLog",
|
Name: "DisableMetadataLog",
|
||||||
@ -391,6 +341,59 @@ see https://lotus.filecoin.io/storage-providers/advanced-configurations/market/#
|
|||||||
Comment: ``,
|
Comment: ``,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"EventsConfig": []DocField{
|
||||||
|
{
|
||||||
|
Name: "DisableRealTimeFilterAPI",
|
||||||
|
Type: "bool",
|
||||||
|
|
||||||
|
Comment: `EnableEthRPC enables APIs that
|
||||||
|
DisableRealTimeFilterAPI will disable the RealTimeFilterAPI that can create and query filters for actor events as they are emitted.
|
||||||
|
The API is enabled when EnableEthRPC is true, but can be disabled selectively with this flag.`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "DisableHistoricFilterAPI",
|
||||||
|
Type: "bool",
|
||||||
|
|
||||||
|
Comment: `DisableHistoricFilterAPI will disable the HistoricFilterAPI that can create and query filters for actor events
|
||||||
|
that occurred in the past. HistoricFilterAPI maintains a queryable index of events.
|
||||||
|
The API is enabled when EnableEthRPC is true, but can be disabled selectively with this flag.`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "FilterTTL",
|
||||||
|
Type: "Duration",
|
||||||
|
|
||||||
|
Comment: `FilterTTL specifies the time to live for actor event filters. Filters that haven't been accessed longer than
|
||||||
|
this time become eligible for automatic deletion.`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "MaxFilters",
|
||||||
|
Type: "int",
|
||||||
|
|
||||||
|
Comment: `MaxFilters specifies the maximum number of filters that may exist at any one time.`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "MaxFilterResults",
|
||||||
|
Type: "int",
|
||||||
|
|
||||||
|
Comment: `MaxFilterResults specifies the maximum number of results that can be accumulated by an actor event filter.`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "MaxFilterHeightRange",
|
||||||
|
Type: "uint64",
|
||||||
|
|
||||||
|
Comment: `MaxFilterHeightRange specifies the maximum range of heights that can be used in a filter (to avoid querying
|
||||||
|
the entire chain)`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "DatabasePath",
|
||||||
|
Type: "string",
|
||||||
|
|
||||||
|
Comment: `DatabasePath is the full path to a sqlite database that will be used to index actor events to
|
||||||
|
support the historic filter APIs. If the database does not exist it will be created. The directory containing
|
||||||
|
the database must already exist and be writeable. If a relative path is provided here, sqlite treats it as
|
||||||
|
relative to the CWD (current working directory).`,
|
||||||
|
},
|
||||||
|
},
|
||||||
"FeeConfig": []DocField{
|
"FeeConfig": []DocField{
|
||||||
{
|
{
|
||||||
Name: "DefaultMaxFee",
|
Name: "DefaultMaxFee",
|
||||||
@ -404,7 +407,8 @@ see https://lotus.filecoin.io/storage-providers/advanced-configurations/market/#
|
|||||||
Name: "EnableEthRPC",
|
Name: "EnableEthRPC",
|
||||||
Type: "bool",
|
Type: "bool",
|
||||||
|
|
||||||
Comment: `EnableEthRPC enables eth_ rpc, and enables storing a mapping of eth transaction hashes to filecoin message Cids.`,
|
Comment: `EnableEthRPC enables eth_ rpc, and enables storing a mapping of eth transaction hashes to filecoin message Cids.
|
||||||
|
This will also enable the RealTimeFilterAPI and HistoricFilterAPI by default, but they can be disabled by config options above.`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "EthTxHashMappingLifetimeDays",
|
Name: "EthTxHashMappingLifetimeDays",
|
||||||
@ -413,6 +417,12 @@ see https://lotus.filecoin.io/storage-providers/advanced-configurations/market/#
|
|||||||
Comment: `EthTxHashMappingLifetimeDays the transaction hash lookup database will delete mappings that have been stored for more than x days
|
Comment: `EthTxHashMappingLifetimeDays the transaction hash lookup database will delete mappings that have been stored for more than x days
|
||||||
Set to 0 to keep all mappings`,
|
Set to 0 to keep all mappings`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "Events",
|
||||||
|
Type: "EventsConfig",
|
||||||
|
|
||||||
|
Comment: ``,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"FullNode": []DocField{
|
"FullNode": []DocField{
|
||||||
{
|
{
|
||||||
@ -446,8 +456,8 @@ Set to 0 to keep all mappings`,
|
|||||||
Comment: ``,
|
Comment: ``,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "ActorEvent",
|
Name: "Events",
|
||||||
Type: "ActorEventConfig",
|
Type: "EventsConfig",
|
||||||
|
|
||||||
Comment: ``,
|
Comment: ``,
|
||||||
},
|
},
|
||||||
|
@ -27,7 +27,7 @@ type FullNode struct {
|
|||||||
Fees FeeConfig
|
Fees FeeConfig
|
||||||
Chainstore Chainstore
|
Chainstore Chainstore
|
||||||
Cluster UserRaftConfig
|
Cluster UserRaftConfig
|
||||||
ActorEvent ActorEventConfig
|
Events EventsConfig
|
||||||
Fevm FevmConfig
|
Fevm FevmConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,13 +660,28 @@ type UserRaftConfig struct {
|
|||||||
Tracing bool
|
Tracing bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type ActorEventConfig struct {
|
type FevmConfig struct {
|
||||||
// EnableRealTimeFilterAPI enables APIs that can create and query filters for actor events as they are emitted.
|
// EnableEthRPC enables eth_ rpc, and enables storing a mapping of eth transaction hashes to filecoin message Cids.
|
||||||
EnableRealTimeFilterAPI bool
|
// This will also enable the RealTimeFilterAPI and HistoricFilterAPI by default, but they can be disabled by config options above.
|
||||||
|
EnableEthRPC bool
|
||||||
|
|
||||||
// EnableHistoricFilterAPI enables APIs that can create and query filters for actor events that occurred in the past.
|
// EthTxHashMappingLifetimeDays the transaction hash lookup database will delete mappings that have been stored for more than x days
|
||||||
// A queryable index of events will be maintained.
|
// Set to 0 to keep all mappings
|
||||||
EnableHistoricFilterAPI bool
|
EthTxHashMappingLifetimeDays int
|
||||||
|
|
||||||
|
Events EventsConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
type EventsConfig struct {
|
||||||
|
// EnableEthRPC enables APIs that
|
||||||
|
// DisableRealTimeFilterAPI will disable the RealTimeFilterAPI that can create and query filters for actor events as they are emitted.
|
||||||
|
// The API is enabled when EnableEthRPC is true, but can be disabled selectively with this flag.
|
||||||
|
DisableRealTimeFilterAPI bool
|
||||||
|
|
||||||
|
// DisableHistoricFilterAPI will disable the HistoricFilterAPI that can create and query filters for actor events
|
||||||
|
// that occurred in the past. HistoricFilterAPI maintains a queryable index of events.
|
||||||
|
// The API is enabled when EnableEthRPC is true, but can be disabled selectively with this flag.
|
||||||
|
DisableHistoricFilterAPI bool
|
||||||
|
|
||||||
// FilterTTL specifies the time to live for actor event filters. Filters that haven't been accessed longer than
|
// FilterTTL specifies the time to live for actor event filters. Filters that haven't been accessed longer than
|
||||||
// this time become eligible for automatic deletion.
|
// this time become eligible for automatic deletion.
|
||||||
@ -682,23 +697,14 @@ type ActorEventConfig struct {
|
|||||||
// the entire chain)
|
// the entire chain)
|
||||||
MaxFilterHeightRange uint64
|
MaxFilterHeightRange uint64
|
||||||
|
|
||||||
// ActorEventDatabasePath is the full path to a sqlite database that will be used to index actor events to
|
// DatabasePath is the full path to a sqlite database that will be used to index actor events to
|
||||||
// support the historic filter APIs. If the database does not exist it will be created. The directory containing
|
// support the historic filter APIs. If the database does not exist it will be created. The directory containing
|
||||||
// the database must already exist and be writeable. If a relative path is provided here, sqlite treats it as
|
// the database must already exist and be writeable. If a relative path is provided here, sqlite treats it as
|
||||||
// relative to the CWD (current working directory).
|
// relative to the CWD (current working directory).
|
||||||
ActorEventDatabasePath string
|
DatabasePath string
|
||||||
|
|
||||||
// Others, not implemented yet:
|
// Others, not implemented yet:
|
||||||
// Set a limit on the number of active websocket subscriptions (may be zero)
|
// Set a limit on the number of active websocket subscriptions (may be zero)
|
||||||
// Set a timeout for subscription clients
|
// Set a timeout for subscription clients
|
||||||
// Set upper bound on index size
|
// Set upper bound on index size
|
||||||
}
|
}
|
||||||
|
|
||||||
type FevmConfig struct {
|
|
||||||
// EnableEthRPC enables eth_ rpc, and enables storing a mapping of eth transaction hashes to filecoin message Cids.
|
|
||||||
EnableEthRPC bool
|
|
||||||
|
|
||||||
// EthTxHashMappingLifetimeDays the transaction hash lookup database will delete mappings that have been stored for more than x days
|
|
||||||
// Set to 0 to keep all mappings
|
|
||||||
EthTxHashMappingLifetimeDays int
|
|
||||||
}
|
|
||||||
|
@ -2,6 +2,7 @@ package modules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/multiformats/go-varint"
|
"github.com/multiformats/go-varint"
|
||||||
@ -20,6 +21,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/node/config"
|
"github.com/filecoin-project/lotus/node/config"
|
||||||
"github.com/filecoin-project/lotus/node/impl/full"
|
"github.com/filecoin-project/lotus/node/impl/full"
|
||||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||||
|
"github.com/filecoin-project/lotus/node/repo"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EventAPI struct {
|
type EventAPI struct {
|
||||||
@ -31,16 +33,16 @@ type EventAPI struct {
|
|||||||
|
|
||||||
var _ events.EventAPI = &EventAPI{}
|
var _ events.EventAPI = &EventAPI{}
|
||||||
|
|
||||||
func EthEventAPI(cfg config.ActorEventConfig) func(helpers.MetricsCtx, fx.Lifecycle, *store.ChainStore, *stmgr.StateManager, EventAPI, *messagepool.MessagePool, full.StateAPI, full.ChainAPI) (*full.EthEvent, error) {
|
func EthEventAPI(cfg config.FevmConfig) func(helpers.MetricsCtx, repo.LockedRepo, fx.Lifecycle, *store.ChainStore, *stmgr.StateManager, EventAPI, *messagepool.MessagePool, full.StateAPI, full.ChainAPI) (*full.EthEvent, error) {
|
||||||
return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, cs *store.ChainStore, sm *stmgr.StateManager, evapi EventAPI, mp *messagepool.MessagePool, stateapi full.StateAPI, chainapi full.ChainAPI) (*full.EthEvent, error) {
|
return func(mctx helpers.MetricsCtx, r repo.LockedRepo, lc fx.Lifecycle, cs *store.ChainStore, sm *stmgr.StateManager, evapi EventAPI, mp *messagepool.MessagePool, stateapi full.StateAPI, chainapi full.ChainAPI) (*full.EthEvent, error) {
|
||||||
ctx := helpers.LifecycleCtx(mctx, lc)
|
ctx := helpers.LifecycleCtx(mctx, lc)
|
||||||
|
|
||||||
ee := &full.EthEvent{
|
ee := &full.EthEvent{
|
||||||
Chain: cs,
|
Chain: cs,
|
||||||
MaxFilterHeightRange: abi.ChainEpoch(cfg.MaxFilterHeightRange),
|
MaxFilterHeightRange: abi.ChainEpoch(cfg.Events.MaxFilterHeightRange),
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cfg.EnableRealTimeFilterAPI {
|
if !cfg.EnableEthRPC || cfg.Events.DisableRealTimeFilterAPI {
|
||||||
// all event functionality is disabled
|
// all event functionality is disabled
|
||||||
// the historic filter API relies on the real time one
|
// the historic filter API relies on the real time one
|
||||||
return ee, nil
|
return ee, nil
|
||||||
@ -51,21 +53,32 @@ func EthEventAPI(cfg config.ActorEventConfig) func(helpers.MetricsCtx, fx.Lifecy
|
|||||||
StateAPI: stateapi,
|
StateAPI: stateapi,
|
||||||
ChainAPI: chainapi,
|
ChainAPI: chainapi,
|
||||||
}
|
}
|
||||||
ee.FilterStore = filter.NewMemFilterStore(cfg.MaxFilters)
|
ee.FilterStore = filter.NewMemFilterStore(cfg.Events.MaxFilters)
|
||||||
|
|
||||||
// Start garbage collection for filters
|
// Start garbage collection for filters
|
||||||
lc.Append(fx.Hook{
|
lc.Append(fx.Hook{
|
||||||
OnStart: func(context.Context) error {
|
OnStart: func(context.Context) error {
|
||||||
go ee.GC(ctx, time.Duration(cfg.FilterTTL))
|
go ee.GC(ctx, time.Duration(cfg.Events.FilterTTL))
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// Enable indexing of actor events
|
// Enable indexing of actor events
|
||||||
var eventIndex *filter.EventIndex
|
var eventIndex *filter.EventIndex
|
||||||
if cfg.EnableHistoricFilterAPI {
|
if !cfg.Events.DisableHistoricFilterAPI {
|
||||||
|
var dbPath string
|
||||||
|
if cfg.Events.DatabasePath == "" {
|
||||||
|
sqlitePath, err := r.SqlitePath()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dbPath = filepath.Join(sqlitePath, "events.db")
|
||||||
|
} else {
|
||||||
|
dbPath = cfg.Events.DatabasePath
|
||||||
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
eventIndex, err = filter.NewEventIndex(cfg.ActorEventDatabasePath)
|
eventIndex, err = filter.NewEventIndex(dbPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -103,13 +116,13 @@ func EthEventAPI(cfg config.ActorEventConfig) func(helpers.MetricsCtx, fx.Lifecy
|
|||||||
return *actor.Address, true
|
return *actor.Address, true
|
||||||
},
|
},
|
||||||
|
|
||||||
MaxFilterResults: cfg.MaxFilterResults,
|
MaxFilterResults: cfg.Events.MaxFilterResults,
|
||||||
}
|
}
|
||||||
ee.TipSetFilterManager = &filter.TipSetFilterManager{
|
ee.TipSetFilterManager = &filter.TipSetFilterManager{
|
||||||
MaxFilterResults: cfg.MaxFilterResults,
|
MaxFilterResults: cfg.Events.MaxFilterResults,
|
||||||
}
|
}
|
||||||
ee.MemPoolFilterManager = &filter.MemPoolFilterManager{
|
ee.MemPoolFilterManager = &filter.MemPoolFilterManager{
|
||||||
MaxFilterResults: cfg.MaxFilterResults,
|
MaxFilterResults: cfg.Events.MaxFilterResults,
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChainHeadConfidence = 1
|
const ChainHeadConfidence = 1
|
||||||
|
@ -19,12 +19,12 @@ import (
|
|||||||
|
|
||||||
func EthModuleAPI(cfg config.FevmConfig) func(helpers.MetricsCtx, repo.LockedRepo, fx.Lifecycle, *store.ChainStore, *stmgr.StateManager, EventAPI, *messagepool.MessagePool, full.StateAPI, full.ChainAPI, full.MpoolAPI) (*full.EthModule, error) {
|
func EthModuleAPI(cfg config.FevmConfig) func(helpers.MetricsCtx, repo.LockedRepo, fx.Lifecycle, *store.ChainStore, *stmgr.StateManager, EventAPI, *messagepool.MessagePool, full.StateAPI, full.ChainAPI, full.MpoolAPI) (*full.EthModule, error) {
|
||||||
return func(mctx helpers.MetricsCtx, r repo.LockedRepo, lc fx.Lifecycle, cs *store.ChainStore, sm *stmgr.StateManager, evapi EventAPI, mp *messagepool.MessagePool, stateapi full.StateAPI, chainapi full.ChainAPI, mpoolapi full.MpoolAPI) (*full.EthModule, error) {
|
return func(mctx helpers.MetricsCtx, r repo.LockedRepo, lc fx.Lifecycle, cs *store.ChainStore, sm *stmgr.StateManager, evapi EventAPI, mp *messagepool.MessagePool, stateapi full.StateAPI, chainapi full.ChainAPI, mpoolapi full.MpoolAPI) (*full.EthModule, error) {
|
||||||
dbPath, err := r.SqlitePath()
|
sqlitePath, err := r.SqlitePath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
transactionHashLookup, err := ethhashlookup.NewTransactionHashLookup(filepath.Join(dbPath, "txhash.db"))
|
transactionHashLookup, err := ethhashlookup.NewTransactionHashLookup(filepath.Join(sqlitePath, "txhash.db"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user