Remove validateCanonicalAddress

This commit is contained in:
coffeepots 2018-07-19 19:04:01 +01:00
parent feaff16e9d
commit e33bc85bfa
4 changed files with 0 additions and 19 deletions

View File

@ -46,17 +46,14 @@ proc setAccount(db: AccountStateDB, address: EthAddress, account: Account) =
db.trie.put createRangeFromAddress(address), rlp.encode(account)
proc getCodeHash*(db: AccountStateDB, address: EthAddress): Hash256 =
validateCanonicalAddress(address, title="Storage Address")
let account = db.getAccount(address)
result = account.codeHash
proc getBalance*(db: AccountStateDB, address: EthAddress): UInt256 =
validateCanonicalAddress(address, title="Storage Address")
let account = db.getAccount(address)
account.balance
proc setBalance*(db: var AccountStateDB, address: EthAddress, balance: UInt256) =
validateCanonicalAddress(address, title="Storage Address")
var account = db.getAccount(address)
account.balance = balance
db.setAccount(address, account)
@ -77,7 +74,6 @@ proc setStorage*(db: var AccountStateDB,
slot: UInt256, value: UInt256) =
#validateGte(value, 0, title="Storage Value")
#validateGte(slot, 0, title="Storage Slot")
validateCanonicalAddress(address, title="Storage Address")
var account = db.getAccount(address)
var accountTrie = initHexaryTrie(db.trie.db, account.storageRoot)
@ -93,7 +89,6 @@ proc setStorage*(db: var AccountStateDB,
db.setAccount(address, account)
proc getStorage*(db: AccountStateDB, address: EthAddress, slot: UInt256): (UInt256, bool) =
validateCanonicalAddress(address, title="Storage Address")
#validateGte(slot, 0, title="Storage Slot")
let
@ -110,7 +105,6 @@ proc getStorage*(db: AccountStateDB, address: EthAddress, slot: UInt256): (UInt2
result = (0.u256, false)
proc setNonce*(db: var AccountStateDB, address: EthAddress, nonce: UInt256) =
validateCanonicalAddress(address, title="Storage Address")
#validateGte(nonce, 0, title="Nonce")
var account = db.getAccount(address)
@ -121,8 +115,6 @@ proc setNonce*(db: var AccountStateDB, address: EthAddress, nonce: UInt256) =
proc getNonce*(db: AccountStateDB, address: EthAddress): UInt256 =
# TODO it is very strange that we require a var param here
validateCanonicalAddress(address, title="Storage Address")
let account = db.getAccount(address)
account.nonce
@ -132,7 +124,6 @@ proc toByteRange_Unnecessary*(h: KeccakHash): ByteRange =
return s.toRange
proc setCode*(db: var AccountStateDB, address: EthAddress, code: ByteRange) =
validateCanonicalAddress(address, title="Storage Address")
var account = db.getAccount(address)
account.codeHash = keccak256.digest code.toOpenArray

View File

@ -9,10 +9,6 @@ import
strformat,
errors, constants, eth_common
template validateCanonicalAddress*(value: EthAddress, title: string = "Value") =
# TODO: This needs to be removed
discard
proc validateGte*(value: Int256 | int, minimum: int, title: string = "Value") =
if value.i256 < minimum.i256:
raise newException(ValidationError,

View File

@ -85,8 +85,6 @@ proc outputHex*(c: BaseComputation): string =
c.rawOutput.bytesToHex
proc registerAccountForDeletion*(c: var BaseComputation, beneficiary: EthAddress) =
validateCanonicalAddress(beneficiary, title="self destruct beneficiary address")
if c.msg.storageAddress in c.accountsToDelete:
raise newException(ValueError,
"invariant: should be impossible for an account to be " &
@ -94,7 +92,6 @@ proc registerAccountForDeletion*(c: var BaseComputation, beneficiary: EthAddress
c.accountsToDelete[c.msg.storageAddress] = beneficiary
proc addLogEntry*(c: var BaseComputation, account: EthAddress, topics: seq[UInt256], data: seq[byte]) =
validateCanonicalAddress(account, title="log entry address")
c.logEntries.add((account, topics, data))
# many methods are basically TODO, but they still return valid values

View File

@ -44,9 +44,6 @@ proc newMessage*(
code: string,
options: MessageOptions = newMessageOptions()): Message =
if to != CREATE_CONTRACT_ADDRESS:
validateCanonicalAddress(to, title="Message.to")
validateCanonicalAddress(sender, title="Message.sender")
validateGte(options.depth, minimum=0, title="Message.depth")
new(result)