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
8 changes: 4 additions & 4 deletions beacon_chain/spec/eth2_apis/eth2_rest_json_serialization.nim
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,10 @@ RestJson.useDefaultSerializationFor(
gloas.SignedAggregateAndProof,
gloas.SignedExecutionPayloadBid,
gloas.TrustedAttestation,
gloas_mev.RequestAuthV1,
gloas_mev.SignedRequestAuthV1,
gloas_mev.BuilderPreferencesV1,
gloas_mev.BuilderPreferencesRequestV1,
gloas_mev.BuilderRequestAuth,
gloas_mev.SignedBuilderRequestAuth,
gloas_mev.BuilderPreferences,
gloas_mev.BuilderPreferencesRequest,
heze.BeaconBlock,
heze.BeaconBlockBody,
heze.BeaconState,
Expand Down
4 changes: 2 additions & 2 deletions beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ type
deneb_mev.SignedBlindedBeaconBlock |
electra_mev.SignedBlindedBeaconBlock |
fulu_mev.SignedBlindedBeaconBlock |
BuilderPreferencesRequestV1 |
SignedRequestAuthV1 |
BuilderPreferencesRequest |
SignedBuilderRequestAuth |
gloas.SignedBeaconBlock

EncodeArrays* =
Expand Down
32 changes: 16 additions & 16 deletions beacon_chain/spec/mev/gloas_mev.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ import
../datatypes/[base, constants]

const
# https://github.com/ethereum/builder-specs/blob/78a5546d9d8253beabf7db8baf988a58abdec87f/specs/gloas/builder.md#constants
DOMAIN_REQUEST_AUTH* = DomainType([byte 0x0b, 0x00, 0x00, 0x01])
MAX_DATA_SIZE: int64 = 4096
# https://github.com/ethereum/builder-specs/blob/5aef563dc3532a5009fef02bae97ca563ec28e5b/specs/gloas/builder.md#constants
DOMAIN_BUILDER_REQUEST_AUTH* = DomainType([byte 0x0b, 0x00, 0x00, 0x01])
MAX_BUILDER_AUTH_DATA_SIZE: int64 = 4096

type
RequestAuthData* = List[byte, Limit MAX_DATA_SIZE]
BuilderRequestAuthData* = List[byte, Limit MAX_BUILDER_AUTH_DATA_SIZE]

# https://github.com/ethereum/builder-specs/blob/78a5546d9d8253beabf7db8baf988a58abdec87f/specs/gloas/validator.md#requestauthv1
RequestAuthV1* = object
data*: RequestAuthData
# https://github.com/ethereum/builder-specs/blob/5aef563dc3532a5009fef02bae97ca563ec28e5b/specs/gloas/validator.md#builderrequestauth
BuilderRequestAuth* = object
data*: BuilderRequestAuthData
slot*: Slot

# https://github.com/ethereum/builder-specs/blob/78a5546d9d8253beabf7db8baf988a58abdec87f/specs/gloas/validator.md#signedrequestauthv1
SignedRequestAuthV1* = object
message*: RequestAuthV1
# https://github.com/ethereum/builder-specs/blob/5aef563dc3532a5009fef02bae97ca563ec28e5b/specs/gloas/validator.md#signedbuilderrequestauth
SignedBuilderRequestAuth* = object
message*: BuilderRequestAuth
signature*: ValidatorSig

# https://github.com/ethereum/builder-specs/blob/78a5546d9d8253beabf7db8baf988a58abdec87f/specs/gloas/validator.md#builderpreferencesv1
BuilderPreferencesV1* = object
# https://github.com/ethereum/builder-specs/blob/5aef563dc3532a5009fef02bae97ca563ec28e5b/specs/gloas/validator.md#builderpreferences
BuilderPreferences* = object
max_execution_payment*: Gwei

# https://github.com/ethereum/builder-specs/blob/78a5546d9d8253beabf7db8baf988a58abdec87f/specs/gloas/validator.md#builderpreferencesrequestv1
BuilderPreferencesRequestV1* = object
preferences*: BuilderPreferencesV1
auth*: SignedRequestAuthV1
# https://github.com/ethereum/builder-specs/blob/5aef563dc3532a5009fef02bae97ca563ec28e5b/specs/gloas/validator.md#builderpreferences
BuilderPreferencesRequest* = object
preferences*: BuilderPreferences
auth*: SignedBuilderRequestAuth
10 changes: 5 additions & 5 deletions beacon_chain/spec/mev/rest_mev_calls.nim
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ proc getExecutionPayloadBidPlain*(
parent_hash: Eth2Digest,
parent_root: Eth2Digest,
proposer_pubkey: ValidatorPubKey,
body: SignedRequestAuthV1
body: SignedBuilderRequestAuth
): RestPlainResponse {.
rest, endpoint:
"/eth/v1/builder/execution_payload_bid/{slot}/{parent_hash}/{parent_root}/{proposer_pubkey}",
Expand All @@ -66,7 +66,7 @@ proc getExecutionPayloadBid*(
parent_root: Eth2Digest,
proposer_pubkey: ValidatorPubKey,
consensus_version: ConsensusFork,
body: SignedRequestAuthV1
body: SignedBuilderRequestAuth
): Future[RestPlainResponse] {.
async: (raises: [CancelledError, RestEncodingError, RestDnsResolveError,
RestCommunicationError], raw: true).} =
Expand Down Expand Up @@ -117,17 +117,17 @@ proc submitSignedBeaconBlock*(

proc submitBuilderPreferencesPlain*(
proposer_pubkey: ValidatorPubKey,
body: BuilderPreferencesRequestV1
body: BuilderPreferencesRequest
): RestPlainResponse {.
rest, endpoint: "/eth/v1/builder/builder_preferences/{proposer_pubkey}",
meth: MethodPost, connection: {Dedicated, Close}.}
## https://github.com/ethereum/builder-specs/blob/78a5546d9d8253beabf7db8baf988a58abdec87f/apis/builder/builder_preferences.yaml
## https://github.com/ethereum/builder-specs/blob/5aef563dc3532a5009fef02bae97ca563ec28e5b/apis/builder/builder_preferences.yaml

proc submitBuilderPreferences*(
client: RestClientRef,
consensus_version: ConsensusFork,
proposer_pubkey: ValidatorPubKey,
body: BuilderPreferencesRequestV1
body: BuilderPreferencesRequest
): Future[RestPlainResponse] {.
async: (raises: [CancelledError, RestEncodingError, RestDnsResolveError,
RestCommunicationError], raw: true).} =
Expand Down
11 changes: 5 additions & 6 deletions beacon_chain/spec/signatures.nim
Original file line number Diff line number Diff line change
Expand Up @@ -583,22 +583,21 @@ proc verify_inclusion_list_signature*(
fork, genesis_validators_root, msg)
blsVerify(pubkey, signing_root.data, signature)

# https://github.com/ethereum/builder-specs/blob/78a5546d9d8253beabf7db8baf988a58abdec87f/specs/gloas/validator.md#constructing-the-requestauthv1
debugGloasComment("update once https://github.com/ethereum/builder-specs/pull/165 is merged")
# https://github.com/ethereum/builder-specs/blob/5aef563dc3532a5009fef02bae97ca563ec28e5b/specs/gloas/builder.md#signing
func compute_builder_request_auth*(
genesis_fork_version: Version, msg: RequestAuthV1): Eth2Digest =
let domain = compute_domain(DOMAIN_REQUEST_AUTH, genesis_fork_version)
genesis_fork_version: Version, msg: BuilderRequestAuth): Eth2Digest =
let domain = compute_domain(DOMAIN_BUILDER_REQUEST_AUTH, genesis_fork_version)
compute_signing_root(msg, domain)

func get_builder_request_auth_signature*(
genesis_fork_version: Version,
msg: RequestAuthV1, privkey: ValidatorPrivKey): CookedSig =
msg: BuilderRequestAuth, privkey: ValidatorPrivKey): CookedSig =
let signing_root = compute_builder_request_auth(
genesis_fork_version, msg)
blsSign(privkey, signing_root.data)

proc verify_builder_request_auth_signature*(
genesis_fork_version: Version, msg: RequestAuthV1,
genesis_fork_version: Version, msg: BuilderRequestAuth,
pubkey: ValidatorPubKey | CookedPubKey, signature: SomeSig): bool =
let signing_root = compute_builder_request_auth(
genesis_fork_version, msg)
Expand Down
10 changes: 5 additions & 5 deletions beacon_chain/validators/block_payloads.nim
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,16 @@ proc makeSignedRequestAuth*(
proposer: AttachedValidator,
builder_url: string, slot: Slot,
genesis_fork_version: presets.Version):
Future[Result[SignedRequestAuthV1, string]]
Future[Result[SignedBuilderRequestAuth, string]]
{.async: (raises: [CancelledError]).} =
let
msg = RequestAuthV1(
data: RequestAuthData.init(toBytes(builder_url)),
msg = BuilderRequestAuth(
data: BuilderRequestAuthData.init(toBytes(builder_url)),
slot: slot)
sig = (await proposer.getBuilderRequestAuthSignature(
genesis_fork_version, msg)).valueOr:
return err(error)
ok(SignedRequestAuthV1(
ok(SignedBuilderRequestAuth(
message: msg,
signature: sig))

Expand All @@ -478,7 +478,7 @@ proc getExecutionPayloadBidFromBuilder*(
parent_root: Eth2Digest,
proposer_pubkey: ValidatorPubKey,
consensus_version: ConsensusFork,
request_auth: SignedRequestAuthV1,
request_auth: SignedBuilderRequestAuth,
): Future[Result[gloas.SignedExecutionPayloadBid, string]] {.
async: (raises: [CancelledError]).} =
info "Requesting execution payload bid",
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/validators/validator_pool.nim
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ proc getProposerPreferencesSignature*(v: AttachedValidator, fork: Fork,

proc getBuilderRequestAuthSignature*(
v: AttachedValidator, genesis_fork_version: Version,
request_auth: RequestAuthV1):
request_auth: BuilderRequestAuth):
Future[SignatureResult] {.async: (raises: [CancelledError]).} =
case v.kind
of ValidatorKind.Local:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_spec_signatures.nim
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,10 @@ suite "Message signatures":
let
version0 = fork0.current_version
version1 = fork1.current_version
auth0 = default(RequestAuthV1)
auth0 = default(BuilderRequestAuth)
auth1 = block:
var v = auth0
v.data = RequestAuthData.init(@[byte 0xaa])
v.data = BuilderRequestAuthData.init(@[byte 0xaa])
v
sig = get_builder_request_auth_signature(
version0, auth0, privkey0).toValidatorSig
Expand Down
Loading