提交 bc836de8 编写于 作者: D Daniel Larimer

it builds again

上级 a9343907
#include <eosio/chain/block_header_state.hpp>
#include <eosio/chain/exceptions.hpp>
namespace eosio { namespace chain {
......@@ -30,7 +31,7 @@ namespace eosio { namespace chain {
}
uint32_t block_header_state::blocks_per_round()const {
return active_producers.producers.size()*config::producer_repetitions;
return active_schedule.producers.size()*config::producer_repetitions;
}
......
#include <eosio/chain/block_state.hpp>
#include <eosio/chain/exceptions.hpp>
namespace eosio { namespace chain {
......@@ -6,7 +7,7 @@ namespace eosio { namespace chain {
/**
* Perform context free validation of transaction state
*/
void validate( const transaction& trx )const {
void validate_transaction( const transaction& trx ) {
EOS_ASSERT( !trx.actions.empty(), tx_no_action, "transaction must have at least one action" );
// Check for at least one authorization in the context-aware actions
......@@ -25,7 +26,7 @@ namespace eosio { namespace chain {
EOS_ASSERT( trx.max_kcpu_usage.value < UINT32_MAX / 1024UL, transaction_exception, "declared max_kcpu_usage overflows when expanded to max cpu usage" );
EOS_ASSERT( trx.max_net_usage_words.value < UINT32_MAX / 8UL, transaction_exception, "declared max_net_usage_words overflows when expanded to max net usage" );
} /// validate
} /// validate_transaction
void validate_shard_locks_unique(const vector<shard_lock>& locks, const string& tag) {
......@@ -41,7 +42,7 @@ namespace eosio { namespace chain {
}
void validate_shard_locks( const shard_summary& shard ) {
void validate_shard_locks( const shard_summary& shard, uint32_t shard_index ) {
validate_shard_locks_unique( shard.read_locks, "read" );
validate_shard_locks_unique( shard.write_locks, "write" );
......@@ -74,12 +75,12 @@ namespace eosio { namespace chain {
{
if( block ) {
for( const auto& packed : b->input_transactions ) {
auto meta_ptr = std::make_shared<transaction_metadata>( packed, chain_id_type() );
auto meta_ptr = std::make_shared<transaction_metadata>( packed, chain_id_type(), block->timestamp );
/** perform context-free validation of transactions */
const auto& trx = meta_ptr->trx();
FC_ASSERT( time_point(trx.expiration) > header.timestamp, "transaction is expired" );
validate( trx );
validate_transaction( trx );
auto id = meta_ptr->id;
input_transactions[id] = move(meta_ptr);
......@@ -90,21 +91,25 @@ namespace eosio { namespace chain {
for( uint32_t i = 1; i < block->regions.size(); ++i )
FC_ASSERT( block->regions[i-1].region < block->regions[i].region );
trace = std::make_shared<block_trace>();
bool found_trx = false;
trace = std::make_shared<block_trace>( block );
/// reserve region_trace
for( uint32_t r = 0; r < block->regions.size(); ++r ) {
FC_ASSERT( block->regions[r].cycles.size() >= 1, "must be at least one cycle" );
// FC_ASSERT( block->regions[r].cycles_summary.size() >= 1, "must be at least one cycle" );
/// reserve cycle traces
for( uint32_t c = 0; c < block->regions[r].cycles.size(); c++ ) {
FC_ASSERT( block->regions[r].cycles.size() >= 1, "must be at least one shard" );
for( uint32_t c = 0; c < block->regions[r].cycles_summary.size(); c++ ) {
// FC_ASSERT( block->regions[r].cycles_summary.size() >= 1, "must be at least one shard" );
/// reserve shard traces
for( uint32_t s = 0; s < block->regions[r].cycles[c][s].size(); s++ ) {
for( uint32_t s = 0; s < block->regions[r].cycles_summary[c][s].transactions.size(); s++ ) {
found_trx = true;
// FC_ASSERT( block->regions[r].cycles.size() >= 1, "must be at least one trx" ); ///
//validate_shard_locks( block->.... )
/// reserve transaction trace...
}
}
}
FC_ASSERT( found_trx, "a block must contain at least one transaction (the implicit on block trx)" );
} // end if block
}
......
......@@ -25,6 +25,7 @@ struct block_header_state {
bool is_active_producer( account_name n )const;
producer_key scheduled_producer( block_timestamp_type t )const;
bool is_start_of_round( uint32_t block_num )const;
uint32_t blocks_per_round()const;
};
......
#pragma once
#include <eosio/chain/block_header_state.hpp>
#include <eosio/chain/block.hpp>
#include <eosio/chain/transaction_metadata.hpp>
#include <eosio/chain/block_trace.hpp>
namespace eosio { namespace chain {
......
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#pragma once
#include <eosio/chain/block.hpp>
#include <eosio/chain/transaction_trace.hpp>
namespace eosio { namespace chain {
struct shard_trace {
digest_type shard_action_root;
digest_type shard_transaction_root;
vector<transaction_trace> transaction_traces;
uint64_t cpu_usage;
flat_set<shard_lock> read_locks;
flat_set<shard_lock> write_locks;
void append( transaction_trace&& res ) {
transaction_traces.emplace_back(move(res));
}
void append( const transaction_trace& res ) {
transaction_traces.emplace_back(res);
}
void finalize_shard();
};
struct cycle_trace {
vector<shard_trace> shard_traces;
};
struct region_trace {
vector<cycle_trace> cycle_traces;
};
struct block_trace {
explicit block_trace(const signed_block_ptr& s)
:block(*s),block_ptr(s)
{}
/// TODO: refactor all useage of block to just reference block_ptr (rename block_ptr to block)
const signed_block& block;
vector<region_trace> region_traces;
vector<transaction> implicit_transactions;
digest_type calculate_action_merkle_root()const;
digest_type calculate_transaction_merkle_root()const;
uint64_t calculate_cpu_usage() const;
signed_block_ptr block_ptr;
};
typedef std::shared_ptr<block_trace> block_trace_ptr;
} } // eosio::chain
FC_REFLECT( eosio::chain::shard_trace, (shard_action_root)(shard_transaction_root)(transaction_traces)(cpu_usage)(read_locks)(write_locks))
FC_REFLECT( eosio::chain::cycle_trace, (shard_traces))
FC_REFLECT( eosio::chain::region_trace, (cycle_traces))
FC_REFLECT( eosio::chain::block_trace, (region_traces))
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#pragma once
#include <fc/exception/exception.hpp>
#include <eosio/chain/protocol.hpp>
#include <eosio/utilities/exception_macros.hpp>
namespace eosio { namespace chain {
FC_DECLARE_EXCEPTION( chain_exception, 3000000, "blockchain exception" )
FC_DECLARE_DERIVED_EXCEPTION( database_query_exception, eosio::chain::chain_exception, 3010000, "database query exception" )
FC_DECLARE_DERIVED_EXCEPTION( block_validate_exception, eosio::chain::chain_exception, 3020000, "block validation exception" )
FC_DECLARE_DERIVED_EXCEPTION( transaction_exception, eosio::chain::chain_exception, 3030000, "transaction validation exception" )
FC_DECLARE_DERIVED_EXCEPTION( action_validate_exception, eosio::chain::chain_exception, 3040000, "message validation exception" )
FC_DECLARE_DERIVED_EXCEPTION( utility_exception, eosio::chain::chain_exception, 3070000, "utility method exception" )
FC_DECLARE_DERIVED_EXCEPTION( undo_database_exception, eosio::chain::chain_exception, 3080000, "undo database exception" )
FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, eosio::chain::chain_exception, 3090000, "unlinkable block" )
FC_DECLARE_DERIVED_EXCEPTION( black_swan_exception, eosio::chain::chain_exception, 3100000, "black swan" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_block_exception, eosio::chain::chain_exception, 3110000, "unknown block" )
FC_DECLARE_DERIVED_EXCEPTION( chain_type_exception, eosio::chain::chain_exception, 3120000, "chain type exception" )
FC_DECLARE_DERIVED_EXCEPTION( missing_plugin_exception, eosio::chain::chain_exception, 3130000, "missing plugin exception" )
FC_DECLARE_DERIVED_EXCEPTION( wallet_exception, eosio::chain::chain_exception, 3140000, "wallet exception" )
FC_DECLARE_DERIVED_EXCEPTION( rate_limiting_invariant_exception, eosio::chain::chain_exception, 3150000, "rate limiting invariant violated" )
FC_DECLARE_DERIVED_EXCEPTION( permission_query_exception, eosio::chain::database_query_exception, 3010001, "Permission Query Exception" )
FC_DECLARE_DERIVED_EXCEPTION( account_query_exception, eosio::chain::database_query_exception, 3010002, "Account Query Exception" )
FC_DECLARE_DERIVED_EXCEPTION( contract_table_query_exception, eosio::chain::database_query_exception, 3010003, "Contract Table Query Exception" )
FC_DECLARE_DERIVED_EXCEPTION( contract_query_exception, eosio::chain::database_query_exception, 3010004, "Contract Query Exception" )
FC_DECLARE_DERIVED_EXCEPTION( block_tx_output_exception, eosio::chain::block_validate_exception, 3020001, "transaction outputs in block do not match transaction outputs from applying block" )
FC_DECLARE_DERIVED_EXCEPTION( block_concurrency_exception, eosio::chain::block_validate_exception, 3020002, "block does not guarantee concurrent exection without conflicts" )
FC_DECLARE_DERIVED_EXCEPTION( block_lock_exception, eosio::chain::block_validate_exception, 3020003, "shard locks in block are incorrect or mal-formed" )
FC_DECLARE_DERIVED_EXCEPTION( block_resource_exhausted, eosio::chain::block_validate_exception, 3020004, "block exhausted allowed resources" )
FC_DECLARE_DERIVED_EXCEPTION( tx_missing_auth, eosio::chain::transaction_exception, 3030001, "missing required authority" )
FC_DECLARE_DERIVED_EXCEPTION( tx_missing_sigs, eosio::chain::transaction_exception, 3030002, "signatures do not satisfy declared authorizations" )
FC_DECLARE_DERIVED_EXCEPTION( tx_irrelevant_auth, eosio::chain::transaction_exception, 3030003, "irrelevant authority included" )
FC_DECLARE_DERIVED_EXCEPTION( tx_irrelevant_sig, eosio::chain::transaction_exception, 3030004, "irrelevant signature included" )
FC_DECLARE_DERIVED_EXCEPTION( tx_duplicate_sig, eosio::chain::transaction_exception, 3030005, "duplicate signature included" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_approval, eosio::chain::transaction_exception, 3030006, "committee account cannot directly approve transaction" )
FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, eosio::chain::transaction_exception, 3030007, "insufficient fee" )
FC_DECLARE_DERIVED_EXCEPTION( tx_missing_recipient, eosio::chain::transaction_exception, 3030009, "missing required recipient" )
FC_DECLARE_DERIVED_EXCEPTION( checktime_exceeded, eosio::chain::transaction_exception, 3030010, "allotted processing time was exceeded" )
FC_DECLARE_DERIVED_EXCEPTION( tx_duplicate, eosio::chain::transaction_exception, 3030011, "duplicate transaction" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_transaction_exception, eosio::chain::transaction_exception, 3030012, "unknown transaction" )
FC_DECLARE_DERIVED_EXCEPTION( tx_scheduling_exception, eosio::chain::transaction_exception, 3030013, "transaction failed during sheduling" )
FC_DECLARE_DERIVED_EXCEPTION( tx_unknown_argument, eosio::chain::transaction_exception, 3030014, "transaction provided an unknown value to a system call" )
FC_DECLARE_DERIVED_EXCEPTION( tx_resource_exhausted, eosio::chain::transaction_exception, 3030015, "transaction exhausted allowed resources" )
FC_DECLARE_DERIVED_EXCEPTION( page_memory_error, eosio::chain::transaction_exception, 3030016, "error in WASM page memory" )
FC_DECLARE_DERIVED_EXCEPTION( unsatisfied_permission, eosio::chain::transaction_exception, 3030017, "Unsatisfied permission" )
FC_DECLARE_DERIVED_EXCEPTION( tx_msgs_auth_exceeded, eosio::chain::transaction_exception, 3030018, "Number of transaction messages per authorized account has been exceeded" )
FC_DECLARE_DERIVED_EXCEPTION( tx_msgs_code_exceeded, eosio::chain::transaction_exception, 3030019, "Number of transaction messages per code account has been exceeded" )
FC_DECLARE_DERIVED_EXCEPTION( wasm_execution_error, eosio::chain::transaction_exception, 3030020, "Runtime Error Processing WASM" )
FC_DECLARE_DERIVED_EXCEPTION( tx_decompression_error, eosio::chain::transaction_exception, 3030021, "Error decompressing transaction" )
FC_DECLARE_DERIVED_EXCEPTION( expired_tx_exception, eosio::chain::transaction_exception, 3030022, "Expired Transaction" )
FC_DECLARE_DERIVED_EXCEPTION( tx_exp_too_far_exception, eosio::chain::transaction_exception, 3030023, "Transaction Expiration Too Far" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_ref_block_exception, eosio::chain::transaction_exception, 3030024, "Invalid Reference Block" )
FC_DECLARE_DERIVED_EXCEPTION( tx_apply_exception, eosio::chain::transaction_exception, 3030025, "Transaction Apply Exception" )
FC_DECLARE_DERIVED_EXCEPTION( wasm_serialization_error, eosio::chain::transaction_exception, 3030026, "Serialization Error Processing WASM" )
FC_DECLARE_DERIVED_EXCEPTION( tx_empty_region, eosio::chain::transaction_exception, 3030027, "Transaction contains an empty region" )
FC_DECLARE_DERIVED_EXCEPTION( tx_empty_cycle, eosio::chain::transaction_exception, 3030028, "Transaction contains an empty cycle" )
FC_DECLARE_DERIVED_EXCEPTION( tx_empty_shard, eosio::chain::transaction_exception, 3030029, "Transaction contains an empty shard" )
FC_DECLARE_DERIVED_EXCEPTION( tx_receipt_inconsistent_status, eosio::chain::transaction_exception, 3030030, "Transaction receipt applied status does not match received status" )
FC_DECLARE_DERIVED_EXCEPTION( cfa_irrelevant_auth, eosio::chain::transaction_exception, 3030031, "context-free action should have no required authority" )
FC_DECLARE_DERIVED_EXCEPTION( tx_no_action, eosio::chain::transaction_exception, 3030032, "transaction should have at least one normal action" )
FC_DECLARE_DERIVED_EXCEPTION( tx_no_auths, eosio::chain::transaction_exception, 3030033, "transaction should have at least one required authority" )
FC_DECLARE_DERIVED_EXCEPTION( tx_receipt_inconsistent_cpu, eosio::chain::transaction_exception, 3030034, "Transaction receipt applied kcpu_usage does not match received kcpu_usage" )
FC_DECLARE_DERIVED_EXCEPTION( tx_receipt_inconsistent_net, eosio::chain::transaction_exception, 3030035, "Transaction receipt applied net_usage_words does not match received net_usage_words" )
FC_DECLARE_DERIVED_EXCEPTION( account_name_exists_exception, eosio::chain::action_validate_exception, 3040001, "account name already exists" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_action_args_exception, eosio::chain::action_validate_exception, 3040002, "Invalid Action Arguments" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_pts_address, eosio::chain::utility_exception, 3060001, "invalid pts address" )
FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, eosio::chain::chain_exception, 37006, "insufficient feeds" )
FC_DECLARE_DERIVED_EXCEPTION( pop_empty_chain, eosio::chain::undo_database_exception, 3070001, "there are no blocks to pop" )
FC_DECLARE_DERIVED_EXCEPTION( name_type_exception, eosio::chain::chain_type_exception, 3120001, "Invalid name" )
FC_DECLARE_DERIVED_EXCEPTION( public_key_type_exception, eosio::chain::chain_type_exception, 3120002, "Invalid public key" )
FC_DECLARE_DERIVED_EXCEPTION( private_key_type_exception, eosio::chain::chain_type_exception, 3120003, "Invalid private key" )
FC_DECLARE_DERIVED_EXCEPTION( authority_type_exception, eosio::chain::chain_type_exception, 3120004, "Invalid authority" )
FC_DECLARE_DERIVED_EXCEPTION( action_type_exception, eosio::chain::chain_type_exception, 3120005, "Invalid action" )
FC_DECLARE_DERIVED_EXCEPTION( transaction_type_exception, eosio::chain::chain_type_exception, 3120006, "Invalid transaction" )
FC_DECLARE_DERIVED_EXCEPTION( abi_type_exception, eosio::chain::chain_type_exception, 3120007, "Invalid ABI" )
FC_DECLARE_DERIVED_EXCEPTION( block_id_type_exception, eosio::chain::chain_type_exception, 3120008, "Invalid block ID" )
FC_DECLARE_DERIVED_EXCEPTION( transaction_id_type_exception, eosio::chain::chain_type_exception, 3120009, "Invalid transaction ID" )
FC_DECLARE_DERIVED_EXCEPTION( packed_transaction_type_exception, eosio::chain::chain_type_exception, 3120010, "Invalid packed transaction" )
FC_DECLARE_DERIVED_EXCEPTION( asset_type_exception, eosio::chain::chain_type_exception, 3120011, "Invalid asset" )
FC_DECLARE_DERIVED_EXCEPTION( missing_chain_api_plugin_exception, eosio::chain::missing_plugin_exception, 3130001, "Missing Chain API Plugin" )
FC_DECLARE_DERIVED_EXCEPTION( missing_wallet_api_plugin_exception, eosio::chain::missing_plugin_exception, 3130002, "Missing Wallet API Plugin" )
FC_DECLARE_DERIVED_EXCEPTION( missing_account_history_api_plugin_exception, eosio::chain::missing_plugin_exception, 3130003, "Missing Account History API Plugin" )
FC_DECLARE_DERIVED_EXCEPTION( missing_net_api_plugin_exception, eosio::chain::missing_plugin_exception, 3130004, "Missing Net API Plugin" )
FC_DECLARE_DERIVED_EXCEPTION( wallet_exist_exception, eosio::chain::wallet_exception, 3140001, "Wallet already exists" )
FC_DECLARE_DERIVED_EXCEPTION( wallet_nonexistent_exception, eosio::chain::wallet_exception, 3140002, "Nonexistent wallet" )
FC_DECLARE_DERIVED_EXCEPTION( wallet_locked_exception, eosio::chain::wallet_exception, 3140003, "Locked wallet" )
FC_DECLARE_DERIVED_EXCEPTION( wallet_missing_pub_key_exception, eosio::chain::wallet_exception, 3140004, "Missing public key" )
FC_DECLARE_DERIVED_EXCEPTION( wallet_invalid_password_exception, eosio::chain::wallet_exception, 3140005, "Invalid wallet password" )
FC_DECLARE_DERIVED_EXCEPTION( rate_limiting_state_inconsistent, eosio::chain::rate_limiting_invariant_exception, 3150001, "internal state is no longer consistent" )
FC_DECLARE_DERIVED_EXCEPTION( rate_limiting_overcommitment, eosio::chain::rate_limiting_invariant_exception, 3150002, "chain resource limits are overcommitted" )
#define EOS_RECODE_EXC( cause_type, effect_type ) \
catch( const cause_type& e ) \
{ throw( effect_type( e.what(), e.get_log() ) ); }
} } // eosio::chain
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#pragma once
#include <eosio/chain/transaction.hpp>
#include <eosio/chain/block.hpp>
namespace eosio { namespace chain {
class transaction_metadata {
public:
transaction_metadata( const transaction& t, const time_point& published, const account_name& sender, uint128_t sender_id, const char* raw_data, size_t raw_size, const optional<time_point>& processing_deadline )
:id(t.id())
,published(published)
,sender(sender),sender_id(sender_id),raw_data(raw_data),raw_size(raw_size)
,processing_deadline(processing_deadline)
,_trx(&t)
{}
transaction_metadata( const packed_transaction& t, chain_id_type chainid, const time_point& published, const optional<time_point>& processing_deadline = optional<time_point>(), bool implicit=false );
transaction_metadata( transaction_metadata && ) = default;
transaction_metadata& operator= (transaction_metadata &&) = default;
// things for packed_transaction
optional<bytes> raw_trx;
optional<transaction> decompressed_trx;
vector<bytes> context_free_data;
digest_type packed_digest;
// things for signed/packed transactions
optional<flat_set<public_key_type>> signing_keys;
transaction_id_type id;
uint32_t region_id = 0;
uint32_t cycle_index = 0;
uint32_t shard_index = 0;
uint32_t billable_packed_size = 0;
uint32_t signature_count = 0;
time_point published;
fc::microseconds delay;
// things for processing deferred transactions
optional<account_name> sender;
uint128_t sender_id = 0;
// packed form to pass to contracts if needed
const char* raw_data = nullptr;
size_t raw_size = 0;
vector<char> packed_trx;
// is this transaction implicit
bool is_implicit = false;
// scopes available to this transaction if we are applying a block
optional<const vector<shard_lock>*> allowed_read_locks;
optional<const vector<shard_lock>*> allowed_write_locks;
//// TODO: ensure _trx is always set right rather than if/else on every query
const transaction& trx() const{
if (decompressed_trx) {
return *decompressed_trx;
} else {
return *_trx;
}
}
// limits
optional<time_point> processing_deadline;
private:
const transaction* _trx = nullptr;
};
typedef std::shared_ptr<transaction_metadata> transaction_metadata_ptr;
} } // eosio::chain
FC_REFLECT( eosio::chain::transaction_metadata, (raw_trx)(signing_keys)(id)(region_id)(cycle_index)(shard_index)(billable_packed_size)(published)(sender)(sender_id)(is_implicit))
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册