Skip to content

Commit

Permalink
Fix for interval. (#1926) (#1928)
Browse files Browse the repository at this point in the history
* Fix for interval.

* Removed defaulting from guardian as there should already be a default value.

* Made the fromSeqNo to be local.

* Modify how the local cached seq no is set.

* Add missing cfg option.

* Another missing default value.

---------

Co-authored-by: StefanIliev545 <[email protected]>
  • Loading branch information
StefanIliev545 and StefanIliev545 authored May 22, 2024
1 parent 108a3d7 commit 51bbb84
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
20 changes: 12 additions & 8 deletions go/host/enclave/guardian.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,15 +629,13 @@ func (g *Guardian) periodicRollupProduction() {
func (g *Guardian) periodicBundleSubmission() {
defer g.logger.Info("Stopping bundle submission")

// check rollup every l1 block time

interval := g.rollupInterval
if interval == 0 {
interval = g.blockTime
}
interval := g.crossChainInterval
g.logger.Info("Starting cross chain bundle submission", "interval", interval)

bundleSubmissionTicker := time.NewTicker(interval)

fromSequenceNumber := uint64(0)

for {
select {
case <-bundleSubmissionTicker.C:
Expand All @@ -646,14 +644,20 @@ 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())
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. Skipping.")
g.logger.Debug("No cross chain data to submit")
fromSequenceNumber = to.Uint64() + 1
continue
}

Expand Down
4 changes: 0 additions & 4 deletions go/host/l1/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,6 @@ func (p *Publisher) PublishCrossChainBundle(bundle *common.ExtCrossChainBundle)
return nil
}

if len(bundle.CrossChainRootHashes) == 0 {
return fmt.Errorf("nothing to publish in cross chain bundle")
}

managementCtr, err := ManagementContract.NewManagementContract(*p.mgmtContractLib.GetContractAddr(), p.ethClient.EthClient())
if err != nil {
p.logger.Error("Unable to instantiate management contract client")
Expand Down
1 change: 1 addition & 0 deletions integration/simulation/devnetwork/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func (n *InMemNodeOperator) createHostContainer() *hostcontainer.HostContainer {
BatchInterval: n.config.BatchInterval,
RollupInterval: n.config.RollupInterval,
L1BlockTime: n.config.L1BlockTime,
CrossChainInterval: n.config.CrossChainInterval,
MaxRollupSize: 1024 * 64,
}

Expand Down
1 change: 1 addition & 0 deletions integration/simulation/network/network_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func createInMemObscuroNode(
ManagementContractAddress: *mgtContractAddress,
MessageBusAddress: l1BusAddress,
BatchInterval: batchInterval,
CrossChainInterval: config.DefaultHostParsedConfig().CrossChainInterval,
IsInboundP2PDisabled: incomingP2PDisabled,
L1BlockTime: l1BlockTime,
UseInMemoryDB: true,
Expand Down

0 comments on commit 51bbb84

Please sign in to comment.