mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
Merge pull request #126 from maticnetwork/denis/disable-bor-logs
chg: option to disable bor logs
This commit is contained in:
commit
b793af2896
6 changed files with 34 additions and 11 deletions
|
|
@ -55,6 +55,7 @@ var (
|
||||||
app = flags.NewApp(gitCommit, gitDate, fmt.Sprintf("the %s command line interface", repositoryIdentifier))
|
app = flags.NewApp(gitCommit, gitDate, fmt.Sprintf("the %s command line interface", repositoryIdentifier))
|
||||||
// flags that configure the node
|
// flags that configure the node
|
||||||
nodeFlags = []cli.Flag{
|
nodeFlags = []cli.Flag{
|
||||||
|
utils.BorLogsFlag,
|
||||||
utils.IdentityFlag,
|
utils.IdentityFlag,
|
||||||
utils.UnlockedAccountFlag,
|
utils.UnlockedAccountFlag,
|
||||||
utils.PasswordFileFlag,
|
utils.PasswordFileFlag,
|
||||||
|
|
|
||||||
|
|
@ -373,6 +373,10 @@ var (
|
||||||
Value: ethconfig.Defaults.TxPool.Lifetime,
|
Value: ethconfig.Defaults.TxPool.Lifetime,
|
||||||
}
|
}
|
||||||
// Performance tuning settings
|
// Performance tuning settings
|
||||||
|
BorLogsFlag = cli.BoolFlag{
|
||||||
|
Name: "bor.logs",
|
||||||
|
Usage: "Enable bor logs retrieval",
|
||||||
|
}
|
||||||
CacheFlag = cli.IntFlag{
|
CacheFlag = cli.IntFlag{
|
||||||
Name: "cache",
|
Name: "cache",
|
||||||
Usage: "Megabytes of memory allocated to internal caching (default = 4096 mainnet full node, 128 light mode)",
|
Usage: "Megabytes of memory allocated to internal caching (default = 4096 mainnet full node, 128 light mode)",
|
||||||
|
|
@ -1482,7 +1486,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
||||||
setWhitelist(ctx, cfg)
|
setWhitelist(ctx, cfg)
|
||||||
setLes(ctx, cfg)
|
setLes(ctx, cfg)
|
||||||
|
|
||||||
// Cap the cache allowance and tune the garbage collector
|
if ctx.GlobalIsSet(BorLogsFlag.Name) {
|
||||||
|
cfg.BorLogs = ctx.GlobalBool(BorLogsFlag.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cap the cache allowance and tune the garbage collector
|
||||||
mem, err := gopsutil.VirtualMemory()
|
mem, err := gopsutil.VirtualMemory()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if 32<<(^uintptr(0)>>63) == 32 && mem.Total > 2*1024*1024*1024 {
|
if 32<<(^uintptr(0)>>63) == 32 && mem.Total > 2*1024*1024*1024 {
|
||||||
|
|
|
||||||
|
|
@ -310,7 +310,7 @@ func (s *Ethereum) APIs() []rpc.API {
|
||||||
|
|
||||||
// BOR change starts
|
// BOR change starts
|
||||||
// set genesis to public filter api
|
// set genesis to public filter api
|
||||||
publicFilterAPI := filters.NewPublicFilterAPI(s.APIBackend, false, 5*time.Minute)
|
publicFilterAPI := filters.NewPublicFilterAPI(s.APIBackend, false, 5*time.Minute, s.config.BorLogs)
|
||||||
// avoiding constructor changed by introducing new method to set genesis
|
// avoiding constructor changed by introducing new method to set genesis
|
||||||
publicFilterAPI.SetChainConfig(s.blockchain.Config())
|
publicFilterAPI.SetChainConfig(s.blockchain.Config())
|
||||||
// BOR change ends
|
// BOR change ends
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,9 @@ type Config struct {
|
||||||
|
|
||||||
// Berlin block override (TODO: remove after the fork)
|
// Berlin block override (TODO: remove after the fork)
|
||||||
OverrideBerlin *big.Int `toml:",omitempty"`
|
OverrideBerlin *big.Int `toml:",omitempty"`
|
||||||
|
|
||||||
|
// Bor logs flag
|
||||||
|
BorLogs bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateConsensusEngine creates a consensus engine for the given chain configuration.
|
// CreateConsensusEngine creates a consensus engine for the given chain configuration.
|
||||||
|
|
|
||||||
|
|
@ -57,18 +57,20 @@ type PublicFilterAPI struct {
|
||||||
filtersMu sync.Mutex
|
filtersMu sync.Mutex
|
||||||
filters map[rpc.ID]*filter
|
filters map[rpc.ID]*filter
|
||||||
timeout time.Duration
|
timeout time.Duration
|
||||||
|
borLogs bool
|
||||||
|
|
||||||
chainConfig *params.ChainConfig
|
chainConfig *params.ChainConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPublicFilterAPI returns a new PublicFilterAPI instance.
|
// NewPublicFilterAPI returns a new PublicFilterAPI instance.
|
||||||
func NewPublicFilterAPI(backend Backend, lightMode bool, timeout time.Duration) *PublicFilterAPI {
|
func NewPublicFilterAPI(backend Backend, lightMode bool, timeout time.Duration, borLogs bool) *PublicFilterAPI {
|
||||||
api := &PublicFilterAPI{
|
api := &PublicFilterAPI{
|
||||||
backend: backend,
|
backend: backend,
|
||||||
chainDb: backend.ChainDb(),
|
chainDb: backend.ChainDb(),
|
||||||
events: NewEventSystem(backend, lightMode),
|
events: NewEventSystem(backend, lightMode),
|
||||||
filters: make(map[rpc.ID]*filter),
|
filters: make(map[rpc.ID]*filter),
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
|
borLogs: borLogs,
|
||||||
}
|
}
|
||||||
go api.timeoutLoop(timeout)
|
go api.timeoutLoop(timeout)
|
||||||
|
|
||||||
|
|
@ -347,7 +349,9 @@ func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([
|
||||||
// Block filter requested, construct a single-shot filter
|
// Block filter requested, construct a single-shot filter
|
||||||
filter = NewBlockFilter(api.backend, *crit.BlockHash, crit.Addresses, crit.Topics)
|
filter = NewBlockFilter(api.backend, *crit.BlockHash, crit.Addresses, crit.Topics)
|
||||||
// Block bor filter
|
// Block bor filter
|
||||||
borLogsFilter = NewBorBlockLogsFilter(api.backend, sprint, *crit.BlockHash, crit.Addresses, crit.Topics)
|
if api.borLogs {
|
||||||
|
borLogsFilter = NewBorBlockLogsFilter(api.backend, sprint, *crit.BlockHash, crit.Addresses, crit.Topics)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Convert the RPC block numbers into internal representations
|
// Convert the RPC block numbers into internal representations
|
||||||
begin := rpc.LatestBlockNumber.Int64()
|
begin := rpc.LatestBlockNumber.Int64()
|
||||||
|
|
@ -361,7 +365,9 @@ func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([
|
||||||
// Construct the range filter
|
// Construct the range filter
|
||||||
filter = NewRangeFilter(api.backend, begin, end, crit.Addresses, crit.Topics)
|
filter = NewRangeFilter(api.backend, begin, end, crit.Addresses, crit.Topics)
|
||||||
// Block bor filter
|
// Block bor filter
|
||||||
borLogsFilter = NewBorBlockLogsRangeFilter(api.backend, sprint, begin, end, crit.Addresses, crit.Topics)
|
if api.borLogs {
|
||||||
|
borLogsFilter = NewBorBlockLogsRangeFilter(api.backend, sprint, begin, end, crit.Addresses, crit.Topics)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the filter and return all the logs
|
// Run the filter and return all the logs
|
||||||
|
|
@ -369,14 +375,19 @@ func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Run the filter and return all the logs
|
|
||||||
borBlockLogs, err := borLogsFilter.Logs(ctx)
|
if borLogsFilter != nil {
|
||||||
if err != nil {
|
// Run the filter and return all the logs
|
||||||
return nil, err
|
borBlockLogs, err := borLogsFilter.Logs(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnLogs(types.MergeBorLogs(logs, borBlockLogs)), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// merge bor block logs and receipt logs and return it
|
// merge bor block logs and receipt logs and return it
|
||||||
return returnLogs(types.MergeBorLogs(logs, borBlockLogs)), err
|
return returnLogs(logs), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// UninstallFilter removes the filter with the given filter id.
|
// UninstallFilter removes the filter with the given filter id.
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,7 @@ func (s *LightEthereum) APIs() []rpc.API {
|
||||||
}, {
|
}, {
|
||||||
Namespace: "eth",
|
Namespace: "eth",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Service: filters.NewPublicFilterAPI(s.ApiBackend, true, 5*time.Minute),
|
Service: filters.NewPublicFilterAPI(s.ApiBackend, true, 5*time.Minute, false),
|
||||||
Public: true,
|
Public: true,
|
||||||
}, {
|
}, {
|
||||||
Namespace: "net",
|
Namespace: "net",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue