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: Update ctx BlockTime for simulations #10467

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e8469d5
Added withBlockTime when creating a ctx for simulations
fkneeland-figure Oct 29, 2021
e55fff7
Merge branch 'master' of github.com:cosmos/cosmos-sdk into update_ctx…
fkneeland-figure Oct 29, 2021
7a7d17f
add changelog
fkneeland-figure Oct 29, 2021
5678355
moved setting of time to init function only
fkneeland-figure Oct 29, 2021
6c59b79
Merge branch 'master' into update_ctx_time_for_simulations
fkneeland-figure Nov 1, 2021
af0ed8c
Merge branch 'master' into update_ctx_time_for_simulations
fkneeland-figure Nov 2, 2021
9cbb1bb
move time now to only in simulation
fkneeland-figure Nov 2, 2021
273fdbe
Merge branch 'update_ctx_time_for_simulations' of github.com:fkneelan…
fkneeland-figure Nov 2, 2021
84cf7b2
Updated how we randomly generate time for simulations
fkneeland-figure Nov 2, 2021
c9ab160
updated
fkneeland-figure Nov 2, 2021
030e33e
Merge branch 'master' into update_ctx_time_for_simulations
fkneeland-figure Nov 2, 2021
9f2af22
Merge branch 'master' of github.com:cosmos/cosmos-sdk into update_ctx…
fkneeland-figure Nov 3, 2021
3d29934
Merge branch 'update_ctx_time_for_simulations' of github.com:fkneelan…
fkneeland-figure Nov 3, 2021
944261f
Merge branch 'master' into update_ctx_time_for_simulations
fkneeland-figure Nov 8, 2021
1f6a783
fix tests
fkneeland-figure Nov 8, 2021
d8198ac
Merge branch 'update_ctx_time_for_simulations' of github.com:fkneelan…
fkneeland-figure Nov 8, 2021
82e81d2
fixing tests more
fkneeland-figure Nov 8, 2021
6ed354d
Merge branch 'master' into update_ctx_time_for_simulations
amaury1093 Nov 9, 2021
b172cfb
Merge branch 'master' into update_ctx_time_for_simulations
fkneeland-figure Nov 9, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#10239](https://github.com/cosmos/cosmos-sdk/pull/10239) Fixed x/bank/044 migrateDenomMetadata.
* (x/upgrade) [\#10189](https://github.com/cosmos/cosmos-sdk/issues/10189) Removed potential sources of non-determinism in upgrades
* [\#10258](https://github.com/cosmos/cosmos-sdk/issues/10258) Fixes issue related to segmentaiton fault on mac m1 arm64
* [\#10466](https://github.com/cosmos/cosmos-sdk/issues/10466) Fixes error with simulation tests when genesis start time is randomly created after the year 2262

### State Machine Breaking

Expand Down
13 changes: 10 additions & 3 deletions types/simulation/rand_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,16 @@ func RandomDecAmount(r *rand.Rand, max sdk.Dec) sdk.Dec {

// RandTimestamp generates a random timestamp
func RandTimestamp(r *rand.Rand) time.Time {
// json.Marshal breaks for timestamps greater with year greater than 9999
unixTime := r.Int63n(253373529600)
return time.Unix(unixTime, 0)
// json.Marshal breaks for timestamps with year greater than 9999
// UnixNano breaks with year greater than 2262
start := time.Date(2062, time.Month(1), 1, 1, 1, 1, 1, time.UTC).UnixMilli()

// Calculate a random amount of time in seconds between 0 and 200 years
unixTime := r.Int63n(60*60*24*365*200) * 1000 // convert to milliseconds

// Get milliseconds for a time between Jan 1, 2062 and Jan 1, 2262
rtime := time.UnixMilli(start + unixTime).UnixMilli() / 1000
return time.Unix(rtime, 0)
}

// RandIntBetween returns a random int between two numbers inclusively.
Expand Down