Skip to content

Commit

Permalink
Changes done in 'origin/develop' specific to v1.27.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
vogel76 committed Oct 20, 2022
2 parents 0d92587 + 4a7df5f commit b322c4c
Show file tree
Hide file tree
Showing 261 changed files with 822 additions and 2,346 deletions.
22 changes: 13 additions & 9 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@

long next_hf_time()
{
// current "next hardfork" is HF26
// current "next hardfork" is HF27
long hfTime =

#ifdef IS_TEST_NET
1643716800; // Tuesday, 1 February 2022 12:00:00
1665532800; // Wednesday, October 12, 2022 0:00:00 GMT
#else
1665489600; // Tuesday, 11 October 2022 12:00:00 GMT
1666612800; // Monday, 24 October 2022 12:00:00 GMT
#endif /// IS_TEST_NET

const char* value = getenv("HIVE_HF26_TIME");
if(value != nullptr)
const char* value = getenv("HIVE_HF27_TIME");
if (value)
{
hfTime = atol(value);
ilog("HIVE_HF26_TIME has been specified through environment variable as ${v}, long value: ${l}", ("v", value)("l", hfTime));
ilog("HIVE_HF27_TIME has been specified through environment variable as ${value}, long value: ${hfTime}", (value)(hfTime));
}

return hfTime;
Expand Down Expand Up @@ -245,7 +245,7 @@ void database::load_state_initial_data(const open_args& args)
FC_ASSERT(hardforks.last_hardfork <= HIVE_NUM_HARDFORKS, "Chain knows of more hardforks than configuration", ("hardforks.last_hardfork", hardforks.last_hardfork)("HIVE_NUM_HARDFORKS", HIVE_NUM_HARDFORKS));
FC_ASSERT(_hardfork_versions.versions[hardforks.last_hardfork] <= HIVE_BLOCKCHAIN_VERSION, "Blockchain version is older than last applied hardfork");
FC_ASSERT(HIVE_BLOCKCHAIN_HARDFORK_VERSION >= HIVE_BLOCKCHAIN_VERSION);
FC_ASSERT(HIVE_BLOCKCHAIN_HARDFORK_VERSION == _hardfork_versions.versions[HIVE_NUM_HARDFORKS]);
FC_ASSERT(HIVE_BLOCKCHAIN_HARDFORK_VERSION == _hardfork_versions.versions[HIVE_NUM_HARDFORKS], "Blockchain version mismatch", (HIVE_BLOCKCHAIN_HARDFORK_VERSION)(_hardfork_versions.versions[HIVE_NUM_HARDFORKS]));
});

