Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for interval. #1926

Merged
merged 6 commits into from
May 22, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions go/host/enclave/guardian.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,13 +632,10 @@ func (g *Guardian) periodicBundleSubmission() {
interval := g.crossChainInterval
g.logger.Info("Starting cross chain bundle submission", "interval", interval)

if interval == 0 {
interval = 20 * time.Second
g.logger.Warn("Cross chain interval not set. Defaulting to 10 seconds")
}

bundleSubmissionTicker := time.NewTicker(interval)

fromSequenceNumber := uint64(0)

for {
select {
case <-bundleSubmissionTicker.C:
Expand All @@ -647,12 +644,23 @@ func (g *Guardian) periodicBundleSubmission() {
g.logger.Error("Unable to get bundle range from management contract", log.ErrKey, err)
continue
}
bundle, err := g.enclaveClient.ExportCrossChainData(context.Background(), from.Uint64(), to.Uint64())

if from.Uint64() > fromSequenceNumber {
fromSequenceNumber = from.Uint64()
}

bundle, err := g.enclaveClient.ExportCrossChainData(context.Background(), fromSequenceNumber, to.Uint64())
StefanIliev545 marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
g.logger.Error("Unable to export cross chain bundle from enclave", log.ErrKey, err)
continue
}

if len(bundle.CrossChainRootHashes) == 0 {
g.logger.Debug("No cross chain data to submit")
fromSequenceNumber = to.Uint64()
continue
}

err = g.sl.L1Publisher().PublishCrossChainBundle(bundle)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean you're publishing even if there is nothing to publish?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's less than ideal

if err != nil {
g.logger.Error("Unable to publish cross chain bundle", log.ErrKey, err)
Expand Down
Loading