Skip to content

Commit 379ff3d

Browse files
committed
Merge branches 'etcm-28-petersbug-changes' and 'phase/etc_forks' of https://github.com/input-output-hk/mantis into etcm-28-petersbug-changes
� Conflicts: � src/main/scala/io/iohk/ethereum/extvm/VMServer.scala � src/main/scala/io/iohk/ethereum/vm/BlockchainConfigForEvm.scala � src/main/scala/io/iohk/ethereum/vm/EvmConfig.scala � src/test/scala/io/iohk/ethereum/extvm/VMClientSpec.scala � src/test/scala/io/iohk/ethereum/vm/Fixtures.scala � src/test/scala/io/iohk/ethereum/vm/VMSpec.scala
2 parents 94d0780 + 1fd0a07 commit 379ff3d

File tree

8 files changed

+30
-9
lines changed

8 files changed

+30
-9
lines changed

src/main/scala/io/iohk/ethereum/extvm/VMServer.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,9 @@ class VMServer(messageHandler: MessageHandler)
188188
accountStartNonce = conf.accountStartNonce,
189189
atlantisBlockNumber = BigInt(8772000), //TODO include atlantis block number in protobuf
190190
aghartaBlockNumber = BigInt(9573000), //TODO include agharta block number in protobuf
191+
petersburgBlockNumber = BigInt(10000000), //TODO include petersburg block number in protobuf
191192
phoenixBlockNumber = BigInt(10500839), //TODO include phoenix block number in protobuf
192-
petersburgBlockNumber = BigInt(10000000) //TODO include petersburg block number in protobuf
193+
chainId = 0x3d.toByte //TODO include chainId in protobuf
193194
)
194195
}
195196
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ case class BlockchainConfigForEvm(
2020
accountStartNonce: UInt256,
2121
atlantisBlockNumber: BigInt,
2222
aghartaBlockNumber: BigInt,
23+
petersburgBlockNumber: BigInt,
2324
phoenixBlockNumber: BigInt,
24-
petersburgBlockNumber: BigInt
25+
chainId: Byte
2526
)
2627

2728
object BlockchainConfigForEvm {
@@ -39,8 +40,9 @@ object BlockchainConfigForEvm {
3940
accountStartNonce = accountStartNonce,
4041
atlantisBlockNumber = atlantisBlockNumber,
4142
aghartaBlockNumber = aghartaBlockNumber,
43+
petersburgBlockNumber = petersburgBlockNumber,
4244
phoenixBlockNumber = phoenixBlockNumber,
43-
petersburgBlockNumber = petersburgBlockNumber
45+
chainId = chainId
4446
)
4547
}
4648

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import akka.util.ByteString
44
import io.iohk.ethereum.domain.UInt256
55
import io.iohk.ethereum.utils.BlockchainConfig
66
import EvmConfig._
7+
import io.iohk.ethereum
78
import io.iohk.ethereum.vm
89

910
// scalastyle:off number.of.methods
@@ -37,7 +38,8 @@ object EvmConfig {
3738
blockchainConfig.constantinopleBlockNumber -> ConstantinopleConfigBuilder,
3839
blockchainConfig.atlantisBlockNumber -> AtlantisConfigBuilder,
3940
blockchainConfig.aghartaBlockNumber -> AghartaConfigBuilder,
40-
blockchainConfig.petersburgBlockNumber -> PetersburgConfigBuilder
41+
blockchainConfig.petersburgBlockNumber -> PetersburgConfigBuilder,
42+
blockchainConfig.phoenixBlockNumber -> PhoenixConfigBuilder
4143
)
4244

