Merge branch 'release/v1.20.0' into iand/issue-9849-filters
This commit is contained in:
@@ -259,9 +259,10 @@ 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))),
|
||||
ApplyIf(isFullNode, Override(new(full.EthEventAPI), modules.EthEventAPI(cfg.Fevm))),
|
||||
|
||||
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{})),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -99,17 +99,17 @@ 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
|
||||
},
|
||||
Fevm: FevmConfig{
|
||||
EnableEthHashToFilecoinCidMapping: false,
|
||||
EthTxHashMappingLifetimeDays: 0,
|
||||
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
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
+62
-59
@@ -29,56 +29,6 @@ var Doc = map[string][]DocField{
|
||||
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{
|
||||
{
|
||||
Name: "DisableMetadataLog",
|
||||
@@ -391,6 +341,59 @@ see https://lotus.filecoin.io/storage-providers/advanced-configurations/market/#
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"Events": []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{
|
||||
{
|
||||
Name: "DefaultMaxFee",
|
||||
@@ -401,11 +404,11 @@ see https://lotus.filecoin.io/storage-providers/advanced-configurations/market/#
|
||||
},
|
||||
"FevmConfig": []DocField{
|
||||
{
|
||||
Name: "EnableEthHashToFilecoinCidMapping",
|
||||
Name: "EnableEthRPC",
|
||||
Type: "bool",
|
||||
|
||||
Comment: `EnableEthHashToFilecoinCidMapping enables storing a mapping of eth transaction hashes to filecoin message Cids
|
||||
You will not be able to look up ethereum transactions by their hash if this is disabled.`,
|
||||
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",
|
||||
@@ -414,6 +417,12 @@ You will not be able to look up ethereum transactions by their hash if this is d
|
||||
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`,
|
||||
},
|
||||
{
|
||||
Name: "Events",
|
||||
Type: "Events",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
},
|
||||
"FullNode": []DocField{
|
||||
{
|
||||
@@ -446,12 +455,6 @@ Set to 0 to keep all mappings`,
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "ActorEvent",
|
||||
Type: "ActorEventConfig",
|
||||
|
||||
Comment: ``,
|
||||
},
|
||||
{
|
||||
Name: "Fevm",
|
||||
Type: "FevmConfig",
|
||||
|
||||
+23
-18
@@ -27,7 +27,6 @@ type FullNode struct {
|
||||
Fees FeeConfig
|
||||
Chainstore Chainstore
|
||||
Cluster UserRaftConfig
|
||||
ActorEvent ActorEventConfig
|
||||
Fevm FevmConfig
|
||||
}
|
||||
|
||||
@@ -660,13 +659,28 @@ 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 FevmConfig struct {
|
||||
// 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.
|
||||
EnableEthRPC bool
|
||||
|
||||
// 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.
|
||||
EnableHistoricFilterAPI 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
|
||||
|
||||
Events Events
|
||||
}
|
||||
|
||||
type Events 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
|
||||
// this time become eligible for automatic deletion.
|
||||
@@ -682,23 +696,14 @@ type ActorEventConfig struct {
|
||||
// the entire chain)
|
||||
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
|
||||
// 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).
|
||||
ActorEventDatabasePath string
|
||||
DatabasePath string
|
||||
|
||||
// Others, not implemented yet:
|
||||
// Set a limit on the number of active websocket subscriptions (may be zero)
|
||||
// Set a timeout for subscription clients
|
||||
// Set upper bound on index size
|
||||
}
|
||||
|
||||
type FevmConfig struct {
|
||||
// EnableEthHashToFilecoinCidMapping enables storing a mapping of eth transaction hashes to filecoin message Cids
|
||||
// You will not be able to look up ethereum transactions by their hash if this is disabled.
|
||||
EnableEthHashToFilecoinCidMapping 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
|
||||
}
|
||||
|
||||
+37
-25
@@ -4,106 +4,118 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
||||
)
|
||||
|
||||
var ErrImplementMe = errors.New("Not implemented yet")
|
||||
var ErrModuleDisabled = errors.New("module disabled, enable with Fevm.EnableEthRPC / LOTUS_FEVM_ENABLEETHPRC")
|
||||
|
||||
type EthModuleDummy struct{}
|
||||
|
||||
func (e *EthModuleDummy) EthGetMessageCidByTransactionHash(ctx context.Context, txHash *ethtypes.EthHash) (*cid.Cid, error) {
|
||||
return nil, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthGetTransactionHashByCid(ctx context.Context, cid cid.Cid) (*ethtypes.EthHash, error) {
|
||||
return nil, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthBlockNumber(ctx context.Context) (ethtypes.EthUint64, error) {
|
||||
return 0, ErrImplementMe
|
||||
return 0, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthAccounts(ctx context.Context) ([]ethtypes.EthAddress, error) {
|
||||
return nil, ErrImplementMe
|
||||
return nil, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum ethtypes.EthUint64) (ethtypes.EthUint64, error) {
|
||||
return 0, ErrImplementMe
|
||||
return 0, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthGetBlockTransactionCountByHash(ctx context.Context, blkHash ethtypes.EthHash) (ethtypes.EthUint64, error) {
|
||||
return 0, ErrImplementMe
|
||||
return 0, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error) {
|
||||
return ethtypes.EthBlock{}, ErrImplementMe
|
||||
return ethtypes.EthBlock{}, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (ethtypes.EthBlock, error) {
|
||||
return ethtypes.EthBlock{}, ErrImplementMe
|
||||
return ethtypes.EthBlock{}, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*ethtypes.EthTx, error) {
|
||||
return nil, ErrImplementMe
|
||||
return nil, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthGetTransactionCount(ctx context.Context, sender ethtypes.EthAddress, blkOpt string) (ethtypes.EthUint64, error) {
|
||||
return 0, ErrImplementMe
|
||||
return 0, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*api.EthTxReceipt, error) {
|
||||
return nil, ErrImplementMe
|
||||
return nil, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) {
|
||||
return ethtypes.EthTx{}, ErrImplementMe
|
||||
return ethtypes.EthTx{}, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) {
|
||||
return ethtypes.EthTx{}, ErrImplementMe
|
||||
return ethtypes.EthTx{}, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthGetCode(ctx context.Context, address ethtypes.EthAddress, blkOpt string) (ethtypes.EthBytes, error) {
|
||||
return nil, ErrImplementMe
|
||||
return nil, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthGetStorageAt(ctx context.Context, address ethtypes.EthAddress, position ethtypes.EthBytes, blkParam string) (ethtypes.EthBytes, error) {
|
||||
return nil, ErrImplementMe
|
||||
return nil, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthGetBalance(ctx context.Context, address ethtypes.EthAddress, blkParam string) (ethtypes.EthBigInt, error) {
|
||||
return ethtypes.EthBigIntZero, ErrImplementMe
|
||||
return ethtypes.EthBigIntZero, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthFeeHistory(ctx context.Context, blkCount ethtypes.EthUint64, newestBlk string, rewardPercentiles []float64) (ethtypes.EthFeeHistory, error) {
|
||||
return ethtypes.EthFeeHistory{}, ErrImplementMe
|
||||
return ethtypes.EthFeeHistory{}, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthChainId(ctx context.Context) (ethtypes.EthUint64, error) {
|
||||
return 0, ErrImplementMe
|
||||
return 0, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) NetVersion(ctx context.Context) (string, error) {
|
||||
return "", ErrImplementMe
|
||||
return "", ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) NetListening(ctx context.Context) (bool, error) {
|
||||
return false, ErrImplementMe
|
||||
return false, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthProtocolVersion(ctx context.Context) (ethtypes.EthUint64, error) {
|
||||
return 0, ErrImplementMe
|
||||
return 0, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthGasPrice(ctx context.Context) (ethtypes.EthBigInt, error) {
|
||||
return ethtypes.EthBigIntZero, ErrImplementMe
|
||||
return ethtypes.EthBigIntZero, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthEstimateGas(ctx context.Context, tx ethtypes.EthCall) (ethtypes.EthUint64, error) {
|
||||
return 0, ErrImplementMe
|
||||
return 0, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthCall(ctx context.Context, tx ethtypes.EthCall, blkParam string) (ethtypes.EthBytes, error) {
|
||||
return nil, ErrImplementMe
|
||||
return nil, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthMaxPriorityFeePerGas(ctx context.Context) (ethtypes.EthBigInt, error) {
|
||||
return ethtypes.EthBigIntZero, ErrImplementMe
|
||||
return ethtypes.EthBigIntZero, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthSendRawTransaction(ctx context.Context, rawTx ethtypes.EthBytes) (ethtypes.EthHash, error) {
|
||||
return ethtypes.EthHash{}, ErrImplementMe
|
||||
return ethtypes.EthHash{}, ErrModuleDisabled
|
||||
}
|
||||
|
||||
var _ EthModuleAPI = &EthModuleDummy{}
|
||||
|
||||
+18
-27
@@ -257,14 +257,11 @@ func (a *EthModule) EthGetTransactionByHash(ctx context.Context, txHash *ethtype
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
c := cid.Undef
|
||||
if a.EthTxHashManager != nil {
|
||||
var err error
|
||||
c, err = a.EthTxHashManager.TransactionHashLookup.GetCidFromHash(*txHash)
|
||||
if err != nil {
|
||||
log.Debug("could not find transaction hash %s in lookup table", txHash.String())
|
||||
}
|
||||
c, err := a.EthTxHashManager.TransactionHashLookup.GetCidFromHash(*txHash)
|
||||
if err != nil {
|
||||
log.Debug("could not find transaction hash %s in lookup table", txHash.String())
|
||||
}
|
||||
|
||||
// This isn't an eth transaction we have the mapping for, so let's look it up as a filecoin message
|
||||
if c == cid.Undef {
|
||||
c = txHash.ToCid()
|
||||
@@ -306,25 +303,22 @@ func (a *EthModule) EthGetMessageCidByTransactionHash(ctx context.Context, txHas
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
c := cid.Undef
|
||||
if a.EthTxHashManager != nil {
|
||||
var err error
|
||||
c, err = a.EthTxHashManager.TransactionHashLookup.GetCidFromHash(*txHash)
|
||||
// We fall out of the first condition and continue
|
||||
if errors.Is(err, ethhashlookup.ErrNotFound) {
|
||||
log.Debug("could not find transaction hash %s in lookup table", txHash.String())
|
||||
} else if err != nil {
|
||||
return nil, xerrors.Errorf("database error: %w", err)
|
||||
} else {
|
||||
return &c, nil
|
||||
}
|
||||
c, err := a.EthTxHashManager.TransactionHashLookup.GetCidFromHash(*txHash)
|
||||
// We fall out of the first condition and continue
|
||||
if errors.Is(err, ethhashlookup.ErrNotFound) {
|
||||
log.Debug("could not find transaction hash %s in lookup table", txHash.String())
|
||||
} else if err != nil {
|
||||
return nil, xerrors.Errorf("database error: %w", err)
|
||||
} else {
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
// This isn't an eth transaction we have the mapping for, so let's try looking it up as a filecoin message
|
||||
if c == cid.Undef {
|
||||
c = txHash.ToCid()
|
||||
}
|
||||
|
||||
_, err := a.StateAPI.Chain.GetSignedMessage(ctx, c)
|
||||
_, err = a.StateAPI.Chain.GetSignedMessage(ctx, c)
|
||||
if err == nil {
|
||||
// This is an Eth Tx, Secp message, Or BLS message in the mpool
|
||||
return &c, nil
|
||||
@@ -369,14 +363,11 @@ func (a *EthModule) EthGetTransactionCount(ctx context.Context, sender ethtypes.
|
||||
}
|
||||
|
||||
func (a *EthModule) EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*api.EthTxReceipt, error) {
|
||||
c := cid.Undef
|
||||
if a.EthTxHashManager != nil {
|
||||
var err error
|
||||
c, err = a.EthTxHashManager.TransactionHashLookup.GetCidFromHash(txHash)
|
||||
if err != nil {
|
||||
log.Debug("could not find transaction hash %s in lookup table", txHash.String())
|
||||
}
|
||||
c, err := a.EthTxHashManager.TransactionHashLookup.GetCidFromHash(txHash)
|
||||
if err != nil {
|
||||
log.Debug("could not find transaction hash %s in lookup table", txHash.String())
|
||||
}
|
||||
|
||||
// This isn't an eth transaction we have the mapping for, so let's look it up as a filecoin message
|
||||
if c == cid.Undef {
|
||||
c = txHash.ToCid()
|
||||
|
||||
@@ -11,9 +11,11 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/crypto"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/chain/messagesigner"
|
||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/chain/wallet"
|
||||
"github.com/filecoin-project/lotus/chain/wallet/key"
|
||||
"github.com/filecoin-project/lotus/lib/sigs"
|
||||
)
|
||||
|
||||
@@ -51,12 +53,20 @@ func (a *WalletAPI) WalletSignMessage(ctx context.Context, k address.Address, ms
|
||||
return nil, xerrors.Errorf("failed to resolve ID address: %w", keyAddr)
|
||||
}
|
||||
|
||||
keyInfo, err := a.Wallet.WalletExport(ctx, k)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sb, err := messagesigner.SigningBytes(msg, key.ActSigType(keyInfo.Type))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mb, err := msg.ToStorageBlock()
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("serializing message: %w", err)
|
||||
}
|
||||
|
||||
sig, err := a.Wallet.WalletSign(ctx, keyAddr, mb.Cid().Bytes(), api.MsgMeta{
|
||||
sig, err := a.Wallet.WalletSign(ctx, keyAddr, sb, api.MsgMeta{
|
||||
Type: api.MTChainMsg,
|
||||
Extra: mb.RawData(),
|
||||
})
|
||||
|
||||
+24
-11
@@ -2,6 +2,7 @@ package modules
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/multiformats/go-varint"
|
||||
@@ -20,6 +21,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/config"
|
||||
"github.com/filecoin-project/lotus/node/impl/full"
|
||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
)
|
||||
|
||||
type EventAPI struct {
|
||||
@@ -31,16 +33,16 @@ type EventAPI struct {
|
||||
|
||||
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) {
|
||||
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) {
|
||||
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, 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)
|
||||
|
||||
ee := &full.EthEvent{
|
||||
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
|
||||
// the historic filter API relies on the real time one
|
||||
return ee, nil
|
||||
@@ -51,21 +53,32 @@ func EthEventAPI(cfg config.ActorEventConfig) func(helpers.MetricsCtx, fx.Lifecy
|
||||
StateAPI: stateapi,
|
||||
ChainAPI: chainapi,
|
||||
}
|
||||
ee.FilterStore = filter.NewMemFilterStore(cfg.MaxFilters)
|
||||
ee.FilterStore = filter.NewMemFilterStore(cfg.Events.MaxFilters)
|
||||
|
||||
// Start garbage collection for filters
|
||||
lc.Append(fx.Hook{
|
||||
OnStart: func(context.Context) error {
|
||||
go ee.GC(ctx, time.Duration(cfg.FilterTTL))
|
||||
go ee.GC(ctx, time.Duration(cfg.Events.FilterTTL))
|
||||
return nil
|
||||
},
|
||||
})
|
||||
|
||||
// Enable indexing of actor events
|
||||
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
|
||||
eventIndex, err = filter.NewEventIndex(cfg.ActorEventDatabasePath)
|
||||
eventIndex, err = filter.NewEventIndex(dbPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -103,13 +116,13 @@ func EthEventAPI(cfg config.ActorEventConfig) func(helpers.MetricsCtx, fx.Lifecy
|
||||
return *actor.Address, true
|
||||
},
|
||||
|
||||
MaxFilterResults: cfg.MaxFilterResults,
|
||||
MaxFilterResults: cfg.Events.MaxFilterResults,
|
||||
}
|
||||
ee.TipSetFilterManager = &filter.TipSetFilterManager{
|
||||
MaxFilterResults: cfg.MaxFilterResults,
|
||||
MaxFilterResults: cfg.Events.MaxFilterResults,
|
||||
}
|
||||
ee.MemPoolFilterManager = &filter.MemPoolFilterManager{
|
||||
MaxFilterResults: cfg.MaxFilterResults,
|
||||
MaxFilterResults: cfg.Events.MaxFilterResults,
|
||||
}
|
||||
|
||||
const ChainHeadConfidence = 1
|
||||
|
||||
+13
-19
@@ -19,26 +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) {
|
||||
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) {
|
||||
em := &full.EthModule{
|
||||
Chain: cs,
|
||||
Mpool: mp,
|
||||
StateManager: sm,
|
||||
ChainAPI: chainapi,
|
||||
MpoolAPI: mpoolapi,
|
||||
StateAPI: stateapi,
|
||||
}
|
||||
|
||||
if !cfg.EnableEthHashToFilecoinCidMapping {
|
||||
// mapping functionality disabled. Nothing to do here
|
||||
return em, nil
|
||||
}
|
||||
|
||||
dbPath, err := r.SqlitePath()
|
||||
sqlitePath, err := r.SqlitePath()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
transactionHashLookup, err := ethhashlookup.NewTransactionHashLookup(filepath.Join(dbPath, "txhash.db"))
|
||||
transactionHashLookup, err := ethhashlookup.NewTransactionHashLookup(filepath.Join(sqlitePath, "txhash.db"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -54,8 +40,6 @@ func EthModuleAPI(cfg config.FevmConfig) func(helpers.MetricsCtx, repo.LockedRep
|
||||
TransactionHashLookup: transactionHashLookup,
|
||||
}
|
||||
|
||||
em.EthTxHashManager = ðTxHashManager
|
||||
|
||||
const ChainHeadConfidence = 1
|
||||
|
||||
ctx := helpers.LifecycleCtx(mctx, lc)
|
||||
@@ -80,6 +64,16 @@ func EthModuleAPI(cfg config.FevmConfig) func(helpers.MetricsCtx, repo.LockedRep
|
||||
},
|
||||
})
|
||||
|
||||
return em, nil
|
||||
return &full.EthModule{
|
||||
Chain: cs,
|
||||
Mpool: mp,
|
||||
StateManager: sm,
|
||||
|
||||
ChainAPI: chainapi,
|
||||
MpoolAPI: mpoolapi,
|
||||
StateAPI: stateapi,
|
||||
|
||||
EthTxHashManager: ðTxHashManager,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user