Compare commits
5 commits
master
...
GRPH-64-Va
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39a6c895b9 | ||
|
|
ee14f4db96 | ||
|
|
a40fa4f545 | ||
|
|
436dfc3da6 | ||
|
|
5f4a1b88a5 |
6 changed files with 66 additions and 1 deletions
|
|
@ -286,6 +286,8 @@ bool database::_push_block(const signed_block& new_block)
|
|||
*/
|
||||
processed_transaction database::push_transaction( const signed_transaction& trx, uint32_t skip )
|
||||
{ try {
|
||||
// see https://github.com/bitshares/bitshares-core/issues/1573
|
||||
FC_ASSERT( fc::raw::pack_size( trx ) < (1024 * 1024), "Transaction exceeds maximum transaction size." );
|
||||
processed_transaction result;
|
||||
detail::with_skip_flags( *this, skip, [&]()
|
||||
{
|
||||
|
|
@ -691,6 +693,10 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
|
|||
FC_ASSERT( trx.expiration <= now + chain_parameters.maximum_time_until_expiration, "",
|
||||
("trx.expiration",trx.expiration)("now",now)("max_til_exp",chain_parameters.maximum_time_until_expiration));
|
||||
FC_ASSERT( now <= trx.expiration, "", ("now",now)("trx.exp",trx.expiration) );
|
||||
if ( !(skip & skip_block_size_check ) ) // don't waste time on replay
|
||||
FC_ASSERT( head_block_time() <= HARDFORK_1002_TIME
|
||||
|| trx.get_packed_size() <= chain_parameters.maximum_transaction_size,
|
||||
"Transaction exceeds maximum transaction size." );
|
||||
}
|
||||
|
||||
//Insert transaction into unique transactions database.
|
||||
|
|
|
|||
|
|
@ -253,7 +253,13 @@ void database::update_active_witnesses()
|
|||
void database::update_active_committee_members()
|
||||
{ try {
|
||||
assert( _committee_count_histogram_buffer.size() > 0 );
|
||||
share_type stake_target = (_total_voting_stake-_witness_count_histogram_buffer[0]) / 2;
|
||||
share_type stake_target = (_total_voting_stake-_committee_count_histogram_buffer[0]) / 2;
|
||||
share_type old_stake_target = (_total_voting_stake-_witness_count_histogram_buffer[0]) / 2;
|
||||
// TODO
|
||||
// all the stuff about old_stake_target can *hopefully* be removed after the
|
||||
// hardfork date has passed
|
||||
if( stake_target != old_stake_target )
|
||||
ilog( "Different stake targets: ${old} / ${new}", ("old",old_stake_target)("new",stake_target) );
|
||||
|
||||
/// accounts that vote for 0 or 1 witness do not get to express an opinion on
|
||||
/// the number of witnesses to have (they abstain and are non-voting accounts)
|
||||
|
|
@ -264,6 +270,20 @@ void database::update_active_committee_members()
|
|||
&& (stake_tally <= stake_target) )
|
||||
stake_tally += _committee_count_histogram_buffer[++committee_member_count];
|
||||
|
||||
if( stake_target != old_stake_target && old_stake_target > 0 && head_block_time() < fc::time_point_sec(HARDFORK_1002_TIME) )
|
||||
{
|
||||
uint64_t old_stake_tally = 0;
|
||||
size_t old_committee_member_count = 0;
|
||||
while( (old_committee_member_count < _committee_count_histogram_buffer.size() - 1)
|
||||
&& (old_stake_tally <= old_stake_target) )
|
||||
old_stake_tally += _committee_count_histogram_buffer[++old_committee_member_count];
|
||||
if( old_committee_member_count != committee_member_count )
|
||||
{
|
||||
ilog( "Committee member count mismatch ${old} / ${new}", ("old",old_committee_member_count)("new", committee_member_count) );
|
||||
committee_member_count = old_committee_member_count;
|
||||
}
|
||||
}
|
||||
|
||||
const chain_property_object& cpo = get_chain_properties();
|
||||
auto committee_members = sort_votable_objects<committee_member_index>(std::max(committee_member_count*2+1, (size_t)cpo.immutable_parameters.min_committee_member_count));
|
||||
|
||||
|
|
|
|||
5
libraries/chain/hardfork.d/1002.hf
Normal file
5
libraries/chain/hardfork.d/1002.hf
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// added transaction size check
|
||||
// Bug fix of update commitee member update
|
||||
#ifndef HARDFORK_1002_TIME
|
||||
#define HARDFORK_1002_TIME (fc::time_point_sec( 1566893013 )) //Tuesday, 27 August 2019 08:03:33 GMT
|
||||
#endif
|
||||
|
|
@ -113,6 +113,8 @@ namespace graphene { namespace chain {
|
|||
}
|
||||
|
||||
void get_required_authorities( flat_set<account_id_type>& active, flat_set<account_id_type>& owner, vector<authority>& other )const;
|
||||
|
||||
virtual uint64_t get_packed_size()const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ void transaction::validate() const
|
|||
operation_validate(op);
|
||||
}
|
||||
|
||||
uint64_t transaction::get_packed_size() const
|
||||
{
|
||||
return fc::raw::pack_size(*this);
|
||||
}
|
||||
|
||||
graphene::chain::transaction_id_type graphene::chain::transaction::id() const
|
||||
{
|
||||
auto h = digest();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
#include <graphene/chain/witness_object.hpp>
|
||||
#include <graphene/chain/protocol/committee_member.hpp>
|
||||
#include <fc/crypto/digest.hpp>
|
||||
#include <graphene/app/database_api.hpp>
|
||||
#include <graphene/app/api.hpp>
|
||||
|
||||
#include "../common/database_fixture.hpp"
|
||||
|
||||
|
|
@ -412,4 +414,29 @@ BOOST_AUTO_TEST_CASE( check_passes_for_duplicated_betting_market_or_group )
|
|||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( broadcast_transaction_too_large ) {
|
||||
try {
|
||||
|
||||
fc::ecc::private_key cid_key = fc::ecc::private_key::regenerate( fc::digest("key") );
|
||||
const account_id_type cid_id = create_account( "cid", cid_key.get_public_key() ).id;
|
||||
fund( cid_id(db) );
|
||||
|
||||
auto nb_api = std::make_shared< graphene::app::network_broadcast_api >( app );
|
||||
|
||||
generate_blocks( HARDFORK_1002_TIME + 10 );
|
||||
|
||||
set_expiration( db, trx );
|
||||
transfer_operation trans;
|
||||
trans.from = cid_id;
|
||||
trans.to = account_id_type();
|
||||
trans.amount = asset(1);
|
||||
for(int i = 0; i < 250; ++i )
|
||||
trx.operations.push_back( trans );
|
||||
sign( trx, cid_key );
|
||||
|
||||
BOOST_CHECK_THROW( nb_api->broadcast_transaction( trx ), fc::exception );
|
||||
|
||||
} FC_LOG_AND_RETHROW()
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
|
|||
Loading…
Reference in a new issue