Skip to content

Commit

Permalink
Set default path for eth event db, set it to enabled by default if En…
Browse files Browse the repository at this point in the history
…ableEthRPC is set
  • Loading branch information
Geoff Stuart committed Jan 19, 2023
1 parent 2335bed commit a5316dd
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 111 deletions.
1 change: 1 addition & 0 deletions cli/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/filecoin-project/lotus/api/v0api"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
)
Expand Down
14 changes: 14 additions & 0 deletions documentation/en/cli-lotus.md
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,7 @@ COMMANDS:
network-version Returns the network version
miner-proving-deadline Retrieve information about a given miner's proving deadline
actor-cids Returns the built-in actor bundle manifest ID & system actor cids
blockhash Get the tipset CID - eth blockhash
help, h Shows a list of commands or help for one command
OPTIONS:
Expand Down Expand Up @@ -2063,6 +2064,19 @@ OPTIONS:
```

### lotus state blockhash
```
NAME:
lotus state blockhash - Get the tipset CID - eth blockhash
USAGE:
lotus state blockhash [command options] [arguments...]
OPTIONS:
--help, -h show help (default: false)
```

## lotus chain
```
NAME:
Expand Down
26 changes: 14 additions & 12 deletions documentation/en/default-lotus-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -293,44 +293,46 @@
#Tracing = false


[ActorEvent]
# EnableRealTimeFilterAPI enables APIs that can create and query filters for actor events as they are emitted.
[Events]
# EnableEthRPC enables APIs that can create and query filters for actor events as they are emitted.
# DisableRealTimeFilterAPI will disable those APIs if you want to opt-out
#
# type: bool
# env var: LOTUS_ACTOREVENT_ENABLEREALTIMEFILTERAPI
#EnableRealTimeFilterAPI = false
# env var: LOTUS_EVENTS_DISABLEREALTIMEFILTERAPI
#DisableRealTimeFilterAPI = false

# EnableHistoricFilterAPI enables APIs that can create and query filters for actor events that occurred in the past.
# EnableEthRPC enables APIs that can create and query filters for actor events that occurred in the past.
# A queryable index of events will be maintained.
# DisableHistoricFilterAPI will disable those APIs if you want to opt-out
#
# type: bool
# env var: LOTUS_ACTOREVENT_ENABLEHISTORICFILTERAPI
#EnableHistoricFilterAPI = false
# env var: LOTUS_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_ACTOREVENT_FILTERTTL
# env var: LOTUS_EVENTS_FILTERTTL
#FilterTTL = "24h0m0s"

# MaxFilters specifies the maximum number of filters that may exist at any one time.
#
# type: int
# env var: LOTUS_ACTOREVENT_MAXFILTERS
# env var: LOTUS_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_ACTOREVENT_MAXFILTERRESULTS
# env var: LOTUS_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_ACTOREVENT_MAXFILTERHEIGHTRANGE
# env var: LOTUS_EVENTS_MAXFILTERHEIGHTRANGE
#MaxFilterHeightRange = 2880

# ActorEventDatabasePath is the full path to a sqlite database that will be used to index actor events to
Expand All @@ -339,7 +341,7 @@
# relative to the CWD (current working directory).
#
# type: string
# env var: LOTUS_ACTOREVENT_ACTOREVENTDATABASEPATH
# env var: LOTUS_EVENTS_ACTOREVENTDATABASEPATH
#ActorEventDatabasePath = ""


Expand Down
7 changes: 1 addition & 6 deletions itests/eth_deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
"github.com/filecoin-project/lotus/itests/kit"
"github.com/filecoin-project/lotus/node/config"
)

// TestDeployment smoke tests the deployment of a contract via the
Expand All @@ -36,11 +35,7 @@ func TestDeployment(t *testing.T) {
client, _, ens := kit.EnsembleMinimal(
t,
kit.MockProofs(),
kit.ThroughRPC(),
kit.WithCfgOpt(func(cfg *config.FullNode) error {
cfg.ActorEvent.EnableRealTimeFilterAPI = true
return nil
}))
kit.ThroughRPC())
ens.InterconnectAll().BeginMining(blockTime)

ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
Expand Down
15 changes: 6 additions & 9 deletions itests/eth_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/hex"
"encoding/json"
"os"
"path/filepath"
"strconv"
"strings"
"testing"
Expand All @@ -30,7 +29,7 @@ func TestEthNewPendingTransactionFilter(t *testing.T) {

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)

