Skip to content

Commit 21219ac

Browse files
committed
Merge branch 'main' into julien/strategies
2 parents f66ab2a + 584a3e5 commit 21219ac

13 files changed

Lines changed: 61 additions & 43 deletions

File tree

block/internal/syncing/da_retriever.go

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"context"
66
"errors"
77
"fmt"
8-
"strings"
98
"time"
109

1110
"github.com/rs/zerolog"
@@ -72,10 +71,6 @@ func (r *DARetriever) RetrieveFromDA(ctx context.Context, daHeight uint64) ([]co
7271

7372
blobsResp, err := r.fetchBlobs(ctx, daHeight)
7473
if err != nil {
75-
if strings.Contains(err.Error(), coreda.ErrHeightFromFuture.Error()) {
76-
return nil, fmt.Errorf("%w: height from future", coreda.ErrHeightFromFuture)
77-
}
78-
7974
return nil, err
8075
}
8176

@@ -84,11 +79,6 @@ func (r *DARetriever) RetrieveFromDA(ctx context.Context, daHeight uint64) ([]co
8479
return nil, err
8580
}
8681

87-
if blobsResp.Code == coreda.StatusNotFound {
88-
r.logger.Debug().Uint64("da_height", daHeight).Msg("no blob data found")
89-
return nil, coreda.ErrBlobNotFound
90-
}
91-
9282
r.logger.Debug().Int("blobs", len(blobsResp.Data)).Uint64("da_height", daHeight).Msg("retrieved blob data")
9383
return r.processBlobs(ctx, blobsResp.Data, daHeight), nil
9484
}
@@ -107,13 +97,15 @@ func (r *DARetriever) fetchBlobs(ctx context.Context, daHeight uint64) (coreda.R
10797

10898
// Validate responses
10999
headerErr := r.validateBlobResponse(headerRes, daHeight)
110-
dataErr := r.validateBlobResponse(dataRes, daHeight)
100+
// ignoring error not found, as data can have data
101+
if headerErr != nil && !errors.Is(headerErr, coreda.ErrBlobNotFound) {
102+
return headerRes, headerErr
103+
}
111104

112-
// Handle errors
113-
if errors.Is(headerErr, coreda.ErrHeightFromFuture) || errors.Is(dataErr, coreda.ErrHeightFromFuture) {
114-
return coreda.ResultRetrieve{
115-
BaseResult: coreda.BaseResult{Code: coreda.StatusHeightFromFuture},
116-
}, fmt.Errorf("%w: height from future", coreda.ErrHeightFromFuture)
105+
dataErr := r.validateBlobResponse(dataRes, daHeight)
106+
// ignoring error not found, as header can have data
107+
if dataErr != nil && !errors.Is(dataErr, coreda.ErrBlobNotFound) {
108+
return dataRes, dataErr
117109
}
118110

119111
// Combine successful results
@@ -127,28 +119,35 @@ func (r *DARetriever) fetchBlobs(ctx context.Context, daHeight uint64) (coreda.R
127119

128120
if headerRes.Code == coreda.StatusSuccess {
129121
combinedResult.Data = append(combinedResult.Data, headerRes.Data...)
130-
if len(headerRes.IDs) > 0 {
131-
combinedResult.IDs = append(combinedResult.IDs, headerRes.IDs...)
132-
}
122+
combinedResult.IDs = append(combinedResult.IDs, headerRes.IDs...)
133123
}
134124

135125
if dataRes.Code == coreda.StatusSuccess {
136126
combinedResult.Data = append(combinedResult.Data, dataRes.Data...)
137-
if len(dataRes.IDs) > 0 {
138-
combinedResult.IDs = append(combinedResult.IDs, dataRes.IDs...)
139-
}
127+
combinedResult.IDs = append(combinedResult.IDs, dataRes.IDs...)
128+
}
129+
130+
// Re-throw error not found if both were not found.
131+
if len(combinedResult.Data) == 0 && len(combinedResult.IDs) == 0 {
132+
r.logger.Debug().Uint64("da_height", daHeight).Msg("no blob data found")
133+
combinedResult.Code = coreda.StatusNotFound
134+
combinedResult.Message = coreda.ErrBlobNotFound.Error()
135+
return combinedResult, coreda.ErrBlobNotFound
140136
}
141137

142138
return combinedResult, nil
143139
}
144140

145141
// validateBlobResponse validates a blob response from DA layer
142+
// those are the only error code returned by da.RetrieveWithHelpers
146143
func (r *DARetriever) validateBlobResponse(res coreda.ResultRetrieve, daHeight uint64) error {
147144
switch res.Code {
148145
case coreda.StatusError:
149146
return fmt.Errorf("DA retrieval failed: %s", res.Message)
150147
case coreda.StatusHeightFromFuture:
151148
return fmt.Errorf("%w: height from future", coreda.ErrHeightFromFuture)
149+
case coreda.StatusNotFound:
150+
return fmt.Errorf("%w: blob not found", coreda.ErrBlobNotFound)
152151
case coreda.StatusSuccess:
153152
r.logger.Debug().Uint64("da_height", daHeight).Msg("successfully retrieved from DA")
154153
return nil

block/internal/syncing/da_retriever_test.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,28 @@ func makeSignedDataBytes(t *testing.T, chainID string, height uint64, proposer [
6969
return bin, sd
7070
}
7171

72+
func TestDARetriever_RetrieveFromDA_Invalid(t *testing.T) {
73+
ds := dssync.MutexWrap(datastore.NewMapDatastore())
74+
st := store.New(ds)
75+
cm, err := cache.NewManager(config.DefaultConfig(), st, zerolog.Nop())
76+
assert.NoError(t, err)
77+
78+
mockDA := testmocks.NewMockDA(t)
79+
80+
mockDA.EXPECT().GetIDs(mock.Anything, mock.Anything, mock.Anything).
81+
Return(nil, errors.New("just invalid")).Maybe()
82+
83+
r := NewDARetriever(mockDA, cm, config.DefaultConfig(), genesis.Genesis{}, common.DefaultBlockOptions(), zerolog.Nop())
84+
events, err := r.RetrieveFromDA(context.Background(), 42)
85+
assert.Error(t, err)
86+
assert.Len(t, events, 0)
87+
}
88+
7289
func TestDARetriever_RetrieveFromDA_NotFound(t *testing.T) {
7390
ds := dssync.MutexWrap(datastore.NewMapDatastore())
7491
st := store.New(ds)
7592
cm, err := cache.NewManager(config.DefaultConfig(), st, zerolog.Nop())
76-
require.NoError(t, err)
93+
assert.NoError(t, err)
7794

7895
mockDA := testmocks.NewMockDA(t)
7996

@@ -83,7 +100,7 @@ func TestDARetriever_RetrieveFromDA_NotFound(t *testing.T) {
83100

84101
r := NewDARetriever(mockDA, cm, config.DefaultConfig(), genesis.Genesis{}, common.DefaultBlockOptions(), zerolog.Nop())
85102
events, err := r.RetrieveFromDA(context.Background(), 42)
86-
require.Error(t, err, coreda.ErrBlobNotFound)
103+
assert.True(t, errors.Is(err, coreda.ErrBlobNotFound))
87104
assert.Len(t, events, 0)
88105
}
89106

docs/adr/adr-017-node-pruning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,5 +943,5 @@ Proposed
943943
## References
944944

945945
- [Rollkit Store Implementation](https://github.com/evstack/ev-node/blob/main/pkg/store/store.go)
946-
- [Block Manager](https://github.com/evstack/ev-node/blob/main/block/manager.go)
946+
- [Block components](https://github.com/evstack/ev-node/blob/main/block/components.go)
947947
- [Store Interface](https://github.com/evstack/ev-node/blob/main/pkg/store/types.go)

docs/guides/da/celestia-da.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import constants from '../../.vitepress/constants/constants.js'
99

1010
This tutorial serves as a comprehensive guide for deploying your chain on Celestia's data availability (DA) network. From the Evolve perspective, there's no difference in posting blocks to Celestia's testnets or Mainnet Beta.
1111

12-
Before proceeding, ensure that you have completed the [gm-world](./gm-world.md) tutorial, which covers installing the Testapp CLI and running a chain against a local DA network.
12+
Before proceeding, ensure that you have completed the [gm-world](../gm-world.md) tutorial, which covers installing the Testapp CLI and running a chain against a local DA network.
1313

1414
## 🪶 Running a Celestia light node
1515

@@ -46,7 +46,7 @@ After successfully starting a light node, it's time to start posting the batches
4646

4747
## 🏗️ Prerequisites {#prerequisites}
4848

49-
- `gmd` CLI installed from the [gm-world](./gm-world.md) tutorial.
49+
- `gmd` CLI installed from the [gm-world](../gm-world.md) tutorial.
5050

5151
## 🛠️ Configuring flags for DA
5252

docs/guides/da/local-da.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import constants from '../../.vitepress/constants/constants.js'
99

1010
This tutorial serves as a comprehensive guide for using the [local-da](https://github.com/evstack/ev-node/tree/main/da/cmd/local-da) with your chain.
1111

12-
Before proceeding, ensure that you have completed the [build a chain](./gm-world.md) tutorial, which covers setting-up, building and running your chain.
12+
Before proceeding, ensure that you have completed the [build a chain](../gm-world.md) tutorial, which covers setting-up, building and running your chain.
1313

1414
## Setting Up a Local DA Network
1515

docs/guides/da/visualizer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,6 @@ done
235235

236236
## Related Configuration
237237

238-
For complete DA layer configuration options, see the [Config Reference](../learn/config.md#data-availability-configuration-da).
238+
For complete DA layer configuration options, see the [Config Reference](../../learn/config.md#data-availability-configuration-da).
239239

240-
For metrics and monitoring setup, see the [Metrics Guide](./metrics.md).
240+
For metrics and monitoring setup, see the [Metrics Guide](../metrics.md).

docs/guides/execution/cosmwasm.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ this tutorial.
2424

2525
## 💻 CosmWasm dependency {#dependencies}
2626

27-
As with the [GM Chain](./gm-world.md), we use [kurtosis](https://docs.kurtosis.com/) to help with managing all the services we need to run. You can [install kurtosis here](https://docs.kurtosis.com/install).
27+
As with the [GM Chain](../gm-world.md), we use [kurtosis](https://docs.kurtosis.com/) to help with managing all the services we need to run. You can [install kurtosis here](https://docs.kurtosis.com/install).
2828

2929
Once installed, you can verify the installation by running:
3030

@@ -174,7 +174,7 @@ we want it to be as small as possible.
174174
<!-- markdownlint-disable MD051 -->
175175

176176
The CosmWasm team provides a tool called `rust-optimizer`, which requires
177-
[Docker](#docker-installation) in order to compile.
177+
Docker in order to compile.
178178

179179
<!-- markdownlint-enable MD051 -->
180180

docs/guides/gm-world.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ Connecting your wallet to your chain is as straightforward as connecting to any
284284

285285
## 🔗 Connecting your wallet
286286

287+
<!-- markdown-link-check-disable -->
287288
Simply open your browser and go to [http://localhost:3000](https://localhost:3000) and use the Ignite UI to interact with your chain.
289+
<!-- markdown-link-check-enable -->
288290

289291
Click the "Connect Wallet" button on the page, and approve the connection request in the Keplr prompt.
290292

docs/learn/config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This document provides a comprehensive reference for all configuration options a
2525
- [DA Gas Multiplier](#da-gas-multiplier)
2626
- [DA Submit Options](#da-submit-options)
2727
- [DA Namespace](#da-namespace)
28-
- [DA Header Namespace](#da-header-namespace)
28+
- [DA Header Namespace](#da-namespace)
2929
- [DA Data Namespace](#da-data-namespace)
3030
- [DA Block Time](#da-block-time)
3131
- [DA Start Height](#da-start-height)
@@ -623,7 +623,7 @@ _Example:_ `--rollkit.rpc.enable_da_visualization`
623623
_Default:_ `false`
624624
_Constant:_ `FlagRPCEnableDAVisualization`
625625

626-
See the [DA Visualizer Guide](../guides/da/da-visualizer.md) for detailed information on using this feature.
626+
See the [DA Visualizer Guide](../guides/da/visualizer.md) for detailed information on using this feature.
627627

628628
## Instrumentation Configuration (`instrumentation`)
629629

docs/learn/data-availability.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ Evolve is designed to be DA-agnostic, meaning it can integrate with different da
2828

2929
## Learn More
3030

31-
- [Set up a local DA](./guides/da/local-da.md)
32-
- [Set up Celestia DA](./guides/da/celestia-da.md)
31+
- [Set up a local DA](../guides/da/local-da.md)
32+
- [Set up Celestia DA](../guides/da/celestia-da.md)
3333
- [Celestia Docs](https://docs.celestia.org/)

0 commit comments

Comments
 (0)