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

Add progress prints for v1.12 store migration #1557

Merged
merged 1 commit into from
Oct 4, 2023

Conversation

assafmo
Copy link
Member

@assafmo assafmo commented Oct 4, 2023

No description provided.

@assafmo assafmo merged commit a3692c6 into master Oct 4, 2023
9 of 10 checks passed
@assafmo assafmo deleted the v1.12-state-migration-progress-prints branch October 4, 2023 16:35
formatter := message.NewPrinter(language.English)
migratedContracts := uint64(0)
totalContracts := m.keeper.peekAutoIncrementID(ctx, types.KeyLastCodeID)
previousTime := time.Now().UnixNano()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
}
migratedContracts++
logMigrationProgress(ctx, formatter, migratedContracts, totalContracts, previousTime)
previousTime = time.Now().UnixNano()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
func logMigrationProgress(ctx sdk.Context, formatter *message.Printer, migratedContracts uint64, totalContracts uint64, previousTime int64) {
if migratedContracts%progressPartSize == 0 || migratedContracts == totalContracts {
if totalContracts > 0 {
timePerPartNs := time.Now().UnixNano() - previousTime

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
if migratedContracts%progressPartSize == 0 || migratedContracts == totalContracts {
if totalContracts > 0 {
timePerPartNs := time.Now().UnixNano() - previousTime
partsLeft := float64(totalContracts-migratedContracts) / float64(progressPartSize)

Check notice

Code scanning / CodeQL

Floating point arithmetic Note

Floating point arithmetic operations are not associative and a possible source of non-determinism
if totalContracts > 0 {
timePerPartNs := time.Now().UnixNano() - previousTime
partsLeft := float64(totalContracts-migratedContracts) / float64(progressPartSize)
timeLeftNs := uint64(partsLeft * float64(timePerPartNs))

Check notice

Code scanning / CodeQL

Floating point arithmetic Note

Floating point arithmetic operations are not associative and a possible source of non-determinism
formatter.Sprintf("Migrated contracts: %d/%d (%f%%), ETA: %s\n",
migratedContracts,
totalContracts,
(float64(migratedContracts)/float64(totalContracts))*100,

Check notice

Code scanning / CodeQL

Floating point arithmetic Note

Floating point arithmetic operations are not associative and a possible source of non-determinism
formatter.Sprintf("Migrated contracts: %d/%d (%f%%), ETA: %s\n",
migratedContracts,
totalContracts,
(float64(migratedContracts)/float64(totalContracts))*100,

Check notice

Code scanning / CodeQL

Floating point arithmetic Note

Floating point arithmetic operations are not associative and a possible source of non-determinism
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant