From 5566481bc174e2bf4219d5399e04f2dffb467a16 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Thu, 21 Sep 2023 16:02:45 +0300 Subject: [PATCH] Blockchain's vmCtx should always be updated to point to the latest Header --- emulator/blockchain.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/emulator/blockchain.go b/emulator/blockchain.go index c3a05696..c7c48ccd 100644 --- a/emulator/blockchain.go +++ b/emulator/blockchain.go @@ -791,10 +791,12 @@ func configureTransactionValidator(conf config, blocks *blocks) *access.Transact } func (b *Blockchain) newFVMContextFromHeader(header *flowgo.Header) fvm.Context { - return fvm.NewContextFromParent( + b.vmCtx = fvm.NewContextFromParent( b.vmCtx, fvm.WithBlockHeader(header), ) + + return b.vmCtx } func (b *Blockchain) CurrentScript() (string, string) { @@ -1421,8 +1423,10 @@ func (b *Blockchain) executeScriptAtBlockID(script []byte, arguments [][]byte, i return nil, err } - header := requestedBlock.Header - blockContext := b.newFVMContextFromHeader(header) + blockContext := fvm.NewContextFromParent( + b.vmCtx, + fvm.WithBlockHeader(requestedBlock.Header), + ) scriptProc := fvm.Script(script).WithArguments(arguments...) b.currentCode = string(script)