Skip to content

Commit

Permalink
create 2 allocation (#1325)
Browse files Browse the repository at this point in the history
  • Loading branch information
hexoscott authored Oct 15, 2024
1 parent 62a81b1 commit 0214dab
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion core/vm/instructions_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,19 @@ func opCreate2_zkevm_lastOpCode(pc *uint64, interpreter *EVMInterpreter, scope *
endowment = scope.Stack.Pop()
offset, size = scope.Stack.Pop(), scope.Stack.Pop()
salt = scope.Stack.Pop()
input = scope.Memory.GetCopy(int64(offset.Uint64()), int64(size.Uint64()))
)

if size.Uint64() > params.MaxInitCodeSize {
// if we are over the maximum size this instruction is invalid and we could be open
// to trying to allocate too much memory causing a panic. Because the address never
// actually gets created in this insance because of out of gas we can just spam
// a random address by cutting the size down to maximum
newSize := uint256.NewInt(params.MaxInitCodeSize)
size = *newSize
}

input := scope.Memory.GetCopy(int64(offset.Uint64()), int64(size.Uint64()))

caller := scope.Contract
codeAndHash := &codeAndHash{code: input}
address := crypto.CreateAddress2(caller.Address(), salt.Bytes32(), codeAndHash.Hash().Bytes())
Expand Down

0 comments on commit 0214dab

Please sign in to comment.