4345
// highest transition block that is less/equal to `blockNumber`
@@ -54,6 +56,7 @@ object EvmConfig {
5456
val AtlantisOpCodes = ByzantiumOpCodes
5557
val ConstantinopleOpCodes = OpCodeList(OpCodes.ConstantinopleOpCodes)
5658
val AghartaOpCodes = ConstantinopleOpCodes
59+
val PhoenixOpCodes = OpCodeList(OpCodes.PhoenixOpCodes)
5760

5861
val FrontierConfigBuilder: EvmConfigBuilder = config => EvmConfig(
5962
blockchainConfig = config,
@@ -108,6 +111,11 @@ object EvmConfig {
108111
opCodeList = AghartaOpCodes
109112
)
110113

114+
val PhoenixConfigBuilder: EvmConfigBuilder = config => AghartaConfigBuilder(config).copy(
115+
feeSchedule = new ethereum.vm.FeeSchedule.PhoenixFeeSchedule,
116+
opCodeList = PhoenixOpCodes
117+
)
118+
111119
case class OpCodeList(opCodes: List[OpCode]) {
112120
val byteToOpCode: Map[Byte, OpCode] =
113121
opCodes.map(op => op.code -> op).toMap
@@ -256,6 +264,8 @@ object FeeSchedule {
256264

257265
class AghartaFeeSchedule extends ByzantiumFeeSchedule
258266

267+
class PhoenixFeeSchedule extends AghartaFeeSchedule
268+
259269
}
260270

261271
trait FeeSchedule {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ object OpCodes {
166166

167167
val ConstantinopleOpCodes: List[OpCode] =
168168
List(EXTCODEHASH, CREATE2, SHL, SHR, SAR) ++ ByzantiumOpCodes
169+
170+
val PhoenixOpCodes: List[OpCode] =
171+
List(CHAINID) ++ ConstantinopleOpCodes
169172
}
170173

171174
object OpCode {
@@ -1151,3 +1154,5 @@ case object SELFDESTRUCT extends OpCode(0xff, 1, 0, _.G_selfdestruct) {
11511154

11521155
override protected def availableInContext[W <: WorldStateProxy[W, S], S <: Storage[S]]: ProgramState[W, S] => Boolean = !_.staticCtx
11531156
}
1157+
1158+
case object CHAINID extends ConstOp(0x46)(state => UInt256(state.env.evmConfig.blockchainConfig.chainId))

src/test/scala/io/iohk/ethereum/extvm/VMClientSpec.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,9 @@ class VMClientSpec extends FlatSpec with Matchers with MockFactory {
177177
accountStartNonce = 0,
178178
atlantisBlockNumber = 0,
179179
aghartaBlockNumber = 0,
180+
petersburgBlockNumber = 0,
180181
phoenixBlockNumber = 0,
181-
petersburgBlockNumber = 0
182+
chainId = 0x3d.toByte
182183
)
183184
val evmConfig = EvmConfig.FrontierConfigBuilder(blockchainConfigForEvm)
184185

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ object Fixtures {
1818
accountStartNonce = 0,
1919
atlantisBlockNumber = 0,
2020
aghartaBlockNumber = 0,
21+
petersburgBlockNumber = PetersburgBlockNumber,
2122
phoenixBlockNumber = 0,
22-
petersburgBlockNumber = PetersburgBlockNumber
23+
chainId = 0x3d.toByte
2324
)
2425

2526
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class OpCodeFunSpec extends FunSuite with OpCodeTesting with Matchers with Prope
1414

1515
import MockWorldState.PS
1616

17-
override val config = EvmConfig.ByzantiumConfigBuilder(blockchainConfig)
17+
override val config = EvmConfig.PhoenixConfigBuilder(blockchainConfig)
1818

1919
def executeOp(op: OpCode, stateIn: PS): PS = {
2020
// gas is not tested in this spec
@@ -819,7 +819,7 @@ class OpCodeFunSpec extends FunSuite with OpCodeTesting with Matchers with Prope
819819
}
820820
}
821821

822-
verifyAllOpCodesRegistered(except = CREATE, CREATE2, CALL, CALLCODE, DELEGATECALL, STATICCALL)
822+
verifyAllOpCodesRegistered(except = CREATE, CREATE2, CALL, CALLCODE, DELEGATECALL, STATICCALL, SHL, SHR, SAR)
823823

824824
test("sliceBytes helper") {
825825
def zeroes(i: Int): ByteString =

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ class VMSpec extends WordSpec with PropertyChecks with Matchers {
157157
accountStartNonce = 0,
158158
atlantisBlockNumber = Long.MaxValue,
159159
aghartaBlockNumber = Long.MaxValue,
160+
petersburgBlockNumber = Long.MaxValue,
160161
phoenixBlockNumber = Long.MaxValue,
161-
petersburgBlockNumber = Long.MaxValue
162+
chainId = 0x3d.toByte
162163
)
163164

164165
val homesteadConfig = EvmConfig.forBlock(0, evmBlockchainConfig.copy(homesteadBlockNumber = 0))

0 commit comments

Comments
 (0)