Skip to content

Commit

Permalink
check current fork to set ExcessBlobGas and BlobGasUsed
Browse files Browse the repository at this point in the history
  • Loading branch information
jinmel committed Aug 14, 2024
1 parent 6e022c9 commit 70eea68
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 12 additions & 5 deletions op-node/node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
builderSpec "github.com/attestantio/go-builder-client/spec"
consensusspec "github.com/attestantio/go-eth2-client/spec"

"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-service/client"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum/go-ethereum/common"
Expand All @@ -28,10 +29,11 @@ type BuilderAPIConfig struct {
type BuilderAPIClient struct {
log log.Logger
config *BuilderAPIConfig
rollupCfg *rollup.Config
httpClient *client.BasicHTTPClient
}

func NewBuilderClient(log log.Logger, endpoint string, timeout time.Duration) *BuilderAPIClient {
func NewBuilderClient(log log.Logger, rollupCfg *rollup.Config, endpoint string, timeout time.Duration) *BuilderAPIClient {
httpClient := client.NewBasicHTTPClient(endpoint, log)
config := &BuilderAPIConfig{
Timeout: timeout,
Expand All @@ -41,6 +43,7 @@ func NewBuilderClient(log log.Logger, endpoint string, timeout time.Duration) *B
return &BuilderAPIClient{
httpClient: httpClient,
config: config,
rollupCfg: rollupCfg,
log: log,
}
}
Expand Down Expand Up @@ -120,8 +123,12 @@ func (s *BuilderAPIClient) versionedExecutionPayloadToExecutionPayloadEnvelope(r

ws := types.Withdrawals(withdrawals)

blobGasUsed := eth.Uint64Quantity(payload.BlobGasUsed)
excessBlobGas := eth.Uint64Quantity(payload.ExcessBlobGas)
var blobGasUsed *eth.Uint64Quantity
var excessBlobGas *eth.Uint64Quantity
if s.rollupCfg.IsEcotone(payload.Timestamp) {
blobGasUsed = (*eth.Uint64Quantity)(&payload.BlobGasUsed)
excessBlobGas = (*eth.Uint64Quantity)(&payload.ExcessBlobGas)
}

var blockValue eth.Uint256Quantity
v, err := resp.Value()
Expand All @@ -148,8 +155,8 @@ func (s *BuilderAPIClient) versionedExecutionPayloadToExecutionPayloadEnvelope(r
BlockHash: common.BytesToHash(payload.BlockHash[:]),
Transactions: txs,
Withdrawals: &ws,
BlobGasUsed: &blobGasUsed,
ExcessBlobGas: &excessBlobGas,
BlobGasUsed: blobGasUsed,
ExcessBlobGas: excessBlobGas,
},
// ParentBeaconBlockRoot will be filled by the engine payload.
ParentBeaconBlockRoot: nil,
Expand Down
4 changes: 2 additions & 2 deletions op-node/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func (n *OpNode) initL2(ctx context.Context, cfg *Config, snapshotLog log.Logger

var payloadBuilder builder.PayloadBuilder = &builder.NoOpBuilder{}
if cfg.BuilderEnabled {
payloadBuilder = NewBuilderClient(n.log, cfg.BuilderEndpoint, cfg.BuilderTimeout)
payloadBuilder = NewBuilderClient(n.log, &cfg.Rollup, cfg.BuilderEndpoint, cfg.BuilderTimeout)
}

// if plasma is not explicitly activated in the node CLI, the config + any error will be ignored.
Expand Down Expand Up @@ -630,7 +630,7 @@ func (n *OpNode) PublishL2Attributes(ctx context.Context, attrs *derive.Attribut
n.log.Warn("failed to marshal payload attributes", "err", err)
return err
}
n.log.Debug("Publishing execution payload attributes on event stream", "attrs", builderAttrs, "json", string(jsonBytes))
n.log.Info("Publishing execution payload attributes on event stream", "attrs", builderAttrs)
n.httpEventStream.Publish("payload_attributes", &sse.Event{Data: jsonBytes})
return nil
}
Expand Down

0 comments on commit 70eea68

Please sign in to comment.