Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create 2 allocation #1325

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading