Fixed compilation errors. Reenabled test

This commit is contained in:
Yuriy Glukhov 2018-11-19 18:47:57 +02:00
parent eff23ba182
commit 7e630bf8bf
4 changed files with 10 additions and 10 deletions

View File

@ -95,7 +95,7 @@ func get_new_shuffling*(seed: Blake2_256_Digest, validators: seq[ValidatorRecord
result.add committees result.add committees
func get_shards_and_committees_for_slot*(state: BeaconState, func get_shards_and_committees_for_slot*(state: BeaconState,
slot: uint64): ShardAndCommittee = slot: uint64): seq[ShardAndCommittee] =
# TODO: Spec why is active_state an argument? # TODO: Spec why is active_state an argument?
# TODO: this returns a scalar, not vector, but its return type in spec is a seq/list? # TODO: this returns a scalar, not vector, but its return type in spec is a seq/list?
@ -103,7 +103,7 @@ func get_shards_and_committees_for_slot*(state: BeaconState,
assert earliest_slot_in_array <= slot assert earliest_slot_in_array <= slot
assert slot < earliest_slot_in_array + CYCLE_LENGTH * 2 assert slot < earliest_slot_in_array + CYCLE_LENGTH * 2
return state.shard_and_committee_for_slots[int slot - earliest_slot_in_array] return @[state.shard_and_committee_for_slots[int slot - earliest_slot_in_array]]
# TODO, slot is a uint64; will be an issue on int32 arch. # TODO, slot is a uint64; will be an issue on int32 arch.
# Clarify with EF if light clients will need the beacon chain # Clarify with EF if light clients will need the beacon chain

View File

@ -26,7 +26,7 @@ import
milagro_crypto # nimble install https://github.com/status-im/nim-milagro-crypto@#master milagro_crypto # nimble install https://github.com/status-im/nim-milagro-crypto@#master
func process_block*(active_state: ActiveState, crystallized_state: CrystallizedState, blck: BeaconBlock, slot: uint64) = func process_block*(active_state: BeaconState, crystallized_state: BeaconState, blck: BeaconBlock, slot: uint64) =
# TODO: unfinished spec # TODO: unfinished spec
for attestation in blck.attestations: for attestation in blck.attestations:
@ -40,7 +40,7 @@ func process_block*(active_state: ActiveState, crystallized_state: CrystallizedS
# TODO - don't allocate in tight loop # TODO - don't allocate in tight loop
var parent_hashes = newSeq[Blake2_256_Digest](CYCLE_LENGTH - attestation.oblique_parent_hashes.len) var parent_hashes = newSeq[Blake2_256_Digest](CYCLE_LENGTH - attestation.oblique_parent_hashes.len)
for idx, val in parent_hashes.mpairs: for idx, val in parent_hashes.mpairs:
val = get_block_hash(active_state, blck, slot - CYCLE_LENGTH + cast[uint64](idx) + 1) val = get_block_hash(active_state, blck, cast[int](slot - CYCLE_LENGTH + cast[uint64](idx) + 1))
parent_hashes.add attestation.oblique_parent_hashes parent_hashes.add attestation.oblique_parent_hashes
# Let attestation_indices be get_shards_and_committees_for_slot(crystallized_state, slot)[x], choosing x so that attestation_indices.shard_id equals the shard_id value provided to find the set of validators that is creating this attestation record. # Let attestation_indices be get_shards_and_committees_for_slot(crystallized_state, slot)[x], choosing x so that attestation_indices.shard_id equals the shard_id value provided to find the set of validators that is creating this attestation record.
@ -49,7 +49,7 @@ func process_block*(active_state: ActiveState, crystallized_state: CrystallizedS
var var
x = 1 x = 1
record_creator = shard_and_committees[0] record_creator = shard_and_committees[0]
while record_creator.shard_id != attestation.shard_id: while record_creator.shard_id != attestation.shard:
record_creator = shard_and_committees[x] record_creator = shard_and_committees[x]
inc x inc x
record_creator record_creator
@ -84,7 +84,7 @@ func process_block*(active_state: ActiveState, crystallized_state: CrystallizedS
ctx.update(cast[ptr byte](parent_hashes[0].addr), size_p_hashes) ctx.update(cast[ptr byte](parent_hashes[0].addr), size_p_hashes)
var be_shard_id: array[2, byte] # Unsure, spec doesn't mention big-endian representation var be_shard_id: array[2, byte] # Unsure, spec doesn't mention big-endian representation
bigEndian16(be_shard_id.addr, attestation.shard_id.unsafeAddr) bigEndian16(be_shard_id.addr, attestation.shard.unsafeAddr)
ctx.update be_shard_id ctx.update be_shard_id
ctx.update attestation.shard_block_hash.data ctx.update attestation.shard_block_hash.data

View File

@ -6,5 +6,5 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms. # at your option. This file may not be copied, modified, or distributed except according to those terms.
import import
./test_ssz ./test_ssz,
# ./test_block_processing ./test_block_processing

View File

@ -13,8 +13,8 @@ suite "Block processing":
## For now just test that we can compile and execute block processing with mock data. ## For now just test that we can compile and execute block processing with mock data.
test "Mock process_block": test "Mock process_block":
let actState = ActiveState() let actState = BeaconState()
let crystState = CrystallizedState() let crystState = BeaconState()
let blck = BeaconBlock() let blck = BeaconBlock()
let slot = 10'u let slot = 10'u