diff options
author | gary rong <garyrong0905@gmail.com> | 2018-07-24 22:22:03 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-07-24 22:22:03 +0800 |
commit | cab1cff11cbcd4ff60f1a149deb71ec87413b487 (patch) | |
tree | 2e7c89b0a541a03e23294d4b444892a9420cbc9c /core/vm/instructions.go | |
parent | 2909f6d7a2ceb5b1cdeb4cc3966531018a0b8334 (diff) | |
download | go-tangerine-cab1cff11cbcd4ff60f1a149deb71ec87413b487.tar.gz go-tangerine-cab1cff11cbcd4ff60f1a149deb71ec87413b487.tar.zst go-tangerine-cab1cff11cbcd4ff60f1a149deb71ec87413b487.zip |
core, crypto, params: implement CREATE2 evm instrction (#17196)
* core, crypto, params: implement CREATE2 evm instrction
* core/vm: add opcode to string mapping
* core: remove past fork checking
* core, crypto: use option2 to generate new address
Diffstat (limited to 'core/vm/instructions.go')
-rw-r--r-- | core/vm/instructions.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 1ec13ba35..b25c0111a 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -665,6 +665,34 @@ func opCreate(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *S return nil, nil } +func opCreate2(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { + var ( + endowment = stack.pop() + offset, size = stack.pop(), stack.pop() + salt = stack.pop() + input = memory.Get(offset.Int64(), size.Int64()) + gas = contract.Gas + ) + + // Apply EIP150 + gas -= gas / 64 + contract.UseGas(gas) + res, addr, returnGas, suberr := evm.Create2(contract, input, gas, endowment, salt) + // Push item on the stack based on the returned error. + if suberr != nil { + stack.push(evm.interpreter.intPool.getZero()) + } else { + stack.push(addr.Big()) + } + contract.Gas += returnGas + evm.interpreter.intPool.put(endowment, offset, size, salt) + + if suberr == errExecutionReverted { + return res, nil + } + return nil, nil +} + func opCall(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { // Pop gas. The actual gas in in evm.callGasTemp. evm.interpreter.intPool.put(stack.pop()) |