Skip to content

Commit

Permalink
New instructions (#1644)
Browse files Browse the repository at this point in the history
* New instructions

* Update evm.py

* Link pyevmasm master

* blkn

* Fix pyevmasm dep

* Fix pyevmasm link

* Fix pyevmasm link

* Fix deps

* Remove bad merge
  • Loading branch information
feliam authored Apr 23, 2020
1 parent 4c51644 commit 96d65e5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 15 additions & 1 deletion manticore/platforms/evm.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def globalfakesha3(data):
MASK160 = 2 ** 160 - 1
TT255 = 2 ** 255
TOOHIGHMEM = 0x1000
DEFAULT_FORK = "constantinople"
DEFAULT_FORK = "istanbul"

# FIXME. We should just use a Transaction() for this
PendingTransaction = namedtuple(
Expand Down Expand Up @@ -1605,6 +1605,9 @@ def BALANCE(self, account):
"""Get balance of the given account"""
return self.world.get_balance(account)

def SELFBALANCE(self):
return self.world.get_balance(self.address)

def ORIGIN(self):
"""Get execution origination address"""
return Operators.ZEXTEND(self.world.tx_origin(), 256)
Expand Down Expand Up @@ -1774,6 +1777,12 @@ def EXTCODESIZE(self, account):
"""Get size of an account's code"""
return len(self.world.get_code(account))

@concretized_args(account="ACCOUNTS")
def EXTCODEHASH(self, account):
"""Get hash of code"""
bytecode = self.world.get_code(account)
return globalsha3(bytecode)

def EXTCODECOPY_gas(self, account, address, offset, size):
GCOPY = 3 # cost to copy one 32 byte word
extbytecode = self.world.get_code(account)
Expand Down Expand Up @@ -1835,6 +1844,11 @@ def GASLIMIT(self):
"""Get the block's gas limit"""
return self.world.block_gaslimit()

def CHAINID(self):
"""Get current chainid."""
# 1:= Ethereum Mainnet - https://chainid.network/
return 1

############################################################################
# Stack, Memory, Storage and Flow Operations
def POP(self, a):
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,14 @@ def rtd_dependent_deps():
python_requires=">=3.6",
install_requires=[
"pyyaml",
# evm dependencies
"pysha3",
"prettytable",
"pyevmasm==0.2.0",
"rlp",
"ply",
"crytic-compile>=0.1.1",
"wasm",
"dataclasses; python_version < '3.7'",
"pyevmasm>=0.2.3",
"psutil",
]
+ rtd_dependent_deps(),
Expand Down

0 comments on commit 96d65e5

Please sign in to comment.