Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions test/e2e/evm_contract_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/stretchr/testify/require"
collpb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
tracepb "go.opentelemetry.io/proto/otlp/trace/v1"
Expand All @@ -44,6 +43,7 @@ import (
func BenchmarkEvmContractRoundtrip(b *testing.B) {
workDir := b.TempDir()
sequencerHome := filepath.Join(workDir, "evm-bench-sequencer")
const blockTime = 5 * time.Millisecond
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

PR description says "10ms" but blockTime is set to 5ms.

The PR description states "Test with 10ms block time," but the constant is 5 * time.Millisecond. Please align the description (or the constant) to avoid confusion.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/e2e/evm_contract_bench_test.go` at line 46, The comment notes a mismatch
between the PR description ("10ms") and the test constant blockTime; update
either the PR description or the constant in evm_contract_bench_test.go so they
match—specifically change the constant named blockTime from 5 * time.Millisecond
to 10 * time.Millisecond if the test is intended to run at 10ms, or revise the
PR text to state 5ms if that is intended; ensure the symbol blockTime is the one
you modify so the code and description remain consistent.


// Start an in-process OTLP/HTTP receiver to collect traces from ev-node.
collector := newOTLPCollector(b)
Expand All @@ -55,6 +55,7 @@ func BenchmarkEvmContractRoundtrip(b *testing.B) {
"--evnode.instrumentation.tracing_endpoint", collector.endpoint(),
"--evnode.instrumentation.tracing_sample_rate", "1.0",
"--evnode.instrumentation.tracing_service_name", "ev-node-bench",
"--evnode.node.block_time="+blockTime.String(),
)
defer cleanup()

Expand Down Expand Up @@ -101,8 +102,11 @@ func BenchmarkEvmContractRoundtrip(b *testing.B) {
err = client.SendTransaction(ctx, signedTxs[i])
require.NoError(b, err)

// 2. Wait for inclusion.
waitForReceipt(b, ctx, client, signedTxs[i].Hash())
// 2. Wait for inclusion with fast polling to reduce variance while avoiding RPC overload.
require.Eventually(b, func() bool {
receipt, err := client.TransactionReceipt(ctx, signedTxs[i].Hash())
return err == nil && receipt != nil
}, 2*time.Second, blockTime/2, "transaction %s not included", signedTxs[i].Hash().Hex())

// 3. Retrieve and verify.
result, err := client.CallContract(ctx, callMsg, nil)
Expand Down Expand Up @@ -279,15 +283,3 @@ func printCollectedTraceReport(b testing.TB, collector *otlpCollector) {
b.Logf("%-40s %5.1f%% %s", name, pct, bar)
}
}

// waitForReceipt polls for a transaction receipt until it is available.
func waitForReceipt(t testing.TB, ctx context.Context, client *ethclient.Client, txHash common.Hash) *types.Receipt {
t.Helper()
var receipt *types.Receipt
var err error
require.Eventually(t, func() bool {
receipt, err = client.TransactionReceipt(ctx, txHash)
return err == nil && receipt != nil
}, 2*time.Second, 50*time.Millisecond, "transaction %s not included", txHash.Hex())
return receipt
}
Loading