@@ -20,7 +20,6 @@ import (
2020 "github.com/ethereum/go-ethereum/common/hexutil"
2121 "github.com/ethereum/go-ethereum/core/types"
2222 "github.com/ethereum/go-ethereum/crypto"
23- "github.com/ethereum/go-ethereum/ethclient"
2423 "github.com/stretchr/testify/require"
2524 collpb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
2625 tracepb "go.opentelemetry.io/proto/otlp/trace/v1"
@@ -43,6 +42,7 @@ import (
4342func BenchmarkEvmContractRoundtrip (b * testing.B ) {
4443 workDir := b .TempDir ()
4544 sequencerHome := filepath .Join (workDir , "evm-bench-sequencer" )
45+ const blockTime = 5 * time .Millisecond
4646
4747 // Start an in-process OTLP/HTTP receiver to collect traces from ev-node.
4848 collector := newOTLPCollector (b )
@@ -54,6 +54,7 @@ func BenchmarkEvmContractRoundtrip(b *testing.B) {
5454 "--evnode.instrumentation.tracing_endpoint" , collector .endpoint (),
5555 "--evnode.instrumentation.tracing_sample_rate" , "1.0" ,
5656 "--evnode.instrumentation.tracing_service_name" , "ev-node-bench" ,
57+ "--evnode.node.block_time=" + blockTime .String (),
5758 )
5859 defer cleanup ()
5960
@@ -100,8 +101,11 @@ func BenchmarkEvmContractRoundtrip(b *testing.B) {
100101 err = client .SendTransaction (ctx , signedTxs [i ])
101102 require .NoError (b , err )
102103
103- // 2. Wait for inclusion.
104- waitForReceipt (b , ctx , client , signedTxs [i ].Hash ())
104+ // 2. Wait for inclusion with fast polling to reduce variance while avoiding RPC overload.
105+ require .Eventually (b , func () bool {
106+ receipt , err := client .TransactionReceipt (ctx , signedTxs [i ].Hash ())
107+ return err == nil && receipt != nil
108+ }, 2 * time .Second , blockTime / 2 , "transaction %s not included" , signedTxs [i ].Hash ().Hex ())
105109
106110 // 3. Retrieve and verify.
107111 result , err := client .CallContract (ctx , callMsg , nil )
@@ -221,15 +225,3 @@ func printCollectedTraceReport(b testing.TB, collector *otlpCollector) {
221225 }
222226 printTraceReport (b , "ev-node" , spans )
223227}
224-
225- // waitForReceipt polls for a transaction receipt until it is available.
226- func waitForReceipt (t testing.TB , ctx context.Context , client * ethclient.Client , txHash common.Hash ) * types.Receipt {
227- t .Helper ()
228- var receipt * types.Receipt
229- var err error
230- require .Eventually (t , func () bool {
231- receipt , err = client .TransactionReceipt (ctx , txHash )
232- return err == nil && receipt != nil
233- }, 2 * time .Second , 50 * time .Millisecond , "transaction %s not included" , txHash .Hex ())
234- return receipt
235- }
0 commit comments