[skip ci] change storageAddress to contractAddres
This commit is contained in:
parent
40ddbca1ee
commit
836e087984
|
@ -113,7 +113,7 @@ proc writeContract*(computation: BaseComputation, fork: Fork): bool {.gcsafe.} =
|
||||||
debug "Contract code size exceeds EIP170", limit=EIP170_CODE_SIZE_LIMIT, actual=contractCode.len
|
debug "Contract code size exceeds EIP170", limit=EIP170_CODE_SIZE_LIMIT, actual=contractCode.len
|
||||||
return false
|
return false
|
||||||
|
|
||||||
let storageAddr = computation.msg.storageAddress
|
let storageAddr = computation.msg.contractAddress
|
||||||
if computation.isSuicided(storageAddr): return
|
if computation.isSuicided(storageAddr): return
|
||||||
|
|
||||||
let gasParams = GasParams(kind: Create, cr_memLength: contractCode.len)
|
let gasParams = GasParams(kind: Create, cr_memLength: contractCode.len)
|
||||||
|
@ -138,7 +138,7 @@ proc transferBalance(computation: BaseComputation, opCode: static[Op]) =
|
||||||
when opCode in {Call, Create}:
|
when opCode in {Call, Create}:
|
||||||
computation.vmState.mutateStateDb:
|
computation.vmState.mutateStateDb:
|
||||||
db.subBalance(computation.msg.sender, computation.msg.value)
|
db.subBalance(computation.msg.sender, computation.msg.value)
|
||||||
db.addBalance(computation.msg.storageAddress, computation.msg.value)
|
db.addBalance(computation.msg.contractAddress, computation.msg.value)
|
||||||
|
|
||||||
template continuation*(comp: BaseComputation, body: untyped) =
|
template continuation*(comp: BaseComputation, body: untyped) =
|
||||||
# this is a helper template to implement continuation
|
# this is a helper template to implement continuation
|
||||||
|
@ -177,10 +177,10 @@ proc applyMessage*(computation: BaseComputation, opCode: static[Op]) =
|
||||||
when opCode in {Create, Create2}:
|
when opCode in {Create, Create2}:
|
||||||
if computation.getFork >= FkSpurious:
|
if computation.getFork >= FkSpurious:
|
||||||
computation.vmState.mutateStateDb:
|
computation.vmState.mutateStateDb:
|
||||||
db.incNonce(computation.msg.storageAddress)
|
db.incNonce(computation.msg.contractAddress)
|
||||||
if computation.getFork >= FkByzantium:
|
if computation.getFork >= FkByzantium:
|
||||||
# RevertInCreateInInit.json
|
# RevertInCreateInInit.json
|
||||||
db.setStorageRoot(computation.msg.storageAddress, emptyRlpHash)
|
db.setStorageRoot(computation.msg.contractAddress, emptyRlpHash)
|
||||||
|
|
||||||
when opCode in {CallCode, Call, Create}:
|
when opCode in {CallCode, Call, Create}:
|
||||||
computation.transferBalance(opCode)
|
computation.transferBalance(opCode)
|
||||||
|
@ -219,7 +219,7 @@ proc addChildComputation*(computation: BaseComputation, child: BaseComputation)
|
||||||
computation.children.add(child)
|
computation.children.add(child)
|
||||||
|
|
||||||
proc registerAccountForDeletion*(c: BaseComputation, beneficiary: EthAddress) =
|
proc registerAccountForDeletion*(c: BaseComputation, beneficiary: EthAddress) =
|
||||||
if c.msg.storageAddress in c.accountsToDelete:
|
if c.msg.contractAddress in c.accountsToDelete:
|
||||||
raise newException(ValueError,
|
raise newException(ValueError,
|
||||||
"invariant: should be impossible for an account to be " &
|
"invariant: should be impossible for an account to be " &
|
||||||
"registered for deletion multiple times")
|
"registered for deletion multiple times")
|
||||||
|
@ -227,8 +227,8 @@ proc registerAccountForDeletion*(c: BaseComputation, beneficiary: EthAddress) =
|
||||||
# we should remove this accountsToDelete map delegate it to state db
|
# we should remove this accountsToDelete map delegate it to state db
|
||||||
# we will only keep suicides list here in order to make
|
# we will only keep suicides list here in order to make
|
||||||
# evmc integration easier
|
# evmc integration easier
|
||||||
c.accountsToDelete[c.msg.storageAddress] = beneficiary
|
c.accountsToDelete[c.msg.contractAddress] = beneficiary
|
||||||
c.suicides.incl(c.msg.storageAddress)
|
c.suicides.incl(c.msg.contractAddress)
|
||||||
|
|
||||||
proc addLogEntry*(c: BaseComputation, log: Log) {.inline.} =
|
proc addLogEntry*(c: BaseComputation, log: Log) {.inline.} =
|
||||||
c.logEntries.add(log)
|
c.logEntries.add(log)
|
||||||
|
@ -284,10 +284,10 @@ proc collectTouchedAccounts*(c: BaseComputation, output: var HashSet[EthAddress]
|
||||||
if condition:
|
if condition:
|
||||||
# Special case to account for geth+parity bug
|
# Special case to account for geth+parity bug
|
||||||
# https://github.com/ethereum/EIPs/issues/716
|
# https://github.com/ethereum/EIPs/issues/716
|
||||||
if cmpThree(c.msg.storageAddress):
|
if cmpThree(c.msg.contractAddress):
|
||||||
output.incl c.msg.storageAddress
|
output.incl c.msg.contractAddress
|
||||||
else:
|
else:
|
||||||
output.incl c.msg.storageAddress
|
output.incl c.msg.contractAddress
|
||||||
|
|
||||||
if c.isSuccess or isIstanbul:
|
if c.isSuccess or isIstanbul:
|
||||||
# recurse into nested computations (even errored ones, since looking for RIPEMD160)
|
# recurse into nested computations (even errored ones, since looking for RIPEMD160)
|
||||||
|
|
|
@ -231,7 +231,7 @@ proc writePaddedResult(mem: var Memory,
|
||||||
|
|
||||||
op address, inline = true:
|
op address, inline = true:
|
||||||
## 0x30, Get address of currently executing account.
|
## 0x30, Get address of currently executing account.
|
||||||
push: computation.msg.storageAddress
|
push: computation.msg.contractAddress
|
||||||
|
|
||||||
op balance, inline = true:
|
op balance, inline = true:
|
||||||
## 0x31, Get balance of the given account.
|
## 0x31, Get balance of the given account.
|
||||||
|
@ -380,7 +380,7 @@ op chainId, inline = true:
|
||||||
op selfBalance, inline = true:
|
op selfBalance, inline = true:
|
||||||
## 0x47, Get current contract's balance.
|
## 0x47, Get current contract's balance.
|
||||||
let stateDb = computation.vmState.readOnlyStateDb
|
let stateDb = computation.vmState.readOnlyStateDb
|
||||||
push: stateDb.getBalance(computation.msg.storageAddress)
|
push: stateDb.getBalance(computation.msg.contractAddress)
|
||||||
|
|
||||||
# ##########################################
|
# ##########################################
|
||||||
# 50s: Stack, Memory, Storage and Flow Operations
|
# 50s: Stack, Memory, Storage and Flow Operations
|
||||||
|
@ -428,26 +428,26 @@ op mstore8, inline = true, memStartPos, value:
|
||||||
op sload, inline = true, slot:
|
op sload, inline = true, slot:
|
||||||
## 0x54, Load word from storage.
|
## 0x54, Load word from storage.
|
||||||
|
|
||||||
let (value, _) = computation.vmState.readOnlyStateDB.getStorage(computation.msg.storageAddress, slot)
|
let (value, _) = computation.vmState.readOnlyStateDB.getStorage(computation.msg.contractAddress, slot)
|
||||||
push(value)
|
push(value)
|
||||||
|
|
||||||
op sstore, inline = false, slot, value:
|
op sstore, inline = false, slot, value:
|
||||||
## 0x55, Save word to storage.
|
## 0x55, Save word to storage.
|
||||||
checkInStaticContext(computation)
|
checkInStaticContext(computation)
|
||||||
|
|
||||||
let (currentValue, existing) = computation.vmState.readOnlyStateDB.getStorage(computation.msg.storageAddress, slot)
|
let (currentValue, existing) = computation.vmState.readOnlyStateDB.getStorage(computation.msg.contractAddress, slot)
|
||||||
|
|
||||||
let
|
let
|
||||||
gasParam = GasParams(kind: Op.Sstore, s_isStorageEmpty: currentValue.isZero)
|
gasParam = GasParams(kind: Op.Sstore, s_isStorageEmpty: currentValue.isZero)
|
||||||
(gasCost, gasRefund) = computation.gasCosts[Sstore].c_handler(value, gasParam)
|
(gasCost, gasRefund) = computation.gasCosts[Sstore].c_handler(value, gasParam)
|
||||||
|
|
||||||
computation.gasMeter.consumeGas(gasCost, &"SSTORE: {computation.msg.storageAddress}[{slot}] -> {value} ({currentValue})")
|
computation.gasMeter.consumeGas(gasCost, &"SSTORE: {computation.msg.contractAddress}[{slot}] -> {value} ({currentValue})")
|
||||||
|
|
||||||
if gasRefund > 0:
|
if gasRefund > 0:
|
||||||
computation.gasMeter.refundGas(gasRefund)
|
computation.gasMeter.refundGas(gasRefund)
|
||||||
|
|
||||||
computation.vmState.mutateStateDB:
|
computation.vmState.mutateStateDB:
|
||||||
db.setStorage(computation.msg.storageAddress, slot, value)
|
db.setStorage(computation.msg.contractAddress, slot, value)
|
||||||
|
|
||||||
proc jumpImpl(computation: BaseComputation, jumpTarget: UInt256) =
|
proc jumpImpl(computation: BaseComputation, jumpTarget: UInt256) =
|
||||||
if jumpTarget >= computation.code.len.u256:
|
if jumpTarget >= computation.code.len.u256:
|
||||||
|
@ -522,7 +522,7 @@ proc canTransfer(computation: BaseComputation, memPos, memLen: int, value: Uint2
|
||||||
# to avoid confusion
|
# to avoid confusion
|
||||||
let senderBalance =
|
let senderBalance =
|
||||||
computation.vmState.readOnlyStateDb().
|
computation.vmState.readOnlyStateDb().
|
||||||
getBalance(computation.msg.storageAddress)
|
getBalance(computation.msg.contractAddress)
|
||||||
|
|
||||||
if senderBalance < value:
|
if senderBalance < value:
|
||||||
debug "Computation Failure", reason = "Insufficient funds available to transfer", required = computation.msg.value, balance = senderBalance
|
debug "Computation Failure", reason = "Insufficient funds available to transfer", required = computation.msg.value, balance = senderBalance
|
||||||
|
@ -559,16 +559,16 @@ proc setupCreate(computation: BaseComputation, memPos, len: int, value: Uint256,
|
||||||
computation.vmState.mutateStateDB:
|
computation.vmState.mutateStateDB:
|
||||||
# Regarding collisions, see: https://github.com/status-im/nimbus/issues/133
|
# Regarding collisions, see: https://github.com/status-im/nimbus/issues/133
|
||||||
# See: https://github.com/ethereum/EIPs/issues/684
|
# See: https://github.com/ethereum/EIPs/issues/684
|
||||||
let creationNonce = db.getNonce(computation.msg.storageAddress)
|
let creationNonce = db.getNonce(computation.msg.contractAddress)
|
||||||
db.setNonce(computation.msg.storageAddress, creationNonce + 1)
|
db.setNonce(computation.msg.contractAddress, creationNonce + 1)
|
||||||
|
|
||||||
contractAddress = generateAddress(computation.msg.storageAddress, creationNonce)
|
contractAddress = generateAddress(computation.msg.contractAddress, creationNonce)
|
||||||
isCollision = db.hasCodeOrNonce(contractAddress)
|
isCollision = db.hasCodeOrNonce(contractAddress)
|
||||||
else:
|
else:
|
||||||
computation.vmState.mutateStateDB:
|
computation.vmState.mutateStateDB:
|
||||||
db.incNonce(computation.msg.storageAddress)
|
db.incNonce(computation.msg.contractAddress)
|
||||||
let salt = computation.stack.popInt()
|
let salt = computation.stack.popInt()
|
||||||
contractAddress = generateSafeAddress(computation.msg.storageAddress, salt, callData)
|
contractAddress = generateSafeAddress(computation.msg.contractAddress, salt, callData)
|
||||||
isCollision = db.hasCodeOrNonce(contractAddress)
|
isCollision = db.hasCodeOrNonce(contractAddress)
|
||||||
|
|
||||||
if isCollision:
|
if isCollision:
|
||||||
|
@ -581,8 +581,8 @@ proc setupCreate(computation: BaseComputation, memPos, len: int, value: Uint256,
|
||||||
gas: createMsgGas,
|
gas: createMsgGas,
|
||||||
gasPrice: computation.msg.gasPrice,
|
gasPrice: computation.msg.gasPrice,
|
||||||
origin: computation.msg.origin,
|
origin: computation.msg.origin,
|
||||||
sender: computation.msg.storageAddress,
|
sender: computation.msg.contractAddress,
|
||||||
storageAddress: contractAddress,
|
contractAddress: contractAddress,
|
||||||
codeAddress: CREATE_CONTRACT_ADDRESS,
|
codeAddress: CREATE_CONTRACT_ADDRESS,
|
||||||
value: value,
|
value: value,
|
||||||
data: @[],
|
data: @[],
|
||||||
|
@ -613,7 +613,7 @@ template genCreate(callName: untyped, opCode: Op): untyped =
|
||||||
if childComp.isError:
|
if childComp.isError:
|
||||||
push: 0
|
push: 0
|
||||||
else:
|
else:
|
||||||
push: childComp.msg.storageAddress
|
push: childComp.msg.contractAddress
|
||||||
|
|
||||||
checkInStaticContext(computation)
|
checkInStaticContext(computation)
|
||||||
childComp.applyMessage(Create)
|
childComp.applyMessage(Create)
|
||||||
|
@ -632,7 +632,7 @@ proc callParams(computation: BaseComputation): (UInt256, UInt256, EthAddress, Et
|
||||||
result = (gas,
|
result = (gas,
|
||||||
value,
|
value,
|
||||||
codeAddress, # contractAddress
|
codeAddress, # contractAddress
|
||||||
computation.msg.storageAddress, # sender
|
computation.msg.contractAddress, # sender
|
||||||
codeAddress,
|
codeAddress,
|
||||||
memoryInputStartPosition,
|
memoryInputStartPosition,
|
||||||
memoryInputSize,
|
memoryInputSize,
|
||||||
|
@ -650,8 +650,8 @@ proc callCodeParams(computation: BaseComputation): (UInt256, UInt256, EthAddress
|
||||||
|
|
||||||
result = (gas,
|
result = (gas,
|
||||||
value,
|
value,
|
||||||
computation.msg.storageAddress, # contractAddress
|
computation.msg.contractAddress, # contractAddress
|
||||||
computation.msg.storageAddress, # sender
|
computation.msg.contractAddress, # sender
|
||||||
codeAddress,
|
codeAddress,
|
||||||
memoryInputStartPosition,
|
memoryInputStartPosition,
|
||||||
memoryInputSize,
|
memoryInputSize,
|
||||||
|
@ -668,7 +668,7 @@ proc delegateCallParams(computation: BaseComputation): (UInt256, UInt256, EthAdd
|
||||||
|
|
||||||
result = (gas,
|
result = (gas,
|
||||||
computation.msg.value, # value
|
computation.msg.value, # value
|
||||||
computation.msg.storageAddress, # contractAddress
|
computation.msg.contractAddress, # contractAddress
|
||||||
computation.msg.sender, # sender
|
computation.msg.sender, # sender
|
||||||
codeAddress,
|
codeAddress,
|
||||||
memoryInputStartPosition,
|
memoryInputStartPosition,
|
||||||
|
@ -687,7 +687,7 @@ proc staticCallParams(computation: BaseComputation): (UInt256, UInt256, EthAddre
|
||||||
result = (gas,
|
result = (gas,
|
||||||
0.u256, # value
|
0.u256, # value
|
||||||
codeAddress, # contractAddress
|
codeAddress, # contractAddress
|
||||||
computation.msg.storageAddress, # sender
|
computation.msg.contractAddress, # sender
|
||||||
codeAddress,
|
codeAddress,
|
||||||
memoryInputStartPosition,
|
memoryInputStartPosition,
|
||||||
memoryInputSize,
|
memoryInputSize,
|
||||||
|
@ -745,7 +745,7 @@ template genCall(callName: untyped, opCode: Op): untyped =
|
||||||
gasPrice: computation.msg.gasPrice,
|
gasPrice: computation.msg.gasPrice,
|
||||||
origin: computation.msg.origin,
|
origin: computation.msg.origin,
|
||||||
sender: sender,
|
sender: sender,
|
||||||
storageAddress: contractAddress,
|
contractAddress: contractAddress,
|
||||||
codeAddress: codeAddress,
|
codeAddress: codeAddress,
|
||||||
value: value,
|
value: value,
|
||||||
data: callData,
|
data: callData,
|
||||||
|
@ -827,7 +827,7 @@ proc selfDestructImpl(computation: BaseComputation, beneficiary: EthAddress) =
|
||||||
# In particular, EIP150 and EIP161 have extra requirements.
|
# In particular, EIP150 and EIP161 have extra requirements.
|
||||||
computation.vmState.mutateStateDB:
|
computation.vmState.mutateStateDB:
|
||||||
let
|
let
|
||||||
localBalance = db.getBalance(computation.msg.storageAddress)
|
localBalance = db.getBalance(computation.msg.contractAddress)
|
||||||
beneficiaryBalance = db.getBalance(beneficiary)
|
beneficiaryBalance = db.getBalance(beneficiary)
|
||||||
|
|
||||||
# Transfer to beneficiary
|
# Transfer to beneficiary
|
||||||
|
@ -836,13 +836,13 @@ proc selfDestructImpl(computation: BaseComputation, beneficiary: EthAddress) =
|
||||||
# Zero the balance of the address being deleted.
|
# Zero the balance of the address being deleted.
|
||||||
# This must come after sending to beneficiary in case the
|
# This must come after sending to beneficiary in case the
|
||||||
# contract named itself as the beneficiary.
|
# contract named itself as the beneficiary.
|
||||||
db.setBalance(computation.msg.storageAddress, 0.u256)
|
db.setBalance(computation.msg.contractAddress, 0.u256)
|
||||||
|
|
||||||
# Register the account to be deleted
|
# Register the account to be deleted
|
||||||
computation.registerAccountForDeletion(beneficiary)
|
computation.registerAccountForDeletion(beneficiary)
|
||||||
|
|
||||||
trace "SELFDESTRUCT",
|
trace "SELFDESTRUCT",
|
||||||
storageAddress = computation.msg.storageAddress.toHex,
|
contractAddress = computation.msg.contractAddress.toHex,
|
||||||
localBalance = localBalance.toString,
|
localBalance = localBalance.toString,
|
||||||
beneficiary = beneficiary.toHex
|
beneficiary = beneficiary.toHex
|
||||||
|
|
||||||
|
@ -868,7 +868,7 @@ op selfDestructEip161, inline = false:
|
||||||
beneficiary = computation.stack.popAddress()
|
beneficiary = computation.stack.popAddress()
|
||||||
stateDb = computation.vmState.readOnlyStateDb
|
stateDb = computation.vmState.readOnlyStateDb
|
||||||
isDead = stateDb.isDeadAccount(beneficiary)
|
isDead = stateDb.isDeadAccount(beneficiary)
|
||||||
balance = stateDb.getBalance(computation.msg.storageAddress)
|
balance = stateDb.getBalance(computation.msg.contractAddress)
|
||||||
|
|
||||||
let gasParams = GasParams(kind: SelfDestruct,
|
let gasParams = GasParams(kind: SelfDestruct,
|
||||||
sd_condition: isDead and not balance.isZero
|
sd_condition: isDead and not balance.isZero
|
||||||
|
@ -929,20 +929,20 @@ op sstoreEIP2200, inline = false, slot, value:
|
||||||
raise newException(OutOfGas, "Gas not enough to perform EIP2200 SSTORE")
|
raise newException(OutOfGas, "Gas not enough to perform EIP2200 SSTORE")
|
||||||
|
|
||||||
let stateDB = computation.vmState.readOnlyStateDB
|
let stateDB = computation.vmState.readOnlyStateDB
|
||||||
let (currentValue, existing) = stateDB.getStorage(computation.msg.storageAddress, slot)
|
let (currentValue, existing) = stateDB.getStorage(computation.msg.contractAddress, slot)
|
||||||
|
|
||||||
let
|
let
|
||||||
gasParam = GasParams(kind: Op.Sstore,
|
gasParam = GasParams(kind: Op.Sstore,
|
||||||
s_isStorageEmpty: currentValue.isZero,
|
s_isStorageEmpty: currentValue.isZero,
|
||||||
s_currentValue: currentValue,
|
s_currentValue: currentValue,
|
||||||
s_originalValue: stateDB.getCommittedStorage(computation.msg.storageAddress, slot)
|
s_originalValue: stateDB.getCommittedStorage(computation.msg.contractAddress, slot)
|
||||||
)
|
)
|
||||||
(gasCost, gasRefund) = computation.gasCosts[Sstore].c_handler(value, gasParam)
|
(gasCost, gasRefund) = computation.gasCosts[Sstore].c_handler(value, gasParam)
|
||||||
|
|
||||||
computation.gasMeter.consumeGas(gasCost, &"SSTORE EIP2200: {computation.msg.storageAddress}[{slot}] -> {value} ({currentValue})")
|
computation.gasMeter.consumeGas(gasCost, &"SSTORE EIP2200: {computation.msg.contractAddress}[{slot}] -> {value} ({currentValue})")
|
||||||
|
|
||||||
if gasRefund != 0:
|
if gasRefund != 0:
|
||||||
computation.gasMeter.refundGas(gasRefund)
|
computation.gasMeter.refundGas(gasRefund)
|
||||||
|
|
||||||
computation.vmState.mutateStateDB:
|
computation.vmState.mutateStateDB:
|
||||||
db.setStorage(computation.msg.storageAddress, slot, value)
|
db.setStorage(computation.msg.contractAddress, slot, value)
|
||||||
|
|
|
@ -125,7 +125,7 @@ proc logImpl(c: BaseComputation, opcode: Op, topicCount: int) =
|
||||||
|
|
||||||
c.memory.extend(memPos, len)
|
c.memory.extend(memPos, len)
|
||||||
log.data = c.memory.read(memPos, len)
|
log.data = c.memory.read(memPos, len)
|
||||||
log.address = c.msg.storageAddress
|
log.address = c.msg.contractAddress
|
||||||
c.addLogEntry(log)
|
c.addLogEntry(log)
|
||||||
|
|
||||||
template genLog*() =
|
template genLog*() =
|
||||||
|
|
|
@ -100,7 +100,7 @@ proc traceOpCodeEnded*(tracer: var TransactionTracer, c: BaseComputation, op: Op
|
||||||
if c.msg.depth < tracer.storageKeys.len:
|
if c.msg.depth < tracer.storageKeys.len:
|
||||||
var stateDB = c.vmState.accountDb
|
var stateDB = c.vmState.accountDb
|
||||||
for key in tracer.storage(c.msg.depth):
|
for key in tracer.storage(c.msg.depth):
|
||||||
let (value, _) = stateDB.getStorage(c.msg.storageAddress, key)
|
let (value, _) = stateDB.getStorage(c.msg.contractAddress, key)
|
||||||
storage[key.dumpHex] = %(value.dumpHex)
|
storage[key.dumpHex] = %(value.dumpHex)
|
||||||
j["storage"] = storage
|
j["storage"] = storage
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ proc setupComputation*(vmState: BaseVMState, tx: Transaction, sender, recipient:
|
||||||
gasPrice: tx.gasPrice,
|
gasPrice: tx.gasPrice,
|
||||||
origin: sender,
|
origin: sender,
|
||||||
sender: sender,
|
sender: sender,
|
||||||
storageAddress: recipient,
|
contractAddress: recipient,
|
||||||
codeAddress: tx.to,
|
codeAddress: tx.to,
|
||||||
value: tx.value,
|
value: tx.value,
|
||||||
data: data,
|
data: data,
|
||||||
|
|
|
@ -103,7 +103,7 @@ type
|
||||||
gasPrice*: GasInt
|
gasPrice*: GasInt
|
||||||
origin*: EthAddress
|
origin*: EthAddress
|
||||||
sender*: EthAddress
|
sender*: EthAddress
|
||||||
storageAddress*: EthAddress
|
contractAddress*: EthAddress
|
||||||
codeAddress*: EthAddress
|
codeAddress*: EthAddress
|
||||||
value*: UInt256
|
value*: UInt256
|
||||||
data*: seq[byte]
|
data*: seq[byte]
|
||||||
|
|
|
@ -287,7 +287,7 @@ proc runVM*(blockNumber: Uint256, chainDB: BaseChainDB, boa: Assembler): bool =
|
||||||
|
|
||||||
var
|
var
|
||||||
stateDB = computation.vmState.accountDb
|
stateDB = computation.vmState.accountDb
|
||||||
account = stateDB.getAccount(computation.msg.storageAddress)
|
account = stateDB.getAccount(computation.msg.contractAddress)
|
||||||
trie = initSecureHexaryTrie(chainDB.db, account.storageRoot)
|
trie = initSecureHexaryTrie(chainDB.db, account.storageRoot)
|
||||||
|
|
||||||
for kv in boa.storage:
|
for kv in boa.storage:
|
||||||
|
|
|
@ -28,8 +28,19 @@ template doTest(fixture: JsonNode, address: byte, action: untyped): untyped =
|
||||||
gas = 1_000_000.GasInt
|
gas = 1_000_000.GasInt
|
||||||
gasPrice = 1.GasInt
|
gasPrice = 1.GasInt
|
||||||
sender: EthAddress
|
sender: EthAddress
|
||||||
to = initAddress(address)
|
toAddress = initAddress(address)
|
||||||
message = newMessage(gas, gasPrice, to, sender, 0.u256, data, @[], contractCreation = false)
|
message = Message(
|
||||||
|
gas: gas,
|
||||||
|
gasPrice: gasPrice,
|
||||||
|
origin: sender,
|
||||||
|
sender: sender,
|
||||||
|
contractAddress: toAddress,
|
||||||
|
codeAddress: toAddress,
|
||||||
|
value: 0.u256,
|
||||||
|
data: data,
|
||||||
|
code: @[],
|
||||||
|
contractCreation: false
|
||||||
|
)
|
||||||
computation = newBaseComputation(vmState, header.blockNumber, message)
|
computation = newBaseComputation(vmState, header.blockNumber, message)
|
||||||
echo "Running ", action.astToStr, " - ", test["name"]
|
echo "Running ", action.astToStr, " - ", test["name"]
|
||||||
`action`(computation)
|
`action`(computation)
|
||||||
|
|
|
@ -45,17 +45,19 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
|
||||||
|
|
||||||
code = fexec{"code"}.getStr.hexToSeqByte
|
code = fexec{"code"}.getStr.hexToSeqByte
|
||||||
let toAddress = fexec{"address"}.getStr.parseAddress
|
let toAddress = fexec{"address"}.getStr.parseAddress
|
||||||
let message = newMessage(
|
let message = Message(
|
||||||
to = toAddress,
|
depth: 0,
|
||||||
sender = fexec{"caller"}.getStr.parseAddress,
|
gas: fexec{"gas"}.getHexadecimalInt,
|
||||||
value = cast[uint64](fexec{"value"}.getHexadecimalInt).u256, # Cast workaround for negative value
|
gasPrice: fexec{"gasPrice"}.getHexadecimalInt,
|
||||||
data = fexec{"data"}.getStr.hexToSeqByte,
|
origin: fexec{"origin"}.getStr.parseAddress,
|
||||||
code = code,
|
sender: fexec{"caller"}.getStr.parseAddress,
|
||||||
contractCreation = toAddress == ZERO_ADDRESS, # assume ZERO_ADDRESS is a contract creation
|
contractAddress: toAddress,
|
||||||
gas = fexec{"gas"}.getHexadecimalInt,
|
codeAddress: toAddress,
|
||||||
gasPrice = fexec{"gasPrice"}.getHexadecimalInt,
|
value: cast[uint64](fexec{"value"}.getHexadecimalInt).u256, # Cast workaround for negative value
|
||||||
options = newMessageOptions(origin=fexec{"origin"}.getStr.parseAddress,
|
data: fexec{"data"}.getStr.hexToSeqByte,
|
||||||
createAddress = toAddress))
|
code: code,
|
||||||
|
contractCreation: toAddress == ZERO_ADDRESS # assume ZERO_ADDRESS is a contract creation
|
||||||
|
)
|
||||||
|
|
||||||
var computation = newBaseComputation(vmState, header.blockNumber, message)
|
var computation = newBaseComputation(vmState, header.blockNumber, message)
|
||||||
computation.executeOpcodes()
|
computation.executeOpcodes()
|
||||||
|
|
Loading…
Reference in New Issue