Skip to content

Commit

Permalink
fix: proper number of chunk evals (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
gballet authored Jun 29, 2023
1 parent e8ace55 commit 0a7efe1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/utils"
"github.com/gballet/go-verkle"
"github.com/holiman/uint256"
)

Expand Down Expand Up @@ -177,15 +178,15 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
if in.evm.ChainConfig().IsCancun(in.evm.Context.BlockNumber) && !contract.IsDeployment {
contract.Chunks = trie.ChunkifyCode(contract.Code)

totalEvals := len(contract.Code) / 31 / 256
if len(contract.Code)%(256*31) != 0 {
totalEvals += 1
}
// number of extra stems to evaluate after the header stem
extraEvals := (len(contract.Chunks) + 127) / verkle.NodeWidth

chunkEvals = make([][]byte, totalEvals)
for i := 0; i < totalEvals; i++ {
chunkEvals = make([][]byte, extraEvals+1)
for i := 1; i < extraEvals+1; i++ {
chunkEvals[i] = utils.GetTreeKeyCodeChunkWithEvaluatedAddress(contract.AddressPoint(), uint256.NewInt(uint64(i)*256))
}
// Header account is already known, it's the header account
chunkEvals[0] = utils.GetTreeKeyVersionWithEvaluatedAddress(contract.AddressPoint())
}

// The Interpreter main run loop (contextual). This loop runs until either an
Expand Down

0 comments on commit 0a7efe1

Please sign in to comment.