Skip to content

Commit

Permalink
Removed validation_code_addr_to_index
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed Sep 20, 2017
1 parent 5b10aa0 commit 9531073
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 11 deletions.
10 changes: 0 additions & 10 deletions sharding/contracts/validator_manager.v.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@

sighasher_addr: address

# mapping validator_code_addr to index of validators
validation_code_addr_to_index: num[address]

# log the latest period number of the shard
period_head: public(num[num])

Expand Down Expand Up @@ -115,13 +112,11 @@ def deposit(validation_code_addr: address, return_addr: address) -> num:
}
self.num_validators += 1
self.is_valcode_deposited[validation_code_addr] = True
self.validation_code_addr_to_index[validation_code_addr] = index
return index


def withdraw(validator_index: num, sig: bytes <= 1000) -> bool:
msg_hash = sha3("withdraw")
self.validation_code_addr_to_index[self.validators[validator_index].validation_code_addr] = 0
result = (extract32(raw_call(self.validators[validator_index].validation_code_addr, concat(msg_hash, sig), gas=self.sig_gas_limit, outsize=32), 0) == as_bytes32(1))
if result:
send(self.validators[validator_index].return_addr, self.validators[validator_index].deposit)
Expand Down Expand Up @@ -314,8 +309,3 @@ def update_gasprice(receipt_id: num, tx_gasprice: num) -> bool:
assert self.receipts[receipt_id].sender == msg.sender
self.receipts[receipt_id].tx_gasprice = tx_gasprice
return True


def get_index(addr: address) -> num:
# FIXME: one validation_code_addr may be reused
return self.validation_code_addr_to_index[addr]
1 change: 0 additions & 1 deletion sharding/tests/test_validator_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def test_validator_manager():
assert c.head_state.get_balance(return_addr) == DEPOSIT_SIZE
# test deposit: make use of empty slots
assert 0 == x.deposit(k0_valcode_addr, return_addr, value=DEPOSIT_SIZE, sender=t.k0)
assert x.get_index(k0_valcode_addr) == 0

assert x.withdraw(1, sign(WITHDRAW_HASH, t.k1))
# test deposit: working fine in the edge condition
Expand Down

0 comments on commit 9531073

Please sign in to comment.