Skip to content
Open
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
4 changes: 2 additions & 2 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ func opCreate(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
var (
value = scope.Stack.pop()
offset, size = scope.Stack.pop(), scope.Stack.pop()
input = scope.Memory.GetCopy(offset.Uint64(), size.Uint64())
input = scope.Memory.GetPtr(offset.Uint64(), size.Uint64())
gas = scope.Contract.Gas
)
if evm.chainRules.IsEIP150 {
Expand Down Expand Up @@ -703,7 +703,7 @@ func opCreate2(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
endowment = scope.Stack.pop()
offset, size = scope.Stack.pop(), scope.Stack.pop()
salt = scope.Stack.pop()
input = scope.Memory.GetCopy(offset.Uint64(), size.Uint64())
input = scope.Memory.GetPtr(offset.Uint64(), size.Uint64())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By changing to the GetPtr, the same byte slice will be referenced/used in two call frames: one in the contract creation and another is the caller frame.

It might introduce some unexpected edge cases where the slice mutations from one side affect another side. It feels a very dangerous change to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. in ethereum white paper mention that "code is theoretically immutable".
  2. "By changing to the GetPtr, the same byte slice will be referenced/used in two call frames: one in the contract creation and another is the caller frame.

It might introduce some unexpected edge cases where the slice mutations from one side affect another side. "
this is same to opcall. but op call already change to GetPtr!.
3. as in this pr. "I'm not 100% sure we need it, but Create/Create2 holds on to that code, and stores it in a struct for later processing. I didn't consider it safe to change that now", actually, Not only code(input) is stores in struct for later processing, but also the opCall input. GetPtr is call here. and assign to contract.Input here. Which is next next to Code field in contract here.

May ask @holiman and @fjl and @karalabe to help with us.

gas = scope.Contract.Gas
)

Expand Down