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

R4R: Simulation Queued Time Operations #2348

Merged
merged 4 commits into from
Sep 19, 2018
Merged

Conversation

sunnya97
Copy link
Member

@sunnya97 sunnya97 commented Sep 18, 2018

closes #2349

  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added entries in PENDING.md with issue #

  • rereviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@ValarDragon
Copy link
Contributor

ValarDragon commented Sep 18, 2018

Why is this a separate operation? Why not just add a BlockTime field to FutureOperation, and then just searching by either? (Or alternatively have NewFutureOperation methods)

@sunnya97 sunnya97 force-pushed the sunny/simulation_time branch from dfdb4f9 to 654cc2d Compare September 18, 2018 02:09
@sunnya97
Copy link
Member Author

@ValarDragon Good point.

@codecov
Copy link

codecov bot commented Sep 18, 2018

Codecov Report

Merging #2348 into develop will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff            @@
##           develop    #2348   +/-   ##
========================================
  Coverage    64.97%   64.97%           
========================================
  Files          135      135           
  Lines         8418     8418           
========================================
  Hits          5470     5470           
  Misses        2587     2587           
  Partials       361      361

@sunnya97 sunnya97 force-pushed the sunny/simulation_time branch from d93c4f5 to 058e470 Compare September 18, 2018 03:56
Copy link
Contributor

@ValarDragon ValarDragon left a comment

Choose a reason for hiding this comment

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

Looks good to me, just left a few minor comments

} else {
queuedOperations[futureOp.BlockHeight] = []Operation{futureOp.Op}
index := sort.Search(len(queuedTimeOperations), func(i int) bool { return queuedTimeOperations[i].BlockTime.After(futureOp.BlockTime) })
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we have to do a search, can you make a TODO comment to make the queued time ops a sorted data structure? (This can then be addressed #postlaunch or if it bottlenecks the simulation)

Right now we have to copy all the time ops on insertion / deletion, which is an O(N) operation.

@@ -274,6 +284,27 @@ func runQueuedOperations(queueOperations map[int][]Operation, height int, tb tes
return 0
}

// nolint: errcheck
Copy link
Contributor

Choose a reason for hiding this comment

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

We do want this passing errcheck though. Is there a specific line/error your trying to skip?

@@ -140,8 +141,10 @@ func SimulateFromSeed(tb testing.TB, app *baseapp.BaseApp,
// Run queued operations. Ignores blocksize if blocksize is too small
numQueuedOpsRan := runQueuedOperations(operationQueue, int(header.Height), tb, r, app, ctx, keys, logWriter, displayLogs, event)
thisBlockSize -= numQueuedOpsRan
numQueuedTimeOpsRan := runQueuedTimeOperations(timeOperationQueue, header.Time, tb, r, app, ctx, keys, logWriter, displayLogs, event)
thisBlockSize -= numQueuedTimeOpsRan
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you combine the lines subtracting the block size?

@alexanderbez alexanderbez changed the title Simulation Queued Time Operations WIP: Simulation Queued Time Operations Sep 18, 2018
@sunnya97 sunnya97 changed the title WIP: Simulation Queued Time Operations R4R: Simulation Queued Time Operations Sep 18, 2018
@sunnya97
Copy link
Member Author

Simulator fail isn't from this PR.

Copy link
Contributor

@ValarDragon ValarDragon left a comment

Choose a reason for hiding this comment

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

UtACK, can you update the existing changelog entry as well?

@jaekwon jaekwon merged commit 5b8a499 into develop Sep 19, 2018
@cwgoes cwgoes deleted the sunny/simulation_time branch September 19, 2018 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simulation - Allow queuing of operations based on time rather than block height
4 participants