Skip to content

Commit 8615079

Browse files
authored
Merge branch 'main' into marko/lazy-aggregation-adr
2 parents be5196c + dcb40d1 commit 8615079

18 files changed

Lines changed: 79 additions & 108 deletions

block/publish_block_test.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,6 @@ func Test_publishBlock_EmptyBatch(t *testing.T) {
328328
// is successfully created, applied, and published.
329329
func Test_publishBlock_Success(t *testing.T) {
330330
require := require.New(t)
331-
ctx, cancel := context.WithCancel(context.Background())
332-
defer cancel()
333331

334332
initialHeight := uint64(5)
335333
newHeight := initialHeight + 1
@@ -338,25 +336,25 @@ func Test_publishBlock_Success(t *testing.T) {
338336
manager, mockStore, mockExec, mockSeq, _, headerCh, dataCh, _ := setupManagerForPublishBlockTest(t, true, initialHeight, 0)
339337
manager.lastState.LastBlockHeight = initialHeight
340338

341-
mockStore.On("Height", ctx).Return(initialHeight, nil).Once()
339+
mockStore.On("Height", t.Context()).Return(initialHeight, nil).Once()
342340
mockSignature := types.Signature([]byte{1, 2, 3})
343-
mockStore.On("GetSignature", ctx, initialHeight).Return(&mockSignature, nil).Once()
341+
mockStore.On("GetSignature", t.Context(), initialHeight).Return(&mockSignature, nil).Once()
344342
lastHeader, lastData := types.GetRandomBlock(initialHeight, 5, chainID)
345343
lastHeader.ProposerAddress = manager.genesis.ProposerAddress
346-
mockStore.On("GetBlockData", ctx, initialHeight).Return(lastHeader, lastData, nil).Once()
347-
mockStore.On("GetBlockData", ctx, newHeight).Return(nil, nil, errors.New("not found")).Once()
348-
mockStore.On("SaveBlockData", ctx, mock.AnythingOfType("*types.SignedHeader"), mock.AnythingOfType("*types.Data"), mock.AnythingOfType("*types.Signature")).Return(nil).Once()
349-
mockStore.On("SaveBlockData", ctx, mock.AnythingOfType("*types.SignedHeader"), mock.AnythingOfType("*types.Data"), mock.AnythingOfType("*types.Signature")).Return(nil).Once()
350-
mockStore.On("SetHeight", ctx, newHeight).Return(nil).Once()
351-
mockStore.On("UpdateState", ctx, mock.AnythingOfType("types.State")).Return(nil).Once()
352-
mockStore.On("SetMetadata", ctx, LastBatchDataKey, mock.AnythingOfType("[]uint8")).Return(nil).Once()
344+
mockStore.On("GetBlockData", t.Context(), initialHeight).Return(lastHeader, lastData, nil).Once()
345+
mockStore.On("GetBlockData", t.Context(), newHeight).Return(nil, nil, errors.New("not found")).Once()
346+
mockStore.On("SaveBlockData", t.Context(), mock.AnythingOfType("*types.SignedHeader"), mock.AnythingOfType("*types.Data"), mock.AnythingOfType("*types.Signature")).Return(nil).Once()
347+
mockStore.On("SaveBlockData", t.Context(), mock.AnythingOfType("*types.SignedHeader"), mock.AnythingOfType("*types.Data"), mock.AnythingOfType("*types.Signature")).Return(nil).Once()
348+
mockStore.On("SetHeight", t.Context(), newHeight).Return(nil).Once()
349+
mockStore.On("UpdateState", t.Context(), mock.AnythingOfType("types.State")).Return(nil).Once()
350+
mockStore.On("SetMetadata", t.Context(), LastBatchDataKey, mock.AnythingOfType("[]uint8")).Return(nil).Once()
353351

354352
// --- Mock Executor ---
355353
sampleTxs := [][]byte{[]byte("tx1"), []byte("tx2")}
356354
// No longer mocking GetTxs since it's handled by reaper.go
357355
newAppHash := []byte("newAppHash")
358-
mockExec.On("ExecuteTxs", ctx, mock.Anything, newHeight, mock.AnythingOfType("time.Time"), manager.lastState.AppHash).Return(newAppHash, uint64(100), nil).Once()
359-
mockExec.On("SetFinal", ctx, newHeight).Return(nil).Once()
356+
mockExec.On("ExecuteTxs", t.Context(), mock.Anything, newHeight, mock.AnythingOfType("time.Time"), manager.lastState.AppHash).Return(newAppHash, uint64(100), nil).Once()
357+
mockExec.On("SetFinal", t.Context(), newHeight).Return(nil).Once()
360358

361359
// No longer mocking SubmitRollupBatchTxs since it's handled by reaper.go
362360
batchTimestamp := lastHeader.Time().Add(1 * time.Second)
@@ -371,8 +369,8 @@ func Test_publishBlock_Success(t *testing.T) {
371369
batchReqMatcher := mock.MatchedBy(func(req coresequencer.GetNextBatchRequest) bool {
372370
return string(req.RollupId) == chainID
373371
})
374-
mockSeq.On("GetNextBatch", ctx, batchReqMatcher).Return(batchResponse, nil).Once()
375-
err := manager.publishBlock(ctx)
372+
mockSeq.On("GetNextBatch", t.Context(), batchReqMatcher).Return(batchResponse, nil).Once()
373+
err := manager.publishBlock(t.Context())
376374
require.NoError(err, "publishBlock should succeed")
377375

378376
select {

block/reaper_test.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package block
22

33
import (
4-
"context"
54
"crypto/sha256"
65
"encoding/hex"
76
"testing"
@@ -18,8 +17,6 @@ import (
1817
)
1918

2019
func TestReaper_SubmitTxs_Success(t *testing.T) {
21-
ctx, cancel := context.WithCancel(context.Background())
22-
defer cancel()
2320

2421
mockExec := testmocks.NewExecutor(t)
2522
mockSeq := testmocks.NewSequencer(t)
@@ -28,7 +25,7 @@ func TestReaper_SubmitTxs_Success(t *testing.T) {
2825
chainID := "test-chain"
2926
interval := 100 * time.Millisecond
3027

31-
reaper := NewReaper(ctx, mockExec, mockSeq, chainID, interval, logger, store)
28+
reaper := NewReaper(t.Context(), mockExec, mockSeq, chainID, interval, logger, store)
3229

3330
// Prepare transaction and its hash
3431
tx := []byte("tx1")
@@ -55,8 +52,6 @@ func TestReaper_SubmitTxs_Success(t *testing.T) {
5552
}
5653

5754
func TestReaper_SubmitTxs_NoTxs(t *testing.T) {
58-
ctx, cancel := context.WithCancel(context.Background())
59-
defer cancel()
6055

6156
mockExec := testmocks.NewExecutor(t)
6257
mockSeq := testmocks.NewSequencer(t)
@@ -65,7 +60,7 @@ func TestReaper_SubmitTxs_NoTxs(t *testing.T) {
6560
chainID := "test-chain"
6661
interval := 100 * time.Millisecond
6762

68-
reaper := NewReaper(ctx, mockExec, mockSeq, chainID, interval, logger, store)
63+
reaper := NewReaper(t.Context(), mockExec, mockSeq, chainID, interval, logger, store)
6964

7065
// Mock GetTxs returning no transactions
7166
mockExec.On("GetTxs", mock.Anything).Return([][]byte{}, nil).Once()
@@ -80,8 +75,6 @@ func TestReaper_SubmitTxs_NoTxs(t *testing.T) {
8075

8176
func TestReaper_TxPersistence_AcrossRestarts(t *testing.T) {
8277
require := require.New(t)
83-
ctx, cancel := context.WithCancel(context.Background())
84-
defer cancel()
8578

8679
// Use separate mocks for each instance but share the store
8780
mockExec1 := testmocks.NewExecutor(t)
@@ -100,7 +93,7 @@ func TestReaper_TxPersistence_AcrossRestarts(t *testing.T) {
10093
txKey := ds.NewKey(hex.EncodeToString(txHash[:]))
10194

10295
// First reaper instance
103-
reaper1 := NewReaper(ctx, mockExec1, mockSeq1, chainID, interval, logger, store)
96+
reaper1 := NewReaper(t.Context(), mockExec1, mockSeq1, chainID, interval, logger, store)
10497

10598
// Mock interactions for the first instance
10699
mockExec1.On("GetTxs", mock.Anything).Return([][]byte{tx}, nil).Once()
@@ -112,12 +105,12 @@ func TestReaper_TxPersistence_AcrossRestarts(t *testing.T) {
112105
reaper1.SubmitTxs()
113106

114107
// Verify the tx was marked as seen in the real store after the first run
115-
has, err := store.Has(ctx, txKey)
108+
has, err := store.Has(t.Context(), txKey)
116109
require.NoError(err)
117110
require.True(has, "Transaction should be marked as seen in the datastore after first submission")
118111

119112
// Create a new reaper instance simulating a restart
120-
reaper2 := NewReaper(ctx, mockExec2, mockSeq2, chainID, interval, logger, store)
113+
reaper2 := NewReaper(t.Context(), mockExec2, mockSeq2, chainID, interval, logger, store)
121114

122115
// Mock interactions for the second instance
123116
mockExec2.On("GetTxs", mock.Anything).Return([][]byte{tx}, nil).Once()

block/submitter.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ daSubmitRetryLoop:
110110
maxBlobSize = initialMaxBlobSize
111111
if m.gasMultiplier > 0 && gasPrice != -1 {
112112
gasPrice = gasPrice / m.gasMultiplier
113-
if gasPrice < initialGasPrice {
114-
gasPrice = initialGasPrice
115-
}
113+
gasPrice = max(gasPrice, initialGasPrice)
116114
}
117115
m.logger.Debug("resetting DA layer submission options", "backoff", backoff, "gasPrice", gasPrice, "maxBlobSize", maxBlobSize)
118116
case coreda.StatusNotIncludedInBlock, coreda.StatusAlreadyInMempool:

node/full_node_integration_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (s *FullNodeTestSuite) SetupTest() {
145145
s.T().Logf("DA client initialized: %v", s.node.blockManager.DALCInitialized())
146146

147147
// Wait longer for height to stabilize and log intermediate values
148-
for i := 0; i < 5; i++ {
148+
for range 5 {
149149
time.Sleep(200 * time.Millisecond)
150150
currentHeight, err := s.node.Store.Height(s.ctx)
151151
require.NoError(err)
@@ -236,7 +236,7 @@ func (s *FullNodeTestSuite) TestSubmitBlocksToDA() {
236236

237237
// Monitor batch retrieval
238238
s.T().Log("=== Monitoring Batch Retrieval ===")
239-
for i := 0; i < 5; i++ {
239+
for i := range 5 {
240240
time.Sleep(200 * time.Millisecond)
241241
// We can't directly check batch queue size, but we can monitor block production
242242
currentHeight, err := s.node.Store.Height(s.ctx)
@@ -252,7 +252,7 @@ func (s *FullNodeTestSuite) TestSubmitBlocksToDA() {
252252
s.node.blockManager.SetLastState(currentState)
253253

254254
// Monitor after trigger
255-
for i := 0; i < 5; i++ {
255+
for i := range 5 {
256256
time.Sleep(200 * time.Millisecond)
257257
currentHeight, err := s.node.Store.Height(s.ctx)
258258
require.NoError(err)
@@ -288,7 +288,7 @@ func (s *FullNodeTestSuite) TestDAInclusion() {
288288

289289
// Monitor state changes in shorter intervals
290290
s.T().Log("=== Monitoring State Changes ===")
291-
for i := 0; i < 10; i++ {
291+
for i := range 10 {
292292
time.Sleep(200 * time.Millisecond)
293293
currentHeight, err := s.node.Store.Height(s.ctx)
294294
require.NoError(err)

node/helpers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ func (m MockTester) Fail() {}
3434
func (m MockTester) FailNow() {}
3535

3636
// Logf is used to log a message to the test logger
37-
func (m MockTester) Logf(format string, args ...interface{}) {}
37+
func (m MockTester) Logf(format string, args ...any) {}
3838

3939
// Errorf is used to log an error to the test logger
40-
func (m MockTester) Errorf(format string, args ...interface{}) {}
40+
func (m MockTester) Errorf(format string, args ...any) {}
4141

4242
func waitForFirstBlock(node Node, source Source) error {
4343
return waitForAtLeastNBlocks(node, 1, source)

pkg/cache/cache_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func TestCacheConcurrency(t *testing.T) {
9999
var wg sync.WaitGroup
100100
wg.Add(goroutines)
101101

102-
for i := 0; i < goroutines; i++ {
102+
for i := range goroutines {
103103
go func(id int) {
104104
defer wg.Done()
105105
for j := 0; j < operations; j++ {

pkg/cmd/run_node_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ func TestParseFlags(t *testing.T) {
9999

100100
testCases := []struct {
101101
name string
102-
got interface{}
103-
expected interface{}
102+
got any
103+
expected any
104104
}{
105105
{"RootDir", nodeConfig.RootDir, "custom/root/dir"},
106106
{"DBPath", nodeConfig.DBPath, "custom/db/path"},

pkg/config/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ signer:
276276
require.Equal(t, "something/config", cfgFromViper.Signer.SignerPath, "Signer.SignerPath should match YAML")
277277
}
278278

279-
func assertFlagValue(t *testing.T, flags *pflag.FlagSet, name string, expectedValue interface{}) {
279+
func assertFlagValue(t *testing.T, flags *pflag.FlagSet, name string, expectedValue any) {
280280
flag := flags.Lookup(name)
281281
assert.NotNil(t, flag, "Flag %s should exist", name)
282282
if flag != nil {

pkg/genesis/io_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func TestLoadAndSaveGenesis(t *testing.T) {
9494
// Verify file contents are valid JSON
9595
fileContent, err := os.ReadFile(filepath.Clean(tmpFile))
9696
assert.NoError(t, err)
97-
var jsonContent map[string]interface{}
97+
var jsonContent map[string]any
9898
err = json.Unmarshal(fileContent, &jsonContent)
9999
assert.NoError(t, err)
100100
})

pkg/os/os.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
type logger interface {
13-
Info(msg string, keyvals ...interface{})
13+
Info(msg string, keyvals ...any)
1414
}
1515

1616
// TrapSignal catches the SIGTERM/SIGINT and executes cb function. After that it exits

0 commit comments

Comments
 (0)