aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/logger.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2017-01-05 18:52:10 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-01-05 18:52:10 +0800
commitbbc4ea4ae8e8a962deae3d5693d9d4a9376eab88 (patch)
treed4743eaa073d1bc7788f5d4fc3771da37f3cb0b5 /core/vm/logger.go
parent2126d8148806b6d8597d6a1c761080e9dc98d745 (diff)
downloadgo-tangerine-bbc4ea4ae8e8a962deae3d5693d9d4a9376eab88.tar.gz
go-tangerine-bbc4ea4ae8e8a962deae3d5693d9d4a9376eab88.tar.zst
go-tangerine-bbc4ea4ae8e8a962deae3d5693d9d4a9376eab88.zip
core/vm: improved EVM run loop & instruction calling (#3378)
The run loop, which previously contained custom opcode executes have been removed and has been simplified to a few checks. Each operation consists of 4 elements: execution function, gas cost function, stack validation function and memory size function. The execution function implements the operation's runtime behaviour, the gas cost function implements the operation gas costs function and greatly depends on the memory and stack, the stack validation function validates the stack and makes sure that enough items can be popped off and pushed on and the memory size function calculates the memory required for the operation and returns it. This commit also allows the EVM to go unmetered. This is helpful for offline operations such as contract calls.
Diffstat (limited to 'core/vm/logger.go')
-rw-r--r--core/vm/logger.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/vm/logger.go b/core/vm/logger.go
index 6a605a59c..db8c20e07 100644
--- a/core/vm/logger.go
+++ b/core/vm/logger.go
@@ -45,7 +45,7 @@ type LogConfig struct {
Limit int // maximum length of output, but zero means unlimited
}
-// StructLog is emitted to the Environment each cycle and lists information about the current internal state
+// StructLog is emitted to the EVM each cycle and lists information about the current internal state
// prior to the execution of the statement.
type StructLog struct {
Pc uint64
@@ -65,7 +65,7 @@ type StructLog struct {
// Note that reference types are actual VM data structures; make copies
// if you need to retain them beyond the current call.
type Tracer interface {
- CaptureState(env *Environment, pc uint64, op OpCode, gas, cost *big.Int, memory *Memory, stack *Stack, contract *Contract, depth int, err error) error
+ CaptureState(env *EVM, pc uint64, op OpCode, gas, cost *big.Int, memory *Memory, stack *Stack, contract *Contract, depth int, err error) error
}
// StructLogger is an EVM state logger and implements Tracer.
@@ -94,10 +94,10 @@ func NewStructLogger(cfg *LogConfig) *StructLogger {
// captureState logs a new structured log message and pushes it out to the environment
//
// captureState also tracks SSTORE ops to track dirty values.
-func (l *StructLogger) CaptureState(env *Environment, pc uint64, op OpCode, gas, cost *big.Int, memory *Memory, stack *Stack, contract *Contract, depth int, err error) error {
+func (l *StructLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost *big.Int, memory *Memory, stack *Stack, contract *Contract, depth int, err error) error {
// check if already accumulated the specified number of logs
if l.cfg.Limit != 0 && l.cfg.Limit <= len(l.logs) {
- return TraceLimitReachedError
+ return ErrTraceLimitReached
}
// initialise new changed values storage container for this contract
@@ -155,7 +155,7 @@ func (l *StructLogger) CaptureState(env *Environment, pc uint64, op OpCode, gas,
}
}
// create a new snaptshot of the EVM.
- log := StructLog{pc, op, new(big.Int).Set(gas), cost, mem, stck, storage, env.Depth, err}
+ log := StructLog{pc, op, new(big.Int).Set(gas), cost, mem, stck, storage, env.depth, err}
l.logs = append(l.logs, log)
return nil