Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into contestable-zkrollup
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Oct 1, 2023
2 parents 920c7b7 + ff8c6b2 commit d66a268
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
43 changes: 36 additions & 7 deletions prover/capacity_manager/capacity_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ func (m *CapacityManager) ReadCapacity() uint64 {
m.mutex.RLock()
defer m.mutex.RUnlock()

log.Info("Reading capacity", "capacity", len(m.capacity))
log.Info("Reading capacity",
"maxCapacity", m.maxCapacity,
"currentCapacity", m.maxCapacity-uint64(len(m.capacity)),
"currentUsage", len(m.capacity),
"currentTempCapacityUsage", len(m.tempCapacity),
)

return m.maxCapacity - uint64((len(m.capacity)))
}
Expand All @@ -44,14 +49,21 @@ func (m *CapacityManager) ReleaseOneCapacity(blockID uint64) (uint64, bool) {
if _, ok := m.capacity[blockID]; !ok {
log.Info("Can not release capacity",
"blockID", blockID,
"maxCapacity", m.maxCapacity,
"currentCapacity", m.maxCapacity-uint64(len(m.capacity)),
"maxCapacity", m.maxCapacity)
"currentUsage", len(m.capacity),
)
return uint64(len(m.capacity)), false
}

delete(m.capacity, blockID)

log.Info("Released capacity", "blockID", blockID, "capacityAfterRelease", len(m.capacity))
log.Info("Released capacity",
"blockID", blockID,
"maxCapacity", m.maxCapacity,
"currentCapacityAfterRelease", m.maxCapacity-uint64(len(m.capacity)),
"currentUsageAfterRelease", len(m.capacity),
)

return m.maxCapacity - uint64(len(m.capacity)), true
}
Expand All @@ -64,15 +76,21 @@ func (m *CapacityManager) TakeOneCapacity(blockID uint64) (uint64, bool) {
if len(m.capacity) == int(m.maxCapacity) {
log.Info("Could not take one capacity",
"blockID", blockID,
"currentCapacity", m.maxCapacity-uint64(len(m.capacity)))
"maxCapacity", m.maxCapacity,
"currentCapacity", m.maxCapacity-uint64(len(m.capacity)),
"currentUsage", len(m.capacity),
)
return 0, false
}

m.capacity[blockID] = true

log.Info("Took one capacity",
"blockID", blockID,
"capacityAfterTaking", m.maxCapacity-uint64(len(m.capacity)))
"maxCapacity", m.maxCapacity,
"currentCapacityAfterTaking", m.maxCapacity-uint64(len(m.capacity)),
"currentUsageAfterTaking", len(m.capacity),
)

return m.maxCapacity - uint64((len(m.capacity))), true
}
Expand All @@ -87,8 +105,12 @@ func (m *CapacityManager) TakeOneTempCapacity() (uint64, bool) {

if len(m.capacity)+len(m.tempCapacity) >= int(m.maxCapacity) {
log.Info("Could not take one temp capacity",
"capacity", m.maxCapacity-uint64(len(m.capacity)),
"tempCapacity", len(m.tempCapacity))
"maxCapacity", m.maxCapacity,
"currentCapacityAfterTaking", m.maxCapacity-uint64(len(m.capacity)),
"currentUsageAfterTaking", len(m.capacity),
"tempCapacity", m.maxCapacity-uint64(len((m.tempCapacity))),
"tempCapacityUsage", len(m.tempCapacity),
)
return 0, false
}

Expand All @@ -101,6 +123,13 @@ func (m *CapacityManager) clearExpiredTempCapacities() {
for i, c := range m.tempCapacity {
if time.Now().UTC().Sub(c) > m.tempCapacityExpiresAt {
m.tempCapacity = append(m.tempCapacity[:i], m.tempCapacity[i+1:]...)
log.Info("Cleared one temp capacity",
"maxCapacity", m.maxCapacity,
"currentCapacityAfterClearing", m.maxCapacity-uint64(len(m.capacity)),
"currentUsageAfterClearing", len(m.capacity),
"tempCapacity", m.maxCapacity-uint64(len((m.tempCapacity))),
"tempCapacityUsage", len(m.tempCapacity),
)
}
}
}
2 changes: 2 additions & 0 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ func (p *Prover) onBlockProposed(
) error {
// If there is newly generated proofs, we need to submit them as soon as possible.
if len(p.proofGenerationCh) > 0 {
log.Info("onBlockProposed early return", "proofGenerationChannelLength", len(p.proofGenerationCh))

end()
return nil
}
Expand Down

0 comments on commit d66a268

Please sign in to comment.