Skip to content

Commit

Permalink
feat(config): move Fevm.Events->Events, implement soft deprecation
Browse files Browse the repository at this point in the history
* Introduce a `moved:"To.New.Config"` tag which prints a stderr warning when
  you use one of these, but will move any set value to the new location if the
	new location isn't already set itself.
* Look for `X is DEPRECATED` to hold certain fields back from documentation.
* Use `toml:"omitempty"` to prevent the default config output from having these
  deprecated values.
  • Loading branch information
rvagg committed Mar 8, 2024
1 parent b4e7374 commit 63e35fa
Show file tree
Hide file tree
Showing 10 changed files with 331 additions and 115 deletions.
101 changes: 50 additions & 51 deletions documentation/en/default-lotus-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -337,68 +337,67 @@
# env var: LOTUS_FEVM_ETHTXHASHMAPPINGLIFETIMEDAYS
#EthTxHashMappingLifetimeDays = 0

[Fevm.Events]
# DisableRealTimeFilterAPI will disable the RealTimeFilterAPI that can create and query filters for actor events as they are emitted.
# The API is enabled when EnableEthRPC or Events.EnableActorEventsAPI 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 or Events.EnableActorEventsAPI 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 = ""
[Events]
# DisableRealTimeFilterAPI will disable the RealTimeFilterAPI that can create and query filters for actor events as they are emitted.
# The API is enabled when Fevm.EnableEthRPC or EnableActorEventsAPI is true, but can be disabled selectively with this flag.
#
# type: bool
# env var: LOTUS_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 Fevm.EnableEthRPC or EnableActorEventsAPI is true, but can be disabled selectively with this flag.
#
# type: bool
# env var: LOTUS_EVENTS_DISABLEHISTORICFILTERAPI
#DisableHistoricFilterAPI = false

[Events]
# EnableActorEventsAPI enables the Actor events API that enables clients to consume events
# emitted by (smart contracts + built-in Actors).
# This will also enable the RealTimeFilterAPI and HistoricFilterAPI by default, but they can be
# disabled by setting their respective Disable* options in Fevm.Events.
# disabled by setting their respective Disable* options.
#
# type: bool
# env var: LOTUS_EVENTS_ENABLEACTOREVENTSAPI
#EnableActorEventsAPI = 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_EVENTS_FILTERTTL
#FilterTTL = "24h0m0s"

# MaxFilters specifies the maximum number of filters that may exist at any one time.
#
# type: int
# 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_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_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_EVENTS_DATABASEPATH
#DatabasePath = ""


[Index]
# EXPERIMENTAL FEATURE. USE WITH CAUTION
Expand Down
2 changes: 1 addition & 1 deletion itests/kit/node_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var DefaultNodeOpts = nodeOpts{
// test defaults

cfg.Fevm.EnableEthRPC = true
cfg.Fevm.Events.MaxFilterHeightRange = math.MaxInt64
cfg.Events.MaxFilterHeightRange = math.MaxInt64
cfg.Events.EnableActorEventsAPI = true
return nil
},
Expand Down
6 changes: 3 additions & 3 deletions node/builder_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ func ConfigFullNode(c interface{}) Option {

// Actor event filtering support
Override(new(events.EventHelperAPI), From(new(modules.EventHelperAPI))),
Override(new(*filter.EventFilterManager), modules.EventFilterManager(cfg.Fevm)),
Override(new(*filter.EventFilterManager), modules.EventFilterManager(cfg.Events)),

// in lite-mode Eth api is provided by gateway
ApplyIf(isFullNode,
If(cfg.Fevm.EnableEthRPC,
Override(new(full.EthModuleAPI), modules.EthModuleAPI(cfg.Fevm)),
Override(new(full.EthEventAPI), modules.EthEventHandler(cfg.Fevm)),
Override(new(full.EthEventAPI), modules.EthEventHandler(cfg.Events, cfg.Fevm.EnableEthRPC)),
),
If(!cfg.Fevm.EnableEthRPC,
Override(new(full.EthModuleAPI), &full.EthModuleDummy{}),
Expand All @@ -282,7 +282,7 @@ func ConfigFullNode(c interface{}) Option {

ApplyIf(isFullNode,
If(cfg.Events.EnableActorEventsAPI,
Override(new(full.ActorEventAPI), modules.ActorEventHandler(cfg.Events.EnableActorEventsAPI, cfg.Fevm)),
Override(new(full.ActorEventAPI), modules.ActorEventHandler(cfg.Events)),
),
If(!cfg.Events.EnableActorEventsAPI,
Override(new(full.ActorEventAPI), &full.ActorEventDummy{}),
Expand Down
5 changes: 5 additions & 0 deletions node/config/cfgdocgen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ func run() error {
name := f[0]
typ := f[1]

if len(comment) > 0 && strings.HasPrefix(comment[0], fmt.Sprintf("%s is DEPRECATED", name)) {
// don't document deprecated fields
continue
}

out[currentType] = append(out[currentType], field{
Name: name,
Type: typ,
Expand Down
16 changes: 7 additions & 9 deletions node/config/def.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,15 @@ func DefaultFullNode() *FullNode {
Fevm: FevmConfig{
EnableEthRPC: false,
EthTxHashMappingLifetimeDays: 0,
Events: Events{
DisableRealTimeFilterAPI: false,
DisableHistoricFilterAPI: false,
FilterTTL: Duration(time.Hour * 24),
MaxFilters: 100,
MaxFilterResults: 10000,
MaxFilterHeightRange: 2880, // conservative limit of one day
},
},
Events: EventsConfig{
EnableActorEventsAPI: false,
DisableRealTimeFilterAPI: false,
DisableHistoricFilterAPI: false,
EnableActorEventsAPI: false,
FilterTTL: Duration(time.Hour * 24),
MaxFilters: 100,
MaxFilterResults: 10000,
MaxFilterHeightRange: 2880, // conservative limit of one day
},
}
}
Expand Down
28 changes: 13 additions & 15 deletions node/config/doc_gen.go

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

Loading

0 comments on commit 63e35fa

Please sign in to comment.