mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
core/vm: opt opLog0
This commit is contained in:
parent
c3ef6c77c2
commit
173d286c78
3 changed files with 44 additions and 1 deletions
|
|
@ -920,6 +920,26 @@ func opSelfdestruct6780(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, erro
|
||||||
return nil, errStopToken
|
return nil, errStopToken
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func opLog0(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
|
if evm.readOnly {
|
||||||
|
return nil, ErrWriteProtection
|
||||||
|
}
|
||||||
|
stack := scope.Stack
|
||||||
|
mStart, mSize := stack.pop(), stack.pop()
|
||||||
|
|
||||||
|
d := scope.Memory.GetCopy(mStart.Uint64(), mSize.Uint64())
|
||||||
|
evm.StateDB.AddLog(&types.Log{
|
||||||
|
Address: scope.Contract.Address(),
|
||||||
|
Topics: nil,
|
||||||
|
Data: d,
|
||||||
|
// This is a non-consensus field, but assigned here because
|
||||||
|
// core/state doesn't know the current block number.
|
||||||
|
BlockNumber: evm.Context.BlockNumber.Uint64(),
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
// following functions are used by the instruction jump table
|
// following functions are used by the instruction jump table
|
||||||
|
|
||||||
// make log instruction function
|
// make log instruction function
|
||||||
|
|
|
||||||
|
|
@ -559,6 +559,29 @@ func BenchmarkOpMstore(bench *testing.B) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkOpLog0(bench *testing.B) {
|
||||||
|
var (
|
||||||
|
statedb, _ = state.New(types.EmptyRootHash, state.NewDatabaseForTesting())
|
||||||
|
evm = NewEVM(BlockContext{BlockNumber: big1}, statedb, params.TestChainConfig, Config{})
|
||||||
|
stack = newstack()
|
||||||
|
mem = NewMemory()
|
||||||
|
caller = common.Address{}
|
||||||
|
to = common.Address{1}
|
||||||
|
contract = NewContract(caller, to, new(uint256.Int), 0, nil)
|
||||||
|
)
|
||||||
|
mem.Resize(64)
|
||||||
|
pc := uint64(0)
|
||||||
|
memStart := new(uint256.Int)
|
||||||
|
size := new(uint256.Int).SetUint64(64)
|
||||||
|
|
||||||
|
bench.ResetTimer()
|
||||||
|
for i := 0; i < bench.N; i++ {
|
||||||
|
stack.push(size)
|
||||||
|
stack.push(memStart)
|
||||||
|
_, _ = opLog0(&pc, evm, &ScopeContext{mem, stack, contract})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestOpTstore(t *testing.T) {
|
func TestOpTstore(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
statedb, _ = state.New(types.EmptyRootHash, state.NewDatabaseForTesting())
|
statedb, _ = state.New(types.EmptyRootHash, state.NewDatabaseForTesting())
|
||||||
|
|
|
||||||
|
|
@ -1005,7 +1005,7 @@ func newFrontierInstructionSet() JumpTable {
|
||||||
maxStack: maxSwapStack(17),
|
maxStack: maxSwapStack(17),
|
||||||
},
|
},
|
||||||
LOG0: {
|
LOG0: {
|
||||||
execute: makeLog(0),
|
execute: opLog0,
|
||||||
dynamicGas: makeGasLog(0),
|
dynamicGas: makeGasLog(0),
|
||||||
minStack: minStack(2, 0),
|
minStack: minStack(2, 0),
|
||||||
maxStack: maxStack(2, 0),
|
maxStack: maxStack(2, 0),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue