diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index a2e16adb40..a6aec7c88e 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -2733,7 +2733,7 @@ void database::apply_block( const signed_block& next_block, uint32_t skip ) | skip_block_size_check | skip_tapos_check | skip_authority_check - | skip_merkle_check + /* | skip_merkle_check While blockchain is being downloaded, txs need to be validated against block headers */ | skip_undo_history_check | skip_witness_schedule_check | skip_validate diff --git a/libraries/chain/include/steemit/chain/config.hpp b/libraries/chain/include/steemit/chain/config.hpp index 20ee7ac543..53d9a91bce 100644 --- a/libraries/chain/include/steemit/chain/config.hpp +++ b/libraries/chain/include/steemit/chain/config.hpp @@ -3,7 +3,7 @@ */ #pragma once -#define STEEMIT_BLOCKCHAIN_VERSION ( version(0, 14, 2) ) +#define STEEMIT_BLOCKCHAIN_VERSION ( version(0, 14, 3) ) #define STEEMIT_BLOCKCHAIN_HARDFORK_VERSION ( hardfork_version( STEEMIT_BLOCKCHAIN_VERSION ) ) #ifdef IS_TEST_NET diff --git a/libraries/chain/steem_evaluator.cpp b/libraries/chain/steem_evaluator.cpp index 9eef5944f6..6dd95162a1 100644 --- a/libraries/chain/steem_evaluator.cpp +++ b/libraries/chain/steem_evaluator.cpp @@ -149,6 +149,9 @@ void account_update_evaluator::do_apply( const account_update_operation& o ) { if( db().has_hardfork( STEEMIT_HARDFORK_0_1 ) ) FC_ASSERT( o.account != STEEMIT_TEMP_ACCOUNT, "cannot update temp account" ); + if( db().is_producing() && o.posting ) // TODO: Add HF 15 + o.posting->validate(); + const auto& account = db().get_account( o.account ); if( o.owner ) @@ -158,9 +161,34 @@ void account_update_evaluator::do_apply( const account_update_operation& o ) FC_ASSERT( db().head_block_time() - account.last_owner_update > STEEMIT_OWNER_UPDATE_LIMIT, "can only update owner authority once a minute" ); #endif + if( db().is_producing() ) // TODO: Add HF 15 + { + for( auto a: o.owner->account_auths ) + { + db().get_account( a.first ); + } + } + + db().update_owner_authority( account, *o.owner ); } + if( o.active && db().is_producing() ) // TODO: Add HF 15 + { + for( auto a: o.active->account_auths ) + { + db().get_account( a.first ); + } + } + + if( o.posting && db().is_producing() ) // TODO: Add HF 15 + { + for( auto a: o.posting->account_auths ) + { + db().get_account( a.first ); + } + } + db().modify( account, [&]( account_object& acc ) { if( o.active ) acc.active = *o.active; diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index dacb79197e..3596e88c87 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -177,6 +177,28 @@ BOOST_AUTO_TEST_CASE( account_update_validate ) { BOOST_TEST_MESSAGE( "Testing: account_update_validate" ); + ACTORS( (alice) ) + + account_update_operation op; + op.account = "alice"; + op.posting = authority(); + op.posting->weight_threshold = 1; + op.posting->add_authorities( "abcdefghijklmnopq", 1 ); + + try + { + op.validate(); + + signed_transaction tx; + tx.set_expiration( db.head_block_time() + STEEMIT_MAX_TIME_UNTIL_EXPIRATION ); + tx.operations.push_back( op ); + tx.sign( alice_private_key, db.get_chain_id() ); + db.push_transaction( tx, 0 ); + + BOOST_FAIL( "An exception was not thrown for an invalid account name" ); + } + catch( fc::assert_exception& ) {} + validate_database(); } FC_LOG_AND_RETHROW() @@ -314,6 +336,19 @@ BOOST_AUTO_TEST_CASE( account_update_apply ) tx.sign( new_private_key, db.get_chain_id() ); STEEMIT_REQUIRE_THROW( db.push_transaction( tx, 0 ), fc::assert_exception ) validate_database(); + + + BOOST_TEST_MESSAGE( "--- Test failure when account authority does not exist" ); + tx.clear(); + op = account_update_operation(); + op.account = "alice"; + op.posting = authority(); + op.posting->weight_threshold = 1; + op.posting->add_authorities( "dave", 1 ); + tx.operations.push_back( op ); + tx.sign( new_private_key, db.get_chain_id() ); + STEEMIT_REQUIRE_THROW( db.push_transaction( tx, 0 ), fc::assert_exception ); + validate_database(); } FC_LOG_AND_RETHROW() } @@ -781,7 +816,6 @@ BOOST_AUTO_TEST_CASE( vote_apply ) new_cashout_time = db.head_block_time().sec_since_epoch() + STEEMIT_CASHOUT_WINDOW_SECONDS; int64_t regenerated_power = (STEEMIT_100_PERCENT * ( db.head_block_time() - db.get_account( "alice").last_vote_time ).to_seconds() ) / STEEMIT_VOTE_REGENERATION_SECONDS; int64_t used_power = ( db.get_account( "alice" ).voting_power + regenerated_power + max_vote_denom - 1 ) / max_vote_denom; - idump( (db.get_account( "alice" ).voting_power)(used_power) ); comment_op.author = "sam"; comment_op.permlink = "foo"; @@ -3555,6 +3589,8 @@ BOOST_AUTO_TEST_CASE( pow2_op ) ACTORS( (bob) ) + target = db.get_pow_summary_target(); + do { nonce++;