Fixed compilation errors. Reenabled test
This commit is contained in:
parent
eff23ba182
commit
7e630bf8bf
|
@ -95,7 +95,7 @@ func get_new_shuffling*(seed: Blake2_256_Digest, validators: seq[ValidatorRecord
|
|||
result.add committees
|
||||
|
||||
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: 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 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.
|
||||
# Clarify with EF if light clients will need the beacon chain
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import
|
|||
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
|
||||
|
||||
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
|
||||
var parent_hashes = newSeq[Blake2_256_Digest](CYCLE_LENGTH - attestation.oblique_parent_hashes.len)
|
||||
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
|
||||
|
||||
# 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
|
||||
x = 1
|
||||
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]
|
||||
inc x
|
||||
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)
|
||||
|
||||
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 attestation.shard_block_hash.data
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
./test_ssz
|
||||
# ./test_block_processing
|
||||
./test_ssz,
|
||||
./test_block_processing
|
||||
|
|
|
@ -13,8 +13,8 @@ suite "Block processing":
|
|||
## For now just test that we can compile and execute block processing with mock data.
|
||||
|
||||
test "Mock process_block":
|
||||
let actState = ActiveState()
|
||||
let crystState = CrystallizedState()
|
||||
let actState = BeaconState()
|
||||
let crystState = BeaconState()
|
||||
let blck = BeaconBlock()
|
||||
let slot = 10'u
|
||||
|
||||
|
|
Loading…
Reference in New Issue