Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Remove operations and evaluators
Browse files Browse the repository at this point in the history
Also remove transaction_evaluation_state and the size_checker program.
  • Loading branch information
nathanielhourt committed Apr 6, 2017
1 parent f986bb3 commit 07f027c
Show file tree
Hide file tree
Showing 16 changed files with 21 additions and 478 deletions.
1 change: 1 addition & 0 deletions libraries/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <eos/app/plugin.hpp>

#include <eos/chain/protocol/types.hpp>
#include <eos/chain/exceptions.hpp>
#include <eos/chain/producer_object.hpp>

#include <eos/egenesis/egenesis.hpp>
Expand Down
3 changes: 0 additions & 3 deletions libraries/chain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ add_library( eos_chain
fork_database.cpp

protocol/types.cpp
protocol/operations.cpp
protocol/transaction.cpp
protocol/block.cpp

genesis_state.cpp
get_config.cpp

evaluator.cpp

block_database.cpp

${HEADERS}
Expand Down
57 changes: 9 additions & 48 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <eos/chain/database.hpp>
#include <eos/chain/db_with.hpp>
#include <eos/chain/exceptions.hpp>
#include <eos/chain/evaluator.hpp>

#include <eos/chain/block_summary_object.hpp>
#include <eos/chain/chain_property_object.hpp>
Expand Down Expand Up @@ -482,9 +481,7 @@ signed_transaction database::_apply_transaction(const signed_transaction& trx)
auto trx_id = trx.id();
FC_ASSERT( (skip & skip_transaction_dupe_check) ||
trx_idx.indices().get<by_trx_id>().find(trx_id) == trx_idx.indices().get<by_trx_id>().end() );
transaction_evaluation_state eval_state(this);
const chain_parameters& chain_parameters = get_global_properties().parameters;
eval_state._trx = &trx;

//Skip all manner of expiration and TaPoS checking if we're on block 1; It's impossible that the transaction is
//expired, and TaPoS makes no sense as no blocks exist.
Expand Down Expand Up @@ -514,32 +511,18 @@ signed_transaction database::_apply_transaction(const signed_transaction& trx)
});
}

//Finally process the operations
//Finally, process the messages
signed_transaction ptrx(trx);
_current_op_in_trx = 0;
for( const auto& op : ptrx.operations )
_current_message_in_trx = 0;
for( const auto& msg : ptrx.messages )
{
apply_operation(eval_state, op);
++_current_op_in_trx;
#warning TODO: Process messages in transaction
++_current_message_in_trx;
}

return ptrx;
} FC_CAPTURE_AND_RETHROW( (trx) ) }

void database::apply_operation(transaction_evaluation_state& eval_state, const operation& op)
{ try {
int i_which = op.which();
uint64_t u_which = uint64_t( i_which );
if( i_which < 0 )
assert( "Negative operation tag" && false );
if( u_which >= _operation_evaluators.size() )
assert( "No registered evaluator for this operation" && false );
unique_ptr<op_evaluator>& eval = _operation_evaluators[ u_which ];
if( !eval )
assert( "No registered evaluator for this operation" && false );
eval->evaluate( eval_state, op, true );
} FC_CAPTURE_AND_RETHROW( (op) ) }

const producer_object& database::validate_block_header( uint32_t skip, const signed_block& next_block )const
{
FC_ASSERT( head_block_id() == next_block.previous, "", ("head_block_id",head_block_id())("next.prev",next_block.previous) );
Expand Down Expand Up @@ -663,21 +646,6 @@ uint32_t database::last_non_undoable_block_num() const
return 1; //head_block_num() - _undo_db.size();
}

// C++ requires that static class variables declared and initialized
// in headers must also have a definition in a single source file,
// else linker errors will occur [1].
//
// The purpose of this source file is to collect such definitions in
// a single place.
//
// [1] http://stackoverflow.com/questions/8016780/undefined-reference-to-static-constexpr-char

void database::initialize_evaluators()
{
_operation_evaluators.resize(255);
// TODO: Figure out how to do this
}

