Skip to content

Commit e19f435

Browse files
[ETCM-912] Rename constGas -> baseGas
1 parent 087551a commit e19f435

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/main/scala/io/iohk/ethereum/vm/OpCode.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ object OpCode {
172172
* @param delta number of words to be popped from stack
173173
* @param alpha number of words to be pushed to stack
174174
*/
175-
abstract class OpCode(val code: Byte, val delta: Int, val alpha: Int, val constGasFn: FeeSchedule => BigInt)
175+
abstract class OpCode(val code: Byte, val delta: Int, val alpha: Int, val baseGasFn: FeeSchedule => BigInt)
176176
extends Product
177177
with Serializable {
178178
def this(code: Int, pop: Int, push: Int, constGasFn: FeeSchedule => BigInt) = this(code.toByte, pop, push, constGasFn)
@@ -193,9 +193,9 @@ abstract class OpCode(val code: Byte, val delta: Int, val alpha: Int, val constG
193193
}
194194

195195
protected def calcGas[W <: WorldStateProxy[W, S], S <: Storage[S]](state: ProgramState[W, S]): BigInt =
196-
constGas(state) + varGas(state)
196+
baseGas(state) + varGas(state)
197197

198-
protected def constGas[W <: WorldStateProxy[W, S], S <: Storage[S]](state: ProgramState[W, S]): BigInt = constGasFn(
198+
protected def baseGas[W <: WorldStateProxy[W, S], S <: Storage[S]](state: ProgramState[W, S]): BigInt = baseGasFn(
199199
state.config.feeSchedule
200200
)
201201

@@ -213,7 +213,7 @@ trait AddrAccessGas { self: OpCode =>
213213
private def coldGasFn: FeeSchedule => BigInt = _.G_cold_account_access
214214
private def warmGasFn: FeeSchedule => BigInt = _.G_warm_storage_read
215215

216-
override protected def constGas[W <: WorldStateProxy[W, S], S <: Storage[S]](state: ProgramState[W, S]): BigInt = {
216+
override protected def baseGas[W <: WorldStateProxy[W, S], S <: Storage[S]](state: ProgramState[W, S]): BigInt = {
217217
val currentBlockNumber = state.env.blockHeader.number
218218
val etcFork = state.config.blockchainConfig.etcForkForBlockNumber(currentBlockNumber)
219219
val eip2929Enabled = isEip2929Enabled(etcFork)
@@ -224,7 +224,7 @@ trait AddrAccessGas { self: OpCode =>
224224
else
225225
coldGasFn(state.config.feeSchedule)
226226
} else
227-
constGasFn(state.config.feeSchedule)
227+
baseGasFn(state.config.feeSchedule)
228228
}
229229

230230
protected def address[W <: WorldStateProxy[W, S], S <: Storage[S]](state: ProgramState[W, S]): Address
@@ -240,8 +240,8 @@ case object STOP extends OpCode(0x00, 0, 0, _.G_zero) with ConstGas {
240240
state.withReturnData(ByteString.empty).halt
241241
}
242242

243-
sealed abstract class UnaryOp(code: Int, constGasFn: FeeSchedule => BigInt)(val f: UInt256 => UInt256)
244-
extends OpCode(code, 1, 1, constGasFn)
243+
sealed abstract class UnaryOp(code: Int, baseGasFn: FeeSchedule => BigInt)(val f: UInt256 => UInt256)
244+
extends OpCode(code, 1, 1, baseGasFn)
245245
with ConstGas {
246246

247247
protected def exec[W <: WorldStateProxy[W, S], S <: Storage[S]](state: ProgramState[W, S]): ProgramState[W, S] = {
@@ -252,8 +252,8 @@ sealed abstract class UnaryOp(code: Int, constGasFn: FeeSchedule => BigInt)(val
252252
}
253253
}
254254

255-
sealed abstract class BinaryOp(code: Int, constGasFn: FeeSchedule => BigInt)(val f: (UInt256, UInt256) => UInt256)
256-
extends OpCode(code.toByte, 2, 1, constGasFn) {
255+
sealed abstract class BinaryOp(code: Int, baseGasFn: FeeSchedule => BigInt)(val f: (UInt256, UInt256) => UInt256)
256+
extends OpCode(code.toByte, 2, 1, baseGasFn) {
257257

258258
protected def exec[W <: WorldStateProxy[W, S], S <: Storage[S]](state: ProgramState[W, S]): ProgramState[W, S] = {
259259
val (Seq(a, b), stack1) = state.stack.pop(2)
@@ -263,9 +263,9 @@ sealed abstract class BinaryOp(code: Int, constGasFn: FeeSchedule => BigInt)(val
263263
}
264264
}
265265

266-
sealed abstract class TernaryOp(code: Int, constGasFn: FeeSchedule => BigInt)(
266+
sealed abstract class TernaryOp(code: Int, baseGasFn: FeeSchedule => BigInt)(
267267
val f: (UInt256, UInt256, UInt256) => UInt256
268-
) extends OpCode(code.toByte, 3, 1, constGasFn) {
268+
) extends OpCode(code.toByte, 3, 1, baseGasFn) {
269269

270270
protected def exec[W <: WorldStateProxy[W, S], S <: Storage[S]](state: ProgramState[W, S]): ProgramState[W, S] = {
271271
val (Seq(a, b, c), stack1) = state.stack.pop(3)
@@ -894,7 +894,7 @@ abstract class CreateOp(code: Int, delta: Int) extends OpCode(code, delta, 1, _.
894894

895895
//FIXME: to avoid calculating this twice, we could adjust state.gas prior to execution in OpCode#execute
896896
//not sure how this would affect other opcodes [EC-243]
897-
val availableGas = state.gas - (constGasFn(state.config.feeSchedule) + varGas(state))
897+
val availableGas = state.gas - (baseGasFn(state.config.feeSchedule) + varGas(state))
898898
val startGas = state.config.gasCap(availableGas)
899899
val (initCode, memory1) = state.memory.load(inOffset, inSize)
900900
val world1 = state.world.increaseNonce(state.ownAddress)

src/test/scala/io/iohk/ethereum/vm/Assembly.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ case class Assembly(byteCode: ByteCode*) {
3131
val program: Program = Program(code)
3232

3333
def linearConstGas(config: EvmConfig): BigInt = byteCode.foldLeft(BigInt(0)) {
34-
case (g, b: OpCodeAsByteCode) => g + b.op.constGasFn(config.feeSchedule)
34+
case (g, b: OpCodeAsByteCode) => g + b.op.baseGasFn(config.feeSchedule)
3535
case (g, _) => g
3636
}
3737
}

src/test/scala/io/iohk/ethereum/vm/OpCodeGasSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class OpCodeGasSpec extends AnyFunSuite with OpCodeTesting with Matchers with Sc
124124
test(constGasOps: _*) { op =>
125125
val stateGen = getProgramStateGen(
126126
stackGen = getStackGen(elems = op.delta),
127-
gasGen = getBigIntGen(max = op.constGasFn(config.feeSchedule) * 2)
127+
gasGen = getBigIntGen(max = op.baseGasFn(config.feeSchedule) * 2)
128128
)
129129

130130
forAll(stateGen) { stateIn =>

0 commit comments

Comments
 (0)