From 236a9cdd1d2a5ac73438c971c46fe22c7be216bc Mon Sep 17 00:00:00 2001 From: tersec Date: Wed, 10 Mar 2021 09:13:32 +0000 Subject: [PATCH] ensure HashList/HashArray maxChunks power of 2 in int64 (#2394) --- beacon_chain/ssz/types.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beacon_chain/ssz/types.nim b/beacon_chain/ssz/types.nim index 99cef8468..724cc3e9d 100644 --- a/beacon_chain/ssz/types.nim +++ b/beacon_chain/ssz/types.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018-2020 Status Research & Development GmbH +# Copyright (c) 2018-2021 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). @@ -168,6 +168,7 @@ template maxChunks*(a: HashList|HashArray): int64 = template maxDepth*(a: HashList|HashArray): int = ## Layer where data is + static: doAssert a.maxChunks <= high(int64) div 2 layer(nextPow2(a.maxChunks.uint64).int64) template chunkIdx(a: HashList|HashArray, dataIdx: int64): int64 =