Skip to content

Commit e84142e

Browse files
committed
namespace hack
1 parent 3c92481 commit e84142e

2 files changed

Lines changed: 43 additions & 4 deletions

File tree

block/internal/da/fiber_client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (c *fiberDAClient) Submit(ctx context.Context, data [][]byte, _ float64, na
100100
wg.Go(func() {
101101
for task := range taskCh {
102102
uploadCtx, cancel := context.WithTimeout(ctx, c.defaultTimeout)
103-
result, err := c.fiber.Upload(uploadCtx, namespace, task.data)
103+
result, err := c.fiber.Upload(uploadCtx, namespace[len(namespace)-10:], task.data)
104104
cancel()
105105
respCh <- uploadResponse{
106106
index: task.index,
@@ -174,7 +174,7 @@ func (c *fiberDAClient) retrieve(ctx context.Context, height uint64, namespace [
174174
listenCtx, listenCancel := context.WithTimeout(ctx, c.defaultTimeout)
175175
defer listenCancel()
176176

177-
blobCh, err := c.fiber.Listen(listenCtx, namespace, height)
177+
blobCh, err := c.fiber.Listen(listenCtx, namespace[len(namespace)-10:], height)
178178
if err != nil {
179179
return datypes.ResultRetrieve{
180180
BaseResult: datypes.BaseResult{
@@ -276,7 +276,7 @@ func (c *fiberDAClient) Subscribe(ctx context.Context, namespace []byte, _ bool)
276276
// height, so start from the live tip (fromHeight=0). A future
277277
// refactor that plumbs resume-from-height through datypes.DA can
278278
// thread the value here.
279-
blobCh, err := c.fiber.Listen(ctx, namespace, 0)
279+
blobCh, err := c.fiber.Listen(ctx, namespace[len(namespace)-10:], 0)
280280
if err != nil {
281281
c.logger.Error().Err(err).Msg("fiber listen failed")
282282
return

tools/celestia-node-fiber/testing/evnode_fiber_test.go

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/evstack/ev-node/pkg/signer/file"
2727
"github.com/evstack/ev-node/pkg/sequencers/solo"
2828
"github.com/evstack/ev-node/pkg/store"
29+
datypes "github.com/evstack/ev-node/pkg/da/types"
2930

3031
"github.com/celestiaorg/celestia-node/api/client"
3132

@@ -49,8 +50,10 @@ const (
4950
// - Starts a single-validator Celestia chain + Fibre server + bridge
5051
// - Creates a celestia-node-fiber adapter (block.FiberClient)
5152
// - Constructs an ev-node aggregator node that uses the adapter as DA
53+
// - Subscribes to the data namespace via adapter.Listen before uploading
5254
// - Injects a transaction and waits for block production
53-
// - Verifies the executor processed the block (blocksProduced >= 1)
55+
// - Confirms the DA submitter pushed blobs to Fiber by receiving events
56+
// on the subscription and round-tripping each through Download
5457
func TestEvNode_FiberDA_Posting(t *testing.T) {
5558
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
5659
t.Cleanup(cancel)
@@ -77,6 +80,16 @@ func TestEvNode_FiberDA_Posting(t *testing.T) {
7780
require.NoError(t, err, "constructing adapter")
7881
t.Cleanup(func() { _ = adapter.Close() })
7982

83+
// Subscribe to the header namespace BEFORE starting the node so we
84+
// don't race against the first DA submission. fromHeight=0 follows
85+
// the live tip. The adapter expects the 10-byte v0 namespace ID
86+
// (the last 10 bytes of the full 29-byte namespace), matching what
87+
// fiberDAClient.Submit extracts before calling fiber.Upload.
88+
fullHeaderNS := datypes.NamespaceFromString(evnodeHeaderNS).Bytes()
89+
headerNSID := fullHeaderNS[len(fullHeaderNS)-10:]
90+
events, err := adapter.Listen(ctx, headerNSID, 0)
91+
require.NoError(t, err, "starting fiber Listen on header namespace")
92+
8093
rollnode, exec, nodeCleanup := newFiberEvNode(t, ctx, adapter)
8194
t.Cleanup(nodeCleanup)
8295

@@ -99,6 +112,32 @@ func TestEvNode_FiberDA_Posting(t *testing.T) {
99112
return stats.BlocksProduced >= 1 && stats.TotalExecutedTxs >= 1
100113
}, evnodeBlockTimeout, 200*time.Millisecond, "ev-node should produce at least one block with the transaction")
101114

115+
// Drain at least one Fiber BlobEvent from the subscription to prove
116+
// the DA submitter pushed data through the fiber adapter's Upload
117+
// path and the settlement landed on-chain.
118+
var seen []block.FiberBlobEvent
119+
require.Eventually(t, func() bool {
120+
select {
121+
case ev, ok := <-events:
122+
if !ok {
123+
return false
124+
}
125+
seen = append(seen, ev)
126+
t.Logf("fiber event: blob_id=%x height=%d data_size=%d",
127+
ev.BlobID, ev.Height, ev.DataSize)
128+
return true
129+
default:
130+
return false
131+
}
132+
}, evnodeBlockTimeout, 500*time.Millisecond, "expected at least one Fiber BlobEvent from DA submission")
133+
134+
for _, ev := range seen {
135+
got, err := adapter.Download(ctx, ev.BlobID)
136+
require.NoError(t, err, "adapter.Download blob_id=%x", ev.BlobID)
137+
require.NotEmpty(t, got, "downloaded blob must not be empty")
138+
t.Logf("download ok: blob_id=%x bytes=%d", ev.BlobID, len(got))
139+
}
140+
102141
select {
103142
case err := <-nodeErrCh:
104143
t.Fatalf("node exited unexpectedly: %v", err)

0 commit comments

Comments
 (0)