Skip to content

Commit

Permalink
Blockchain's vmCtx should always be updated to point to the latest He…
Browse files Browse the repository at this point in the history
…ader
  • Loading branch information
m-Peter committed Sep 21, 2023
1 parent e300dd2 commit 5566481
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions emulator/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5566481

Please sign in to comment.