-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add In Support For Builder in E2E #12343
Changes from all commits
711e8c5
fe2bb6e
e4ab567
c0aca7d
1256e59
39dd0ac
c948e90
fa77ed4
3271679
00b71be
59074bb
658e217
430a161
9186b07
845e129
0edbd0d
e5bc6cd
f39286c
967435c
32de0a2
0996518
58c1896
dddced7
65c1f0e
cec893a
39b5d05
8c17472
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -346,6 +346,74 @@ func (p *ExecutionPayload) ToProto() (*v1.ExecutionPayload, error) { | |
}, nil | ||
} | ||
|
||
// FromProto converts a proto execution payload type to our builder | ||
// compatible payload type. | ||
func FromProto(payload *v1.ExecutionPayload) (ExecutionPayload, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should probably have a comment as a public exported function. |
||
bFee, err := sszBytesToUint256(payload.BaseFeePerGas) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this take care of endianness? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it does , everything in these methods are just the inverse of |
||
if err != nil { | ||
return ExecutionPayload{}, err | ||
} | ||
txs := make([]hexutil.Bytes, len(payload.Transactions)) | ||
for i := range payload.Transactions { | ||
txs[i] = payload.Transactions[i] | ||
} | ||
return ExecutionPayload{ | ||
ParentHash: payload.ParentHash, | ||
FeeRecipient: payload.FeeRecipient, | ||
StateRoot: payload.StateRoot, | ||
ReceiptsRoot: payload.ReceiptsRoot, | ||
LogsBloom: payload.LogsBloom, | ||
PrevRandao: payload.PrevRandao, | ||
BlockNumber: Uint64String(payload.BlockNumber), | ||
GasLimit: Uint64String(payload.GasLimit), | ||
GasUsed: Uint64String(payload.GasUsed), | ||
Timestamp: Uint64String(payload.Timestamp), | ||
ExtraData: payload.ExtraData, | ||
BaseFeePerGas: bFee, | ||
BlockHash: payload.BlockHash, | ||
Transactions: txs, | ||
}, nil | ||
} | ||
|
||
// FromProtoCapella converts a proto execution payload type for capella to our | ||
// builder compatible payload type. | ||
func FromProtoCapella(payload *v1.ExecutionPayloadCapella) (ExecutionPayloadCapella, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it better to have one such function that takes an interface to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is the end goal, but it would be served better in a follow up PR. I don't think we need a new payload type in each fork, this can all be a super struct. It would be one thing to tackle after so that deneb doesn't need a new payload type |
||
bFee, err := sszBytesToUint256(payload.BaseFeePerGas) | ||
if err != nil { | ||
return ExecutionPayloadCapella{}, err | ||
} | ||
txs := make([]hexutil.Bytes, len(payload.Transactions)) | ||
for i := range payload.Transactions { | ||
txs[i] = payload.Transactions[i] | ||
} | ||
withdrawals := make([]Withdrawal, len(payload.Withdrawals)) | ||
for i, w := range payload.Withdrawals { | ||
withdrawals[i] = Withdrawal{ | ||
Index: Uint256{Int: big.NewInt(0).SetUint64(w.Index)}, | ||
ValidatorIndex: Uint256{Int: big.NewInt(0).SetUint64(uint64(w.ValidatorIndex))}, | ||
Address: w.Address, | ||
Amount: Uint256{Int: big.NewInt(0).SetUint64(w.Amount)}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this correct in uint256? I feel either this is an uint64 or you should convert to Wei There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is due to how the builder api wants to represent |
||
} | ||
} | ||
return ExecutionPayloadCapella{ | ||
ParentHash: payload.ParentHash, | ||
FeeRecipient: payload.FeeRecipient, | ||
StateRoot: payload.StateRoot, | ||
ReceiptsRoot: payload.ReceiptsRoot, | ||
LogsBloom: payload.LogsBloom, | ||
PrevRandao: payload.PrevRandao, | ||
BlockNumber: Uint64String(payload.BlockNumber), | ||
GasLimit: Uint64String(payload.GasLimit), | ||
GasUsed: Uint64String(payload.GasUsed), | ||
Timestamp: Uint64String(payload.Timestamp), | ||
ExtraData: payload.ExtraData, | ||
BaseFeePerGas: bFee, | ||
BlockHash: payload.BlockHash, | ||
Transactions: txs, | ||
Withdrawals: withdrawals, | ||
}, nil | ||
} | ||
|
||
type ExecHeaderResponseCapella struct { | ||
Data struct { | ||
Signature hexutil.Bytes `json:"signature"` | ||
|
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ package execution | |
import ( | ||
"context" | ||
"fmt" | ||
"net/url" | ||
"strings" | ||
"time" | ||
|
||
|
@@ -107,26 +106,10 @@ func (s *Service) retryExecutionClientConnection(ctx context.Context, err error) | |
|
||
// Initializes an RPC connection with authentication headers. | ||
func (s *Service) newRPCClientWithAuth(ctx context.Context, endpoint network.Endpoint) (*gethRPC.Client, error) { | ||
// Need to handle ipc and http | ||
var client *gethRPC.Client | ||
u, err := url.Parse(endpoint.Url) | ||
client, err := network.NewExecutionRPCClient(ctx, endpoint) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice cleanup |
||
if err != nil { | ||
return nil, err | ||
} | ||
switch u.Scheme { | ||
case "http", "https": | ||
client, err = gethRPC.DialOptions(ctx, endpoint.Url, gethRPC.WithHTTPClient(endpoint.HttpClient())) | ||
if err != nil { | ||
return nil, err | ||
} | ||
case "", "ipc": | ||
client, err = gethRPC.DialIPC(ctx, endpoint.Url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
default: | ||
return nil, fmt.Errorf("no known transport for URL scheme %q", u.Scheme) | ||
} | ||
if endpoint.Auth.Method != authorization.None { | ||
header, err := endpoint.Auth.ToHeaderValue() | ||
if err != nil { | ||
|
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.
Helper methods to convert the payload to a builder api comformant type
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.
typo in description 😄