Skip to content

Commit

Permalink
fix: comment
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Jan 31, 2025
1 parent ee04e1a commit 02e2bd9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
1 change: 1 addition & 0 deletions aggsender/aggsender.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ func (a *AggSender) sendCertificate(ctx context.Context) (*agglayer.SignedCertif
ToBlock: certificateParams.ToBlock,
CreatedAt: certificateParams.CreatedAt,
UpdatedAt: certificateParams.CreatedAt,
AggchainProof: certificateParams.AggchainProof,
SignedCertificate: string(raw),
}
// TODO: Improve this case, if a cert is not save in the storage, we are going to settle a unknown certificate
Expand Down
8 changes: 5 additions & 3 deletions aggsender/flow_aggchain_prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ func (a *aggchainProverFlow) GetCertificateBuildParams(ctx context.Context) (*ty
"but no bridges to resend the same certificate", lastSentCertificateInfo.String())
}

if lastSentCertificateInfo.AggchainProof == "" {
proof := lastSentCertificateInfo.AggchainProof
if proof == "" {
aggchainProof, err := a.aggchainProofClient.GenerateAggchainProof(lastSentCertificateInfo.FromBlock,
lastSentCertificateInfo.ToBlock)
if err != nil {
Expand All @@ -74,7 +75,7 @@ func (a *aggchainProverFlow) GetCertificateBuildParams(ctx context.Context) (*ty
"so got it from the aggchain prover for range %d : %d. Proof: %s",
lastSentCertificateInfo.FromBlock, lastSentCertificateInfo.ToBlock, aggchainProof.Proof)

lastSentCertificateInfo.AggchainProof = aggchainProof.Proof
proof = aggchainProof.Proof
}

// we need to resend the exact same certificate
Expand All @@ -86,6 +87,7 @@ func (a *aggchainProverFlow) GetCertificateBuildParams(ctx context.Context) (*ty
Claims: claims,
LastSentCertificate: lastSentCertificateInfo,
CreatedAt: lastSentCertificateInfo.CreatedAt,
AggchainProof: proof,
}, nil
}

Expand All @@ -104,7 +106,7 @@ func (a *aggchainProverFlow) GetCertificateBuildParams(ctx context.Context) (*ty
a.log.Infof("fetched auth proof: %s for new certificate of block range %d : %d",
aggchainProof.Proof, buildParams.FromBlock, buildParams.ToBlock)

buildParams.LastSentCertificate.AggchainProof = aggchainProof.Proof
buildParams.AggchainProof = aggchainProof.Proof

return buildParams, nil
}
Expand Down
32 changes: 17 additions & 15 deletions aggsender/flow_aggchain_prover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ func Test_AggchainProverFlow_GetCertificateBuildParams(t *testing.T) {
mockClient.On("GenerateAggchainProof", uint64(1), uint64(10)).Return(&types.AggchainProof{Proof: "some-proof"}, nil)
},
expectedParams: &types.CertificateBuildParams{
FromBlock: 1,
ToBlock: 10,
RetryCount: 1,
Bridges: []bridgesync.Bridge{{}},
Claims: []bridgesync.Claim{{}},
FromBlock: 1,
ToBlock: 10,
RetryCount: 1,
Bridges: []bridgesync.Bridge{{}},
Claims: []bridgesync.Claim{{}},
AggchainProof: "some-proof",
LastSentCertificate: &types.CertificateInfo{
FromBlock: 1,
ToBlock: 10,
Status: agglayer.InError,
AggchainProof: "some-proof",
FromBlock: 1,
ToBlock: 10,
Status: agglayer.InError,
},
},
},
Expand All @@ -91,11 +91,12 @@ func Test_AggchainProverFlow_GetCertificateBuildParams(t *testing.T) {
mockL2Syncer.On("GetClaims", ctx, uint64(1), uint64(10)).Return([]bridgesync.Claim{{}}, nil)
},
expectedParams: &types.CertificateBuildParams{
FromBlock: 1,
ToBlock: 10,
RetryCount: 1,
Bridges: []bridgesync.Bridge{{}},
Claims: []bridgesync.Claim{{}},
FromBlock: 1,
ToBlock: 10,
RetryCount: 1,
Bridges: []bridgesync.Bridge{{}},
Claims: []bridgesync.Claim{{}},
AggchainProof: "existing-proof",
LastSentCertificate: &types.CertificateInfo{
FromBlock: 1,
ToBlock: 10,
Expand Down Expand Up @@ -132,9 +133,10 @@ func Test_AggchainProverFlow_GetCertificateBuildParams(t *testing.T) {
FromBlock: 6,
ToBlock: 10,
RetryCount: 0,
LastSentCertificate: &types.CertificateInfo{ToBlock: 5, AggchainProof: "some-proof"},
LastSentCertificate: &types.CertificateInfo{ToBlock: 5},
Bridges: []bridgesync.Bridge{{}},
Claims: []bridgesync.Claim{{}},
AggchainProof: "some-proof",
CreatedAt: uint32(time.Now().UTC().Unix()),
},
},
Expand Down
1 change: 1 addition & 0 deletions aggsender/types/certificate_build_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type CertificateBuildParams struct {
CreatedAt uint32
RetryCount int
LastSentCertificate *CertificateInfo
AggchainProof string
}

func (c *CertificateBuildParams) String() string {
Expand Down

0 comments on commit 02e2bd9

Please sign in to comment.