#ifdef USE_ALTERNATE_CHAIN_ID
Expand Down Expand Up @@ -1891,7 +1891,8 @@ void database::adjust_witness_votes( const account_object& a, const share_type&

void database::adjust_witness_vote( const witness_object& witness, share_type delta )
{
const witness_schedule_object& wso = get_witness_schedule_object();
const witness_schedule_object& wso = has_hardfork(HIVE_HARDFORK_1_27_FIX_TIMESHARE_WITNESS_SCHEDULING) ?
get_witness_schedule_object_for_irreversibility() : get_witness_schedule_object();
modify( witness, [&]( witness_object& w )
{
auto delta_pos = w.votes.value * (wso.current_virtual_time - w.virtual_last_update);
Expand Down Expand Up @@ -6422,10 +6423,13 @@ void database::init_hardforks()
FC_ASSERT( HIVE_HARDFORK_1_26 == 26, "Invalid hardfork configuration" );
_hardfork_versions.times[ HIVE_HARDFORK_1_26 ] = fc::time_point_sec( HIVE_HARDFORK_1_26_TIME );
_hardfork_versions.versions[ HIVE_HARDFORK_1_26 ] = HIVE_HARDFORK_1_26_VERSION;
#if defined(IS_TEST_NET) && defined(HIVE_ENABLE_SMT)
FC_ASSERT( HIVE_HARDFORK_1_27 == 27, "Invalid hardfork configuration" );
_hardfork_versions.times[ HIVE_HARDFORK_1_27 ] = fc::time_point_sec( HIVE_HARDFORK_1_27_TIME );
_hardfork_versions.versions[ HIVE_HARDFORK_1_27 ] = HIVE_HARDFORK_1_27_VERSION;
#if defined(IS_TEST_NET) && defined(HIVE_ENABLE_SMT)
FC_ASSERT( HIVE_HARDFORK_1_28 == 28, "Invalid hardfork configuration" );
_hardfork_versions.times[ HIVE_HARDFORK_1_28 ] = fc::time_point_sec( HIVE_HARDFORK_1_28_TIME );
_hardfork_versions.versions[ HIVE_HARDFORK_1_28 ] = HIVE_HARDFORK_1_28_VERSION;
#endif
}

Expand Down
5 changes: 2 additions & 3 deletions libraries/chain/witness_schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ using hive::chain::util::rd_system_params;
using hive::chain::util::rd_user_params;
using hive::chain::util::rd_validate_user_params;

// this is only called on application of hf4, and the future witness schedule doesn't take
// effect until a much later hard fork, so we only need to operate on the current witness schedule here.
void reset_virtual_schedule_time( database& db )
{ try {
const witness_schedule_object& wso = db.get_witness_schedule_object();
const witness_schedule_object& wso = db.has_hardfork(HIVE_HARDFORK_1_27_FIX_TIMESHARE_WITNESS_SCHEDULING) ?
db.get_witness_schedule_object_for_irreversibility() : db.get_witness_schedule_object();
db.modify( wso, [&](witness_schedule_object& o )
{
o.current_virtual_time = fc::uint128(); // reset it 0
Expand Down
4 changes: 2 additions & 2 deletions libraries/protocol/hardfork.d/0-preamble.hf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <set>

#if defined(IS_TEST_NET) && defined(HIVE_ENABLE_SMT)
#define HIVE_NUM_HARDFORKS 27
#define HIVE_NUM_HARDFORKS 28
#else
#define HIVE_NUM_HARDFORKS 26
#define HIVE_NUM_HARDFORKS 27
#endif
4 changes: 1 addition & 3 deletions libraries/protocol/hardfork.d/1_26.hf
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#ifndef HIVE_HARDFORK_1_26
#define HIVE_HARDFORK_1_26 26

long next_hf_time();

#define HIVE_HARDFORK_1_26_TIME next_hf_time()
# define HIVE_HARDFORK_1_26_TIME 1665489600 // Tuesday, 11 October 2022 12:00:00 GMT

#define HIVE_HARDFORK_1_26_VERSION hive::protocol::hardfork_version( 1, 26 )

Expand Down
7 changes: 5 additions & 2 deletions libraries/protocol/hardfork.d/1_27.hf
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#ifndef HIVE_HARDFORK_1_27
#define HIVE_HARDFORK_1_27 27
#define HIVE_SMT_HARDFORK HIVE_HARDFORK_1_27

#define HIVE_HARDFORK_1_27_TIME 1654084800 // Wednesday, 1 June 2022 12:00:00
long next_hf_time();
#define HIVE_HARDFORK_1_27_TIME next_hf_time()

#define HIVE_HARDFORK_1_27_VERSION hive::protocol::hardfork_version( 1, 27 )

// fix scheduling of timeshare witnesses to restore pre-hf26 behavior
#define HIVE_HARDFORK_1_27_FIX_TIMESHARE_WITNESS_SCHEDULING (HIVE_HARDFORK_1_27)

#endif
9 changes: 9 additions & 0 deletions libraries/protocol/hardfork.d/1_28.hf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef HIVE_HARDFORK_1_28
#define HIVE_HARDFORK_1_28 28
#define HIVE_SMT_HARDFORK HIVE_HARDFORK_1_28

#define HIVE_HARDFORK_1_28_TIME 1654084800 // Wednesday, 1 June 2022 12:00:00

#define HIVE_HARDFORK_1_28_VERSION hive::protocol::hardfork_version( 1, 28 )

#endif
6 changes: 3 additions & 3 deletions libraries/protocol/include/hive/protocol/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ using namespace hive::protocol::testnet_blockchain_configuration;
#ifdef IS_TEST_NET

#ifdef HIVE_ENABLE_SMT
#define HIVE_BLOCKCHAIN_VERSION ( version(1, 27, 0) )
#define HIVE_BLOCKCHAIN_VERSION ( version(1, 28, 0) )
#else
#define HIVE_BLOCKCHAIN_VERSION ( version(1, 26, 0) )
#define HIVE_BLOCKCHAIN_VERSION ( version(1, 27, 0) )
#endif

#define OLD_CHAIN_ID (fc::sha256::hash("testnet"))
Expand Down Expand Up @@ -89,7 +89,7 @@ using namespace hive::protocol::testnet_blockchain_configuration;
/// LIVE HIVE NETWORK (MainNet) ///
///////////////////////////////////////////////////////////////////////////////////////////////////

#define HIVE_BLOCKCHAIN_VERSION ( version(1, 26, 0) )
#define HIVE_BLOCKCHAIN_VERSION ( version(1, 27, 0) )

#ifndef HIVE_INIT_PUBLIC_KEY_STR
# define HIVE_INIT_PUBLIC_KEY_STR "STM8GC13uCZbP44HzMLV6zPZGwVQ8Nt4Kji8PapsPiNq1BK153XTX"
Expand Down
3 changes: 2 additions & 1 deletion libraries/protocol/include/hive/protocol/hardfork_block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
#define HIVE_HARDFORK_0_23_BLOCK 41818752
#define HIVE_HARDFORK_1_24_BLOCK 47797680
#define HIVE_HARDFORK_1_25_BLOCK 55235767
#define HIVE_HARDFORK_1_26_BLOCK 100000000
#define HIVE_HARDFORK_1_26_BLOCK 68676505
#define HIVE_HARDFORK_1_27_BLOCK 100000000
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import pytest

pytest.register_assert_rewrite("tests.api_tests.message_format_tests.cli_wallet_tests.output_formatter_tests.local_tools")
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import test_tools as tt

from local_tools import create_account_and_fund_it


def prepare_block_log_with_transactions():
node = tt.InitNode()
Expand All @@ -22,7 +20,7 @@ def prepare_block_log_with_transactions():


def prepare_transactions(wallet) -> None:
create_account_and_fund_it(wallet, 'alice', tests=tt.Asset.Test(100), vests=tt.Asset.Test(100))
wallet.create_account('alice', hives=tt.Asset.Test(100), vests=tt.Asset.Test(100))

wallet.api.post_comment('alice', 'test-permlink', '', 'someone0', 'test-title', 'this is a body', '{}')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import test_tools as tt

from .local_tools import are_close, create_buy_order, create_sell_order, verify_json_patterns, verify_text_patterns
from .....local_tools import create_account_and_fund_it


def test_get_order_book_json_format(node, wallet_with_json_formatter):
Expand Down Expand Up @@ -90,8 +89,8 @@ def parse_total_bids_and_asks(line_with_bids_summary: str, line_with_asks_summar

def prepare_accounts_and_orders(wallet):
for account in ['alice', 'bob', 'carol', 'dan']:
create_account_and_fund_it(wallet, account, tests=tt.Asset.Test(1000000),
tbds=tt.Asset.Tbd(1000000), vests=tt.Asset.Test(1000000))
wallet.create_account(account, hives=tt.Asset.Test(1000000), hbds=tt.Asset.Tbd(1000000),
vests=tt.Asset.Test(1000000))

with wallet.in_single_transaction():
buy_order0 = create_buy_order(wallet, 'alice', tt.Asset.Test(100), tt.Asset.Tbd(20), 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,63 @@
import test_tools as tt

from .local_tools import verify_json_patterns, verify_text_patterns
from .....local_tools import create_account_and_fund_it

BALANCES = {
'alice': {
'tests': tt.Asset.Test(100),
'hives': tt.Asset.Test(100),
'vests': tt.Asset.Test(110),
'tbds': tt.Asset.Tbd(120),
'hbds': tt.Asset.Tbd(120),
},
'bob': {
'tests': tt.Asset.Test(200),
'hives': tt.Asset.Test(200),
'vests': tt.Asset.Test(210),
'tbds': tt.Asset.Tbd(220),
'hbds': tt.Asset.Tbd(220),
},
'carol': {
'tests': tt.Asset.Test(300),
'hives': tt.Asset.Test(300),
'vests': tt.Asset.Test(310),
'tbds': tt.Asset.Tbd(320),
'hbds': tt.Asset.Tbd(320),
}
}

TOTAL_BALANCES = {
'tests': sum((balance['tests'] for balance in BALANCES.values()), start=tt.Asset.Test(0)),
'tbds': sum((balance['tbds'] for balance in BALANCES.values()), start=tt.Asset.Tbd(0))
'hives': sum((balance['hives'] for balance in BALANCES.values()), start=tt.Asset.Test(0)),
'hbds': sum((balance['hbds'] for balance in BALANCES.values()), start=tt.Asset.Tbd(0))
}


def test_list_my_accounts_json_format(wallet_with_json_formatter):
for name, balances in BALANCES.items():
create_account_and_fund_it(wallet_with_json_formatter, name=name, **balances)
wallet_with_json_formatter.create_account(name=name, **balances)

accounts_summary = wallet_with_json_formatter.api.list_my_accounts()
for name, balances, returned_account in zip(BALANCES.keys(), BALANCES.values(), accounts_summary['accounts']):
assert returned_account['name'] == name
assert returned_account['balance'] == balances['tests'].as_nai()
assert returned_account['hbd_balance'] == balances['tbds'].as_nai()
assert returned_account['balance'] == balances['hives'].as_nai()
assert returned_account['hbd_balance'] == balances['hbds'].as_nai()

assert accounts_summary['total_hive'] == TOTAL_BALANCES['tests'].as_nai()
assert accounts_summary['total_hbd'] == TOTAL_BALANCES['tbds'].as_nai()
assert accounts_summary['total_hive'] == TOTAL_BALANCES['hives'].as_nai()
assert accounts_summary['total_hbd'] == TOTAL_BALANCES['hbds'].as_nai()


def test_list_my_accounts_text_format(wallet_with_text_formatter):
for name, balances in BALANCES.items():
create_account_and_fund_it(wallet_with_text_formatter, name=name, **balances)
wallet_with_text_formatter.create_account(name=name, **balances)

accounts_summary = parse_text_response(wallet_with_text_formatter.api.list_my_accounts())

for name, balances, returned_account in zip(BALANCES.keys(), BALANCES.values(), accounts_summary['accounts']):
assert returned_account['name'] == name
assert returned_account['balance'] == balances['tests']
assert returned_account['hbd_balance'] == balances['tbds']
assert returned_account['balance'] == balances['hives']
assert returned_account['hbd_balance'] == balances['hbds']

assert accounts_summary['total_hive'] == TOTAL_BALANCES['tests']
assert accounts_summary['total_hbd'] == TOTAL_BALANCES['tbds']
assert accounts_summary['total_hive'] == TOTAL_BALANCES['hives']
assert accounts_summary['total_hbd'] == TOTAL_BALANCES['hbds']


def test_list_my_accounts_json_format_pattern_comparison(wallet_with_json_formatter):
for name, balances in BALANCES.items():
create_account_and_fund_it(wallet_with_json_formatter, name=name, **balances)
wallet_with_json_formatter.create_account(name=name, **balances)

accounts_summary = wallet_with_json_formatter.api.list_my_accounts()

Expand All @@ -70,7 +69,7 @@ def test_list_my_accounts_json_format_pattern_comparison(wallet_with_json_format

def test_list_my_accounts_text_format_pattern_comparison(wallet_with_text_formatter):
for name, balances in BALANCES.items():
create_account_and_fund_it(wallet_with_text_formatter, name=name, **balances)
wallet_with_text_formatter.create_account(name=name, **balances)

accounts_summary = wallet_with_text_formatter.api.list_my_accounts()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import test_tools as tt

from ..local_tools import create_account_and_fund_it, run_for
from ..local_tools import run_for


@run_for('testnet', 'mainnet_5m', 'mainnet_64m')
def test_get_account_history(prepared_node, should_prepare):
if should_prepare:
wallet = tt.Wallet(attach_to=prepared_node)
create_account_and_fund_it(wallet, 'alice', tbds=tt.Asset.Tbd(100), vests=tt.Asset.Test(100))
wallet.create_account('alice', hbds=tt.Asset.Tbd(100), vests=tt.Asset.Test(100))

# Wait until block containing above transaction will become irreversible.
prepared_node.wait_number_of_blocks(21)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import test_tools as tt

from ..local_tools import create_account_and_fund_it, run_for
from ..local_tools import run_for


@run_for('testnet', 'mainnet_5m', 'mainnet_64m')
def test_get_active_votes(prepared_node, should_prepare):
if should_prepare:
wallet = tt.Wallet(attach_to=prepared_node)
create_account_and_fund_it(wallet, 'acidyo', tests=tt.Asset.Test(100), vests=tt.Asset.Test(100))
wallet.create_account('acidyo', hives=tt.Asset.Test(100), vests=tt.Asset.Test(100))
wallet.api.post_comment('acidyo', 'drew-an-avatar-signature-for-my-posts', '', 'test-parent-permlink', 'test-title', 'test-body', '{}')
wallet.api.vote('initminer', 'acidyo', 'drew-an-avatar-signature-for-my-posts', 100, broadcast=True)
prepared_node.api.condenser.get_active_votes('acidyo', 'drew-an-avatar-signature-for-my-posts')
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import test_tools as tt

from ..local_tools import create_account_and_fund_it, run_for
from ..local_tools import run_for


@run_for('testnet', 'mainnet_5m', 'mainnet_64m')
def test_get_conversion_request(prepared_node, should_prepare):
if should_prepare:
wallet = tt.Wallet(attach_to=prepared_node)
create_account_and_fund_it(wallet, 'seanmclellan', tbds=tt.Asset.Tbd(100), vests=tt.Asset.Test(100))
wallet.create_account('seanmclellan', hbds=tt.Asset.Tbd(100), vests=tt.Asset.Test(100))
wallet.api.convert_hbd('seanmclellan', tt.Asset.Tbd(10))
prepared_node.api.condenser.get_conversion_requests('seanmclellan')
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import test_tools as tt

from ..local_tools import create_account_and_fund_it, create_and_cancel_vesting_delegation, date_from_now, run_for
from ..local_tools import create_and_cancel_vesting_delegation, date_from_now, run_for


@run_for('testnet', 'mainnet_5m', 'mainnet_64m')
def test_get_expiring_vesting_delegations(prepared_node, should_prepare):
if should_prepare:
wallet = tt.Wallet(attach_to=prepared_node)

create_account_and_fund_it(wallet, 'alice', tests=tt.Asset.Test(100), vests=tt.Asset.Test(100))
wallet.create_account('alice', hives=tt.Asset.Test(100), vests=tt.Asset.Test(100))
wallet.api.create_account('initminer', 'bob', '{}')
create_and_cancel_vesting_delegation(wallet, 'alice', 'bob')
prepared_node.api.condenser.get_expiring_vesting_delegations('alice', date_from_now(weeks=0))
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import test_tools as tt

from ..local_tools import create_account_and_fund_it, date_from_now, run_for
from ..local_tools import date_from_now, run_for


@run_for('testnet', 'mainnet_5m', 'mainnet_64m')
def test_get_market_history(prepared_node, should_prepare):
if should_prepare:
wallet = tt.Wallet(attach_to=prepared_node)
create_account_and_fund_it(wallet, 'alice', tests=tt.Asset.Test(100), vests=tt.Asset.Test(100))
wallet.create_account('alice', hives=tt.Asset.Test(100), vests=tt.Asset.Test(100))
wallet.api.create_order('alice', 0, tt.Asset.Test(50), tt.Asset.Tbd(5), False, 3600)
wallet.api.create_order('initminer', 1, tt.Asset.Tbd(50), tt.Asset.Test(100), False, 3600)
prepared_node.api.condenser.get_market_history(3600, date_from_now(weeks=-100), date_from_now(weeks=1))
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import test_tools as tt

from ..local_tools import create_account_and_fund_it, run_for
from ..local_tools import run_for


@run_for('testnet', 'mainnet_5m', 'mainnet_64m')
def test_get_open_orders(prepared_node, should_prepare):
if should_prepare:
wallet = tt.Wallet(attach_to=prepared_node)
create_account_and_fund_it(wallet, 'abit', tests=tt.Asset.Test(100), vests=tt.Asset.Test(100))
wallet.create_account('abit', hives=tt.Asset.Test(100), vests=tt.Asset.Test(100))
wallet.api.create_order('abit', 0, tt.Asset.Test(50), tt.Asset.Tbd(5), False, 3600)
prepared_node.api.condenser.get_open_orders('abit')
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import test_tools as tt

from ..local_tools import create_account_and_fund_it, run_for
from ..local_tools import run_for


@run_for('testnet', 'mainnet_5m', 'mainnet_64m')
def test_get_order_book(prepared_node, should_prepare):
if should_prepare:
wallet = tt.Wallet(attach_to=prepared_node)
create_account_and_fund_it(wallet, 'alice', tests=tt.Asset.Test(100), vests=tt.Asset.Test(100))
create_account_and_fund_it(wallet, 'bob', tests=tt.Asset.Test(100), vests=tt.Asset.Test(100),
tbds=tt.Asset.Tbd(100))
wallet.create_account('alice', hives=tt.Asset.Test(100), vests=tt.Asset.Test(100))
wallet.create_account('bob', hives=tt.Asset.Test(100), vests=tt.Asset.Test(100),
hbds=tt.Asset.Tbd(100))

wallet.api.create_order('alice', 1, tt.Asset.Test(100), tt.Asset.Tbd(50), False, 3600)
wallet.api.create_order('bob', 2, tt.Asset.Tbd(20), tt.Asset.Test(100), False, 3600)
Expand Down
Loading

0 comments on commit b322c4c

Please sign in to comment.