Skip to content

Commit 482edd9

Browse files
committed
doc: comments on all exported identifiers
1 parent 7105d78 commit 482edd9

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

core/vm/jump_table.libevm.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package vm
22

33
import "github.com/ethereum/go-ethereum/params"
44

5+
// NewOperation constructs a new operation for inclusion in a [JumpTable].
56
func NewOperation(
67
execute func(pc *uint64, interpreter *EVMInterpreter, callContext *ScopeContext) ([]byte, error),
78
constantGas uint64,
@@ -18,12 +19,18 @@ func NewOperation(
1819
}
1920
}
2021

22+
// Hooks are arbitrary configuration functions to modify default VM behaviour.
2123
type Hooks interface {
24+
// OverrideJumpTable will only be called if
25+
// [params.RulesHooks.OverrideJumpTable] returns true. This allows for
26+
// recursive calling into [LookupInstructionSet].
2227
OverrideJumpTable(params.Rules, *JumpTable) *JumpTable
2328
}
2429

2530
var libevmHooks Hooks
2631

32+
// RegisterHooks registers the Hooks. It is expected to be called in an `init()`
33+
// function and MUST NOT be called more than once.
2734
func RegisterHooks(h Hooks) {
2835
if libevmHooks != nil {
2936
panic("already registered")

params/hooks.libevm.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ type RulesHooks interface {
2727
// [PrecompiledContract] is non-nil. If it returns `false` then the default
2828
// precompile behaviour is honoured.
2929
PrecompileOverride(common.Address) (_ libevm.PrecompiledContract, override bool)
30+
// OverrideJumpTable signals that [vm.Hooks.OverrideJumpTable] MUST be used.
31+
// Toggling the behaviour via [Rules] allows for recursive calling into
32+
// functions that would otherwise infinitely call the override hook.
3033
OverrideJumpTable() bool
3134
}
3235

@@ -86,6 +89,8 @@ func (NOOPHooks) PrecompileOverride(common.Address) (libevm.PrecompiledContract,
8689
return nil, false
8790
}
8891

92+
// OverrideJumpTable returns false, leaving all JumpTables unmodified even if
93+
// [vm.Hooks] have been registered.
8994
func (NOOPHooks) OverrideJumpTable() bool {
9095
return false
9196
}

0 commit comments

Comments
 (0)