Compare commits
5 Commits
master
...
ian/events
Author | SHA1 | Date | |
---|---|---|---|
|
87b8e0a8fd | ||
|
82f754f31e | ||
|
670b72ff1f | ||
|
a17b6af00c | ||
|
a8829a049e |
@ -9,6 +9,7 @@
|
||||
## Improvements
|
||||
- fix: Add time slicing to splitstore purging step during compaction to reduce lock congestion [filecoin-project/lotus#11269](https://github.com/filecoin-project/lotus/pull/11269)
|
||||
- feat: Added instructions on how to setup Prometheus/Grafana for monitoring a local Lotus node [filecoin-project/lotus#11276](https://github.com/filecoin-project/lotus/pull/11276)
|
||||
- feat: Add a `FilterThresholdEpoch` configuration option [filecoin-project/lotus#11346](https://github.com/filecoin-project/lotus/pull/11346)
|
||||
|
||||
## New features
|
||||
- feat: Add move-partition command ([filecoin-project/lotus#11290](https://github.com/filecoin-project/lotus/pull/11290))
|
||||
|
@ -380,6 +380,21 @@
|
||||
# env var: LOTUS_FEVM_EVENTS_MAXFILTERHEIGHTRANGE
|
||||
#MaxFilterHeightRange = 2880
|
||||
|
||||
# FilterThresholdSet signals whether a FilterThresholdEpoch is set. If it is it will be used instead of
|
||||
# MaxFilterHeightRange to define the supported range.
|
||||
#
|
||||
# type: bool
|
||||
# env var: LOTUS_FEVM_EVENTS_FILTERTHRESHOLDSET
|
||||
#FilterThresholdSet = false
|
||||
|
||||
# FilterThresholdEpoch specifies an epoch above which the node will support returning filtered logs.
|
||||
# This is useful for setting a static start epoch for support, rather than a static window size with a start epoch
|
||||
# that shifts as the chain progresses.
|
||||
#
|
||||
# type: uint64
|
||||
# env var: LOTUS_FEVM_EVENTS_FILTERTHRESHOLDEPOCH
|
||||
#FilterThresholdEpoch = 2683348
|
||||
|
||||
# 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
|
||||
|
@ -116,7 +116,9 @@ func DefaultFullNode() *FullNode {
|
||||
FilterTTL: Duration(time.Hour * 24),
|
||||
MaxFilters: 100,
|
||||
MaxFilterResults: 10000,
|
||||
MaxFilterHeightRange: 2880, // conservative limit of one day
|
||||
MaxFilterHeightRange: 2880, // conservative limit of one day
|
||||
FilterThresholdSet: false, // use MaxFilterHeightRange by default
|
||||
FilterThresholdEpoch: 2683348, // FEVM start epoch
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -383,6 +383,21 @@ this time become eligible for automatic deletion.`,
|
||||
|
||||
Comment: `MaxFilterHeightRange specifies the maximum range of heights that can be used in a filter (to avoid querying
|
||||
the entire chain)`,
|
||||
},
|
||||
{
|
||||
Name: "FilterThresholdSet",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `FilterThresholdSet signals whether a FilterThresholdEpoch is set. If it is it will be used instead of
|
||||
MaxFilterHeightRange to define the supported range.`,
|
||||
},
|
||||
{
|
||||
Name: "FilterThresholdEpoch",
|
||||
Type: "uint64",
|
||||
|
||||
Comment: `FilterThresholdEpoch specifies an epoch above which the node will support returning filtered logs.
|
||||
This is useful for setting a static start epoch for support, rather than a static window size with a start epoch
|
||||
that shifts as the chain progresses.`,
|
||||
},
|
||||
{
|
||||
Name: "DatabasePath",
|
||||
|
@ -717,6 +717,15 @@ type Events struct {
|
||||
// the entire chain)
|
||||
MaxFilterHeightRange uint64
|
||||
|
||||
// FilterThresholdSet signals whether a FilterThresholdEpoch is set. If it is it will be used instead of
|
||||
// MaxFilterHeightRange to define the supported range.
|
||||
FilterThresholdSet bool
|
||||
|
||||
// FilterThresholdEpoch specifies an epoch above which the node will support returning filtered logs.
|
||||
// This is useful for setting a static start epoch for support, rather than a static window size with a start epoch
|
||||
// that shifts as the chain progresses.
|
||||
FilterThresholdEpoch uint64
|
||||
|
||||
// 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
|
||||
|
@ -143,6 +143,8 @@ type EthEvent struct {
|
||||
FilterStore filter.FilterStore
|
||||
SubManager *EthSubscriptionManager
|
||||
MaxFilterHeightRange abi.ChainEpoch
|
||||
FilterThresholdSet bool
|
||||
FilterThresholdEpoch abi.ChainEpoch
|
||||
SubscribtionCtx context.Context
|
||||
}
|
||||
|
||||
@ -1292,27 +1294,53 @@ func (e *EthEvent) installEthFilterSpec(ctx context.Context, filterSpec *ethtype
|
||||
}
|
||||
|
||||
// Validate height ranges are within limits set by node operator
|
||||
if minHeight == -1 && maxHeight > 0 {
|
||||
// Here the client is looking for events between the head and some future height
|
||||
ts := e.Chain.GetHeaviestTipSet()
|
||||
if maxHeight-ts.Height() > e.MaxFilterHeightRange {
|
||||
return nil, xerrors.Errorf("invalid epoch range: to block is too far in the future (maximum: %d)", e.MaxFilterHeightRange)
|
||||
}
|
||||
} else if minHeight >= 0 && maxHeight == -1 {
|
||||
// Here the client is looking for events between some time in the past and the current head
|
||||
ts := e.Chain.GetHeaviestTipSet()
|
||||
if ts.Height()-minHeight > e.MaxFilterHeightRange {
|
||||
return nil, xerrors.Errorf("invalid epoch range: from block is too far in the past (maximum: %d)", e.MaxFilterHeightRange)
|
||||
if e.FilterThresholdSet {
|
||||
if minHeight == -1 && maxHeight > 0 {
|
||||
// Here the client is looking for events between the head and some future height
|
||||
ts := e.Chain.GetHeaviestTipSet()
|
||||
if maxHeight < ts.Height() {
|
||||
return nil, xerrors.Errorf("invalid epoch range: to block (%d) must be after from block (%d)", maxHeight, ts.Height())
|
||||
}
|
||||
if ts.Height() < e.FilterThresholdEpoch {
|
||||
return nil, xerrors.Errorf("invalid epoch range: from block (%d) is below the set FilterThresholdEpoch (%d)", ts.Height(), e.FilterThresholdEpoch)
|
||||
}
|
||||
} else if minHeight >= 0 && maxHeight == -1 {
|
||||
// Here the client is looking for events between some time in the past and the current head
|
||||
if minHeight < e.FilterThresholdEpoch {
|
||||
return nil, xerrors.Errorf("invalid epoch range: from block is too far in the past (minimum from epoch: %d)", e.FilterThresholdEpoch)
|
||||
}
|
||||
} else if minHeight >= 0 && maxHeight >= 0 {
|
||||
if minHeight > maxHeight {
|
||||
return nil, xerrors.Errorf("invalid epoch range: to block (%d) must be after from block (%d)", maxHeight, minHeight)
|
||||
} else if minHeight < e.FilterThresholdEpoch {
|
||||
return nil, xerrors.Errorf("invalid epoch range: from block (%d) is below the set FilterThresholdEpoch (%d)", minHeight, e.FilterThresholdEpoch)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if minHeight == -1 && maxHeight > 0 {
|
||||
// Here the client is looking for events between the head and some future height
|
||||
ts := e.Chain.GetHeaviestTipSet()
|
||||
if maxHeight < ts.Height() {
|
||||
return nil, xerrors.Errorf("invalid epoch range: to block (%d) must be after from block (%d)", maxHeight, ts.Height())
|
||||
}
|
||||
if maxHeight-ts.Height() > e.MaxFilterHeightRange {
|
||||
return nil, xerrors.Errorf("invalid epoch range: to block is too far in the future (maximum: %d)", e.MaxFilterHeightRange)
|
||||
}
|
||||
} else if minHeight >= 0 && maxHeight == -1 {
|
||||
// Here the client is looking for events between some time in the past and the current head
|
||||
ts := e.Chain.GetHeaviestTipSet()
|
||||
if ts.Height()-minHeight > e.MaxFilterHeightRange {
|
||||
return nil, xerrors.Errorf("invalid epoch range: from block is too far in the past (maximum: %d)", e.MaxFilterHeightRange)
|
||||
}
|
||||
|
||||
} else if minHeight >= 0 && maxHeight >= 0 {
|
||||
if minHeight > maxHeight {
|
||||
return nil, xerrors.Errorf("invalid epoch range: to block (%d) must be after from block (%d)", minHeight, maxHeight)
|
||||
} else if maxHeight-minHeight > e.MaxFilterHeightRange {
|
||||
return nil, xerrors.Errorf("invalid epoch range: range between to and from blocks is too large (maximum: %d)", e.MaxFilterHeightRange)
|
||||
} else if minHeight >= 0 && maxHeight >= 0 {
|
||||
if minHeight > maxHeight {
|
||||
return nil, xerrors.Errorf("invalid epoch range: to block (%d) must be after from block (%d)", maxHeight, minHeight)
|
||||
} else if maxHeight-minHeight > e.MaxFilterHeightRange {
|
||||
return nil, xerrors.Errorf("invalid epoch range: range between to and from blocks is too large (maximum: %d)", e.MaxFilterHeightRange)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Convert all addresses to filecoin f4 addresses
|
||||
|
@ -40,6 +40,8 @@ func EthEventAPI(cfg config.FevmConfig) func(helpers.MetricsCtx, repo.LockedRepo
|
||||
ee := &full.EthEvent{
|
||||
Chain: cs,
|
||||
MaxFilterHeightRange: abi.ChainEpoch(cfg.Events.MaxFilterHeightRange),
|
||||
FilterThresholdSet: cfg.Events.FilterThresholdSet,
|
||||
FilterThresholdEpoch: abi.ChainEpoch(cfg.Events.FilterThresholdEpoch),
|
||||
SubscribtionCtx: ctx,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user