Skip to content

Commit

Permalink
Merge pull request #337 from graft-project/feature/increase-stake-period
Browse files Browse the repository at this point in the history
max stake period is 32 days
  • Loading branch information
mbg033 committed Aug 6, 2019
2 parents 3147ba2 + a70cb40 commit c75ea7c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -84,6 +84,8 @@ Dates are provided in the format YYYY-MM-DD.
| 2019-03-20 | v13 | 1.7.7 | 1.7.7 | RTA Mining |
| 2019-06-06 | v14 | 1.8.1 | 1.8.1 | Merge with monero 13: bulletproofs enabled, fixed ring size 11 |
| 2019-06-07 | v15 | 1.8.1 | 1.8.4 | bulletproofs required
| 2019-08-08 | v16 | 1.9.0 | 1.9.0 | maximum stake period is 32 days |



## Installing Graft Network from a package
Expand Down
4 changes: 4 additions & 0 deletions src/cryptonote_core/blockchain.cpp
Expand Up @@ -127,6 +127,8 @@ static const struct {
{ 14, 364590, 0, 1559833200 },
// hf 15 disable non-bulletproof, ~2019-06-07T15:00:00+00
{ 15, 365310, 0, 1559919600 },
// hf 15 increase stake period to 32 days, 2019-08-12@15:00:00+00
{ 16, 412780, 0, 1565622000 },
};
// static const uint64_t mainnet_hard_fork_version_1_till = 1009826;
static const uint64_t mainnet_hard_fork_version_1_till = 1;
Expand Down Expand Up @@ -169,6 +171,8 @@ static const struct {
{ 14, 336400, 0, 1558504800 },
// hf 15 disable non-bulletproof
{ 15, 343750, 0, 1559401200 },
// hf 16 increase stake period to 32 days, 2019-08-05T@09:00:00+00
{ 16, 381520, 0, 1564995600 }
};

// static const uint64_t testnet_hard_fork_version_1_till = 624633;
Expand Down
7 changes: 4 additions & 3 deletions src/cryptonote_core/stake_transaction_processor.cpp
Expand Up @@ -214,11 +214,12 @@ void StakeTransactionProcessor::process_block_stake_transaction(uint64_t block_i
<< " because unlock time " << unlock_time << " is less than minimum allowed " << config::graft::STAKE_MIN_UNLOCK_TIME);
continue;
}

if (unlock_time > config::graft::STAKE_MAX_UNLOCK_TIME)
const auto CURRENT_STAKE_MAX_UNLOCK_TIME = m_blockchain.get_current_hard_fork_version() < 16 ? config::graft::STAKE_MAX_UNLOCK_TIME_V15
: config::graft::STAKE_MAX_UNLOCK_TIME;
if (unlock_time > CURRENT_STAKE_MAX_UNLOCK_TIME)
{
MWARNING("Ignore stake transaction at block #" << block_index << ", tx_hash=" << tx_hash << ", supernode_public_id '" << stake_tx.supernode_public_id << "'"
<< " because unlock time " << unlock_time << " is greater than maximum allowed " << config::graft::STAKE_MAX_UNLOCK_TIME);
<< " because unlock time " << unlock_time << " is greater than maximum allowed " << CURRENT_STAKE_MAX_UNLOCK_TIME);
continue;
}

Expand Down
3 changes: 2 additions & 1 deletion src/graft_rta_config.h
Expand Up @@ -13,7 +13,8 @@ namespace graft
constexpr uint8_t STAKE_TRANSACTION_PROCESSING_DB_VERSION = 13;

constexpr uint64_t STAKE_MIN_UNLOCK_TIME = 10;
constexpr uint64_t STAKE_MAX_UNLOCK_TIME = 5000;
constexpr uint64_t STAKE_MAX_UNLOCK_TIME_V15 = 5000;
constexpr uint64_t STAKE_MAX_UNLOCK_TIME = 23040;
constexpr uint64_t STAKE_MIN_UNLOCK_TIME_FOR_WALLET = 60;
constexpr uint64_t STAKE_VALIDATION_PERIOD = 6;
constexpr uint64_t TRUSTED_RESTAKING_PERIOD = 6;
Expand Down
11 changes: 9 additions & 2 deletions src/simplewallet/simplewallet.cpp
Expand Up @@ -5017,9 +5017,16 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri
return true;
}

if (locked_blocks > config::graft::STAKE_MAX_UNLOCK_TIME)
// allow 32 days stake period from HF16
uint64_t hf16_height = 0;
m_wallet->get_hard_fork_info(16, hf16_height);

const auto CURRENT_STAKE_MAX_UNLOCK_TIME = m_wallet->get_blockchain_current_height() < hf16_height ? config::graft::STAKE_MAX_UNLOCK_TIME_V15
: config::graft::STAKE_MAX_UNLOCK_TIME;

if (locked_blocks > CURRENT_STAKE_MAX_UNLOCK_TIME)
{
fail_msg_writer() << tr("locked blocks number ") << locked_blocks << tr(" is greater than maximum allowed ") << config::graft::STAKE_MAX_UNLOCK_TIME;
fail_msg_writer() << tr("locked blocks number ") << locked_blocks << tr(" is greater than maximum allowed ") << CURRENT_STAKE_MAX_UNLOCK_TIME;
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/version.cpp.in
@@ -1,5 +1,5 @@
#define DEF_GRAFT_VERSION_TAG "@VERSIONTAG@"
#define DEF_GRAFT_VERSION "1.8.4"
#define DEF_GRAFT_VERSION "1.9.0"
#define DEF_GRAFT_RELEASE_NAME "Vela Pulsar"
#define DEF_GRAFT_VERSION_FULL DEF_GRAFT_VERSION "-" DEF_GRAFT_VERSION_TAG

Expand Down
8 changes: 7 additions & 1 deletion src/wallet/wallet_rpc_server.cpp
Expand Up @@ -135,8 +135,14 @@ namespace
er.message = "unlock_time is too low";
return false;
}
// allow 32 days stake period from HF16
uint64_t hf16_height = 0;
wallet->get_hard_fork_info(16, hf16_height);

if (req.unlock_time > current_height + config::graft::STAKE_MAX_UNLOCK_TIME)
const auto CURRENT_STAKE_MAX_UNLOCK_TIME = wallet->get_blockchain_current_height() < hf16_height ? config::graft::STAKE_MAX_UNLOCK_TIME_V15
: config::graft::STAKE_MAX_UNLOCK_TIME;

if (req.unlock_time > current_height + CURRENT_STAKE_MAX_UNLOCK_TIME)
{
er.code = WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR;
er.message = "unlock_time is too high";
Expand Down

0 comments on commit c75ea7c

Please sign in to comment.