Skip to content

Commit

Permalink
Work-around for #373 (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
zah authored and tersec committed Sep 5, 2019
1 parent d17d7db commit 7ebf685
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
10 changes: 8 additions & 2 deletions beacon_chain/spec/state_transition_epoch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,14 @@ proc process_final_updates*(state: var BeaconState) =
let
index_epoch = next_epoch + ACTIVATION_EXIT_DELAY
index_root_position = index_epoch mod EPOCHS_PER_HISTORICAL_VECTOR
indices_list = sszList(get_active_validator_indices(state, index_epoch), VALIDATOR_REGISTRY_LIMIT)
state.active_index_roots[index_root_position] = hash_tree_root(indices_list)
indices_list = get_active_validator_indices(state, index_epoch)

state.active_index_roots[index_root_position] = hash_tree_root(
# TODO The +1 on the next line is not conforming to the spec.
# Without it, our merkleization padding is missing one final
# level of mixing with a zero hash. We need to investigate
# why this is happening only in the particular case here.
sszList(indices_list, VALIDATOR_REGISTRY_LIMIT + 1))

# Set committees root
let committee_root_position = next_epoch mod EPOCHS_PER_HISTORICAL_VECTOR
Expand Down
11 changes: 4 additions & 7 deletions beacon_chain/ssz/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,16 @@ func fixedPortionSize*(T0: type): int {.compileTime.} =

when T is BasicType: sizeof(T)
elif T is array:
const elementCount = high(T).ord - low(T).ord + 1
type E = ElemType(T)
when isFixedSize(E): elementCount * fixedPortionSize(E)
else: elementCount * offsetSize
when isFixedSize(E): len(T) * fixedPortionSize(E)
else: len(T) * offsetSize
elif T is seq|string|openarray|ref|ptr|Option: offsetSize
elif T is object|tuple:
var res = 0
enumAllSerializedFields(T):
when isFixedSize(FieldType):
res += fixedPortionSize(FieldType)
result += fixedPortionSize(FieldType)
else:
res += offsetSize
res
result += offsetSize
else:
unsupported T0

Expand Down
9 changes: 4 additions & 5 deletions tests/official/test_fixture_state_transition_epoch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ runSuite(RegistryUpdatesDir, "Registry updates", process_registry_updates, useC
const SlashingsDir = SszTestsDir/const_preset/"phase0"/"epoch_processing"/"slashings"/"pyspec_tests"
runSuite(SlashingsDir, "Slashings", process_slashings, useCache = false)

when false: # TODO: Failing
# Final updates
# ---------------------------------------------------------------
# Final updates
# ---------------------------------------------------------------

const FinalUpdatesDir = SszTestsDir/const_preset/"phase0"/"epoch_processing"/"final_updates"/"pyspec_tests"
runSuite(FinalUpdatesDir, "Final updates", process_final_updates, useCache = false)
const FinalUpdatesDir = SszTestsDir/const_preset/"phase0"/"epoch_processing"/"final_updates"/"pyspec_tests"
runSuite(FinalUpdatesDir, "Final updates", process_final_updates, useCache = false)

0 comments on commit 7ebf685

Please sign in to comment.