Skip to content

Commit 04abef7

Browse files
committed
Merge branch 'phase/release2_0' of github-scalac:input-output-hk/mantis into rpc-tests-fixes
2 parents 0c07bf9 + 4c11fd2 commit 04abef7

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

src/ets/resources/ets

Submodule ets updated 20 files

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,21 @@ case object EXTCODEHASH extends OpCode(0x3F, 1, 1, _.G_balance) with ConstGas {
376376
protected def exec[W <: WorldStateProxy[W, S], S <: Storage[S]](state: ProgramState[W, S]): ProgramState[W, S] = {
377377
val (accountAddress, stack1) = state.stack.pop
378378
val address = Address(accountAddress)
379-
val accountExists = state.world.accountExists(address)
379+
380+
/**
381+
* Specification of EIP1052 - https://eips.ethereum.org/EIPS/eip-1052, says that we should return 0
382+
* In case the account does not exist 0 is pushed to the stack.
383+
*
384+
* But the interpretation is, that account does not exists if:
385+
* - it do not exists or,
386+
* - is empty according to eip161 rules (account is considered empty when it has no code and zero nonce and zero balance)
387+
*
388+
* Example of existing check in geth:
389+
* https://github.com/ethereum/go-ethereum/blob/aad3c67a92cd4f3cc3a885fdc514ba2a7fb3e0a3/core/state/statedb.go#L203
390+
*
391+
*
392+
*/
393+
val accountExists = !state.world.isAccountDead(address)
380394

381395
val codeHash =
382396
if (accountExists) {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ class OpCodeFunSpec extends FunSuite with OpCodeTesting with Matchers with Prope
191191
val stateOutWithAccount = executeOp(op, stateInWithAccount)
192192

193193
withStackVerification(op, stateInWithAccount, stateOutWithAccount) {
194-
val stack2 = stack1.push(UInt256(codeHash))
194+
// if account is empty we should push 0 onto stack
195+
val toPushOnStack = if (codeHash == Account.EmptyCodeHash) UInt256.Zero else UInt256(codeHash)
196+
val stack2 = stack1.push(toPushOnStack)
195197
stateOutWithAccount shouldEqual stateInWithAccount.withStack(stack2).step()
196198
}
197199
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ class StackSpec extends FunSuite with Matchers with PropertyChecks {
1010
val maxStackSize = 32
1111
val stackGen = Generators.getStackGen(maxSize = maxStackSize)
1212
val intGen = Gen.choose(0, maxStackSize).filter(_ >= 0)
13-
val nonFullStackGen = stackGen.filter(stack => stack.size < stack.maxSize)
14-
val fullStackGen = intGen.flatMap(Generators.getStackGen)
1513
val uint256Gen = Generators.getUInt256Gen()
1614
val uint256ListGen = Generators.getListGen(0, 16, uint256Gen)
15+
val fullStackGen = intGen.flatMap(n => Generators.getStackGen(n, n, uint256Gen, n))
16+
val nonFullStackGen = Generators.getStackGen(maxElems = maxStackSize - 1, maxSize = maxStackSize, valueGen = uint256Gen)
1717

1818
test("pop single element") {
1919
forAll(stackGen) { stack =>

0 commit comments

Comments
 (0)