Skip to content

Commit

Permalink
Merge branch 'develop' into c/integrate-tx-scrambler
Browse files Browse the repository at this point in the history
  • Loading branch information
cabrador authored Nov 14, 2024
2 parents ea87f9f + 189d3c2 commit 2f929d3
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
2 changes: 2 additions & 0 deletions cmd/sonicd/app/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ func initFlags() {
flags.RPCGlobalTimeoutFlag,
flags.BatchRequestLimit,
flags.BatchResponseMaxSize,
flags.MaxResponseSizeFlag,
flags.StructLogLimitFlag,
}

metricsFlags = []cli.Flag{
Expand Down
7 changes: 6 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ func gossipConfigWithFlags(ctx *cli.Context, src gossip.Config) gossip.Config {
if ctx.GlobalIsSet(flags.RPCGlobalTimeoutFlag.Name) {
cfg.RPCTimeout = ctx.GlobalDuration(flags.RPCGlobalTimeoutFlag.Name)
}

if ctx.GlobalIsSet(flags.MaxResponseSizeFlag.Name) {
cfg.MaxResponseSize = ctx.GlobalInt(flags.MaxResponseSizeFlag.Name)
}
if ctx.IsSet(flags.StructLogLimitFlag.Name) {
cfg.StructLogLimit = ctx.GlobalInt(flags.StructLogLimitFlag.Name)
}
return cfg
}

Expand Down
5 changes: 5 additions & 0 deletions config/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ var (
Usage: "Limit maximum size in some RPC calls execution",
Value: gossip.DefaultConfig(cachescale.Identity).MaxResponseSize,
}
StructLogLimitFlag = cli.IntFlag{
Name: "rpc.structloglimit",
Usage: "Limit maximum number of debug logs for structured EVM logs, 0=unlimited, negative value means no log results",
Value: gossip.DefaultConfig(cachescale.Identity).StructLogLimit,
}
ModeFlag = cli.StringFlag{
Name: "mode",
Usage: `Mode of the node ("rpc" or "validator")`,
Expand Down
18 changes: 16 additions & 2 deletions ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1923,12 +1923,17 @@ func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, sendArgs Transact
type PublicDebugAPI struct {
b Backend
maxResponseSize int // in bytes
structLogLimit int
}

// NewPublicDebugAPI creates a new API definition for the public debug methods
// of the Ethereum service.
func NewPublicDebugAPI(b Backend, maxResponseSize int) *PublicDebugAPI {
return &PublicDebugAPI{b: b, maxResponseSize: maxResponseSize}
func NewPublicDebugAPI(b Backend, maxResponseSize int, structLogLimit int) *PublicDebugAPI {
return &PublicDebugAPI{
b: b,
maxResponseSize: maxResponseSize,
structLogLimit: structLogLimit,
}
}

// GetBlockRlp retrieves the RLP encoded for of a single block.
Expand Down Expand Up @@ -2037,6 +2042,15 @@ func (api *PublicDebugAPI) traceTx(ctx context.Context, tx *types.Transaction, m
}
// Default tracer is the struct logger
if config.Tracer == nil {
if config.Config == nil {
config.Config = &logger.Config{Limit: api.structLogLimit}
} else {
if api.structLogLimit > 0 &&
(config.Config.Limit == 0 || config.Config.Limit > api.structLogLimit) {

config.Config.Limit = api.structLogLimit
}
}
logger := logger.NewStructLogger(config.Config)
tracer = &tracers.Tracer{
Hooks: logger.Hooks(),
Expand Down
4 changes: 4 additions & 0 deletions gossip/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ type (
// MaxResponseSize is a limit for maximum response size in some RPC calls in bytes
MaxResponseSize int

// StructLogLimit is a limit for maximum number of logs in structured EVM debug log
StructLogLimit int

RPCBlockExt bool
}

Expand Down Expand Up @@ -197,6 +200,7 @@ func DefaultConfig(scale cachescale.Func) Config {
RPCTimeout: 5 * time.Second,

MaxResponseSize: 25 * 1024 * 1024,
StructLogLimit: 2000,
}
sessionCfg := cfg.Protocol.DagStreamLeecher.Session
cfg.Protocol.DagProcessor.EventsBufferLimit.Num = idx.Event(sessionCfg.ParallelChunksDownload)*
Expand Down
2 changes: 1 addition & 1 deletion gossip/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func (s *Service) APIs() []rpc.API {
}, {
Namespace: "debug",
Version: "1.0",
Service: ethapi.NewPublicDebugAPI(s.EthAPI, s.config.MaxResponseSize),
Service: ethapi.NewPublicDebugAPI(s.EthAPI, s.config.MaxResponseSize, s.config.StructLogLimit),
Public: true,
}, {
Namespace: "trace",
Expand Down

0 comments on commit 2f929d3

Please sign in to comment.