Skip to content

Commit e324f2a

Browse files
committed
fix ci
1 parent e713424 commit e324f2a

File tree

8 files changed

+246
-44
lines changed

8 files changed

+246
-44
lines changed

build/.golangci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ linters-settings:
9191
#local-prefixes: github.com/org/project
9292
gocyclo:
9393
# minimal code complexity to report, 30 by default (but we recommend 10-20)
94-
min-complexity: 30
94+
min-complexity: 40
9595
maligned:
9696
# print struct with more effective memory layout or not, false by default
9797
suggest-new: true
@@ -254,6 +254,9 @@ issues:
254254
- linters:
255255
- wsl
256256
text: "expressions should not be cuddled with declarations or returns"
257+
- linters:
258+
- govet
259+
text: 'shadow: declaration of "(err|ctx)" shadows declaration at'
257260

258261
# Independently from option `exclude` we use default exclude patterns,
259262
# it can be disabled by this option. To list all

database/migrate/migrate_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,20 @@ func testResetDB(t *testing.T) {
5959
cur, err := Current(pgDB)
6060
assert.NoError(t, err)
6161
// total number of tables.
62-
assert.Equal(t, int64(24), cur)
62+
assert.Equal(t, int64(25), cur)
6363
}
6464

6565
func testMigrate(t *testing.T) {
6666
assert.NoError(t, Migrate(pgDB))
6767
cur, err := Current(pgDB)
6868
assert.NoError(t, err)
69-
assert.Equal(t, int64(24), cur)
69+
assert.Equal(t, int64(25), cur)
7070
}
7171

