Merge branch 'master' of github.com:status-im/nim-beacon-chain

This commit is contained in:
Ștefan Talpalaru 2019-09-05 12:42:21 +02:00
commit b6f4fa5532
No known key found for this signature in database
GPG Key ID: CBF7934204F1B6F9
3 changed files with 16 additions and 14 deletions

View File

@ -485,8 +485,14 @@ proc process_final_updates*(state: var BeaconState) =
let let
index_epoch = next_epoch + ACTIVATION_EXIT_DELAY index_epoch = next_epoch + ACTIVATION_EXIT_DELAY
index_root_position = index_epoch mod EPOCHS_PER_HISTORICAL_VECTOR index_root_position = index_epoch mod EPOCHS_PER_HISTORICAL_VECTOR
indices_list = sszList(get_active_validator_indices(state, index_epoch), VALIDATOR_REGISTRY_LIMIT) indices_list = get_active_validator_indices(state, index_epoch)
state.active_index_roots[index_root_position] = hash_tree_root(indices_list)
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 # Set committees root
let committee_root_position = next_epoch mod EPOCHS_PER_HISTORICAL_VECTOR let committee_root_position = next_epoch mod EPOCHS_PER_HISTORICAL_VECTOR

View File

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

View File

@ -81,9 +81,8 @@ runSuite(RegistryUpdatesDir, "Registry updates", process_registry_updates, useC
const SlashingsDir = SszTestsDir/const_preset/"phase0"/"epoch_processing"/"slashings"/"pyspec_tests" const SlashingsDir = SszTestsDir/const_preset/"phase0"/"epoch_processing"/"slashings"/"pyspec_tests"
runSuite(SlashingsDir, "Slashings", process_slashings, useCache = false) 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" const FinalUpdatesDir = SszTestsDir/const_preset/"phase0"/"epoch_processing"/"final_updates"/"pyspec_tests"
runSuite(FinalUpdatesDir, "Final updates", process_final_updates, useCache = false) runSuite(FinalUpdatesDir, "Final updates", process_final_updates, useCache = false)