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

resolve conflicts

......@@ -47,8 +47,8 @@ struct controller_impl {
chainbase::database db;
block_log blog;
optional<pending_state> pending;
block_state_ptr head;
fork_database fork_db;
block_state_ptr head;
fork_database fork_db;
wasm_interface wasmif;
resource_limits_manager resource_limits;
controller::config conf;
......@@ -87,7 +87,7 @@ struct controller_impl {
}
controller_impl( const controller::config& cfg, controller& s )
:db( cfg.shared_memory_dir,
:db( cfg.shared_memory_dir,
cfg.read_only ? database::read_only : database::read_write,
cfg.shared_memory_size ),
blog( cfg.block_log_dir ),
......@@ -130,7 +130,7 @@ struct controller_impl {
* unwind that pending state. This state will be regenerated
* when we catch up to the head block later.
*/
//clear_all_undo();
//clear_all_undo();
}
~controller_impl() {
......@@ -175,7 +175,7 @@ struct controller_impl {
db.with_write_lock([&] {
db.undo_all();
/*
FC_ASSERT(db.revision() == self.head_block_num(),
FC_ASSERT(db.revision() == self.head_block_num(),
"Chainbase revision does not match head block num",
("rev", db.revision())("head_block", self.head_block_num()));
*/
......@@ -212,7 +212,7 @@ struct controller_impl {
db.set_revision( head->block_num );
fork_db.set( head );
initialize_database();
}
FC_ASSERT( db.revision() == head->block_num, "fork database is inconsistant with shared memory",
......@@ -313,7 +313,7 @@ struct controller_impl {
if( add_to_fork_db ) {
pending->_pending_block_state->validated = true;
head = fork_db.add( pending->_pending_block_state );
}
}
set_pending_tapos();
......@@ -325,11 +325,12 @@ struct controller_impl {
transaction_trace_ptr push_transaction( const transaction_metadata_ptr& trx ) {
unapplied_transactions.erase( trx->signed_id );
auto r = db.with_write_lock( [&](){
auto r = db.with_write_lock( [&](){
return apply_transaction( trx );
});
pending->_pending_block_state->block->transactions.emplace_back( trx->packed_trx );
r->receipt = pending->_pending_block_state->block->transactions.back();
pending->_pending_block_state->trxs.emplace_back(trx);
self.accepted_transaction(trx);
......@@ -384,7 +385,7 @@ struct controller_impl {
static_cast<signed_block_header&>(*p->block) = p->header;
} /// sign_block
void apply_block( const signed_block_ptr& b ) {
void apply_block( const signed_block_ptr& b ) {
try {
start_block( b->timestamp );
......@@ -443,16 +444,16 @@ struct controller_impl {
catch (const fc::exception& e) { except = e; }
if (except) {
wlog("exception thrown while switching forks ${e}", ("e",except->to_detail_string()));
while (ritr != branches.first.rend() ) {
fork_db.set_validity( *ritr, false );
++ritr;
}
// pop all blocks from the bad fork
while( head_block_id() != branches.second.back()->header.previous )
pop_block();
// re-apply good blocks
for( auto ritr = branches.second.rbegin(); ritr != branches.second.rend(); ++ritr ) {
apply_block( (*ritr)->block );
......@@ -507,15 +508,15 @@ struct controller_impl {
}
void finalize_block()
void finalize_block()
{ try {
ilog( "finalize block ${p} ${t} schedule_version: ${v} lib: ${lib} ${np} ${signed}",
ilog( "finalize block ${p} ${t} schedule_version: ${v} lib: ${lib} ${np} ${signed}",
("p",pending->_pending_block_state->header.producer)
("t",pending->_pending_block_state->header.timestamp)
("v",pending->_pending_block_state->header.schedule_version)
("lib",pending->_pending_block_state->dpos_last_irreversible_blocknum)
("np",pending->_pending_block_state->header.new_producers)
("signed", pending->_pending_block_state->block_signing_key)
("signed", pending->_pending_block_state->block_signing_key)
);
set_action_merkle();
......@@ -527,7 +528,7 @@ struct controller_impl {
create_block_summary();
/* TODO RESTORE
/* TODO RESTORE
const auto& b = trace.block;
update_global_properties( b );
update_global_dynamic_data( b );
......@@ -624,11 +625,11 @@ struct controller_impl {
}; /// controller_impl
const resource_limits_manager& controller::get_resource_limits_manager()const
const resource_limits_manager& controller::get_resource_limits_manager()const
{
return my->resource_limits;
}
resource_limits_manager& controller::get_mutable_resource_limits_manager()
resource_limits_manager& controller::get_mutable_resource_limits_manager()
{
return my->resource_limits;
}
......@@ -694,7 +695,7 @@ void controller::push_block( const signed_block_ptr& b ) {
my->push_block( b );
}
transaction_trace_ptr controller::push_transaction( const transaction_metadata_ptr& trx ) {
transaction_trace_ptr controller::push_transaction( const transaction_metadata_ptr& trx ) {
return my->push_transaction(trx);
}
......@@ -736,14 +737,14 @@ const global_property_object& controller::get_global_properties()const {
/**
* This method reads the current dpos_irreverible block number, if it is higher
* than the last block number of the log, it grabs the next block from the
* fork database, saves it to disk, then removes the block from the fork database.
* fork database, saves it to disk, then removes the block from the fork database.
*
* Any forks built off of a different block with the same number are also pruned.
*/
void controller::log_irreversible_blocks() {
if( !my->blog.head() )
if( !my->blog.head() )
my->blog.read_head();
const auto& log_head = my->blog.head();
auto lib = my->head->dpos_last_irreversible_blocknum;
......@@ -843,7 +844,7 @@ wasm_interface& controller::get_wasm_interface() {
return my->wasmif;
}
const account_object& controller::get_account( account_name name )const
const account_object& controller::get_account( account_name name )const
{ try {
return my->db.get<account_object, by_name>(name);
} FC_CAPTURE_AND_RETHROW( (name) ) }
......@@ -861,7 +862,7 @@ void controller::validate_referenced_accounts( const transaction& trx )const {
bool one_auth = false;
for( const auto& a : trx.actions ) {
get_account( a.account );
for( const auto& auth : a.authorization ) {
for( const auto& auth : a.authorization ) {
one_auth = true;
get_account( auth.actor );
}
......@@ -903,7 +904,7 @@ void controller::validate_tapos( const transaction& trx )const { try {
EOS_ASSERT(trx.verify_reference_block(tapos_block_summary.block_id), invalid_ref_block_exception,
"Transaction's reference block did not match. Is this transaction from a different fork?",
("tapos_summary", tapos_block_summary));
} FC_CAPTURE_AND_RETHROW() }
} FC_CAPTURE_AND_RETHROW() }
} } /// eosio::chain
......@@ -8,7 +8,8 @@ namespace eosio { namespace chain {
* When a transaction is referenced by a block it could imply one of several outcomes which
* describe the state-transition undertaken by the block producer.
*/
struct transaction_receipt {
struct transaction_receipt_header {
enum status_enum {
executed = 0, ///< succeed, no error handler executed
soft_fail = 1, ///< objectively failed (not executed), error handler executed
......@@ -17,19 +18,25 @@ namespace eosio { namespace chain {
implicit = 4 ///< transaction that is implied or implicit with the block generation (such as on block action)
};
transaction_receipt() : status(hard_fail) {}
transaction_receipt( transaction_id_type tid ):status(executed),trx(tid){}
transaction_receipt( packed_transaction ptrx ):status(executed),trx(ptrx){}
transaction_receipt_header():status(hard_fail){}
transaction_receipt_header( status_enum s ):status(s){}
fc::enum_type<uint8_t,status_enum> status;
fc::unsigned_int kcpu_usage; ///< total billed CPU usage
fc::unsigned_int net_usage_words; ///< total billed NET usage, so we can reconstruct resource state when skipping context free data... hard failures...
fc::static_variant<transaction_id_type, packed_transaction> trx;
fc::enum_type<uint8_t,status_enum> status;
fc::unsigned_int kcpu_usage; ///< total billed CPU usage
fc::unsigned_int net_usage_words; ///< total billed NET usage, so we can reconstruct resource state when skipping context free data... hard failures...
};
struct transaction_receipt : public transaction_receipt_header {
transaction_receipt():transaction_receipt_header(){}
transaction_receipt( transaction_id_type tid ):transaction_receipt_header(executed),trx(tid){}
transaction_receipt( packed_transaction ptrx ):transaction_receipt_header(executed),trx(ptrx){}
fc::static_variant<transaction_id_type, packed_transaction> trx;
digest_type digest()const {
/* TODO
if( packed_trx ) {
if( packed_trx ) {
return hash(status, usage, packed.trx().id(), packed.packed_digest() )
}
*/
......@@ -53,8 +60,9 @@ namespace eosio { namespace chain {
} } /// eosio::chain
FC_REFLECT_ENUM( eosio::chain::transaction_receipt::status_enum,
FC_REFLECT_ENUM( eosio::chain::transaction_receipt::status_enum,
(executed)(soft_fail)(hard_fail)(delayed)(implicit) )
FC_REFLECT(eosio::chain::transaction_receipt, (status)(kcpu_usage)(net_usage_words)(trx) )
FC_REFLECT(eosio::chain::transaction_receipt_header, (status)(kcpu_usage)(net_usage_words) )
FC_REFLECT_DERIVED(eosio::chain::transaction_receipt, (eosio::chain::transaction_receipt_header), (trx) )
FC_REFLECT_DERIVED(eosio::chain::signed_block, (eosio::chain::signed_block_header), (transactions))
......@@ -6,6 +6,7 @@
#include <eosio/chain/action.hpp>
#include <eosio/chain/action_receipt.hpp>
#include <eosio/chain/block.hpp>
namespace eosio { namespace chain {
......@@ -24,9 +25,11 @@ namespace eosio { namespace chain {
};
struct transaction_trace {
fc::microseconds elapsed;
uint64_t cpu_usage = 0;
vector<action_trace> action_traces; ///< disposable
transaction_id_type id;
transaction_receipt_header receipt;
fc::microseconds elapsed;
uint64_t cpu_usage = 0;
vector<action_trace> action_traces; ///< disposable
};
typedef std::shared_ptr<transaction_trace> transaction_trace_ptr;
......@@ -41,5 +44,5 @@ namespace eosio { namespace chain {
FC_REFLECT( eosio::chain::action_trace,
(receipt)(act)(elapsed)(cpu_usage)(console)(total_inline_cpu_usage)(inline_traces) )
FC_REFLECT( eosio::chain::transaction_trace, (elapsed)(cpu_usage)(action_traces) )
FC_REFLECT( eosio::chain::transaction_trace, (id)(receipt)(elapsed)(cpu_usage)(action_traces) )
FC_REFLECT( eosio::chain::block_trace, (elapsed)(cpu_usage)(trx_traces) )
......@@ -7,12 +7,13 @@ namespace eosio { namespace chain {
class transaction_context {
public:
transaction_context( controller& c, const transaction_metadata_ptr& trx )
transaction_context( controller& c, const transaction_metadata_ptr& trx )
:control(c),
trx_meta(trx),
undo_session(c.db().start_undo_session(true))
{
trace = std::make_shared<transaction_trace>();
trace->id = trx->id;
executed.reserve( trx_meta->total_actions() );
}
......
......@@ -8,7 +8,7 @@
#include <eosio/account_history_plugin/public_key_history_object.hpp>
#include <eosio/account_history_plugin/transaction_history_object.hpp>
#include <eosio/chain/account_object.hpp>
#include <eosio/chain/chain_controller.hpp>
#include <eosio/chain/controller.hpp>
#include <eosio/chain/config.hpp>
#include <eosio/chain/exceptions.hpp>
#include <eosio/chain/transaction.hpp>
......@@ -60,7 +60,7 @@ public:
void check_init_db() {
if( !init_db ) {
init_db = true;
auto& db = chain_plug->chain().get_mutable_database();
auto& db = chain_plug->chain().db();
db.add_index<account_control_history_multi_index>();
db.add_index<account_transaction_history_multi_index>();
db.add_index<public_key_history_multi_index>();
......@@ -144,7 +144,7 @@ packed_transaction account_history_plugin_impl::find_transaction(const chain::tr
packed_transaction account_history_plugin_impl::get_transaction(const chain::transaction_id_type& transaction_id) const
{
const auto& db = chain_plug->chain().get_database();
const auto& db = chain_plug->chain().db();
optional<block_id_type> block_id;
db.with_read_lock( [&]() {
block_id = find_block_id(db, transaction_id);
......@@ -163,7 +163,7 @@ packed_transaction account_history_plugin_impl::get_transaction(const chain::tra
get_transactions_results account_history_plugin_impl::get_transactions(const account_name& account_name, const optional<uint32_t>& skip_seq, const optional<uint32_t>& num_seq) const
{
fc::time_point start_time = fc::time_point::now();
const auto& db = chain_plug->chain().get_database();
const auto& db = chain_plug->chain().db();
block_transaction_id_map block_transaction_ids;
db.with_read_lock( [&]() {
......@@ -276,7 +276,7 @@ bool account_history_plugin_impl::time_exceeded(const fc::time_point& start_time
vector<account_name> account_history_plugin_impl::get_key_accounts(const public_key_type& public_key) const
{
std::set<account_name> accounts;
const auto& db = chain_plug->chain().get_database();
const auto& db = chain_plug->chain().db();
db.with_read_lock( [&]() {
const auto& pub_key_idx = db.get_index<public_key_history_multi_index, by_pub_key>();
auto range = pub_key_idx.equal_range( public_key );
......@@ -291,7 +291,7 @@ vector<account_name> account_history_plugin_impl::get_key_accounts(const public_
vector<account_name> account_history_plugin_impl::get_controlled_accounts(const account_name& controlling_account) const
{
std::set<account_name> accounts;
const auto& db = chain_plug->chain().get_database();
const auto& db = chain_plug->chain().db();
db.with_read_lock( [&]() {
const auto& account_control_idx = db.get_index<account_control_history_multi_index, by_controlling>();
auto range = account_control_idx.equal_range( controlling_account );
......@@ -310,7 +310,7 @@ static vector<account_name> generated_affected_accounts(const chain::transaction
result.emplace_back(auth.actor);
}
result.emplace_back(at.receiver);
result.emplace_back(at.receipt.receiver);
}
fc::deduplicate(result);
......@@ -321,7 +321,7 @@ void account_history_plugin_impl::applied_block(const chain::block_trace& trace)
{
const auto& block = trace.block;
const auto block_id = block.id();
auto& db = chain_plug->chain().get_mutable_database();
auto& db = chain_plug->chain().db();
const bool check_relevance = filter_on.size();
auto process_one = [&](const chain::transaction_trace& trx_trace )
{
......@@ -351,11 +351,11 @@ void account_history_plugin_impl::applied_block(const chain::block_trace& trace)
for (const auto& act_trace : trx_trace.action_traces)
{
if (act_trace.receiver == chain::config::system_account_name)
if (act_trace.receipt.receiver == chain::config::system_account_name)
{
if (act_trace.act.name == NEW_ACCOUNT)
{
const auto create = act_trace.act.data_as<chain::contracts::newaccount>();
const auto create = act_trace.act.data_as<chain::newaccount>();
add(db, create.owner.keys, create.name, OWNER);
add(db, create.active.keys, create.name, ACTIVE);
add(db, create.recovery.keys, create.name, RECOVERY);
......@@ -366,7 +366,7 @@ void account_history_plugin_impl::applied_block(const chain::block_trace& trace)
}
else if (act_trace.act.name == UPDATE_AUTH)
{
const auto update = act_trace.act.data_as<chain::contracts::updateauth>();
const auto update = act_trace.act.data_as<chain::updateauth>();
remove<public_key_history_multi_index, by_account_permission>(db, update.account, update.permission);
add(db, update.data.keys, update.account, update.permission);
......@@ -375,7 +375,7 @@ void account_history_plugin_impl::applied_block(const chain::block_trace& trace)
}
else if (act_trace.act.name == DELETE_AUTH)
{
const auto del = act_trace.act.data_as<chain::contracts::deleteauth>();
const auto del = act_trace.act.data_as<chain::deleteauth>();
remove<public_key_history_multi_index, by_account_permission>(db, del.account, del.permission);
remove<account_control_history_multi_index, by_controlled_authority>(db, del.account, del.permission);
......@@ -427,7 +427,7 @@ bool account_history_plugin_impl::is_scope_relevant(const vector<account_name>&
fc::variant account_history_plugin_impl::transaction_to_variant(const packed_transaction& ptrx) const
{
const chainbase::database& database = chain_plug->chain().get_database();
const chainbase::database& database = chain_plug->chain().db();
auto resolver = [&database]( const account_name& name ) -> optional<abi_serializer> {
const auto* accnt = database.find<chain::account_object,chain::by_name>( name );
if (accnt != nullptr) {
......@@ -477,7 +477,7 @@ void account_history_plugin::plugin_initialize(const variables_map& options)
}
my->chain_plug = app().find_plugin<chain_plugin>();
my->chain_plug->chain_config().applied_block_callbacks.emplace_back(
my->chain_plug->chain_config().applied_block_callbacks.emplace_back(
[&impl = my](const chain::block_trace& trace) {
impl->check_init_db();
impl->applied_block(trace);
......@@ -488,7 +488,7 @@ void account_history_plugin::plugin_initialize(const variables_map& options)
void account_history_plugin::plugin_startup()
{
/*
auto& db = my->chain_plug->chain().get_mutable_database();
auto& db = my->chain_plug->chain().db();
db.add_index<account_control_history_multi_index>();
db.add_index<account_transaction_history_multi_index>();
db.add_index<public_key_history_multi_index>();
......
......@@ -15,10 +15,10 @@ using namespace eosio;
class chain_api_plugin_impl {
public:
chain_api_plugin_impl(chain_controller& db)
chain_api_plugin_impl(controller& db)
: db(db) {}
chain_controller& db;
controller& db;
};
......
......@@ -7,10 +7,10 @@
#include <eosio/http_plugin/http_plugin.hpp>
#include <appbase/application.hpp>
#include <eosio/chain/chain_controller.hpp>
#include <eosio/chain/controller.hpp>
namespace eosio {
using eosio::chain::chain_controller;
using eosio::chain::controller;
using std::unique_ptr;
using namespace appbase;
......
......@@ -351,7 +351,7 @@ auto make_resolver(const Api *api) {
}
fc::variant read_only::get_block(const read_only::get_block_params& params) const {
optional<signed_block> block;
signed_block_ptr block;
try {
block = db.fetch_block_by_id(fc::json::from_string(params.block_num_or_id).as<block_id_type>());
if (!block) {
......@@ -360,9 +360,7 @@ fc::variant read_only::get_block(const read_only::get_block_params& params) cons
} EOS_RETHROW_EXCEPTIONS(chain::block_id_type_exception, "Invalid block ID: ${block_num_or_id}", ("block_num_or_id", params.block_num_or_id))
if (!block)
FC_THROW_EXCEPTION(unknown_block_exception,
"Could not find block: ${block}", ("block", params.block_num_or_id));
EOS_ASSERT( block, unknown_block_exception, "Could not find block: ${block}", ("block", params.block_num_or_id));
fc::variant pretty_output;
abi_serializer::to_variant(*block, pretty_output, make_resolver(this));
......@@ -387,11 +385,11 @@ read_write::push_transaction_results read_write::push_transaction(const read_wri
abi_serializer::from_variant(params, pretty_input, resolver);
} EOS_RETHROW_EXCEPTIONS(chain::packed_transaction_type_exception, "Invalid packed transaction")
auto result = db.push_transaction( std::make_shared<transaction_metadata>(move(pretty_input)) );
auto trx_trace_ptr = db.push_transaction( std::make_shared<transaction_metadata>(move(pretty_input)) );
#warning TODO: get transaction results asynchronously
fc::variant pretty_output;
abi_serializer::to_variant(result, pretty_output, resolver);
return read_write::push_transaction_results{ result.id, pretty_output };
abi_serializer::to_variant(*trx_trace_ptr, pretty_output, resolver);
return read_write::push_transaction_results{ trx_trace_ptr->id, pretty_output };
}
read_write::push_transactions_results read_write::push_transactions(const read_write::push_transactions_params& params) {
......
......@@ -221,7 +221,7 @@ struct faucet_testnet_plugin_impl {
chain::chain_id_type chainid;
auto& plugin = _app.get_plugin<chain_plugin>();
plugin.get_chain_id(chainid);
chain_controller& cc = plugin.chain();
controller& cc = plugin.chain();
signed_transaction trx;
auto memo = fc::variant(fc::time_point::now()).as_string() + " " + fc::variant(fc::time_point::now().time_since_epoch()).as_string();
......@@ -232,14 +232,16 @@ struct faucet_testnet_plugin_impl {
auto recovery_auth = chain::authority{1, {}, {{{_create_account_name, "active"}, 1}}};
trx.actions.emplace_back(vector<chain::permission_level>{{_create_account_name,"active"}},
contracts::newaccount{_create_account_name, new_account_name, owner_auth, active_auth, recovery_auth});
newaccount{_create_account_name, new_account_name, owner_auth, active_auth, recovery_auth});
trx.expiration = cc.head_block_time() + fc::seconds(30);
trx.set_reference_block(cc.head_block_id());
trx.sign(_create_account_private_key, chainid);
try {
cc.push_transaction(packed_transaction(trx));
if( !cc.pending_block_state() )
cc.start_block();
cc.push_transaction( std::make_shared<transaction_metadata>(trx) );
} catch (const account_name_exists_exception& ) {
// another transaction ended up adding the account, so look for alternates
return find_alternates(new_account_name);
......@@ -260,7 +262,7 @@ struct faucet_testnet_plugin_impl {
const chainbase::database& database() {
static const chainbase::database* db = nullptr;
if (db == nullptr)
db = &_app.get_plugin<chain_plugin>().chain().get_database();
db = &_app.get_plugin<chain_plugin>().chain().db();
return *db;
}
......
......@@ -3,7 +3,7 @@
* @copyright defined in eos/LICENSE.txt
*/
#include <eosio/mongo_db_plugin/mongo_db_plugin.hpp>
#include <eosio/chain/contracts/chain_initializer.hpp>
#include <eosio/chain/eosio_contract.hpp>
#include <eosio/chain/config.hpp>
#include <eosio/chain/exceptions.hpp>
#include <eosio/chain/transaction.hpp>
......@@ -249,7 +249,7 @@ namespace {
}
abi_serializer abis;
if (msg.account == chain::config::system_account_name) {
abi = chain::contracts::chain_initializer::eos_contract_abi(abi);
abi = chain::eosio_contract_abi(abi);
}
abis.set_abi(abi);
auto v = abis.binary_to_variant(abis.get_action_type(msg.name), msg.data);
......@@ -472,7 +472,7 @@ void mongo_db_plugin_impl::_process_block(const block_trace& bt, const signed_bl
(trx_trace.status == chain::transaction_receipt::hard_fail) ? "hard_fail" :
"unknown";
trx_status_map[trx_trace.id] = trx_status;
for (const auto& req : trx_trace.deferred_transaction_requests) {
if ( req.contains<chain::deferred_transaction>() ) {
auto trx = req.get<chain::deferred_transaction>();
......@@ -666,7 +666,7 @@ void mongo_db_plugin_impl::update_account(const chain::action& msg) {
} else if (msg.name == newaccount) {
auto now = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::microseconds{fc::time_point::now().time_since_epoch().count()});
auto newaccount = msg.data_as<chain::contracts::newaccount>();
auto newaccount = msg.data_as<chain::newaccount>();
// create new account
bsoncxx::builder::stream::document doc{};
......@@ -683,7 +683,7 @@ void mongo_db_plugin_impl::update_account(const chain::action& msg) {
} else if (msg.name == setabi) {
auto now = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::microseconds{fc::time_point::now().time_since_epoch().count()});
auto setabi = msg.data_as<chain::contracts::setabi>();
auto setabi = msg.data_as<chain::setabi>();
auto from_account = find_account(accounts, setabi.account);
document update_from{};
......
......@@ -52,7 +52,7 @@ class producer_plugin_impl {
producer_plugin* _self = nullptr;
void on_block( const block_trace& bt ) {
chain::chain_controller& chain = app().get_plugin<chain_plugin>().chain();
chain::controller& chain = app().get_plugin<chain_plugin>().chain();
if( bt.block.timestamp <= _last_signed_block_time ) return;
if( bt.block.timestamp <= _start_time ) return;
......
......@@ -71,15 +71,22 @@ using namespace eosio::chain;
eosio::detail::txn_test_gen_empty result;
struct txn_test_gen_plugin_impl {
transaction_trace_ptr push_transaction( signed_transaction& trx ) { try {
controller& cc = app().get_plugin<chain_plugin>().chain();
if( !cc.pending_block_state() )
cc.start_block();
return cc.push_transaction( std::make_shared<transaction_metadata>(trx) );
} FC_CAPTURE_AND_RETHROW( (transaction_header(trx)) ) }
void create_test_accounts(const std::string& init_name, const std::string& init_priv_key) {
name newaccountA("txn.test.a");
name newaccountB("txn.test.b");
name newaccountC("currency");
name creator(init_name);
contracts::abi_def currency_abi_def = fc::json::from_string(currency_abi).as<contracts::abi_def>();
abi_def currency_abi_def = fc::json::from_string(currency_abi).as<abi_def>();
chain_controller& cc = app().get_plugin<chain_plugin>().chain();
controller& cc = app().get_plugin<chain_plugin>().chain();
chain::chain_id_type chainid;
app().get_plugin<chain_plugin>().get_chain_id(chainid);
......@@ -102,7 +109,7 @@ struct txn_test_gen_plugin_impl {
auto active_auth = eosio::chain::authority{1, {{txn_text_receiver_A_pub_key, 1}}, {}};
auto recovery_auth = eosio::chain::authority{1, {}, {{{creator, "active"}, 1}}};
trx.actions.emplace_back(vector<chain::permission_level>{{creator,"active"}}, contracts::newaccount{creator, newaccountA, owner_auth, active_auth, recovery_auth});
trx.actions.emplace_back(vector<chain::permission_level>{{creator,"active"}}, newaccount{creator, newaccountA, owner_auth, active_auth, recovery_auth});
}
//create "B" account
{
......@@ -110,7 +117,7 @@ struct txn_test_gen_plugin_impl {
auto active_auth = eosio::chain::authority{1, {{txn_text_receiver_B_pub_key, 1}}, {}};
auto recovery_auth = eosio::chain::authority{1, {}, {{{creator, "active"}, 1}}};
trx.actions.emplace_back(vector<chain::permission_level>{{creator,"active"}}, contracts::newaccount{creator, newaccountB, owner_auth, active_auth, recovery_auth});
trx.actions.emplace_back(vector<chain::permission_level>{{creator,"active"}}, newaccount{creator, newaccountB, owner_auth, active_auth, recovery_auth});
}
//create "currency" account
{
......@@ -118,13 +125,13 @@ struct txn_test_gen_plugin_impl {
auto active_auth = eosio::chain::authority{1, {{txn_text_receiver_C_pub_key, 1}}, {}};
auto recovery_auth = eosio::chain::authority{1, {}, {{{creator, "active"}, 1}}};
trx.actions.emplace_back(vector<chain::permission_level>{{creator,"active"}}, contracts::newaccount{creator, newaccountC, owner_auth, active_auth, recovery_auth});
trx.actions.emplace_back(vector<chain::permission_level>{{creator,"active"}}, newaccount{creator, newaccountC, owner_auth, active_auth, recovery_auth});
}
trx.expiration = cc.head_block_time() + fc::seconds(30);
trx.set_reference_block(cc.head_block_id());
trx.sign(creator_priv_key, chainid);
cc.push_transaction(packed_transaction(trx));
push_transaction(trx);
}
//set currency contract & initialize it
......@@ -133,14 +140,14 @@ struct txn_test_gen_plugin_impl {
vector<uint8_t> wasm = wast_to_wasm(std::string(currency_wast));
contracts::setcode handler;
setcode handler;
handler.account = newaccountC;
handler.code.assign(wasm.begin(), wasm.end());
trx.actions.emplace_back( vector<chain::permission_level>{{newaccountC,"active"}}, handler);
{
contracts::setabi handler;
setabi handler;
handler.account = newaccountC;
handler.abi = currency_abi_def;
trx.actions.emplace_back( vector<chain::permission_level>{{newaccountC,"active"}}, handler);
......@@ -185,7 +192,7 @@ struct txn_test_gen_plugin_impl {
trx.set_reference_block(cc.head_block_id());
trx.max_net_usage_words = 5000;
trx.sign(txn_test_receiver_C_priv_key, chainid);
cc.push_transaction(packed_transaction(trx));
push_transaction(trx);
}
}
......@@ -238,7 +245,7 @@ struct txn_test_gen_plugin_impl {
}
void send_transaction() {
chain_controller& cc = app().get_plugin<chain_plugin>().chain();
controller& cc = app().get_plugin<chain_plugin>().chain();
chain::chain_id_type chainid;
app().get_plugin<chain_plugin>().get_chain_id(chainid);
......@@ -258,7 +265,7 @@ struct txn_test_gen_plugin_impl {
trx.expiration = cc.head_block_time() + fc::seconds(30);
trx.max_net_usage_words = 100;
trx.sign(a_priv_key, chainid);
cc.push_transaction(packed_transaction(trx));
push_transaction(trx);
}
{
......@@ -269,7 +276,7 @@ struct txn_test_gen_plugin_impl {
trx.expiration = cc.head_block_time() + fc::seconds(30);
trx.max_net_usage_words = 100;
trx.sign(b_priv_key, chainid);
cc.push_transaction(packed_transaction(trx));
push_transaction(trx);
}
}
}
......@@ -291,7 +298,7 @@ struct txn_test_gen_plugin_impl {
action act_a_to_b;
action act_b_to_a;
abi_serializer currency_serializer = fc::json::from_string(currency_abi).as<contracts::abi_def>();
abi_serializer currency_serializer = fc::json::from_string(currency_abi).as<abi_def>();
};
txn_test_gen_plugin::txn_test_gen_plugin() {}
......
......@@ -4,7 +4,7 @@
#include <fc/variant_object.hpp>
using namespace eosio;
using namespace eosio::chain::contracts;
using namespace eosio::chain;
using mvo = fc::mutable_variant_object;
......
......@@ -32,7 +32,7 @@
#include <sys/types.h>
#include <netinet/in.h>
#include <net/if.h>
#include <eosio/chain/contracts/genesis_state.hpp>
#include <eosio/chain/genesis_state.hpp>
#include "config.hpp"
......@@ -1055,7 +1055,7 @@ launcher_def::init_genesis () {
bfs::ifstream src(genesis_path);
if (!src.good()) {
cout << "generating default genesis file " << genesis_path << endl;
eosio::chain::contracts::genesis_state_type default_genesis;
eosio::chain::genesis_state default_genesis;
fc::json::save_to_file( default_genesis, genesis_path, true );
src.open(genesis_path);
}
......
#include <boost/test/unit_test.hpp>
#include <eosio/testing/tester.hpp>
#include <eosio/chain/contracts/abi_serializer.hpp>
#include <eosio/chain/abi_serializer.hpp>
#ifdef NON_VALIDATING_TEST
#define TESTER tester
......@@ -10,7 +10,6 @@
using namespace eosio;
using namespace eosio::chain;
using namespace eosio::chain::contracts;
using namespace eosio::testing;
BOOST_AUTO_TEST_SUITE(auth_tests)
......@@ -23,7 +22,7 @@ BOOST_FIXTURE_TEST_CASE( missing_sigs, TESTER ) { try {
auto trace = push_reqauth(N(alice), "owner");
produce_block();
BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trace.id));
BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trace->id));
} FC_LOG_AND_RETHROW() } /// missing_sigs
......@@ -36,7 +35,7 @@ BOOST_FIXTURE_TEST_CASE( missing_multi_sigs, TESTER ) { try {
auto trace = push_reqauth(N(alice), "owner", true); // with multisig
produce_block();
BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trace.id));
BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trace->id));
} FC_LOG_AND_RETHROW() } /// missing_multi_sigs
......@@ -70,7 +69,7 @@ BOOST_FIXTURE_TEST_CASE( delegate_auth, TESTER ) { try {
auto trace = push_reqauth(N(alice), {permission_level{N(alice), config::active_name}}, { get_private_key(N(bob), "active") } );
produce_block();
BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trace.id));
BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trace->id));
} FC_LOG_AND_RETHROW() }
......
......@@ -4,7 +4,6 @@
using namespace eosio;
using namespace eosio::chain;
using namespace eosio::chain::contracts;
using namespace eosio::testing;
#ifdef NON_VALIDATING_TEST
......
#include <boost/test/unit_test.hpp>
#include <eosio/testing/tester.hpp>
#include <eosio/chain/contracts/abi_serializer.hpp>
#include <eosio/chain/abi_serializer.hpp>
#include <eosio/chain_plugin/chain_plugin.hpp>
#include <eosio.system/eosio.system.wast.hpp>
......@@ -164,7 +164,7 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
ilog(".");
// Set privileges for eosio.msig
auto trace = base_tester::push_action(config::system_account_name, N(setpriv),
auto trace = base_tester::push_action(config::system_account_name, N(setpriv),
config::system_account_name, mutable_variant_object()
("account", "eosio.msig")
("is_priv", 1)
......@@ -182,7 +182,7 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
// Issue the genesis supply of 1 billion EOS tokens to eosio.system
// Issue the genesis supply of 1 billion EOS tokens to eosio.system
issue(N(eosio.token), config::system_account_name, config::system_account_name, expected);
issue(N(eosio.token), config::system_account_name, config::system_account_name, expected);
ilog(".");
......
......@@ -14,7 +14,6 @@
using namespace eosio;
using namespace eosio::chain;
using namespace eosio::chain::contracts;
using namespace eosio::testing;
......@@ -1296,7 +1295,7 @@ BOOST_AUTO_TEST_CASE( mindelay_test ) { try {
// send transfer with delay_sec set to 10
const auto& acnt = chain.control->get_database().get<account_object,by_name>(N(currency));
const auto abi = acnt.get_abi();
chain::contracts::abi_serializer abis(abi);
chain::abi_serializer abis(abi);
const auto a = chain.control->get_database().get<account_object,by_name>(N(currency)).get_abi();
string action_type_name = abis.get_action_type(name("transfer"));
......@@ -1495,7 +1494,7 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
// send canceldelay for first delayed transaction
signed_transaction trx;
trx.actions.emplace_back(vector<permission_level>{{N(tester), config::active_name}},
chain::contracts::canceldelay{ids[0]});
chain::canceldelay{ids[0]});
trx.actions.back().authorization.push_back({N(tester), config::active_name});
chain.set_transaction_headers(trx);
......
......@@ -32,7 +32,7 @@ BOOST_AUTO_TEST_SUITE(producer_schedule_tests)
// Calculate the block num of the next round first block
// The new producer schedule will become effective when it's in the block of the next round first block
// However, it won't be applied until the effective block num is deemed irreversible
uint64_t calc_block_num_of_next_round_first_block(const chain_controller& control){
uint64_t calc_block_num_of_next_round_first_block(const controller& control){
auto res = control.get_dynamic_global_properties().head_block_number + 1;
const auto blocks_per_round = control.get_global_properties().active_producers.producers.size() * config::producer_repetitions;
while((res % blocks_per_round) != 0) {
......@@ -115,7 +115,7 @@ BOOST_AUTO_TEST_SUITE(producer_schedule_tests)
BOOST_FIXTURE_TEST_CASE( verify_producers, TESTER ) try {
vector<account_name> valid_producers = {
"inita", "initb", "initc", "initd", "inite", "initf", "initg",
"inith", "initi", "initj", "initk", "initl", "initm", "initn",
......@@ -127,7 +127,7 @@ BOOST_AUTO_TEST_SUITE(producer_schedule_tests)
// account initz does not exist
vector<account_name> nonexisting_producer = { "initz" };
BOOST_CHECK_THROW(set_producers(nonexisting_producer), wasm_execution_error);
// replace initg with inita, inita is now duplicate
vector<account_name> invalid_producers = {
"inita", "initb", "initc", "initd", "inite", "initf", "inita",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册