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

GPOS2 HF - Handle rolling period on missing blocks #369

Merged
merged 1 commit into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 10 additions & 5 deletions libraries/chain/db_maint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,6 @@ uint32_t database::get_gpos_current_subperiod()
const auto now = this->head_block_time();
auto seconds_since_period_start = now.sec_since_epoch() - period_start.sec_since_epoch();

FC_ASSERT(period_start <= now && now <= period_end);

// get in what sub period we are
uint32_t current_subperiod = 0;
std::list<uint32_t> period_list(number_of_subperiods);
Expand Down Expand Up @@ -926,9 +924,16 @@ void rolling_period_start(database& db)
if(now.sec_since_epoch() >= (period_start + vesting_period))
{
// roll
db.modify(db.get_global_properties(), [now](global_property_object& p) {
p.parameters.extensions.value.gpos_period_start = now.sec_since_epoch();
});
if(db.head_block_time() >= HARDFORK_GPOS2_TIME)
{
db.modify(db.get_global_properties(), [period_start, vesting_period](global_property_object& p) {
p.parameters.extensions.value.gpos_period_start = period_start + vesting_period;
});
} else {
db.modify(db.get_global_properties(), [now](global_property_object& p) {
p.parameters.extensions.value.gpos_period_start = now.sec_since_epoch();
});
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions libraries/chain/hardfork.d/GPOS2.hf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// GPOS2 HARDFORK Tuesday, 28 July 2020 01:00:00 GMT
#ifndef HARDFORK_GPOS2_TIME
#define HARDFORK_GPOS2_TIME (fc::time_point_sec( 1595898000 ))
#endif