Skip to content

Commit

Permalink
fix: renamed ForbiddenSendCertificateAfterEpochPercentage to MaxEpoch…
Browse files Browse the repository at this point in the history
…PercentageAllowedToSendCertificate
  • Loading branch information
joanestebanr committed Feb 4, 2025
1 parent fb94332 commit 31b1ff2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions aggsender/aggsender.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,12 @@ func (a *AggSender) sendCertificate(ctx context.Context) (*agglayer.SignedCertif
return signedCertificate, nil
}
func (a *AggSender) isAllowedSendCertificateEpochPercent() bool {
if a.cfg.ForbiddenSendCertificateAfterEpochPercentage == 0 ||
a.cfg.ForbiddenSendCertificateAfterEpochPercentage >= maxPercent {
if a.cfg.MaxEpochPercentageAllowedToSendCertificate == 0 ||
a.cfg.MaxEpochPercentageAllowedToSendCertificate >= maxPercent {
return true
}
status := a.epochNotifier.GetEpochStatus()
if status.PercentEpoch >= float64(a.cfg.ForbiddenSendCertificateAfterEpochPercentage)/100.0 {
if status.PercentEpoch >= float64(a.cfg.MaxEpochPercentageAllowedToSendCertificate)/100.0 {
a.log.Warnf("forbidden to send certificate after epoch percentage: %f", status.PercentEpoch)
return false
}
Expand Down
4 changes: 2 additions & 2 deletions aggsender/aggsender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestConfigString(t *testing.T) {
"CheckStatusCertificateInterval: 0s\n" +
"RetryCertInmediatlyAfterInError: false\n" +
"MaxSubmitRate: RateLimitConfig{Unlimited}\n" +
"ForbiddenSendCertificateAfterEpochPercentage: 0\n"
"MaxEpochPercentageAllowedToSendCertificate: 0\n"

require.Equal(t, expected, config.String())
}
Expand Down Expand Up @@ -2095,7 +2095,7 @@ func TestGetLastSentBlockAndRetryCount(t *testing.T) {
func TestLimitEpochPercent_Greater(t *testing.T) {
testData := newAggsenderTestData(t, testDataFlagMockStorage)
testData.sut.cfg.MaxCertSize = (aggsendertypes.EstimatedSizeBridgeExit * 3) + 1
testData.sut.cfg.ForbiddenSendCertificateAfterEpochPercentage = 80
testData.sut.cfg.MaxEpochPercentageAllowedToSendCertificate = 80

ctx := context.TODO()
testData.storageMock.EXPECT().GetCertificatesByStatus(mock.Anything).Return([]*aggsendertypes.CertificateInfo{}, nil).Once()
Expand Down
8 changes: 4 additions & 4 deletions aggsender/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ type Config struct {
// RetryCertAfterInError when a cert pass to 'InError'
// state the AggSender will try to resend it inmediatly
RetryCertAfterInError bool `mapstructure:"RetryCertAfterInError"`
// ForbiddenSendCertificateAfterEpochPercentage is the percentage of the epoch
// MaxEpochPercentageAllowedToSendCertificate is the percentage of the epoch
// after which the AggSender is forbidden to send the certificate.
// If value==0 || value >= 100 the check is disabled
// 0 -> Begin
// 50 -> Middle
// 100 -> End
ForbiddenSendCertificateAfterEpochPercentage uint `mapstructure:"ForbiddenSendCertificateAfterEpochPercentage"`
MaxEpochPercentageAllowedToSendCertificate uint `mapstructure:"MaxEpochPercentageAllowedToSendCertificate"`
// MaxSubmitCertificateRate is the maximum rate of certificate submission allowed
MaxSubmitCertificateRate common.RateLimitConfig `mapstructure:"MaxSubmitCertificateRate"`
}
Expand All @@ -79,6 +79,6 @@ func (c Config) String() string {
"CheckStatusCertificateInterval: " + c.CheckStatusCertificateInterval.String() + "\n" +
"RetryCertInmediatlyAfterInError: " + fmt.Sprintf("%t", c.RetryCertAfterInError) + "\n" +
"MaxSubmitRate: " + c.MaxSubmitCertificateRate.String() + "\n" +
"ForbiddenSendCertificateAfterEpochPercentage: " +
fmt.Sprintf("%d", c.ForbiddenSendCertificateAfterEpochPercentage) + "\n"
"MaxEpochPercentageAllowedToSendCertificate: " +
fmt.Sprintf("%d", c.MaxEpochPercentageAllowedToSendCertificate) + "\n"
}
2 changes: 1 addition & 1 deletion config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ EnableRPC = true
CheckStatusCertificateInterval = "5m"
RetryCertInmediatlyAfterInError = true
# Don't send certificate over 80% of the epoch
ForbiddenSendCertificateAfterEpochPercentage=80
MaxEpochPercentageAllowedToSendCertificate=80
[AggSender.MaxSubmitCertificateRate]
NumRequests = 20
Interval = "1h"
Expand Down

0 comments on commit 31b1ff2

Please sign in to comment.