Skip to content
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

Electra: exclude empty requests in requests list #14580

Merged
merged 25 commits into from
Oct 31, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ace832c
implementing new decisions around exectuion requests
james-prysm Oct 24, 2024
0884e0e
fixing test fixture
james-prysm Oct 25, 2024
bd26494
adding in more edge case checks and tests
james-prysm Oct 25, 2024
d932f6e
Merge branch 'develop' into execution-requests-serialization-changes
james-prysm Oct 25, 2024
e0ffd1a
changelog
james-prysm Oct 25, 2024
3c7cbf7
fixing unsafe type cast
james-prysm Oct 25, 2024
2852bcc
Update beacon-chain/execution/engine_client_test.go
james-prysm Oct 25, 2024
3cdb4ad
Update proto/engine/v1/electra.go
james-prysm Oct 25, 2024
9f7997b
Update proto/engine/v1/electra.go
james-prysm Oct 25, 2024
14f5f0a
Update proto/engine/v1/electra.go
james-prysm Oct 25, 2024
4b22e25
Update proto/engine/v1/electra.go
james-prysm Oct 25, 2024
e7ba3b1
Update proto/engine/v1/electra_test.go
james-prysm Oct 25, 2024
b077cfd
Update proto/engine/v1/electra_test.go
james-prysm Oct 25, 2024
b48d359
Merge branch 'develop' into execution-requests-serialization-changes
james-prysm Oct 28, 2024
8f62720
updating based on preston's feedback and adding more tests for edge c…
james-prysm Oct 28, 2024
44de042
adding more edgecases, and unit tests
james-prysm Oct 28, 2024
c879cfb
Merge branch 'develop' into execution-requests-serialization-changes
james-prysm Oct 28, 2024
ace1aa5
fixing tests
james-prysm Oct 28, 2024
dc7eebd
missed some export changes
james-prysm Oct 28, 2024
8bf061b
Merge branch 'develop' into execution-requests-serialization-changes
james-prysm Oct 28, 2024
c69ac6c
adding more tests
james-prysm Oct 28, 2024
cbdc3ad
Update proto/engine/v1/electra.go
james-prysm Oct 28, 2024
b077638
reducing complexity of function based on feedback
james-prysm Oct 28, 2024
14c629b
Merge branch 'develop' into execution-requests-serialization-changes
james-prysm Oct 31, 2024
46b8205
Merge branch 'develop' into execution-requests-serialization-changes
james-prysm Oct 31, 2024
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
Next Next commit
implementing new decisions around exectuion requests
  • Loading branch information
james-prysm committed Oct 24, 2024
commit ace832cc772ddbf861dfd69b759349f8962c0128
92 changes: 56 additions & 36 deletions proto/engine/v1/electra.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,39 @@ var (
crSize = crExample.SizeSSZ()
)

const LenExecutionRequestsElectra = 3
const (
depositRequestType = 0
withdrawalRequestType = 1
consolidationRequestType = 2
)

func (ebe *ExecutionBundleElectra) GetDecodedExecutionRequests() (*ExecutionRequests, error) {
requests := &ExecutionRequests{}

if len(ebe.ExecutionRequests) != LenExecutionRequestsElectra /* types of requests */ {
return nil, errors.Errorf("invalid execution request size: %d", len(ebe.ExecutionRequests))
}

// deposit requests
drs, err := unmarshalItems(ebe.ExecutionRequests[0], drSize, func() *DepositRequest { return &DepositRequest{} })
if err != nil {
return nil, err
}
requests.Deposits = drs

// withdrawal requests
wrs, err := unmarshalItems(ebe.ExecutionRequests[1], wrSize, func() *WithdrawalRequest { return &WithdrawalRequest{} })
if err != nil {
return nil, err
}
requests.Withdrawals = wrs

// consolidation requests
crs, err := unmarshalItems(ebe.ExecutionRequests[2], crSize, func() *ConsolidationRequest { return &ConsolidationRequest{} })
if err != nil {
return nil, err
for i := range ebe.ExecutionRequests {
requestType := ebe.ExecutionRequests[i][0]
requestListInSSZBytes := ebe.ExecutionRequests[i][1:]
switch requestType {
case depositRequestType:
drs, err := unmarshalItems(requestListInSSZBytes, drSize, func() *DepositRequest { return &DepositRequest{} })
if err != nil {
return nil, err
}
requests.Deposits = drs
case withdrawalRequestType:
wrs, err := unmarshalItems(requestListInSSZBytes, wrSize, func() *WithdrawalRequest { return &WithdrawalRequest{} })
if err != nil {
return nil, err
}
requests.Withdrawals = wrs
case consolidationRequestType:
crs, err := unmarshalItems(requestListInSSZBytes, crSize, func() *ConsolidationRequest { return &ConsolidationRequest{} })
if err != nil {
return nil, err
}
requests.Consolidations = crs
}
}
requests.Consolidations = crs

return requests, nil
}
Expand All @@ -57,21 +61,37 @@ func EncodeExecutionRequests(requests *ExecutionRequests) ([]hexutil.Bytes, erro
return nil, errors.New("invalid execution requests")
}

drBytes, err := marshalItems(requests.Deposits)
if err != nil {
return nil, errors.Wrap(err, "failed to marshal deposit requests")
}
var requestsData []hexutil.Bytes

wrBytes, err := marshalItems(requests.Withdrawals)
if err != nil {
return nil, errors.Wrap(err, "failed to marshal withdrawal requests")
if len(requests.Deposits) > 0 {
drBytes, err := marshalItems(requests.Deposits)
if err != nil {
return nil, errors.Wrap(err, "failed to marshal deposit requests")
}
requestData := []byte{0}
requestData = append(requestData, drBytes...)
requestsData = append(requestsData, requestData)
}

crBytes, err := marshalItems(requests.Consolidations)
if err != nil {
return nil, errors.Wrap(err, "failed to marshal consolidation requests")
if len(requests.Withdrawals) > 0 {
wrBytes, err := marshalItems(requests.Withdrawals)
if err != nil {
return nil, errors.Wrap(err, "failed to marshal withdrawal requests")
}
requestData := []byte{1}
requestData = append(requestData, wrBytes...)
requestsData = append(requestsData, requestData)
}
return []hexutil.Bytes{drBytes, wrBytes, crBytes}, nil
if len(requests.Consolidations) > 0 {
crBytes, err := marshalItems(requests.Consolidations)
if err != nil {
return nil, errors.Wrap(err, "failed to marshal consolidation requests")
}
requestData := []byte{2}
requestData = append(requestData, crBytes...)
requestsData = append(requestsData, requestData)
}

return requestsData, nil
}

type sszUnmarshaler interface {
Expand Down
Loading