From 70eea68417a29a1683a311648c1eb2e9bca7deb1 Mon Sep 17 00:00:00 2001 From: Jinsuk Park Date: Wed, 14 Aug 2024 20:46:19 +0900 Subject: [PATCH] check current fork to set ExcessBlobGas and BlobGasUsed --- op-node/node/builder.go | 17 ++++++++++++----- op-node/node/node.go | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/op-node/node/builder.go b/op-node/node/builder.go index 2231740dbf4c..b3cff4a3edce 100644 --- a/op-node/node/builder.go +++ b/op-node/node/builder.go @@ -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" @@ -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, @@ -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, } } @@ -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() @@ -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, diff --git a/op-node/node/node.go b/op-node/node/node.go index 0ac0ac4ec93c..1424c1ed838f 100644 --- a/op-node/node/node.go +++ b/op-node/node/node.go @@ -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. @@ -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 }