void database::initialize_indexes()
{
add_index<account_multi_index>();
Expand Down Expand Up @@ -717,27 +685,26 @@ void database::init_genesis(const genesis_state_type& genesis_state)
});
}
// Create initial producers
std::vector<producer_id_type> initialProducers;
std::vector<producer_id_type> initial_producers;
for (const auto& producer : genesis_state.initial_producers) {
auto owner = find<account_object, by_name>(producer.owner_name);
FC_ASSERT(owner != nullptr, "Producer belongs to an unknown account: ${acct}", ("acct", producer.owner_name));
auto id = create<producer_object>([&producer](producer_object& w) {
w.signing_key = producer.block_signing_key;
w.owner_name = producer.owner_name.c_str();
}).id;
initialProducers.push_back(id);
initial_producers.push_back(id);
}

transaction_evaluation_state genesis_eval_state(this);

// Initialize block summary index
#warning TODO: Figure out how to do this

chain_id_type chain_id = genesis_state.compute_chain_id();

// Create global properties
create<global_property_object>([&](global_property_object& p) {
p.parameters = genesis_state.initial_parameters;
p.active_producers = initialProducers;
p.active_producers = initial_producers;
});
create<dynamic_global_property_object>([&](dynamic_global_property_object& p) {
p.time = genesis_state.initial_timestamp;
Expand All @@ -753,11 +720,6 @@ void database::init_genesis(const genesis_state_type& genesis_state)
p.immutable_parameters = genesis_state.immutable_parameters;
} );
create<block_summary_object>([&](block_summary_object&) {});

//TODO: Figure out how to do this
// Create initial accounts
// Create initial producers
// Set active producers
} FC_CAPTURE_AND_RETHROW() }

database::database()
Expand Down Expand Up @@ -838,7 +800,6 @@ void database::open(const fc::path& data_dir, uint64_t shared_file_size,
chainbase::database::open(data_dir, read_write, shared_file_size);

initialize_indexes();
initialize_evaluators();

_block_id_to_block.open(data_dir / "database" / "block_num_to_block");

Expand Down
42 changes: 0 additions & 42 deletions libraries/chain/evaluator.cpp

This file was deleted.

11 changes: 1 addition & 10 deletions libraries/chain/include/eos/chain/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <eos/chain/fork_database.hpp>
#include <eos/chain/block_database.hpp>
#include <eos/chain/genesis_state.hpp>
#include <eos/chain/evaluator.hpp>

#include <chainbase/chainbase.hpp>
#include <fc/signals.hpp>
Expand All @@ -39,11 +38,6 @@
#include <map>

namespace eos { namespace chain {
class op_evaluator;
class transaction_evaluation_state;

struct budget_record;

/**
* @class database
* @brief tracks the blockchain state in an extensible manner
Expand Down Expand Up @@ -217,7 +211,6 @@ namespace eos { namespace chain {

uint32_t last_non_undoable_block_num() const;

void initialize_evaluators();
/// Reset the object graph in-memory
void initialize_indexes();
void init_genesis(const genesis_state_type& genesis_state = genesis_state_type());
Expand All @@ -239,13 +232,11 @@ namespace eos { namespace chain {

private:
optional<session> _pending_tx_session;
vector<unique_ptr<op_evaluator>> _operation_evaluators;

public:
// these were formerly private, but they have a fairly well-defined API, so let's make them public
void apply_block( const signed_block& next_block, uint32_t skip = skip_nothing );
signed_transaction apply_transaction( const signed_transaction& trx, uint32_t skip = skip_nothing );
void apply_operation( transaction_evaluation_state& eval_state, const operation& op );
private:
void _apply_block( const signed_block& next_block );
signed_transaction _apply_transaction( const signed_transaction& trx );
Expand Down Expand Up @@ -278,7 +269,7 @@ namespace eos { namespace chain {

uint32_t _current_block_num = 0;
uint16_t _current_trx_in_block = 0;
uint16_t _current_op_in_trx = 0;
uint16_t _current_message_in_trx = 0;
uint16_t _current_virtual_op = 0;

vector<uint64_t> _vote_tally_buffer;
Expand Down
97 changes: 0 additions & 97 deletions libraries/chain/include/eos/chain/evaluator.hpp

This file was deleted.

44 changes: 0 additions & 44 deletions libraries/chain/include/eos/chain/protocol/operations.hpp

This file was deleted.

Loading

0 comments on commit 07f027c

Please sign in to comment.