Added a max transaction size check, next hardfork timing
This commit is contained in:
parent
4d426e1f5a
commit
5f4a1b88a5
5 changed files with 40 additions and 0 deletions
|
|
@ -691,6 +691,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.
|
||||
|
|
|
|||
4
libraries/chain/hardfork.d/1002.hf
Normal file
4
libraries/chain/hardfork.d/1002.hf
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
// added transaction size check
|
||||
#ifndef HARDFORK_1002_TIME
|
||||
#define HARDFORK_1002_TIME (fc::time_point_sec( 1566797400 )) //Monday, 26 August 2019 05:30:00 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();
|
||||
|
|
|
|||
|
|
@ -412,4 +412,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