-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extend light client protocol for Electra #6375
Conversation
Add missing Electra support for light client protocol: - ethereum/consensus-specs#3811 Tested against PR consensus-spec-tests, the test runner automatically picks up the new tests once available.
@@ -188,8 +213,71 @@ template kind*( | |||
deneb.LightClientStore]): LightClientDataFork = | |||
LightClientDataFork.Deneb | |||
|
|||
template kind*( | |||
x: typedesc[ # `SomeLightClientObject` doesn't work here (Nim 1.6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might link to nim-lang/Nim#18095 here
@@ -951,6 +1135,108 @@ func toDenebLightClientHeader( | |||
execution_branch: blck.message.body.build_proof( | |||
capella.EXECUTION_PAYLOAD_GINDEX).get) | |||
|
|||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/light-client/full-node.md#modified-block_to_light_client_header | |||
func toElectraLightClientHeader( | |||
blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beacon: blck.message.toBeaconBlockHeader()) | ||
|
||
func toElectraLightClientHeader( | ||
blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way it won't be a mystery to check if/when it's eventually fixed
capella.EXECUTION_PAYLOAD_GINDEX).get) | ||
|
||
func toElectraLightClientHeader( | ||
blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
capella.EXECUTION_PAYLOAD_GINDEX).get) | ||
|
||
func toElectraLightClientHeader( | ||
blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hash_tree_root(payload.consolidation_requests)), | ||
execution_branch: blck.message.body.build_proof( | ||
capella.EXECUTION_PAYLOAD_GINDEX).get) | ||
|
||
func toLightClientHeader*( | ||
blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -990,9 +1275,13 @@ func shortLog*[ | |||
capellaData: typeof(x.capellaData.shortLog()) | |||
of LightClientDataFork.Deneb: | |||
denebData: typeof(x.denebData.shortLog()) | |||
of LightClientDataFork.Electra: | |||
electraData: typeof(x.electraData.shortLog()) | |||
|
|||
let xKind = x.kind # Nim 1.6.12: Using `kind: x.kind` inside case is broken |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this ever isolated/reproduced/fixed/reported/already-reported-upstream or maybe fixed in 2.0.6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not reported upstream, but this is the error that is produced when trying to inline x.kind
:
Error: a case selecting discriminator 'kind' with value 'x.kind' appears in the object construction, but the field(s) 'denebData' are in conflict with this value.
Still applies to 2.0.6, have updated the comment in #6389
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also for all the "... works in Nim 1.6 ..." etc comments, as of the last couple days, |
|
||
if epoch < cfg.CAPELLA_FORK_EPOCH: | ||
return | ||
header.execution == default(ExecutionPayloadHeader) and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general,
type L = object
a: string
b: int
c: array[32, byte]
d: array[32, byte]
e: uint64
func a(x: L): bool =
x == default(L)
discard a(L())
produces, with Nim 2.0.6 using refc
,
struct tyObject_L__0ubpPjj6L2pwUQ1bt60yqg {
NimStringDesc *a;
NI b;
tyArray__vEOa9c5qaE9ajWxR5R4zwfQg c;
tyArray__vEOa9c5qaE9ajWxR5R4zwfQg d;
NU64 e;
};
...
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL,
a__a_u7)(tyObject_L__0ubpPjj6L2pwUQ1bt60yqg *x_p0) {
NIM_BOOL result;
tyObject_L__0ubpPjj6L2pwUQ1bt60yqg T1_;
result = (NIM_BOOL)0;
nimZeroMem((void *)(&T1_), sizeof(tyObject_L__0ubpPjj6L2pwUQ1bt60yqg));
result = eqeq___a_u15(x_p0, (&T1_));
popFrame();
return result;
}
whereas
type L = object
a: string
b: int
c: array[32, byte]
d: array[32, byte]
e: uint64
func a(x: L): bool =
x == static(default(L))
discard a(L())
results in
struct tyObject_L__0ubpPjj6L2pwUQ1bt60yqg {
NimStringDesc *a;
NI b;
tyArray__vEOa9c5qaE9ajWxR5R4zwfQg c;
tyArray__vEOa9c5qaE9ajWxR5R4zwfQg d;
NU64 e;
};
...
static NIM_CONST tyObject_L__0ubpPjj6L2pwUQ1bt60yqg
TM__R8RUzYq41iOx0I9bZH5Nyrw_2 = {
((NimStringDesc *)NIM_NIL),
((NI)0),
{((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0),
((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0),
((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0),
((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0),
((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0)},
{((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0),
((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0),
((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0),
((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0),
((NU8)0), ((NU8)0), ((NU8)0), ((NU8)0)},
0ULL};
...
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL,
a__a_u7)(tyObject_L__0ubpPjj6L2pwUQ1bt60yqg *x_p0) {
NIM_BOOL result;
result = (NIM_BOOL)0;
result = eqeq___a_u15(x_p0, (&TM__R8RUzYq41iOx0I9bZH5Nyrw_2));
popFrame();
return result;
}
It's possible gcc and clang can both under -O3 -flto
deduce that they don't have to consume the stack space, reinitialize/zero every time, et cetera, but that seems fairly excessive when wrapping the default(...)
as static(default(...))
or using const foo = default(...); compare_with(foo)
avoids the per-call construction/zeroing/stack space altogether of this object.
Addresses feedback from #6375 that is applicable to pre-existing code moreso than to the new PR.
Addresses feedback from #6375 that is applicable to pre-existing code moreso than to the new PR.
Followup on incorrect upgrade procedure in #6375 where `blob_gas_used` was accidentally copied into `excess_blob_gas` when running Electra `LightClientStore` with earlier `LightClient(Bootstrap|Update)`.
Followup on incorrect upgrade procedure in #6375 where `blob_gas_used` was accidentally copied into `excess_blob_gas` when running Electra `LightClientStore` with earlier `LightClient(Bootstrap|Update)`.
Add missing Electra support for light client protocol:
Tested against PR consensus-spec-tests, the test runner automatically picks up the new tests once available.