From f271a2933a010482b4a4b6c19f2c1c116f0fba59 Mon Sep 17 00:00:00 2001 From: phrwlk Date: Thu, 1 Jan 2026 22:30:53 +0200 Subject: [PATCH 1/2] core/vm/runtime: don't overwrite user-provided Random --- core/vm/runtime/runtime.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index b40e99d047..af394aa054 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -109,7 +109,9 @@ func setDefaults(cfg *Config) { if cfg.BlobBaseFee == nil { cfg.BlobBaseFee = big.NewInt(params.BlobTxMinBlobGasprice) } - cfg.Random = &(common.Hash{}) + if cfg.Random == nil { + cfg.Random = new(common.Hash) + } } // Execute executes the code using the input as call data during the execution. From b8ff52c729be10a31abfdd7fcfd70daf6af8eb69 Mon Sep 17 00:00:00 2001 From: phrwlk Date: Thu, 1 Jan 2026 22:31:40 +0200 Subject: [PATCH 2/2] core/vm/runtime: add test --- core/vm/runtime/runtime_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/vm/runtime/runtime_test.go b/core/vm/runtime/runtime_test.go index a001d81623..40fb770454 100644 --- a/core/vm/runtime/runtime_test.go +++ b/core/vm/runtime/runtime_test.go @@ -65,6 +65,21 @@ func TestDefaults(t *testing.T) { if cfg.BlockNumber == nil { t.Error("expected block number to be non nil") } + if cfg.Random == nil { + t.Error("expected Random to be non nil") + } +} + +func TestDefaultsPreserveRandom(t *testing.T) { + h := common.HexToHash("0x01") + cfg := &Config{Random: &h} + setDefaults(cfg) + if cfg.Random == nil { + t.Fatal("expected Random to remain non-nil") + } + if *cfg.Random != h { + t.Fatalf("expected Random to be preserved, got %x, want %x", *cfg.Random, h) + } } func TestEVM(t *testing.T) {