From 48f0d1caeefc0fb0d88d019748a02079c5a17abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Bebi=C4=87=E2=80=AE?= Date: Mon, 9 Sep 2024 10:27:32 +0200 Subject: [PATCH] Pass address in `Database.ContractCode()` --- arbos/programs/programs.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/arbos/programs/programs.go b/arbos/programs/programs.go index 12102bac84..d6f15612b7 100644 --- a/arbos/programs/programs.go +++ b/arbos/programs/programs.go @@ -425,15 +425,17 @@ func (p Programs) SetProgramCached( if err != nil { return err } - if cache { - // Not passing in an address is supported pre-Verkle, as in Blockchain's ContractCodeWithPrefix method. - code, err := db.Database().ContractCode(common.Address{}, codeHash) - if err != nil { - return err + if address != (common.Address{}) { + if cache { + // Not passing in an address is supported pre-Verkle, as in Blockchain's ContractCodeWithPrefix method. + code, err := db.Database().ContractCode(address, codeHash) + if err != nil { + return err + } + cacheProgram(db, moduleHash, program, address, code, codeHash, params, debug, time, runMode) + } else { + evictProgram(db, moduleHash, program.version, debug, runMode, expired) } - cacheProgram(db, moduleHash, program, address, code, codeHash, params, debug, time, runMode) - } else { - evictProgram(db, moduleHash, program.version, debug, runMode, expired) } program.cached = cache return p.setProgram(codeHash, program)