Skip to content

Commit 7e47af8

Browse files
committed
test: if call to debug_trace would produce a fatal but for bridge
1 parent 7ef9a7a commit 7e47af8

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

bridgesync/downloader.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
bridgetypes "github.com/agglayer/aggkit/bridgeservice/types"
1313
bridgesynctypes "github.com/agglayer/aggkit/bridgesync/types"
1414
"github.com/agglayer/aggkit/db"
15-
"github.com/agglayer/aggkit/log"
1615
logger "github.com/agglayer/aggkit/log"
1716
"github.com/agglayer/aggkit/sync"
1817
aggkittypes "github.com/agglayer/aggkit/types"
@@ -582,10 +581,14 @@ func findCall(rootCall Call, targetAddr common.Address, callback func(Call) (boo
582581
return nil, db.ErrNotFound
583582
}
584583

584+
var AllowDebugTraceCalls = true
585+
585586
// extractRootCall extracts the root call for a transaction using debug_traceTransaction.
586587
func extractRootCall(client aggkittypes.RPCClienter, contractAddr common.Address, txHash common.Hash) (*Call, error) {
587588
rootCall := &Call{To: contractAddr}
588-
log.Warn("*** USE DEBUG_TRACE :extractRootCall: " + DebugTraceTxEndpoint)
589+
if !AllowDebugTraceCalls {
590+
logger.Fatal("*** USE DEBUG_TRACE :extractRootCall: " + DebugTraceTxEndpoint)
591+
}
589592
err := client.Call(rootCall, DebugTraceTxEndpoint, txHash, tracerCfg{Tracer: callTracerType})
590593
if err != nil {
591594
return nil, err

claimsync/downloader.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,14 @@ func findCall(rootCall Call,
430430
return nil, db.ErrNotFound
431431
}
432432

433+
var AllowDebugTraceCalls = true
434+
433435
// extractRootCall extracts the root call for a transaction using debug_traceTransaction.
434436
func extractRootCall(client aggkittypes.RPCClienter, contractAddr common.Address, txHash common.Hash) (*Call, error) {
435437
rootCall := &Call{To: contractAddr}
436-
log.Warn("*** USE DEBUG_TRACE :extractRootCall: " + DebugTraceTxEndpoint)
438+
if !AllowDebugTraceCalls {
439+
log.Fatal("*** USE DEBUG_TRACE :extractRootCall: " + DebugTraceTxEndpoint)
440+
}
437441
err := client.Call(rootCall, DebugTraceTxEndpoint, txHash, tracerCfg{Tracer: callTracerType})
438442
if err != nil {
439443
return nil, err

cmd/run.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ func start(cliCtx *cli.Context) error {
9090
prometheus.Init()
9191
}
9292
log.Debugf("Components to run: %v", components)
93+
isBridgeRunning := isNeeded([]string{aggkitcommon.BRIDGE}, components)
94+
bridgesync.AllowDebugTraceCalls = isBridgeRunning
95+
claimsync.AllowDebugTraceCalls = isBridgeRunning
96+
9397
l1Client := runL1ClientIfNeeded(cliCtx.Context, cfg.L1NetworkConfig.RPC)
9498
l2Client := runL2ClientIfNeeded(cliCtx.Context, components, cfg.Common.L2RPC)
9599
reorgDetectorL1, errChanL1 := runReorgDetectorL1IfNeeded(cliCtx.Context, components, l1Client, &cfg.ReorgDetectorL1)

0 commit comments

Comments
 (0)