implement constantinople bitwise opcode
This commit is contained in:
parent
2f08a6bc0e
commit
4a7f58c7dc
|
@ -198,9 +198,7 @@ proc isEmptyAccount*(db: AccountStateDB, address: EthAddress): bool =
|
||||||
account.balance.isZero and
|
account.balance.isZero and
|
||||||
account.nonce == 0
|
account.nonce == 0
|
||||||
|
|
||||||
proc isDeadAccount*(db: AccountStateDB, address: EthAddress, dust: static[bool]): bool =
|
proc isDeadAccount*(db: AccountStateDB, address: EthAddress): bool =
|
||||||
## dust == true: deadAccount == accountExists or emptyAccount
|
|
||||||
## dust == false: deadAccount == accountExists and emptyAccount(used in EIP158)
|
|
||||||
let recordFound = db.trie.get(createRangeFromAddress address)
|
let recordFound = db.trie.get(createRangeFromAddress address)
|
||||||
if recordFound.len > 0:
|
if recordFound.len > 0:
|
||||||
let account = rlp.decode(recordFound, Account)
|
let account = rlp.decode(recordFound, Account)
|
||||||
|
@ -208,10 +206,7 @@ proc isDeadAccount*(db: AccountStateDB, address: EthAddress, dust: static[bool])
|
||||||
account.balance.isZero and
|
account.balance.isZero and
|
||||||
account.nonce == 0
|
account.nonce == 0
|
||||||
else:
|
else:
|
||||||
result = dust
|
result = true
|
||||||
|
|
||||||
template isDeadAccount*(db: AccountStateDB, address: EthAddress): bool =
|
|
||||||
isDeadAccount(db, address, true)
|
|
||||||
|
|
||||||
proc rootHash*(db: ReadOnlyStateDB): KeccakHash {.borrow.}
|
proc rootHash*(db: ReadOnlyStateDB): KeccakHash {.borrow.}
|
||||||
proc getAccount*(db: ReadOnlyStateDB, address: EthAddress): Account {.borrow.}
|
proc getAccount*(db: ReadOnlyStateDB, address: EthAddress): Account {.borrow.}
|
||||||
|
@ -223,6 +218,5 @@ proc getNonce*(db: ReadOnlyStateDB, address: EthAddress): AccountNonce {.borrow.
|
||||||
proc getCode*(db: ReadOnlyStateDB, address: EthAddress): ByteRange {.borrow.}
|
proc getCode*(db: ReadOnlyStateDB, address: EthAddress): ByteRange {.borrow.}
|
||||||
proc hasCodeOrNonce*(db: ReadOnlyStateDB, address: EthAddress): bool {.borrow.}
|
proc hasCodeOrNonce*(db: ReadOnlyStateDB, address: EthAddress): bool {.borrow.}
|
||||||
proc accountExists*(db: ReadOnlyStateDB, address: EthAddress): bool {.borrow.}
|
proc accountExists*(db: ReadOnlyStateDB, address: EthAddress): bool {.borrow.}
|
||||||
|
proc isDeadAccount*(db: ReadOnlyStateDB, address: EthAddress): bool {.borrow.}
|
||||||
template isDeadAccount*(db: ReadOnlyStateDB, address: EthAddress): bool =
|
proc isEmptyAccount*(db: ReadOnlyStateDB, address: EthAddress): bool {.borrow.}
|
||||||
isDeadAccount(AccountStateDB(db), address, true)
|
|
||||||
|
|
|
@ -878,21 +878,37 @@ op selfDestructEip161, inline = false:
|
||||||
selfDestructImpl(computation, beneficiary)
|
selfDestructImpl(computation, beneficiary)
|
||||||
|
|
||||||
# Constantinople's new opcodes
|
# Constantinople's new opcodes
|
||||||
op shlOp, inline = true, num, shift:
|
op shlOp, inline = true, shift, num:
|
||||||
# TODO: implementation
|
let shiftLen = shift.safeInt
|
||||||
discard
|
if shiftLen >= 256:
|
||||||
|
push: 0
|
||||||
|
else:
|
||||||
|
push: num shl shiftLen
|
||||||
|
|
||||||
op shrOp, inline = true, num, shift:
|
op shrOp, inline = true, shift, num:
|
||||||
# TODO: implementation
|
let shiftLen = shift.safeInt
|
||||||
discard
|
if shiftLen >= 256:
|
||||||
|
push: 0
|
||||||
|
else:
|
||||||
|
push: num shr shiftLen
|
||||||
|
|
||||||
op sarOp, inline = true, num, shift:
|
op sarOp, inline = true:
|
||||||
# TODO: implementation
|
let shiftLen = computation.stack.popInt().safeInt
|
||||||
discard
|
let num = cast[Int256](computation.stack.popInt())
|
||||||
|
if shiftLen >= 256:
|
||||||
|
if num.isNegative:
|
||||||
|
push: cast[Uint256]((-1).i256)
|
||||||
|
else:
|
||||||
|
push: 0
|
||||||
|
else:
|
||||||
|
push: cast[Uint256](ashr(num, shiftLen))
|
||||||
|
|
||||||
op extCodeHash, inline = true, address:
|
op extCodeHash, inline = true:
|
||||||
# TODO: implementation
|
let address = computation.stack.popAddress()
|
||||||
discard
|
if computation.vmState.readOnlyStateDB.isEmptyAccount(address):
|
||||||
|
push: 0
|
||||||
|
else:
|
||||||
|
push: computation.vmState.readOnlyStateDB.getCodeHash(address)
|
||||||
|
|
||||||
op create2, inline = false:
|
op create2, inline = false:
|
||||||
# TODO: implementation
|
# TODO: implementation
|
||||||
|
|
Loading…
Reference in New Issue