Skip to content

Commit

Permalink
Add gaslimit function.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Dec 11, 2024
1 parent d55ff5e commit dc6247b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions api/versionedproposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,36 @@ func (v *VersionedProposal) Timestamp() (uint64, error) {
}
}

// GasLimit returns the gas limit of the proposal.
func (v *VersionedProposal) GasLimit() (uint64, error) {
if v.Version >= spec.DataVersionBellatrix && !v.payloadPresent() {
return 0, ErrDataMissing
}

switch v.Version {
case spec.DataVersionBellatrix:
if v.Blinded {
return v.BellatrixBlinded.Body.ExecutionPayloadHeader.GasLimit, nil
}

return v.Bellatrix.Body.ExecutionPayload.GasLimit, nil
case spec.DataVersionCapella:
if v.Blinded {
return v.CapellaBlinded.Body.ExecutionPayloadHeader.GasLimit, nil
}

return v.Capella.Body.ExecutionPayload.GasLimit, nil
case spec.DataVersionDeneb:
if v.Blinded {
return v.DenebBlinded.Body.ExecutionPayloadHeader.GasLimit, nil
}

return v.Deneb.Block.Body.ExecutionPayload.GasLimit, nil
default:
return 0, ErrUnsupportedVersion
}
}

// Blobs returns the blobs of the proposal.
func (v *VersionedProposal) Blobs() ([]deneb.Blob, error) {
if v.Version >= spec.DataVersionDeneb && !v.payloadPresent() {
Expand Down

0 comments on commit dc6247b

Please sign in to comment.