From 73188555ba2181303c9936c085fc0921997f7721 Mon Sep 17 00:00:00 2001 From: Goran Rojovic Date: Mon, 28 Oct 2024 20:52:02 +0100 Subject: [PATCH] fix: comments and get imported bridge exits --- aggsender/aggsender.go | 111 ++++++---------- aggsender/aggsender_test.go | 207 ++++++++--------------------- aggsender/config.go | 6 +- config/default.go | 3 +- test/helpers/lxly-bridge-test.bash | 2 - 5 files changed, 102 insertions(+), 227 deletions(-) diff --git a/aggsender/aggsender.go b/aggsender/aggsender.go index b172a324..b7165946 100644 --- a/aggsender/aggsender.go +++ b/aggsender/aggsender.go @@ -11,7 +11,6 @@ import ( "github.com/0xPolygon/cdk/agglayer" "github.com/0xPolygon/cdk/aggsender/db" - "github.com/0xPolygon/cdk/aggsender/types" aggsendertypes "github.com/0xPolygon/cdk/aggsender/types" "github.com/0xPolygon/cdk/bridgesync" cdkcommon "github.com/0xPolygon/cdk/common" @@ -53,7 +52,7 @@ func New( aggLayerClient agglayer.AgglayerClientInterface, l1InfoTreeSyncer *l1infotreesync.L1InfoTreeSync, l2Syncer *bridgesync.BridgeSync) (*AggSender, error) { - storage, err := db.NewAggSenderSQLStorage(logger, cfg.DBPath) + storage, err := db.NewAggSenderSQLStorage(logger, cfg.StoragePath) if err != nil { return nil, err } @@ -164,8 +163,7 @@ func (a *AggSender) sendCertificate(ctx context.Context) error { return fmt.Errorf("error signing certificate: %w", err) } - a.logJSONCertificate(signedCertificate) - a.saveCertificate(signedCertificate) + a.saveCertificateToFile(signedCertificate) certificateHash, err := a.aggLayerClient.SendCertificate(signedCertificate) if err != nil { @@ -188,40 +186,30 @@ func (a *AggSender) sendCertificate(ctx context.Context) error { return nil } -func (a *AggSender) saveCertificate(signedCertificate *agglayer.SignedCertificate) { - if signedCertificate == nil { + +// saveCertificate saves the certificate to a tmp file +func (a *AggSender) saveCertificateToFile(signedCertificate *agglayer.SignedCertificate) { + if signedCertificate == nil || !a.cfg.SaveCertificatesToFiles { return } + fn := fmt.Sprintf("/tmp/certificate_%04d.json", signedCertificate.Height) a.log.Infof("saving certificate to file: %s", fn) jsonData, err := json.Marshal(signedCertificate) if err != nil { a.log.Errorf("error marshalling certificate: %w", err) } - // write json data to file - err = os.WriteFile(fn, jsonData, 0644) - if err != nil { - a.log.Errorf("error writing certificate to file: %w", err) - } -} -// logJSONCertificate logs the certificate in JSON format to the logs -func (a *AggSender) logJSONCertificate(certificate *agglayer.SignedCertificate) { - raw, err := json.Marshal(certificate) - if err != nil { - a.log.Errorf("error marshalling certificate: %w", err) - return + if err = os.WriteFile(fn, jsonData, 0644); err != nil { + a.log.Errorf("error writing certificate to file: %w", err) } - - a.log.Debug("JSON certificate:") - a.log.Debug(string(raw)) } // buildCertificate builds a certificate from the bridge events func (a *AggSender) buildCertificate(ctx context.Context, bridges []bridgesync.Bridge, claims []bridgesync.Claim, - lastSentCertificateInfo types.CertificateInfo) (*agglayer.Certificate, error) { + lastSentCertificateInfo aggsendertypes.CertificateInfo) (*agglayer.Certificate, error) { if len(bridges) == 0 && len(claims) == 0 { return nil, errNoBridgesAndClaims } @@ -318,93 +306,72 @@ func (a *AggSender) getBridgeExits(bridges []bridgesync.Bridge) []*agglayer.Brid // getImportedBridgeExits converts claims to agglayer.ImportedBridgeExit objects and calculates necessary proofs func (a *AggSender) getImportedBridgeExits(ctx context.Context, claims []bridgesync.Claim) ([]*agglayer.ImportedBridgeExit, error) { - var ( - importedBridgeExits = make([]*agglayer.ImportedBridgeExit, 0, len(claims)) - greatestL1InfoTreeIndex = uint32(0) - ger common.Hash - timestamp uint64 - blockHash common.Hash - greatestClaimIndex = 0 - ) - - l1Infos := make([]*l1infotreesync.L1InfoTreeLeaf, 0, len(claims)) - for i, claim := range claims[:] { + importedBridgeExits := make([]*agglayer.ImportedBridgeExit, 0, len(claims)) + + for i, claim := range claims { a.log.Debugf("claim[%d]: destAddr: %s GER:%s", i, claim.DestinationAddress.String(), claim.GlobalExitRoot.String()) - info, err := a.l1infoTreeSyncer.GetInfoByGlobalExitRoot(claim.GlobalExitRoot) + l1Info, err := a.l1infoTreeSyncer.GetInfoByGlobalExitRoot(claim.GlobalExitRoot) if err != nil { return nil, fmt.Errorf("error getting info by global exit root: %w", err) } - if greatestL1InfoTreeIndex < info.L1InfoTreeIndex { - greatestL1InfoTreeIndex = info.L1InfoTreeIndex - ger = claim.GlobalExitRoot - timestamp = info.Timestamp - blockHash = info.PreviousBlockHash - greatestClaimIndex = i - } - - importedBridgeExit, err := a.convertClaimToImportedBridgeExit(claim) + ibe, err := a.convertClaimToImportedBridgeExit(claim) if err != nil { return nil, fmt.Errorf("error converting claim to imported bridge exit: %w", err) } - importedBridgeExits = append(importedBridgeExits, importedBridgeExit) - l1Infos = append(l1Infos, info) - } - - for i, ibe := range importedBridgeExits { - l1Info := l1Infos[i] + importedBridgeExits = append(importedBridgeExits, ibe) - gerToL1Proof, err := a.l1infoTreeSyncer.GetL1InfoTreeMerkleProofFromIndexToRoot(ctx, l1Info.L1InfoTreeIndex, ger) + gerToL1Proof, err := a.l1infoTreeSyncer.GetL1InfoTreeMerkleProofFromIndexToRoot(ctx, l1Info.L1InfoTreeIndex, l1Info.GlobalExitRoot) if err != nil { return nil, fmt.Errorf("error getting L1 Info tree merkle proof for leaf index: %d. GER: %s. Error: %w", - l1Info.L1InfoTreeIndex, ger, err) + l1Info.L1InfoTreeIndex, l1Info.GlobalExitRoot, err) } claim := claims[i] if ibe.GlobalIndex.MainnetFlag { ibe.ClaimData = &agglayer.ClaimFromMainnnet{ L1Leaf: &agglayer.L1InfoTreeLeaf{ - L1InfoTreeIndex: greatestL1InfoTreeIndex, - RollupExitRoot: claims[greatestClaimIndex].RollupExitRoot, - MainnetExitRoot: claims[greatestClaimIndex].MainnetExitRoot, + L1InfoTreeIndex: l1Info.L1InfoTreeIndex, + RollupExitRoot: claim.RollupExitRoot, + MainnetExitRoot: claim.MainnetExitRoot, Inner: &agglayer.L1InfoTreeLeafInner{ - GlobalExitRoot: ger, - Timestamp: timestamp, - BlockHash: blockHash, + GlobalExitRoot: l1Info.GlobalExitRoot, + Timestamp: l1Info.Timestamp, + BlockHash: l1Info.PreviousBlockHash, }, }, ProofLeafMER: &agglayer.MerkleProof{ - Root: claims[greatestClaimIndex].MainnetExitRoot, - Proof: claims[greatestClaimIndex].ProofLocalExitRoot, + Root: claim.MainnetExitRoot, + Proof: claim.ProofLocalExitRoot, }, ProofGERToL1Root: &agglayer.MerkleProof{ - Root: ger, + Root: l1Info.GlobalExitRoot, Proof: gerToL1Proof, }, } } else { ibe.ClaimData = &agglayer.ClaimFromRollup{ L1Leaf: &agglayer.L1InfoTreeLeaf{ - L1InfoTreeIndex: greatestL1InfoTreeIndex, - RollupExitRoot: claims[greatestClaimIndex].RollupExitRoot, - MainnetExitRoot: claims[greatestClaimIndex].MainnetExitRoot, + L1InfoTreeIndex: l1Info.L1InfoTreeIndex, + RollupExitRoot: claim.RollupExitRoot, + MainnetExitRoot: claim.MainnetExitRoot, Inner: &agglayer.L1InfoTreeLeafInner{ - GlobalExitRoot: claim.GlobalExitRoot, - Timestamp: timestamp, - BlockHash: blockHash, + GlobalExitRoot: l1Info.GlobalExitRoot, + Timestamp: l1Info.Timestamp, + BlockHash: l1Info.PreviousBlockHash, }, }, ProofLeafLER: &agglayer.MerkleProof{ - Root: claims[greatestClaimIndex].MainnetExitRoot, - Proof: claims[greatestClaimIndex].ProofLocalExitRoot, + Root: claim.MainnetExitRoot, + Proof: claim.ProofLocalExitRoot, }, ProofLERToRER: &agglayer.MerkleProof{ - Root: claims[greatestClaimIndex].RollupExitRoot, - Proof: claims[greatestClaimIndex].ProofRollupExitRoot, + Root: claim.RollupExitRoot, + Proof: claim.ProofRollupExitRoot, }, ProofGERToL1Root: &agglayer.MerkleProof{ - Root: ger, + Root: l1Info.GlobalExitRoot, Proof: gerToL1Proof, }, } @@ -467,7 +434,7 @@ func (a *AggSender) checkPendingCertificatesStatus(ctx context.Context) { continue } - if certificateHeader.Status == agglayer.Settled || certificateHeader.Status == agglayer.InError { + if certificateHeader.Status != agglayer.Pending { certificate.Status = certificateHeader.Status a.log.Infof("certificate %s changed status to %s", certificateHeader.String(), certificate.Status) diff --git a/aggsender/aggsender_test.go b/aggsender/aggsender_test.go index fad0dc9c..dd4e3901 100644 --- a/aggsender/aggsender_test.go +++ b/aggsender/aggsender_test.go @@ -251,12 +251,12 @@ func TestGetImportedBridgeExits(t *testing.T) { t.Parallel() mockProof := generateTestProof(t) - mockL1InfoTreeSyncer := mocks.NewL1InfoTreeSyncerMock(t) mockL1InfoTreeSyncer.On("GetInfoByGlobalExitRoot", mock.Anything).Return(&l1infotreesync.L1InfoTreeLeaf{ L1InfoTreeIndex: 1, Timestamp: 123456789, PreviousBlockHash: common.HexToHash("0xabc"), + GlobalExitRoot: common.HexToHash("0x7891"), }, nil) mockL1InfoTreeSyncer.On("GetL1InfoTreeMerkleProofFromIndexToRoot", mock.Anything, mock.Anything, mock.Anything).Return(mockProof, nil) @@ -271,18 +271,19 @@ func TestGetImportedBridgeExits(t *testing.T) { name: "Single claim", claims: []bridgesync.Claim{ { - IsMessage: false, - OriginNetwork: 1, - OriginAddress: common.HexToAddress("0x1234"), - DestinationNetwork: 2, - DestinationAddress: common.HexToAddress("0x4567"), - Amount: big.NewInt(111), - Metadata: []byte("metadata1"), - GlobalIndex: big.NewInt(1), - GlobalExitRoot: common.HexToHash("0x7891"), - RollupExitRoot: common.HexToHash("0xaaab"), - MainnetExitRoot: common.HexToHash("0xbbba"), - ProofLocalExitRoot: mockProof, + IsMessage: false, + OriginNetwork: 1, + OriginAddress: common.HexToAddress("0x1234"), + DestinationNetwork: 2, + DestinationAddress: common.HexToAddress("0x4567"), + Amount: big.NewInt(111), + Metadata: []byte("metadata1"), + GlobalIndex: bridgesync.GenerateGlobalIndex(false, 1, 1), + GlobalExitRoot: common.HexToHash("0x7891"), + RollupExitRoot: common.HexToHash("0xaaab"), + MainnetExitRoot: common.HexToHash("0xbbba"), + ProofLocalExitRoot: mockProof, + ProofRollupExitRoot: mockProof, }, }, expectedError: false, @@ -301,7 +302,7 @@ func TestGetImportedBridgeExits(t *testing.T) { }, GlobalIndex: &agglayer.GlobalIndex{ MainnetFlag: false, - RollupIndex: 0, + RollupIndex: 1, LeafIndex: 1, }, ClaimData: &agglayer.ClaimFromRollup{ @@ -319,7 +320,10 @@ func TestGetImportedBridgeExits(t *testing.T) { Root: common.HexToHash("0xbbba"), Proof: mockProof, }, - ProofLERToRER: &agglayer.MerkleProof{}, + ProofLERToRER: &agglayer.MerkleProof{ + Root: common.HexToHash("0xaaab"), + Proof: mockProof, + }, ProofGERToL1Root: &agglayer.MerkleProof{ Root: common.HexToHash("0x7891"), Proof: mockProof, @@ -332,32 +336,34 @@ func TestGetImportedBridgeExits(t *testing.T) { name: "Multiple claims", claims: []bridgesync.Claim{ { - IsMessage: false, - OriginNetwork: 1, - OriginAddress: common.HexToAddress("0x123"), - DestinationNetwork: 2, - DestinationAddress: common.HexToAddress("0x456"), - Amount: big.NewInt(100), - Metadata: []byte("metadata"), - GlobalIndex: big.NewInt(1), - GlobalExitRoot: common.HexToHash("0x789"), - RollupExitRoot: common.HexToHash("0xaaa"), - MainnetExitRoot: common.HexToHash("0xbbb"), - ProofLocalExitRoot: mockProof, + IsMessage: false, + OriginNetwork: 1, + OriginAddress: common.HexToAddress("0x123"), + DestinationNetwork: 2, + DestinationAddress: common.HexToAddress("0x456"), + Amount: big.NewInt(100), + Metadata: []byte("metadata"), + GlobalIndex: big.NewInt(1), + GlobalExitRoot: common.HexToHash("0x7891"), + RollupExitRoot: common.HexToHash("0xaaa"), + MainnetExitRoot: common.HexToHash("0xbbb"), + ProofLocalExitRoot: mockProof, + ProofRollupExitRoot: mockProof, }, { - IsMessage: true, - OriginNetwork: 3, - OriginAddress: common.HexToAddress("0x789"), - DestinationNetwork: 4, - DestinationAddress: common.HexToAddress("0xabc"), - Amount: big.NewInt(200), - Metadata: []byte("data"), - GlobalIndex: bridgesync.GenerateGlobalIndex(true, 0, 2), - GlobalExitRoot: common.HexToHash("0xdef"), - RollupExitRoot: common.HexToHash("0xbbb"), - MainnetExitRoot: common.HexToHash("0xccc"), - ProofLocalExitRoot: mockProof, + IsMessage: true, + OriginNetwork: 3, + OriginAddress: common.HexToAddress("0x789"), + DestinationNetwork: 4, + DestinationAddress: common.HexToAddress("0xabc"), + Amount: big.NewInt(200), + Metadata: []byte("data"), + GlobalIndex: bridgesync.GenerateGlobalIndex(true, 0, 2), + GlobalExitRoot: common.HexToHash("0x7891"), + RollupExitRoot: common.HexToHash("0xbbb"), + MainnetExitRoot: common.HexToHash("0xccc"), + ProofLocalExitRoot: mockProof, + ProofRollupExitRoot: mockProof, }, }, expectedError: false, @@ -385,7 +391,7 @@ func TestGetImportedBridgeExits(t *testing.T) { RollupExitRoot: common.HexToHash("0xaaa"), MainnetExitRoot: common.HexToHash("0xbbb"), Inner: &agglayer.L1InfoTreeLeafInner{ - GlobalExitRoot: common.HexToHash("0x789"), + GlobalExitRoot: common.HexToHash("0x7891"), Timestamp: 123456789, BlockHash: common.HexToHash("0xabc"), }, @@ -394,9 +400,12 @@ func TestGetImportedBridgeExits(t *testing.T) { Root: common.HexToHash("0xbbb"), Proof: mockProof, }, - ProofLERToRER: &agglayer.MerkleProof{}, + ProofLERToRER: &agglayer.MerkleProof{ + Root: common.HexToHash("0xaaa"), + Proof: mockProof, + }, ProofGERToL1Root: &agglayer.MerkleProof{ - Root: common.HexToHash("0x789"), + Root: common.HexToHash("0x7891"), Proof: mockProof, }, }, @@ -424,7 +433,7 @@ func TestGetImportedBridgeExits(t *testing.T) { RollupExitRoot: common.HexToHash("0xbbb"), MainnetExitRoot: common.HexToHash("0xccc"), Inner: &agglayer.L1InfoTreeLeafInner{ - GlobalExitRoot: common.HexToHash("0xdef"), + GlobalExitRoot: common.HexToHash("0x7891"), Timestamp: 123456789, BlockHash: common.HexToHash("0xabc"), }, @@ -434,7 +443,7 @@ func TestGetImportedBridgeExits(t *testing.T) { Proof: mockProof, }, ProofGERToL1Root: &agglayer.MerkleProof{ - Root: common.HexToHash("0x789"), + Root: common.HexToHash("0x7891"), Proof: mockProof, }, }, @@ -836,9 +845,6 @@ func TestSendCertificate(t *testing.T) { shouldSendCertificate []interface{} getLastSentCertificate []interface{} lastL2BlockProcessed []interface{} - getCertificateHeader []interface{} - deleteCertificate []interface{} - getCertificateByHeight []interface{} getBridges []interface{} getClaims []interface{} getInfoByGlobalExitRoot []interface{} @@ -863,8 +869,8 @@ func TestSendCertificate(t *testing.T) { mockL1InfoTreeSyncer *mocks.L1InfoTreeSyncerMock ) - if cfg.shouldSendCertificate != nil || cfg.getLastSentCertificate != nil || cfg.deleteCertificate != nil || - cfg.getCertificateByHeight != nil || cfg.saveLastSentCertificate != nil { + if cfg.shouldSendCertificate != nil || cfg.getLastSentCertificate != nil || + cfg.saveLastSentCertificate != nil { mockStorage = mocks.NewAggSenderStorageMock(t) mockStorage.On("GetCertificatesByStatus", mock.Anything, []agglayer.CertificateStatus{agglayer.Pending}). Return(cfg.shouldSendCertificate...).Once() @@ -875,14 +881,6 @@ func TestSendCertificate(t *testing.T) { mockStorage.On("GetLastSentCertificate", mock.Anything).Return(cfg.getLastSentCertificate...).Once() } - if cfg.deleteCertificate != nil { - mockStorage.On("DeleteCertificate", mock.Anything, mock.Anything).Return(cfg.deleteCertificate...).Once() - } - - if cfg.getCertificateByHeight != nil { - mockStorage.On("GetCertificateByHeight", mock.Anything, mock.Anything).Return(cfg.getCertificateByHeight...).Once() - } - if cfg.saveLastSentCertificate != nil { mockStorage.On("SaveLastSentCertificate", mock.Anything, mock.Anything).Return(cfg.saveLastSentCertificate...).Once() } @@ -913,13 +911,9 @@ func TestSendCertificate(t *testing.T) { aggsender.l2Syncer = mockL2Syncer } - if cfg.getCertificateHeader != nil || cfg.sendCertificate != nil { + if cfg.sendCertificate != nil { mockAggLayerClient = agglayer.NewAgglayerClientMock(t) - mockAggLayerClient.On("GetCertificateHeader", mock.Anything).Return(cfg.getCertificateHeader...).Once() - - if cfg.sendCertificate != nil { - mockAggLayerClient.On("SendCertificate", mock.Anything).Return(cfg.sendCertificate...).Once() - } + mockAggLayerClient.On("SendCertificate", mock.Anything).Return(cfg.sendCertificate...).Once() aggsender.aggLayerClient = mockAggLayerClient } @@ -953,55 +947,6 @@ func TestSendCertificate(t *testing.T) { getLastSentCertificate: []interface{}{aggsendertypes.CertificateInfo{}, errors.New("error getting last sent certificate")}, expectedError: "error getting last sent certificate", }, - { - name: "error getting last certificate header", - shouldSendCertificate: []interface{}{[]*aggsendertypes.CertificateInfo{}, nil}, - lastL2BlockProcessed: []interface{}{uint64(8), nil}, - getLastSentCertificate: []interface{}{aggsendertypes.CertificateInfo{ - Height: 1, - CertificateID: common.HexToHash("0x1"), - NewLocalExitRoot: common.HexToHash("0x123"), - FromBlock: 1, - ToBlock: 10, - }, nil}, - getCertificateHeader: []interface{}{nil, errors.New("error getting certificate header")}, - expectedError: "error getting certificate", - }, - { - name: "error deleting in error certificate", - shouldSendCertificate: []interface{}{[]*aggsendertypes.CertificateInfo{}, nil}, - lastL2BlockProcessed: []interface{}{uint64(20), nil}, - getLastSentCertificate: []interface{}{aggsendertypes.CertificateInfo{ - Height: 1, - CertificateID: common.HexToHash("0x1"), - NewLocalExitRoot: common.HexToHash("0x123"), - FromBlock: 1, - ToBlock: 10, - }, nil}, - getCertificateHeader: []interface{}{&agglayer.CertificateHeader{ - Status: agglayer.InError, - }, nil}, - deleteCertificate: []interface{}{errors.New("error deleting certificate")}, - expectedError: "error deleting certificate", - }, - { - name: "error getting certificate by height", - shouldSendCertificate: []interface{}{[]*aggsendertypes.CertificateInfo{}, nil}, - lastL2BlockProcessed: []interface{}{uint64(29), nil}, - getLastSentCertificate: []interface{}{aggsendertypes.CertificateInfo{ - Height: 11, - CertificateID: common.HexToHash("0x1"), - NewLocalExitRoot: common.HexToHash("0x123"), - FromBlock: 19, - ToBlock: 28, - }, nil}, - getCertificateHeader: []interface{}{&agglayer.CertificateHeader{ - Status: agglayer.InError, - }, nil}, - deleteCertificate: []interface{}{nil}, - getCertificateByHeight: []interface{}{aggsendertypes.CertificateInfo{}, errors.New("error getting certificate by height")}, - expectedError: "error getting certificate by height", - }, { name: "no new blocks to send certificate", shouldSendCertificate: []interface{}{[]*aggsendertypes.CertificateInfo{}, nil}, @@ -1013,9 +958,6 @@ func TestSendCertificate(t *testing.T) { FromBlock: 31, ToBlock: 41, }, nil}, - getCertificateHeader: []interface{}{&agglayer.CertificateHeader{ - Status: agglayer.Settled, - }, nil}, }, { name: "get bridges error", @@ -1028,11 +970,6 @@ func TestSendCertificate(t *testing.T) { FromBlock: 40, ToBlock: 41, }, nil}, - getCertificateHeader: []interface{}{&agglayer.CertificateHeader{ - Status: agglayer.Settled, - CertificateID: common.HexToHash("0x1110"), - Height: 49, - }, nil}, getBridges: []interface{}{nil, errors.New("error getting bridges")}, expectedError: "error getting bridges", }, @@ -1047,11 +984,6 @@ func TestSendCertificate(t *testing.T) { FromBlock: 50, ToBlock: 51, }, nil}, - getCertificateHeader: []interface{}{&agglayer.CertificateHeader{ - Status: agglayer.Settled, - CertificateID: common.HexToHash("0x1110"), - Height: 59, - }, nil}, getBridges: []interface{}{[]bridgesync.Bridge{}, nil}, }, { @@ -1065,11 +997,6 @@ func TestSendCertificate(t *testing.T) { FromBlock: 60, ToBlock: 61, }, nil}, - getCertificateHeader: []interface{}{&agglayer.CertificateHeader{ - Status: agglayer.Settled, - CertificateID: common.HexToHash("0x1110"), - Height: 69, - }, nil}, getBridges: []interface{}{[]bridgesync.Bridge{ { BlockNum: 61, @@ -1092,11 +1019,6 @@ func TestSendCertificate(t *testing.T) { FromBlock: 70, ToBlock: 71, }, nil}, - getCertificateHeader: []interface{}{&agglayer.CertificateHeader{ - Status: agglayer.Settled, - CertificateID: common.HexToHash("0x1110"), - Height: 79, - }, nil}, getBridges: []interface{}{[]bridgesync.Bridge{ { BlockNum: 71, @@ -1124,11 +1046,6 @@ func TestSendCertificate(t *testing.T) { FromBlock: 80, ToBlock: 81, }, nil}, - getCertificateHeader: []interface{}{&agglayer.CertificateHeader{ - Status: agglayer.Settled, - CertificateID: common.HexToHash("0x1110"), - Height: 89, - }, nil}, getBridges: []interface{}{[]bridgesync.Bridge{ { BlockNum: 81, @@ -1156,11 +1073,6 @@ func TestSendCertificate(t *testing.T) { FromBlock: 90, ToBlock: 91, }, nil}, - getCertificateHeader: []interface{}{&agglayer.CertificateHeader{ - Status: agglayer.Settled, - CertificateID: common.HexToHash("0x11110"), - Height: 99, - }, nil}, getBridges: []interface{}{[]bridgesync.Bridge{ { BlockNum: 91, @@ -1189,11 +1101,6 @@ func TestSendCertificate(t *testing.T) { FromBlock: 100, ToBlock: 101, }, nil}, - getCertificateHeader: []interface{}{&agglayer.CertificateHeader{ - Status: agglayer.Settled, - CertificateID: common.HexToHash("0x11110"), - Height: 109, - }, nil}, getBridges: []interface{}{[]bridgesync.Bridge{ { BlockNum: 101, diff --git a/aggsender/config.go b/aggsender/config.go index 2d88569d..506b4e9a 100644 --- a/aggsender/config.go +++ b/aggsender/config.go @@ -6,8 +6,8 @@ import ( // Config is the configuration for the AggSender type Config struct { - // DBPath is the path of the sqlite db on which the AggSender will store the data - DBPath string `mapstructure:"DBPath"` + // StoragePath is the path of the sqlite db on which the AggSender will store the data + StoragePath string `mapstructure:"StoragePath"` // AggLayerURL is the URL of the AggLayer AggLayerURL string `mapstructure:"AggLayerURL"` // BlockGetInterval is the interval at which the AggSender will get the blocks from L1 @@ -18,4 +18,6 @@ type Config struct { AggsenderPrivateKey types.KeystoreFileConfig `mapstructure:"AggsenderPrivateKey"` // URLRPCL2 is the URL of the L2 RPC node URLRPCL2 string `mapstructure:"URLRPCL2"` + // SaveCertificatesToFiles is a flag which tells the AggSender to save the certificates to a file + SaveCertificatesToFiles bool `mapstructure:"SaveCertificatesToFiles"` } diff --git a/config/default.go b/config/default.go index f07b3f17..6898af50 100644 --- a/config/default.go +++ b/config/default.go @@ -341,10 +341,11 @@ GlobalExitRootManagerAddr = "{{L1Config.polygonZkEVMGlobalExitRootAddress}}" [AggSender] -DBPath = "{{PathRWData}}/aggsender.sqlite" +StoragePath = "{{PathRWData}}/aggsender.sqlite" AggLayerURL = "{{AggLayerURL}}" AggsenderPrivateKey = {Path = "{{SequencerPrivateKeyPath}}", Password = "{{SequencerPrivateKeyPassword}}"} BlockGetInterval = "2s" URLRPCL2="{{L2URL}}" CheckSettledInterval = "2s" +SaveCertificatesToFiles = false ` diff --git a/test/helpers/lxly-bridge-test.bash b/test/helpers/lxly-bridge-test.bash index 7ec356da..7b3cb008 100644 --- a/test/helpers/lxly-bridge-test.bash +++ b/test/helpers/lxly-bridge-test.bash @@ -37,8 +37,6 @@ function claim() { readonly claimable_deposit_file=$(mktemp) echo "Getting full list of deposits" >&3 curl -s "$bridge_api_url/bridges/$destination_addr?limit=100&offset=0" | jq '.' | tee $bridge_deposit_file - cat $bridge_deposit_file >&3 - echo "Looking for claimable deposits" >&3 jq '[.deposits[] | select(.ready_for_claim == true and .claim_tx_hash == "" and .dest_net == '$destination_net')]' $bridge_deposit_file | tee $claimable_deposit_file