// create a new address where to send funds.
Expand Down Expand Up @@ -124,7 +123,7 @@ func TestEthNewBlockFilter(t *testing.T) {

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)

// create a new address where to send funds.
Expand Down Expand Up @@ -204,7 +203,7 @@ func TestEthNewFilterCatchAll(t *testing.T) {
kit.QuietMiningLogs()

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)

ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
Expand Down Expand Up @@ -569,9 +568,8 @@ func TestEthGetLogsAll(t *testing.T) {
kit.QuietMiningLogs()

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)

ethContractAddr, received := invokeContractAndWaitUntilAllOnChain(t, client, 10)
Expand Down Expand Up @@ -632,9 +630,8 @@ func TestEthGetLogsByTopic(t *testing.T) {
kit.QuietMiningLogs()

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)

invocations := 1
Expand Down Expand Up @@ -696,7 +693,7 @@ func TestEthSubscribeLogs(t *testing.T) {
kit.QuietMiningLogs()

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)

ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
Expand Down
13 changes: 2 additions & 11 deletions itests/kit/node_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,18 +290,9 @@ func SplitstoreMessges() NodeOpt {
})
}

func RealTimeFilterAPI() NodeOpt {
func WithEthRPC() NodeOpt {
return WithCfgOpt(func(cfg *config.FullNode) error {
cfg.ActorEvent.EnableRealTimeFilterAPI = 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
cfg.Fevm.EnableEthRPC = true
return nil
})
}
Expand Down
2 changes: 1 addition & 1 deletion node/builder_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func ConfigFullNode(c interface{}) Option {
// Actor event filtering support
Override(new(events.EventAPI), From(new(modules.EventAPI))),
// in lite-mode Eth event api is provided by gateway
ApplyIf(isFullNode, Override(new(full.EthEventAPI), modules.EthEventAPI(cfg.ActorEvent))),
If(cfg.Fevm.EnableEthRPC, ApplyIf(isFullNode, Override(new(full.EthEventAPI), modules.EthEventAPI(cfg.Events)))),

If(cfg.Fevm.EnableEthRPC, Override(new(full.EthModuleAPI), modules.EthModuleAPI(cfg.Fevm))),
If(!cfg.Fevm.EnableEthRPC, Override(new(full.EthModuleAPI), &full.EthModuleDummy{})),
Expand Down
14 changes: 7 additions & 7 deletions node/config/def.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ func DefaultFullNode() *FullNode {
},
},
Cluster: *DefaultUserRaftConfig(),
ActorEvent: ActorEventConfig{
EnableRealTimeFilterAPI: false,
EnableHistoricFilterAPI: false,
FilterTTL: Duration(time.Hour * 24),
MaxFilters: 100,
MaxFilterResults: 10000,
MaxFilterHeightRange: 2880, // conservative limit of one day
Events: EventsConfig{
DisableRealTimeFilterAPI: false,
DisableHistoricFilterAPI: false,
FilterTTL: Duration(time.Hour * 24),
MaxFilters: 100,
MaxFilterResults: 10000,
MaxFilterHeightRange: 2880, // conservative limit of one day
},
Fevm: FevmConfig{
EnableEthRPC: false,
Expand Down
106 changes: 54 additions & 52 deletions node/config/doc_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions node/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type FullNode struct {
Fees FeeConfig
Chainstore Chainstore
Cluster UserRaftConfig
ActorEvent ActorEventConfig
Events EventsConfig
Fevm FevmConfig
}

Expand Down Expand Up @@ -660,13 +660,15 @@ type UserRaftConfig struct {
Tracing bool
}

type ActorEventConfig struct {
// EnableRealTimeFilterAPI enables APIs that can create and query filters for actor events as they are emitted.
EnableRealTimeFilterAPI bool
type EventsConfig struct {
// EnableEthRPC enables APIs that can create and query filters for actor events as they are emitted.
// DisableRealTimeFilterAPI will disable those APIs if you want to opt-out
DisableRealTimeFilterAPI bool

// EnableHistoricFilterAPI enables APIs that can create and query filters for actor events that occurred in the past.
// EnableEthRPC enables APIs that can create and query filters for actor events that occurred in the past.
// A queryable index of events will be maintained.
EnableHistoricFilterAPI bool
// DisableHistoricFilterAPI will disable those APIs if you want to opt-out
DisableHistoricFilterAPI bool

// 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.
Expand Down
Loading

0 comments on commit a5316dd

Please sign in to comment.