From 1a8474744cb7d53c40fab4d89b163e23ec743c2b Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Fri, 15 Aug 2014 13:52:07 -0400 Subject: [PATCH] Block & transaction size limit changes and price feed operations only take effect after hardfork --- libraries/blockchain/chain_database.cpp | 11 +++++++++- .../transaction_evaluation_state.cpp | 20 +++++++++++-------- libraries/wallet/wallet.cpp | 5 +++++ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/libraries/blockchain/chain_database.cpp b/libraries/blockchain/chain_database.cpp index d18bc6367..65d8a654d 100644 --- a/libraries/blockchain/chain_database.cpp +++ b/libraries/blockchain/chain_database.cpp @@ -1645,7 +1645,16 @@ namespace bts { namespace blockchain { for( const auto& item : pending_trx ) { auto trx_size = item->trx.data_size(); - if( block_size + trx_size > BTS_BLOCKCHAIN_MAX_BLOCK_SIZE ) break; + if( get_head_block_num() + 1 < BTS_BLOCKCHAIN_FORK_MARKET_BLOCK_NUM ) + { + if( block_size + trx_size > 2560 ) + break; + } + else + { + if( block_size + trx_size > BTS_BLOCKCHAIN_MAX_BLOCK_SIZE ) + break; + } block_size += trx_size; /* Make modifications to temporary state */ diff --git a/libraries/blockchain/transaction_evaluation_state.cpp b/libraries/blockchain/transaction_evaluation_state.cpp index 139fbe1ec..dbe3c48f4 100644 --- a/libraries/blockchain/transaction_evaluation_state.cpp +++ b/libraries/blockchain/transaction_evaluation_state.cpp @@ -2,6 +2,8 @@ #include #include +#include + namespace bts { namespace blockchain { transaction_evaluation_state::transaction_evaluation_state( const chain_interface_ptr& current_state, digest_type chain_id ) @@ -88,11 +90,11 @@ namespace bts { namespace blockchain { void transaction_evaluation_state::post_evaluate() { try { // NOTE: this line was removed in favor of trusting delegates to set the required fees rather - // than charging per byte. This allows the network to scale without hard fork. + // than charging per byte. This allows the network to scale without hard fork. // // By removing this check I am reducing restrictions so the current blockchain should still validate - // - // required_fees += asset(_current_state->calculate_data_fee(fc::raw::pack_size(trx)),0); + if( _current_state->get_head_block_num() < BTS_BLOCKCHAIN_FORK_MARKET_BLOCK_NUM ) + required_fees += asset( _current_state->calculate_data_fee( fc::raw::pack_size( trx ) ), 0 ); // Should this be here? We may not have fees in XTS now... balance[0]; // make sure we have something for this. @@ -160,11 +162,13 @@ namespace bts { namespace blockchain { * * Note: this is to give delegates maximum flexibility without having to * introduce hard forks to support larger transaction sizes. - * - auto trx_size = fc::raw::pack_size(trx_arg); - if( trx_size > BTS_BLOCKCHAIN_MAX_TRANSACTION_SIZE ) - FC_CAPTURE_AND_THROW( oversized_transaction, (trx_size ) ); - */ + */ + if( _current_state->get_head_block_num() < BTS_BLOCKCHAIN_FORK_MARKET_BLOCK_NUM ) + { + auto trx_size = fc::raw::pack_size( trx_arg ); + if( trx_size > 1280 ) + FC_CAPTURE_AND_THROW( oversized_transaction, (trx_size ) ); + } auto trx_id = trx_arg.id(); diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 4771c5dd4..80ef5d83a 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -29,6 +29,8 @@ #include #include +#include + namespace bts { namespace wallet { FC_REGISTER_EXCEPTIONS( (wallet_exception) @@ -2727,6 +2729,9 @@ namespace bts { namespace wallet { double amount_per_xts, const string& amount_asset_symbol, bool sign ) { try { + if( my->_blockchain->get_pending_state()->get_head_block_num() < BTS_BLOCKCHAIN_FORK_MARKET_BLOCK_NUM ) + FC_THROW_EXCEPTION( invalid_operation, "Price feeds can only be published after the market hardfork!" ); + FC_ASSERT( is_open() ); FC_ASSERT( is_unlocked() );