Skip to content

Commit

Permalink
use the CertificateBuildParams
Browse files Browse the repository at this point in the history
  • Loading branch information
vcastellm committed Dec 5, 2024
1 parent a55f8fb commit ae015b3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions aggsender/aggsender.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ func (a *AggSender) sendCertificate(ctx context.Context) (*agglayer.SignedCertif
ToBlock: toBlock,
Bridges: bridges,
Claims: claims,
CreatedAt: uint32(time.Now().UTC().Unix()),
}

certificateParams, err = a.limitCertSize(certificateParams)
Expand Down Expand Up @@ -228,7 +229,6 @@ func (a *AggSender) sendCertificate(ctx context.Context) (*agglayer.SignedCertif
return nil, fmt.Errorf("error marshalling signed certificate. Cert:%s. Err: %w", signedCertificate.Brief(), err)
}

createdTime := time.Now().UTC().UnixMilli()
prevLER := common.BytesToHash(certificate.PrevLocalExitRoot[:])
certInfo := types.CertificateInfo{
Height: certificate.Height,
Expand All @@ -238,8 +238,8 @@ func (a *AggSender) sendCertificate(ctx context.Context) (*agglayer.SignedCertif
PreviousLocalExitRoot: &prevLER,
FromBlock: fromBlock,
ToBlock: toBlock,
CreatedAt: createdTime,
UpdatedAt: createdTime,
CreatedAt: int64(certificateParams.CreatedAt),
UpdatedAt: int64(certificateParams.CreatedAt),
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 Expand Up @@ -396,7 +396,7 @@ func (a *AggSender) buildCertificate(ctx context.Context,
meta := types.NewCertificateMetadata(
certParams.FromBlock,
uint32(certParams.ToBlock-certParams.FromBlock),
uint32(time.Now().UTC().Unix()),
certParams.CreatedAt,
)

return &agglayer.Certificate{
Expand Down
2 changes: 1 addition & 1 deletion aggsender/aggsender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ func TestBuildCertificate(t *testing.T) {
NetworkID: 1,
PrevLocalExitRoot: common.HexToHash("0x123"),
NewLocalExitRoot: common.HexToHash("0x789"),
Metadata: aggsendertypes.NewCertificateMetadata(0, 10, uint32(time.Now().Unix())).ToHash(),
Metadata: aggsendertypes.NewCertificateMetadata(0, 10, 0).ToHash(),
BridgeExits: []*agglayer.BridgeExit{
{
LeafType: agglayer.LeafTypeAsset,
Expand Down
5 changes: 3 additions & 2 deletions aggsender/types/certificate_build_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ type CertificateBuildParams struct {
ToBlock uint64
Bridges []bridgesync.Bridge
Claims []bridgesync.Claim
CreatedAt uint32
}

func (c *CertificateBuildParams) String() string {
return fmt.Sprintf("FromBlock: %d, ToBlock: %d, numBridges: %d, numClaims: %d",
c.FromBlock, c.ToBlock, c.NumberOfBridges(), c.NumberOfClaims())
return fmt.Sprintf("FromBlock: %d, ToBlock: %d, numBridges: %d, numClaims: %d, createdAt: %d",
c.FromBlock, c.ToBlock, c.NumberOfBridges(), c.NumberOfClaims(), c.CreatedAt)
}

// Range create a new CertificateBuildParams with the given range
Expand Down

0 comments on commit ae015b3

Please sign in to comment.