7272
func testRollback(t *testing.T) {
7373
version, err := Current(pgDB)
7474
assert.NoError(t, err)
75-
assert.Equal(t, int64(24), version)
75+
assert.Equal(t, int64(25), version)
7676

7777
assert.NoError(t, Rollback(pgDB, nil))
7878

database/migrate/migrations/00025_add_l1_message_queue_hash.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
-- +goose StatementBegin
33

44
ALTER TABLE chunk
5-
ADD COLUMN initial_l1_message_queue_hash VARCHAR DEFAULT '';
5+
ADD COLUMN initial_l1_message_queue_hash VARCHAR DEFAULT '',
66
ADD COLUMN last_l1_message_queue_hash VARCHAR DEFAULT '';
77

88
ALTER TABLE batch
9-
ADD COLUMN initial_l1_message_queue_hash VARCHAR DEFAULT '';
9+
ADD COLUMN initial_l1_message_queue_hash VARCHAR DEFAULT '',
1010
ADD COLUMN last_l1_message_queue_hash VARCHAR DEFAULT '';
1111

1212

@@ -16,11 +16,11 @@ ADD COLUMN last_l1_message_queue_hash VARCHAR DEFAULT '';
1616
-- +goose StatementBegin
1717

1818
ALTER TABLE IF EXISTS chunk
19-
DROP COLUMN IF EXISTS initial_l1_message_queue_hash;
19+
DROP COLUMN IF EXISTS initial_l1_message_queue_hash,
2020
DROP COLUMN IF EXISTS last_l1_message_queue_hash;
2121

2222
ALTER TABLE IF EXISTS batch
23-
DROP COLUMN IF EXISTS initial_l1_message_queue_hash;
23+
DROP COLUMN IF EXISTS initial_l1_message_queue_hash,
2424
DROP COLUMN IF EXISTS last_l1_message_queue_hash;
2525

2626
-- +goose StatementEnd

go.work.sum

Lines changed: 192 additions & 0 deletions
Large diffs are not rendered by default.

rollup/conf/config.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@
4949
"tx_type": "DynamicFeeTx",
5050
"check_pending_time": 1,
5151
"min_gas_tip": 100000000,
52-
"max_pending_blob_txs": 3
52+
"max_pending_blob_txs": 3,
53+
"batch_submission": {
54+
"min_batches": 1,
55+
"max_batches": 6,
56+
"timeout": 300
57+
}
5358
},
5459
"gas_oracle_config": {
5560
"min_gas_price": 0,

rollup/go.sum

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,9 @@ github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6ke
249249
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
250250
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
251251
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
252-
github.com/scroll-tech/da-codec v0.1.3-0.20250128015324-64133efc3843 h1:Qd6bh5Cn5hqf/yyz4ucq4Z2qIStH4KUYsPNK/zfaAb8=
253-
github.com/scroll-tech/da-codec v0.1.3-0.20250128015324-64133efc3843/go.mod h1:+ho/ItbapMf2xM9YUv/SfGFg3AJx9lBD7ksR7T0ZVmM=
254-
github.com/scroll-tech/da-codec v0.1.3-0.20250205011841-edaf5d2f9f24 h1:E+DYPJPoIxviTfyjttoHoZ0ylv2n9fNHHwTK6n4vCss=
255-
github.com/scroll-tech/da-codec v0.1.3-0.20250205011841-edaf5d2f9f24/go.mod h1:irqXJdRI5fsGkilJCpNTnJb8oV8KR51j68QXIWoth6U=
256252
github.com/scroll-tech/da-codec v0.1.3-0.20250205043214-894a93bb6b53 h1:07eHUuUhQ2rOP6ij5+KV1MgQurkwyweomkxp5nAG6o8=
257253
github.com/scroll-tech/da-codec v0.1.3-0.20250205043214-894a93bb6b53/go.mod h1:irqXJdRI5fsGkilJCpNTnJb8oV8KR51j68QXIWoth6U=
258-
github.com/scroll-tech/go-ethereum v1.10.14-0.20250103082839-ea3ec93d8c1e h1:g8jtcGiHbjWYh/V7O245IDho3WfQT4CwEpBV+MhYDrg=
259-
github.com/scroll-tech/go-ethereum v1.10.14-0.20250103082839-ea3ec93d8c1e/go.mod h1:Ik3OBLl7cJxPC+CFyCBYNXBPek4wpdzkWehn/y5qLM8=
254+
github.com/scroll-tech/go-ethereum v1.10.14-0.20250129031936-44c72cd3fa47 h1:JbYYsGZMU1yAYsF/Ds6STMlItYy0SXj86nqdXC7nHyk=
260255
github.com/scroll-tech/go-ethereum v1.10.14-0.20250129031936-44c72cd3fa47/go.mod h1:8WbNuuUjie/LTdFXGGT7Z711MRW8Vv2zWLrcibg7hDc=
261256
github.com/scroll-tech/zktrie v0.8.4 h1:UagmnZ4Z3ITCk+aUq9NQZJNAwnWl4gSxsLb2Nl7IgRE=
262257
github.com/scroll-tech/zktrie v0.8.4/go.mod h1:XvNo7vAk8yxNyTjBDj5WIiFzYW4bx/gJ78+NK6Zn6Uk=

rollup/internal/controller/relayer/l2_relayer.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import (
1010
"strings"
1111
"time"
1212

13+
"scroll-tech/common/types"
14+
"scroll-tech/common/types/message"
15+
"scroll-tech/common/utils"
16+
1317
"github.com/go-resty/resty/v2"
1418
"github.com/prometheus/client_golang/prometheus"
1519
"github.com/scroll-tech/da-codec/encoding"
@@ -23,10 +27,6 @@ import (
2327
"github.com/scroll-tech/go-ethereum/params"
2428
"gorm.io/gorm"
2529

26-
"scroll-tech/common/types"
27-
"scroll-tech/common/types/message"
28-
"scroll-tech/common/utils"
29-
3030
bridgeAbi "scroll-tech/rollup/abi"
3131
"scroll-tech/rollup/internal/config"
3232
"scroll-tech/rollup/internal/controller/sender"
@@ -378,6 +378,7 @@ func (r *Layer2Relayer) ProcessGasPriceOracle() {
378378
// ProcessPendingBatches processes the pending batches by sending commitBatch transactions to layer 1.
379379
func (r *Layer2Relayer) ProcessPendingBatches() {
380380
// get pending batches from database in ascending order by their index.
381+
// TODO: sanity check config?
381382
dbBatches, err := r.batchOrm.GetFailedAndPendingBatches(r.ctx, max(5, r.cfg.SenderConfig.BatchSubmission.MaxBatches))
382383
if err != nil {
383384
log.Error("Failed to fetch pending L2 batches", "err", err)

rollup/internal/controller/sender/sender_test.go

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var (
4444
cfg *config.Config
4545
testApps *testcontainers.TestcontainerApps
4646
txTypes = []string{"LegacyTx", "DynamicFeeTx", "DynamicFeeTx"}
47-
txBlob = []*kzg4844.Blob{nil, nil, randBlob()}
47+
txBlob = []*kzg4844.Blob{nil, nil, randBlobs(2)[0]}
4848
txUint8Types = []uint8{0, 2, 3}
4949
db *gorm.DB
5050
testContractsAddress common.Address
@@ -185,7 +185,7 @@ func testSendAndRetrieveTransaction(t *testing.T) {
185185
s, err := NewSender(context.Background(), &cfgCopy, signerConfig, "test", "test", types.SenderTypeUnknown, db, nil)
186186
assert.NoError(t, err)
187187

188-
hash, err := s.SendTransaction("0", &common.Address{}, nil, txBlob[i], 0)
188+
hash, err := s.SendTransaction("0", &common.Address{}, nil, []*kzg4844.Blob{txBlob[i]}, 0)
189189
assert.NoError(t, err)
190190
txs, err := s.pendingTransactionOrm.GetPendingOrReplacedTransactionsBySenderType(context.Background(), s.senderType, 1)
191191
assert.NoError(t, err)
@@ -225,7 +225,7 @@ func testFallbackGasLimit(t *testing.T) {
225225
assert.NoError(t, err)
226226

227227
// FallbackGasLimit = 0
228-
txHash0, err := s.SendTransaction("0", &common.Address{}, nil, txBlob[i], 0)
228+
txHash0, err := s.SendTransaction("0", &common.Address{}, nil, []*kzg4844.Blob{txBlob[i]}, 0)
229229
assert.NoError(t, err)
230230
tx0, _, err := client.TransactionByHash(context.Background(), txHash0)
231231
assert.NoError(t, err)
@@ -245,7 +245,7 @@ func testFallbackGasLimit(t *testing.T) {
245245
},
246246
)
247247

248-
txHash1, err := s.SendTransaction("1", &common.Address{}, nil, txBlob[i], 100000)
248+
txHash1, err := s.SendTransaction("1", &common.Address{}, nil, []*kzg4844.Blob{txBlob[i]}, 100000)
249249
assert.NoError(t, err)
250250
tx1, _, err := client.TransactionByHash(context.Background(), txHash1)
251251
assert.NoError(t, err)
@@ -329,7 +329,7 @@ func testAccessListTransactionGasLimit(t *testing.T) {
329329

330330
var sidecar *gethTypes.BlobTxSidecar
331331
if txBlob[i] != nil {
332-
sidecar, err = makeSidecar(txBlob[i])
332+
sidecar, err = makeSidecar([]*kzg4844.Blob{txBlob[i]})
333333
assert.NoError(t, err)
334334
}
335335

@@ -370,7 +370,7 @@ func testResubmitNonZeroGasPriceTransaction(t *testing.T) {
370370
}
371371
var sidecar *gethTypes.BlobTxSidecar
372372
if txBlob[i] != nil {
373-
sidecar, err = makeSidecar(txBlob[i])
373+
sidecar, err = makeSidecar([]*kzg4844.Blob{txBlob[i]})
374374
assert.NoError(t, err)
375375
}
376376
tx, err := s.createTx(feeData, &common.Address{}, nil, sidecar, s.transactionSigner.GetNonce())
@@ -505,7 +505,7 @@ func testResubmitBlobTransactionWithRisingBaseFeeAndBlobBaseFee(t *testing.T) {
505505
})
506506
defer patchGuard.Reset()
507507

508-
sidecar, err := makeSidecar(randBlob())
508+
sidecar, err := makeSidecar(randBlobs(1))
509509
assert.NoError(t, err)
510510
tx := gethTypes.NewTx(&gethTypes.BlobTx{
511511
ChainID: uint256.MustFromBig(s.chainID),
@@ -579,10 +579,10 @@ func testResubmitNonceGappedTransaction(t *testing.T) {
579579
return nil, errors.New("simulated transaction receipt error")
580580
})
581581

582-
_, err = s.SendTransaction("test-1", &common.Address{}, nil, txBlob[i], 0)
582+
_, err = s.SendTransaction("test-1", &common.Address{}, nil, []*kzg4844.Blob{txBlob[i]}, 0)
583583
assert.NoError(t, err)
584584

585-
_, err = s.SendTransaction("test-2", &common.Address{}, nil, txBlob[i], 0)
585+
_, err = s.SendTransaction("test-2", &common.Address{}, nil, []*kzg4844.Blob{txBlob[i]}, 0)
586586
assert.NoError(t, err)
587587

588588
s.checkPendingTransaction()
@@ -623,7 +623,7 @@ func testCheckPendingTransactionTxConfirmed(t *testing.T) {
623623
return nil
624624
})
625625

626-
_, err = s.SendTransaction("test", &common.Address{}, nil, randBlob(), 0)
626+
_, err = s.SendTransaction("test", &common.Address{}, nil, randBlobs(1), 0)
627627
assert.NoError(t, err)
628628

629629
txs, err := s.pendingTransactionOrm.GetPendingOrReplacedTransactionsBySenderType(context.Background(), s.senderType, 1)
@@ -665,7 +665,7 @@ func testCheckPendingTransactionResubmitTxConfirmed(t *testing.T) {
665665
return nil
666666
})
667667

668-
originTxHash, err := s.SendTransaction("test", &common.Address{}, nil, randBlob(), 0)
668+
originTxHash, err := s.SendTransaction("test", &common.Address{}, nil, randBlobs(1), 0)
669669
assert.NoError(t, err)
670670

671671
txs, err := s.pendingTransactionOrm.GetPendingOrReplacedTransactionsBySenderType(context.Background(), s.senderType, 1)
@@ -725,7 +725,7 @@ func testCheckPendingTransactionReplacedTxConfirmed(t *testing.T) {
725725
return nil
726726
})
727727

728-
txHash, err := s.SendTransaction("test", &common.Address{}, nil, randBlob(), 0)
728+
txHash, err := s.SendTransaction("test", &common.Address{}, nil, randBlobs(1), 0)
729729
assert.NoError(t, err)
730730

731731
txs, err := s.pendingTransactionOrm.GetPendingOrReplacedTransactionsBySenderType(context.Background(), s.senderType, 1)
@@ -795,7 +795,7 @@ func testCheckPendingTransactionTxMultipleTimesWithOnlyOneTxPending(t *testing.T
795795
return nil
796796
})
797797

798-
_, err = s.SendTransaction("test", &common.Address{}, nil, randBlob(), 0)
798+
_, err = s.SendTransaction("test", &common.Address{}, nil, randBlobs(1), 0)
799799
assert.NoError(t, err)
800800

801801
txs, err := s.pendingTransactionOrm.GetPendingOrReplacedTransactionsBySenderType(context.Background(), s.senderType, 1)
@@ -832,8 +832,8 @@ func testBlobTransactionWithBlobhashOpContractCall(t *testing.T) {
832832
assert.NoError(t, err)
833833
assert.NoError(t, migrate.ResetDB(sqlDB))
834834

835-
blob := randBlob()
836-
sideCar, err := makeSidecar(blob)
835+
blobs := randBlobs(1)
836+
sideCar, err := makeSidecar(blobs)
837837
assert.NoError(t, err)
838838
versionedHash := sideCar.BlobHashes()[0]
839839
blsModulo, ok := new(big.Int).SetString("52435875175126190479447740508185965837690552500527637822603658699938581184513", 10)
@@ -845,7 +845,7 @@ func testBlobTransactionWithBlobhashOpContractCall(t *testing.T) {
845845
var point kzg4844.Point
846846
copy(point[start:], pointBytes)
847847
commitment := sideCar.Commitments[0]
848-
proof, claim, err := kzg4844.ComputeProof(blob, point)
848+
proof, claim, err := kzg4844.ComputeProof(blobs[0], point)
849849
assert.NoError(t, err)
850850

851851
var claimArray [32]byte
@@ -869,7 +869,7 @@ func testBlobTransactionWithBlobhashOpContractCall(t *testing.T) {
869869
assert.NoError(t, err)
870870
defer s.Stop()
871871

872-
_, err = s.SendTransaction("0", &testContractsAddress, data, blob, 0)
872+
_, err = s.SendTransaction("0", &testContractsAddress, data, blobs, 0)
873873
assert.NoError(t, err)
874874

875875
var txHash common.Hash
@@ -889,13 +889,19 @@ func testBlobTransactionWithBlobhashOpContractCall(t *testing.T) {
889889
}, 30*time.Second, time.Second)
890890
}
891891

892-
func randBlob() *kzg4844.Blob {
893-
var blob kzg4844.Blob
894-
for i := 0; i < len(blob); i += gokzg4844.SerializedScalarSize {
895-
fieldElementBytes := randFieldElement()
896-
copy(blob[i:i+gokzg4844.SerializedScalarSize], fieldElementBytes[:])
892+
func randBlobs(count int) []*kzg4844.Blob {
893+
blobs := make([]*kzg4844.Blob, 0, count)
894+
895+
for c := 0; c < count; c++ {
896+
var blob kzg4844.Blob
897+
for i := 0; i < len(blob); i += gokzg4844.SerializedScalarSize {
898+
fieldElementBytes := randFieldElement()
899+
copy(blob[i:i+gokzg4844.SerializedScalarSize], fieldElementBytes[:])
900+
}
901+
blobs = append(blobs, &blob)
897902
}
898-
return &blob
903+
904+
return blobs
899905
}
900906

901907
func randFieldElement() [32]byte {
@@ -921,10 +927,10 @@ func testSendBlobCarryingTxOverLimit(t *testing.T) {
921927
assert.NoError(t, err)
922928

923929
for i := 0; i < int(cfgCopy.MaxPendingBlobTxs); i++ {
924-
_, err = s.SendTransaction("0", &common.Address{}, nil, randBlob(), 0)
930+
_, err = s.SendTransaction("0", &common.Address{}, nil, randBlobs(1), 0)
925931
assert.NoError(t, err)
926932
}
927-
_, err = s.SendTransaction("0", &common.Address{}, nil, randBlob(), 0)
933+
_, err = s.SendTransaction("0", &common.Address{}, nil, randBlobs(1), 0)
928934
assert.ErrorIs(t, err, ErrTooManyPendingBlobTxs)
929935
s.Stop()
930936
}

0 commit comments

Comments
 (0)