Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion beacon_chain/libnimbus_lc/libnimbus_lc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import
std/[json, sequtils, times],
stew/objects,
eth/common/eth_types_rlp,
eth/common/keys,
eth/p2p/discoveryv5/random2,
Expand Down Expand Up @@ -957,7 +958,7 @@ proc ETHLightClientHeaderCopyExecutionHash(
root.toUnmanagedPtr()

type ExecutionPayloadHeader =
typeof(default(lcDataFork.LightClientHeader).execution)
typeof(declval(lcDataFork.LightClientHeader).execution)

func ETHLightClientHeaderGetExecution(
header: ptr lcDataFork.LightClientHeader
Expand Down
21 changes: 12 additions & 9 deletions beacon_chain/spec/datatypes/base.nim
Original file line number Diff line number Diff line change
Expand Up @@ -884,19 +884,22 @@ func getSizeofSig(x: auto, n: int = 0): seq[(string, int, int)] =
template isomorphicCast*[T](x: auto): T =
# Each of these pairs of types has ABI-compatible memory representations.
type U = typeof(x)

static: doAssert (T is ref) == (U is ref)
when T is ref:
type
TT = typeof default(typeof T)[]
UU = typeof default(typeof U)[]
static:
doAssert sizeof(TT) == sizeof(UU)
doAssert getSizeofSig(TT()) == getSizeofSig(UU())
when defined(debug):
type
TT = pointerBase(T)
UU = pointerBase(U)
static:
doAssert sizeof(TT) == sizeof(UU)
doAssert getSizeofSig(TT()) == getSizeofSig(UU())
cast[T](x)
else:
static:
doAssert getSizeofSig(T()) == getSizeofSig(U())
doAssert sizeof(T) == sizeof(U)
when defined(debug): # 10s+ compile time due to `default(T)` and `replace`!
static:
doAssert sizeof(T) == sizeof(U)
doAssert getSizeofSig(T()) == getSizeofSig(U())
cast[ptr T](unsafeAddr x)[]

func prune*(cache: var StateCache, epoch: Epoch) =
Expand Down
10 changes: 6 additions & 4 deletions beacon_chain/spec/state_transition.nim
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@
import
chronicles,
results,
stew/objects,
../extras,
"."/[
beaconstate, eth2_merkleization, forks, helpers, signatures,
state_transition_block, state_transition_epoch, validator]
./[
beaconstate, eth2_merkleization, forks, helpers, signatures, state_transition_block,
state_transition_epoch, validator,
]

export results, extras, state_transition_block

Expand Down Expand Up @@ -377,7 +379,7 @@ proc makeBeaconBlockWithRewards*(
## the block is to be created.
type
MaybeBlindedBeaconBlock = consensusFork.BeaconBlock(type(execution_payload))
MaybeBlindedBlockBody = typeof(default(MaybeBlindedBeaconBlock).body)
MaybeBlindedBlockBody = typeof(declval(MaybeBlindedBeaconBlock).body)

# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.2/specs/phase0/validator.md#preparing-for-a-beaconblock
var blck = MaybeBlindedBeaconBlock(
Expand Down
Loading