Skip to content

Commit b0f91b4

Browse files
committed
refactor: abstract CallType.readOnly
1 parent f8824ab commit b0f91b4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

core/vm/contracts.libevm.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ func (t CallType) isValid() bool {
101101
}
102102
}
103103

104+
// readOnly returns whether the CallType induces a read-only state if not
105+
// already in one.
106+
func (t CallType) readOnly() bool {
107+
return t == StaticCall
108+
}
109+
104110
// String returns a human-readable representation of the CallType.
105111
func (t CallType) String() string {
106112
if t.isValid() {
@@ -134,7 +140,7 @@ func (args *evmCallArgs) run(p PrecompiledContract, input []byte) (ret []byte, e
134140
in.evm.depth++
135141
defer func() { in.evm.depth-- }()
136142

137-
if env.callType == StaticCall && !in.readOnly {
143+
if env.callType.readOnly() && !in.readOnly {
138144
in.readOnly = true
139145
defer func() { in.readOnly = false }()
140146
}

0 commit comments

Comments
 (0)