diff --git a/frax-da/client.go b/frax-da/client.go index f6d6de9b63..9532d739ff 100644 --- a/frax-da/client.go +++ b/frax-da/client.go @@ -62,6 +62,29 @@ func (c DAClient) Read(ctx context.Context, id []byte) ([]byte, error) { return body, nil } +func (c DAClient) ReadCelestia(ctx context.Context, hexString string) ([]byte, error) { + fetchUrl := c.baseUrl.ResolveReference(&url.URL{Path: fmt.Sprintf("/v1/blobs/celestia-%s", hexString)}) + request, err := http.NewRequestWithContext(ctx, "GET", fetchUrl.String(), nil) + if err != nil { + return nil, fmt.Errorf("unable to create request to fetch celestia data from DA: %w", err) + } + resp, err := c.httpClient.Do(request) + + if err != nil { + return nil, fmt.Errorf("unable to fetch DA celestia data: %w", err) + } + if resp.StatusCode != 200 { + return nil, fmt.Errorf("unable to fetch DA celestia data, got status code %d", resp.StatusCode) + } + + body, err := io.ReadAll(resp.Body) + if err != nil { + return nil, fmt.Errorf("unable to read DA celestia data fetch response: %w", err) + } + + return body, nil +} + func (c DAClient) Write(ctx context.Context, data []byte) ([]byte, error) { submitUrl := c.baseUrl.ResolveReference(&url.URL{Path: "/v1/blobs"}) diff --git a/frax-da/da.go b/frax-da/da.go index 77ed0e0aa5..e369f4adb3 100644 --- a/frax-da/da.go +++ b/frax-da/da.go @@ -2,3 +2,6 @@ package fraxda // DerivationVersionFraxDa is a byte prefix of frax DA based references const DerivationVersionFraxDa = 0xfc + +// DerivationVersionCelestia is used for retrocompatibility with the old testnet data +const DerivationVersionCelestia = 0xce diff --git a/op-node/rollup/derive/calldata_source.go b/op-node/rollup/derive/calldata_source.go index 7eb7f46cb7..9444fb289b 100644 --- a/op-node/rollup/derive/calldata_source.go +++ b/op-node/rollup/derive/calldata_source.go @@ -169,6 +169,15 @@ func DataFromEVMTransactions(dsCfg DataSourceConfig, batcherAddr common.Address, return nil, NewResetError(fmt.Errorf("fraxda: failed to fetch data for id %s: %w", hex.EncodeToString(data), err)) } out = append(out, data) + case fraxda.DerivationVersionCelestia: + log.Info("fraxda: requesting old celestia data", "id", hex.EncodeToString(data)) + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + data, err := daClient.ReadCelestia(ctx, hex.EncodeToString(data[1:])) + cancel() + if err != nil { + return nil, NewResetError(fmt.Errorf("fraxda: failed to fetch celestia data for id %s: %w", hex.EncodeToString(data), err)) + } + out = append(out, data) default: out = append(out, data) log.Info("fraxda: using eth fallback")