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

cleanup contract abi

上级 b5387e3a
...@@ -15,6 +15,7 @@ add_library( eosio_chain ...@@ -15,6 +15,7 @@ add_library( eosio_chain
genesis_state.cpp genesis_state.cpp
transaction_context.cpp transaction_context.cpp
eosio_contract.cpp eosio_contract.cpp
eosio_contract_abi.cpp
# chain_config.cpp # chain_config.cpp
# block_trace.cpp # block_trace.cpp
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <eosio/chain/resource_limits.hpp> #include <eosio/chain/resource_limits.hpp>
#include <eosio/chain/scope_sequence_object.hpp> #include <eosio/chain/scope_sequence_object.hpp>
#include <eosio/chain/account_object.hpp> #include <eosio/chain/account_object.hpp>
#include <eosio/chain/global_property_object.hpp>
#include <boost/container/flat_set.hpp> #include <boost/container/flat_set.hpp>
using boost::container::flat_set; using boost::container::flat_set;
...@@ -36,11 +37,11 @@ action_trace apply_context::exec_one() ...@@ -36,11 +37,11 @@ action_trace apply_context::exec_one()
action_receipt r; action_receipt r;
r.receiver = receiver; r.receiver = receiver;
r.act_digest = digest_type::hash(act); r.act_digest = digest_type::hash(act);
r.global_sequence = control.next_global_sequence(); r.global_sequence = next_global_sequence();
r.recv_sequence = control.next_recv_sequence( receiver ); r.recv_sequence = next_recv_sequence( receiver );
for( const auto& auth : act.authorization ) { for( const auto& auth : act.authorization ) {
r.auth_sequence[auth.actor] = control.next_auth_sequence( auth.actor ); r.auth_sequence[auth.actor] = next_auth_sequence( auth.actor );
} }
action_trace t(r); action_trace t(r);
...@@ -313,7 +314,7 @@ const table_id_object& apply_context::find_or_create_table( name code, name scop ...@@ -313,7 +314,7 @@ const table_id_object& apply_context::find_or_create_table( name code, name scop
update_db_usage(payer, config::billable_size_v<table_id_object>); update_db_usage(payer, config::billable_size_v<table_id_object>);
return mutable_db.create<table_id_object>([&](table_id_object &t_id){ return db.create<table_id_object>([&](table_id_object &t_id){
t_id.code = code; t_id.code = code;
t_id.scope = scope; t_id.scope = scope;
t_id.table = table; t_id.table = table;
...@@ -323,7 +324,7 @@ const table_id_object& apply_context::find_or_create_table( name code, name scop ...@@ -323,7 +324,7 @@ const table_id_object& apply_context::find_or_create_table( name code, name scop
void apply_context::remove_table( const table_id_object& tid ) { void apply_context::remove_table( const table_id_object& tid ) {
update_db_usage(tid.payer, - config::billable_size_v<table_id_object>); update_db_usage(tid.payer, - config::billable_size_v<table_id_object>);
mutable_db.remove(tid); db.remove(tid);
} }
vector<account_name> apply_context::get_active_producers() const { vector<account_name> apply_context::get_active_producers() const {
...@@ -431,7 +432,7 @@ int apply_context::db_store_i64( uint64_t code, uint64_t scope, uint64_t table, ...@@ -431,7 +432,7 @@ int apply_context::db_store_i64( uint64_t code, uint64_t scope, uint64_t table,
FC_ASSERT( payer != account_name(), "must specify a valid account to pay for new record" ); FC_ASSERT( payer != account_name(), "must specify a valid account to pay for new record" );
const auto& obj = mutable_db.create<key_value_object>( [&]( auto& o ) { const auto& obj = db.create<key_value_object>( [&]( auto& o ) {
o.t_id = tableid; o.t_id = tableid;
o.primary_key = id; o.primary_key = id;
o.value.resize( buffer_size ); o.value.resize( buffer_size );
...@@ -439,7 +440,7 @@ int apply_context::db_store_i64( uint64_t code, uint64_t scope, uint64_t table, ...@@ -439,7 +440,7 @@ int apply_context::db_store_i64( uint64_t code, uint64_t scope, uint64_t table,
memcpy( o.value.data(), buffer, buffer_size ); memcpy( o.value.data(), buffer, buffer_size );
}); });
mutable_db.modify( tab, [&]( auto& t ) { db.modify( tab, [&]( auto& t ) {
++t.count; ++t.count;
}); });
...@@ -474,7 +475,7 @@ void apply_context::db_update_i64( int iterator, account_name payer, const char* ...@@ -474,7 +475,7 @@ void apply_context::db_update_i64( int iterator, account_name payer, const char*
update_db_usage( obj.payer, new_size - old_size); update_db_usage( obj.payer, new_size - old_size);
} }
mutable_db.modify( obj, [&]( auto& o ) { db.modify( obj, [&]( auto& o ) {
o.value.resize( buffer_size ); o.value.resize( buffer_size );
memcpy( o.value.data(), buffer, buffer_size ); memcpy( o.value.data(), buffer, buffer_size );
o.payer = payer; o.payer = payer;
...@@ -491,10 +492,10 @@ void apply_context::db_remove_i64( int iterator ) { ...@@ -491,10 +492,10 @@ void apply_context::db_remove_i64( int iterator ) {
update_db_usage( obj.payer, -(obj.value.size() + config::billable_size_v<key_value_object>) ); update_db_usage( obj.payer, -(obj.value.size() + config::billable_size_v<key_value_object>) );
mutable_db.modify( table_obj, [&]( auto& t ) { db.modify( table_obj, [&]( auto& t ) {
--t.count; --t.count;
}); });
mutable_db.remove( obj ); db.remove( obj );
if (table_obj.count == 0) { if (table_obj.count == 0) {
remove_table(table_obj); remove_table(table_obj);
...@@ -611,4 +612,22 @@ int apply_context::db_end_i64( uint64_t code, uint64_t scope, uint64_t table ) { ...@@ -611,4 +612,22 @@ int apply_context::db_end_i64( uint64_t code, uint64_t scope, uint64_t table ) {
return keyval_cache.cache_table( *tab ); return keyval_cache.cache_table( *tab );
} }
uint64_t apply_context::next_global_sequence() {
const auto& p = control.get_dynamic_global_properties();
db.modify( p, [&]( auto& dgp ) {
++dgp.global_action_sequence;
});
return p.global_action_sequence;
}
uint64_t apply_context::next_recv_sequence( account_name receiver ) {
return 0;
}
uint64_t apply_context::next_auth_sequence( account_name actor ) {
return 0;
}
} } /// eosio::chain } } /// eosio::chain
...@@ -25,7 +25,6 @@ namespace eosio { namespace chain { ...@@ -25,7 +25,6 @@ namespace eosio { namespace chain {
using resource_limits::resource_limits_manager; using resource_limits::resource_limits_manager;
abi_def eos_contract_abi(const abi_def& eosio_system_abi);
struct pending_state { struct pending_state {
pending_state( database::session&& s ) pending_state( database::session&& s )
...@@ -217,7 +216,7 @@ struct controller_impl { ...@@ -217,7 +216,7 @@ struct controller_impl {
a.privileged = true; a.privileged = true;
if( name == config::system_account_name ) { if( name == config::system_account_name ) {
a.set_abi(eos_contract_abi(abi_def())); a.set_abi(eosio_contract_abi(abi_def()));
} }
}); });
const auto& owner = db.create<permission_object>([&](permission_object& p) { const auto& owner = db.create<permission_object>([&](permission_object& p) {
...@@ -776,20 +775,6 @@ time_point controller::head_block_time()const { ...@@ -776,20 +775,6 @@ time_point controller::head_block_time()const {
return my->head->header.timestamp; return my->head->header.timestamp;
} }
uint64_t controller::next_global_sequence() {
const auto& p = get_dynamic_global_properties();
my->db.modify( p, [&]( auto& dgp ) {
++dgp.global_action_sequence;
});
return p.global_action_sequence;
}
uint64_t controller::next_recv_sequence( account_name receiver ) {
return 0;
}
uint64_t controller::next_auth_sequence( account_name actor ) {
return 0;
}
void controller::record_transaction( const transaction_metadata_ptr& trx ) { void controller::record_transaction( const transaction_metadata_ptr& trx ) {
my->record_transaction( trx ); my->record_transaction( trx );
} }
...@@ -853,286 +838,6 @@ void controller::pop_block() { ...@@ -853,286 +838,6 @@ void controller::pop_block() {
} }
abi_def eos_contract_abi(const abi_def& eosio_system_abi)
{
abi_def eos_abi(eosio_system_abi);
eos_abi.types.push_back( type_def{"account_name","name"} );
eos_abi.types.push_back( type_def{"table_name","name"} );
eos_abi.types.push_back( type_def{"share_type","int64"} );
eos_abi.types.push_back( type_def{"onerror","bytes"} );
eos_abi.types.push_back( type_def{"context_free_type","bytes"} );
eos_abi.types.push_back( type_def{"weight_type","uint16"} );
eos_abi.types.push_back( type_def{"fields","field[]"} );
eos_abi.types.push_back( type_def{"time_point_sec","time"} );
// TODO add ricardian contracts
eos_abi.actions.push_back( action_def{name("setcode"), "setcode",""} );
eos_abi.actions.push_back( action_def{name("setabi"), "setabi",""} );
eos_abi.actions.push_back( action_def{name("linkauth"), "linkauth",""} );
eos_abi.actions.push_back( action_def{name("unlinkauth"), "unlinkauth",""} );
eos_abi.actions.push_back( action_def{name("updateauth"), "updateauth",""} );
eos_abi.actions.push_back( action_def{name("deleteauth"), "deleteauth",""} );
eos_abi.actions.push_back( action_def{name("newaccount"), "newaccount",""} );
eos_abi.actions.push_back( action_def{name("postrecovery"), "postrecovery",""} );
eos_abi.actions.push_back( action_def{name("passrecovery"), "passrecovery",""} );
eos_abi.actions.push_back( action_def{name("vetorecovery"), "vetorecovery",""} );
eos_abi.actions.push_back( action_def{name("onerror"), "onerror",""} );
eos_abi.actions.push_back( action_def{name("onblock"), "onblock",""} );
eos_abi.actions.push_back( action_def{name("canceldelay"), "canceldelay",""} );
// TODO add any ricardian_clauses
//
// ACTION PAYLOADS
eos_abi.structs.emplace_back( struct_def {
"setcode", "", {
{"account", "account_name"},
{"vmtype", "uint8"},
{"vmversion", "uint8"},
{"code", "bytes"}
}
});
eos_abi.structs.emplace_back( struct_def {
"setabi", "", {
{"account", "account_name"},
{"abi", "abi_def"}
}
});
eos_abi.structs.emplace_back( struct_def {
"updateauth", "", {
{"account", "account_name"},
{"permission", "permission_name"},
{"parent", "permission_name"},
{"data", "authority"},
{"delay", "uint32"}
}
});
eos_abi.structs.emplace_back( struct_def {
"linkauth", "", {
{"account", "account_name"},
{"code", "account_name"},
{"type", "action_name"},
{"requirement", "permission_name"},
}
});
eos_abi.structs.emplace_back( struct_def {
"unlinkauth", "", {
{"account", "account_name"},
{"code", "account_name"},
{"type", "action_name"},
}
});
eos_abi.structs.emplace_back( struct_def {
"deleteauth", "", {
{"account", "account_name"},
{"permission", "permission_name"},
}
});
eos_abi.structs.emplace_back( struct_def {
"newaccount", "", {
{"creator", "account_name"},
{"name", "account_name"},
{"owner", "authority"},
{"active", "authority"},
{"recovery", "authority"},
}
});
eos_abi.structs.emplace_back( struct_def {
"postrecovery", "", {
{"account", "account_name"},
{"data", "authority"},
{"memo", "string"},
}
});
eos_abi.structs.emplace_back( struct_def {
"passrecovery", "", {
{"account", "account_name"},
}
});
eos_abi.structs.emplace_back( struct_def {
"vetorecovery", "", {
{"account", "account_name"},
}
});
eos_abi.structs.emplace_back( struct_def {
"canceldelay", "", {
{"trx_id", "transaction_id_type"},
}
});
// DATABASE RECORDS
eos_abi.structs.emplace_back( struct_def {
"pending_recovery", "", {
{"account", "name"},
{"request_id", "uint128"},
{"update", "updateauth"},
{"memo", "string"}
}
});
eos_abi.tables.emplace_back( table_def {
"recovery", "i64", {
"account",
}, {
"name"
},
"pending_recovery"
});
// abi_def fields
eos_abi.structs.emplace_back( struct_def {
"field", "", {
{"name", "field_name"},
{"type", "type_name"}
}
});
eos_abi.structs.emplace_back( struct_def {
"struct_def", "", {
{"name", "type_name"},
{"base", "type_name"},
{"fields", "fields"}
}
});
eos_abi.structs.emplace_back( struct_def {
"permission_level", "", {
{"actor", "account_name"},
{"permission", "permission_name"}
}
});
eos_abi.structs.emplace_back( struct_def {
"action", "", {
{"account", "account_name"},
{"name", "action_name"},
{"authorization", "permission_level[]"},
{"data", "bytes"}
}
});
eos_abi.structs.emplace_back( struct_def {
"permission_level_weight", "", {
{"permission", "permission_level"},
{"weight", "weight_type"}
}
});
eos_abi.structs.emplace_back( struct_def {
"transaction_header", "", {
{"expiration", "time_point_sec"},
{"region", "uint16"},
{"ref_block_num", "uint16"},
{"ref_block_prefix", "uint32"},
{"max_net_usage_words", "varuint32"},
{"max_kcpu_usage", "varuint32"},
{"delay_sec", "varuint32"}
}
});
eos_abi.structs.emplace_back( struct_def {
"transaction", "transaction_header", {
{"context_free_actions", "action[]"},
{"actions", "action[]"}
}
});
eos_abi.structs.emplace_back( struct_def {
"signed_transaction", "transaction", {
{"signatures", "signature[]"},
{"context_free_data", "bytes[]"}
}
});
eos_abi.structs.emplace_back( struct_def {
"key_weight", "", {
{"key", "public_key"},
{"weight", "weight_type"}
}
});
eos_abi.structs.emplace_back( struct_def {
"authority", "", {
{"threshold", "uint32"},
{"keys", "key_weight[]"},
{"accounts", "permission_level_weight[]"}
}
});
eos_abi.structs.emplace_back( struct_def {
"clause_pair", "", {
{"id", "string"},
{"body", "string"}
}
});
eos_abi.structs.emplace_back( struct_def {
"type_def", "", {
{"new_type_name", "type_name"},
{"type", "type_name"}
}
});
eos_abi.structs.emplace_back( struct_def {
"action_def", "", {
{"name", "action_name"},
{"type", "type_name"},
{"ricardian_contract", "string"}
}
});
eos_abi.structs.emplace_back( struct_def {
"table_def", "", {
{"name", "table_name"},
{"index_type", "type_name"},
{"key_names", "field_name[]"},
{"key_types", "type_name[]"},
{"type", "type_name"}
}
});
eos_abi.structs.emplace_back( struct_def {
"abi_def", "", {
{"types", "type_def[]"},
{"structs", "struct_def[]"},
{"actions", "action_def[]"},
{"tables", "table_def[]"},
{"ricardian_clauses", "clause_pair[]"}
}
});
eos_abi.structs.emplace_back( struct_def {
"block_header", "", {
{"previous", "checksum256"},
{"timestamp", "uint32"},
{"transaction_mroot", "checksum256"},
{"action_mroot", "checksum256"},
{"block_mroot", "checksum256"},
{"producer", "account_name"},
{"schedule_version", "uint32"},
{"new_producers", "producer_schedule?"}
}
});
eos_abi.structs.emplace_back( struct_def {
"onblock", "", {
{"header", "block_header"}
}
});
return eos_abi;
}
/** /**
* @param actions - the actions to check authorization across * @param actions - the actions to check authorization across
* @param provided_keys - the set of public keys which have authorized the transaction * @param provided_keys - the set of public keys which have authorized the transaction
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
namespace eosio { namespace chain { namespace eosio { namespace chain {
abi_def eos_contract_abi(const abi_def& eosio_system_abi);
uint128_t transaction_id_to_sender_id( const transaction_id_type& tid ) { uint128_t transaction_id_to_sender_id( const transaction_id_type& tid ) {
fc::uint128_t _id(tid._hash[3], tid._hash[2]); fc::uint128_t _id(tid._hash[3], tid._hash[2]);
...@@ -54,7 +53,7 @@ void apply_eosio_newaccount(apply_context& context) { ...@@ -54,7 +53,7 @@ void apply_eosio_newaccount(apply_context& context) {
EOS_ASSERT( validate(create.active), action_validate_exception, "Invalid active authority"); EOS_ASSERT( validate(create.active), action_validate_exception, "Invalid active authority");
EOS_ASSERT( validate(create.recovery), action_validate_exception, "Invalid recovery authority"); EOS_ASSERT( validate(create.recovery), action_validate_exception, "Invalid recovery authority");
auto& db = context.mutable_db; auto& db = context.db;
auto name_str = name(create.name).to_string(); auto name_str = name(create.name).to_string();
...@@ -111,7 +110,7 @@ void apply_eosio_newaccount(apply_context& context) { ...@@ -111,7 +110,7 @@ void apply_eosio_newaccount(apply_context& context) {
} FC_CAPTURE_AND_RETHROW( (create) ) } } FC_CAPTURE_AND_RETHROW( (create) ) }
void apply_eosio_setcode(apply_context& context) { void apply_eosio_setcode(apply_context& context) {
auto& db = context.mutable_db; auto& db = context.db;
auto& resources = context.mutable_controller.get_mutable_resource_limits_manager(); auto& resources = context.mutable_controller.get_mutable_resource_limits_manager();
auto act = context.act.data_as<setcode>(); auto act = context.act.data_as<setcode>();
context.require_authorization(act.account); context.require_authorization(act.account);
...@@ -154,7 +153,7 @@ void apply_eosio_setcode(apply_context& context) { ...@@ -154,7 +153,7 @@ void apply_eosio_setcode(apply_context& context) {
} }
void apply_eosio_setabi(apply_context& context) { void apply_eosio_setabi(apply_context& context) {
auto& db = context.mutable_db; auto& db = context.db;
auto& resources = context.mutable_controller.get_mutable_resource_limits_manager(); auto& resources = context.mutable_controller.get_mutable_resource_limits_manager();
auto act = context.act.data_as<setabi>(); auto act = context.act.data_as<setabi>();
...@@ -162,7 +161,7 @@ void apply_eosio_setabi(apply_context& context) { ...@@ -162,7 +161,7 @@ void apply_eosio_setabi(apply_context& context) {
// if system account append native abi // if system account append native abi
if ( act.account == eosio::chain::config::system_account_name ) { if ( act.account == eosio::chain::config::system_account_name ) {
act.abi = eos_contract_abi(act.abi); act.abi = eosio_contract_abi(act.abi);
} }
/// if an ABI is specified make sure it is well formed and doesn't /// if an ABI is specified make sure it is well formed and doesn't
/// reference any undefined types /// reference any undefined types
...@@ -190,7 +189,7 @@ void apply_eosio_updateauth(apply_context& context) { ...@@ -190,7 +189,7 @@ void apply_eosio_updateauth(apply_context& context) {
auto& resources = context.mutable_controller.get_mutable_resource_limits_manager(); auto& resources = context.mutable_controller.get_mutable_resource_limits_manager();
// context.require_write_lock( config::eosio_auth_scope ); // context.require_write_lock( config::eosio_auth_scope );
auto& db = context.mutable_db; auto& db = context.db;
auto update = context.act.data_as<updateauth>(); auto update = context.act.data_as<updateauth>();
EOS_ASSERT(!update.permission.empty(), action_validate_exception, "Cannot create authority with empty name"); EOS_ASSERT(!update.permission.empty(), action_validate_exception, "Cannot create authority with empty name");
...@@ -294,7 +293,7 @@ void apply_eosio_deleteauth(apply_context& context) { ...@@ -294,7 +293,7 @@ void apply_eosio_deleteauth(apply_context& context) {
EOS_ASSERT(remove.permission != config::active_name, action_validate_exception, "Cannot delete active authority"); EOS_ASSERT(remove.permission != config::active_name, action_validate_exception, "Cannot delete active authority");
EOS_ASSERT(remove.permission != config::owner_name, action_validate_exception, "Cannot delete owner authority"); EOS_ASSERT(remove.permission != config::owner_name, action_validate_exception, "Cannot delete owner authority");
auto& db = context.mutable_db; auto& db = context.db;
context.require_authorization(remove.account); context.require_authorization(remove.account);
// TODO/QUESTION: // TODO/QUESTION:
// Inconsistency between permissions that can be satisfied to create/modify (via updateauth) a permission and the // Inconsistency between permissions that can be satisfied to create/modify (via updateauth) a permission and the
...@@ -331,7 +330,7 @@ void apply_eosio_linkauth(apply_context& context) { ...@@ -331,7 +330,7 @@ void apply_eosio_linkauth(apply_context& context) {
context.require_authorization(requirement.account); context.require_authorization(requirement.account);
auto& db = context.mutable_db; auto& db = context.db;
const auto *account = db.find<account_object, by_name>(requirement.account); const auto *account = db.find<account_object, by_name>(requirement.account);
EOS_ASSERT(account != nullptr, account_query_exception, EOS_ASSERT(account != nullptr, account_query_exception,
"Failed to retrieve account: ${account}", ("account", requirement.account)); // Redundant? "Failed to retrieve account: ${account}", ("account", requirement.account)); // Redundant?
...@@ -371,7 +370,7 @@ void apply_eosio_linkauth(apply_context& context) { ...@@ -371,7 +370,7 @@ void apply_eosio_linkauth(apply_context& context) {
void apply_eosio_unlinkauth(apply_context& context) { void apply_eosio_unlinkauth(apply_context& context) {
auto& resources = context.mutable_controller.get_mutable_resource_limits_manager(); auto& resources = context.mutable_controller.get_mutable_resource_limits_manager();
auto& db = context.mutable_db; auto& db = context.db;
auto unlink = context.act.data_as<unlinkauth>(); auto unlink = context.act.data_as<unlinkauth>();
context.require_authorization(unlink.account); context.require_authorization(unlink.account);
...@@ -396,7 +395,7 @@ void apply_eosio_onerror(apply_context& context) { ...@@ -396,7 +395,7 @@ void apply_eosio_onerror(apply_context& context) {
static const abi_serializer& get_abi_serializer() { static const abi_serializer& get_abi_serializer() {
static optional<abi_serializer> _abi_serializer; static optional<abi_serializer> _abi_serializer;
if (!_abi_serializer) { if (!_abi_serializer) {
_abi_serializer.emplace(eos_contract_abi(abi_def())); _abi_serializer.emplace(eosio_contract_abi(abi_def()));
} }
return *_abi_serializer; return *_abi_serializer;
......
#include <eosio/chain/eosio_contract.hpp>
namespace eosio { namespace chain {
abi_def eosio_contract_abi(const abi_def& eosio_system_abi)
{
abi_def eos_abi(eosio_system_abi);
eos_abi.types.push_back( type_def{"account_name","name"} );
eos_abi.types.push_back( type_def{"table_name","name"} );
eos_abi.types.push_back( type_def{"share_type","int64"} );
eos_abi.types.push_back( type_def{"onerror","bytes"} );
eos_abi.types.push_back( type_def{"context_free_type","bytes"} );
eos_abi.types.push_back( type_def{"weight_type","uint16"} );
eos_abi.types.push_back( type_def{"fields","field[]"} );
eos_abi.types.push_back( type_def{"time_point_sec","time"} );
// TODO add ricardian contracts
eos_abi.actions.push_back( action_def{name("setcode"), "setcode",""} );
eos_abi.actions.push_back( action_def{name("setabi"), "setabi",""} );
eos_abi.actions.push_back( action_def{name("linkauth"), "linkauth",""} );
eos_abi.actions.push_back( action_def{name("unlinkauth"), "unlinkauth",""} );
eos_abi.actions.push_back( action_def{name("updateauth"), "updateauth",""} );
eos_abi.actions.push_back( action_def{name("deleteauth"), "deleteauth",""} );
eos_abi.actions.push_back( action_def{name("newaccount"), "newaccount",""} );
eos_abi.actions.push_back( action_def{name("postrecovery"), "postrecovery",""} );
eos_abi.actions.push_back( action_def{name("passrecovery"), "passrecovery",""} );
eos_abi.actions.push_back( action_def{name("vetorecovery"), "vetorecovery",""} );
eos_abi.actions.push_back( action_def{name("onerror"), "onerror",""} );
eos_abi.actions.push_back( action_def{name("onblock"), "onblock",""} );
eos_abi.actions.push_back( action_def{name("canceldelay"), "canceldelay",""} );
// TODO add any ricardian_clauses
//
// ACTION PAYLOADS
eos_abi.structs.emplace_back( struct_def {
"setcode", "", {
{"account", "account_name"},
{"vmtype", "uint8"},
{"vmversion", "uint8"},
{"code", "bytes"}
}
});
eos_abi.structs.emplace_back( struct_def {
"setabi", "", {
{"account", "account_name"},
{"abi", "abi_def"}
}
});
eos_abi.structs.emplace_back( struct_def {
"updateauth", "", {
{"account", "account_name"},
{"permission", "permission_name"},
{"parent", "permission_name"},
{"data", "authority"},
{"delay", "uint32"}
}
});
eos_abi.structs.emplace_back( struct_def {
"linkauth", "", {
{"account", "account_name"},
{"code", "account_name"},
{"type", "action_name"},
{"requirement", "permission_name"},
}
});
eos_abi.structs.emplace_back( struct_def {
"unlinkauth", "", {
{"account", "account_name"},
{"code", "account_name"},
{"type", "action_name"},
}
});
eos_abi.structs.emplace_back( struct_def {
"deleteauth", "", {
{"account", "account_name"},
{"permission", "permission_name"},
}
});
eos_abi.structs.emplace_back( struct_def {
"newaccount", "", {
{"creator", "account_name"},
{"name", "account_name"},
{"owner", "authority"},
{"active", "authority"},
{"recovery", "authority"},
}
});
eos_abi.structs.emplace_back( struct_def {
"postrecovery", "", {
{"account", "account_name"},
{"data", "authority"},
{"memo", "string"},
}
});
eos_abi.structs.emplace_back( struct_def {
"passrecovery", "", {
{"account", "account_name"},
}
});
eos_abi.structs.emplace_back( struct_def {
"vetorecovery", "", {
{"account", "account_name"},
}
});
eos_abi.structs.emplace_back( struct_def {
"canceldelay", "", {
{"trx_id", "transaction_id_type"},
}
});
// DATABASE RECORDS
eos_abi.structs.emplace_back( struct_def {
"pending_recovery", "", {
{"account", "name"},
{"request_id", "uint128"},
{"update", "updateauth"},
{"memo", "string"}
}
});
eos_abi.tables.emplace_back( table_def {
"recovery", "i64", {
"account",
}, {
"name"
},
"pending_recovery"
});
// abi_def fields
eos_abi.structs.emplace_back( struct_def {
"field", "", {
{"name", "field_name"},
{"type", "type_name"}
}
});
eos_abi.structs.emplace_back( struct_def {
"struct_def", "", {
{"name", "type_name"},
{"base", "type_name"},
{"fields", "fields"}
}
});
eos_abi.structs.emplace_back( struct_def {
"permission_level", "", {
{"actor", "account_name"},
{"permission", "permission_name"}
}
});
eos_abi.structs.emplace_back( struct_def {
"action", "", {
{"account", "account_name"},
{"name", "action_name"},
{"authorization", "permission_level[]"},
{"data", "bytes"}
}
});
eos_abi.structs.emplace_back( struct_def {
"permission_level_weight", "", {
{"permission", "permission_level"},
{"weight", "weight_type"}
}
});
eos_abi.structs.emplace_back( struct_def {
"transaction_header", "", {
{"expiration", "time_point_sec"},
{"region", "uint16"},
{"ref_block_num", "uint16"},
{"ref_block_prefix", "uint32"},
{"max_net_usage_words", "varuint32"},
{"max_kcpu_usage", "varuint32"},
{"delay_sec", "varuint32"}
}
});
eos_abi.structs.emplace_back( struct_def {
"transaction", "transaction_header", {
{"context_free_actions", "action[]"},
{"actions", "action[]"}
}
});
eos_abi.structs.emplace_back( struct_def {
"signed_transaction", "transaction", {
{"signatures", "signature[]"},
{"context_free_data", "bytes[]"}
}
});
eos_abi.structs.emplace_back( struct_def {
"key_weight", "", {
{"key", "public_key"},
{"weight", "weight_type"}
}
});
eos_abi.structs.emplace_back( struct_def {
"authority", "", {
{"threshold", "uint32"},
{"keys", "key_weight[]"},
{"accounts", "permission_level_weight[]"}
}
});
eos_abi.structs.emplace_back( struct_def {
"clause_pair", "", {
{"id", "string"},
{"body", "string"}
}
});
eos_abi.structs.emplace_back( struct_def {
"type_def", "", {
{"new_type_name", "type_name"},
{"type", "type_name"}
}
});
eos_abi.structs.emplace_back( struct_def {
"action_def", "", {
{"name", "action_name"},
{"type", "type_name"},
{"ricardian_contract", "string"}
}
});
eos_abi.structs.emplace_back( struct_def {
"table_def", "", {
{"name", "table_name"},
{"index_type", "type_name"},
{"key_names", "field_name[]"},
{"key_types", "type_name[]"},
{"type", "type_name"}
}
});
eos_abi.structs.emplace_back( struct_def {
"abi_def", "", {
{"types", "type_def[]"},
{"structs", "struct_def[]"},
{"actions", "action_def[]"},
{"tables", "table_def[]"},
{"ricardian_clauses", "clause_pair[]"}
}
});
eos_abi.structs.emplace_back( struct_def {
"block_header", "", {
{"previous", "checksum256"},
{"timestamp", "uint32"},
{"transaction_mroot", "checksum256"},
{"action_mroot", "checksum256"},
{"block_mroot", "checksum256"},
{"producer", "account_name"},
{"schedule_version", "uint32"},
{"new_producers", "producer_schedule?"}
}
});
eos_abi.structs.emplace_back( struct_def {
"onblock", "", {
{"header", "block_header"}
}
});
return eos_abi;
}
} } /// eosio::chain
...@@ -185,14 +185,14 @@ class apply_context { ...@@ -185,14 +185,14 @@ class apply_context {
const auto& tab = context.find_or_create_table( context.receiver, scope, table, payer ); const auto& tab = context.find_or_create_table( context.receiver, scope, table, payer );
const auto& obj = context.mutable_db.create<ObjectType>( [&]( auto& o ){ const auto& obj = context.db.create<ObjectType>( [&]( auto& o ){
o.t_id = tab.id; o.t_id = tab.id;
o.primary_key = id; o.primary_key = id;
secondary_key_helper_t::set(o.secondary_key, value); secondary_key_helper_t::set(o.secondary_key, value);
o.payer = payer; o.payer = payer;
}); });
context.mutable_db.modify( tab, [&]( auto& t ) { context.db.modify( tab, [&]( auto& t ) {
++t.count; ++t.count;
}); });
...@@ -211,10 +211,10 @@ class apply_context { ...@@ -211,10 +211,10 @@ class apply_context {
// context.require_write_lock( table_obj.scope ); // context.require_write_lock( table_obj.scope );
context.mutable_db.modify( table_obj, [&]( auto& t ) { context.db.modify( table_obj, [&]( auto& t ) {
--t.count; --t.count;
}); });
context.mutable_db.remove( obj ); context.db.remove( obj );
if (table_obj.count == 0) { if (table_obj.count == 0) {
context.remove_table(table_obj); context.remove_table(table_obj);
...@@ -240,7 +240,7 @@ class apply_context { ...@@ -240,7 +240,7 @@ class apply_context {
context.update_db_usage( payer, +(billing_size) ); context.update_db_usage( payer, +(billing_size) );
} }
context.mutable_db.modify( obj, [&]( auto& o ) { context.db.modify( obj, [&]( auto& o ) {
secondary_key_helper_t::set(o.secondary_key, secondary); secondary_key_helper_t::set(o.secondary_key, secondary);
o.payer = payer; o.payer = payer;
}); });
...@@ -457,7 +457,6 @@ class apply_context { ...@@ -457,7 +457,6 @@ class apply_context {
db(con.db()), db(con.db()),
act(a), act(a),
mutable_controller(con), mutable_controller(con),
mutable_db(con.db()),
used_authorizations(act.authorization.size(), false), used_authorizations(act.authorization.size(), false),
trx_meta(trx_meta), trx_meta(trx_meta),
idx64(*this), idx64(*this),
...@@ -512,8 +511,8 @@ class apply_context { ...@@ -512,8 +511,8 @@ class apply_context {
const bytes& get_packed_transaction(); const bytes& get_packed_transaction();
controller& control; controller& control;
const chainbase::database& db; ///< database where state is stored chainbase::database& db; ///< database where state is stored
const action& act; ///< message being applied const action& act; ///< message being applied
account_name receiver; ///< the code that is currently running account_name receiver; ///< the code that is currently running
bool privileged = false; bool privileged = false;
...@@ -521,7 +520,6 @@ class apply_context { ...@@ -521,7 +520,6 @@ class apply_context {
bool used_context_free_api = false; bool used_context_free_api = false;
controller& mutable_controller; controller& mutable_controller;
chainbase::database& mutable_db;
///< Parallel to act.authorization; tracks which permissions have been used while processing the message ///< Parallel to act.authorization; tracks which permissions have been used while processing the message
...@@ -588,6 +586,12 @@ class apply_context { ...@@ -588,6 +586,12 @@ class apply_context {
uint64_t cpu_usage; uint64_t cpu_usage;
uint64_t total_cpu_usage; uint64_t total_cpu_usage;
uint64_t next_global_sequence();
uint64_t next_recv_sequence( account_name receiver );
uint64_t next_auth_sequence( account_name actor );
private: private:
iterator_cache<key_value_object> keyval_cache; iterator_cache<key_value_object> keyval_cache;
......
...@@ -90,9 +90,6 @@ namespace eosio { namespace chain { ...@@ -90,9 +90,6 @@ namespace eosio { namespace chain {
block_state_ptr head_block_state()const; block_state_ptr head_block_state()const;
block_state_ptr pending_block_state()const; block_state_ptr pending_block_state()const;
uint64_t next_global_sequence();
uint64_t next_recv_sequence( account_name receiver );
uint64_t next_auth_sequence( account_name actor );
void record_transaction( const transaction_metadata_ptr& trx ); void record_transaction( const transaction_metadata_ptr& trx );
const account_object& get_account( account_name n )const; const account_object& get_account( account_name n )const;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#pragma once #pragma once
#include <eosio/chain/types.hpp> #include <eosio/chain/types.hpp>
#include <eosio/chain/contract_types.hpp>
namespace eosio { namespace chain { namespace eosio { namespace chain {
...@@ -31,5 +32,7 @@ namespace eosio { namespace chain { ...@@ -31,5 +32,7 @@ namespace eosio { namespace chain {
void apply_eosio_canceldelay(apply_context&); void apply_eosio_canceldelay(apply_context&);
///@} end action handlers ///@} end action handlers
abi_def eosio_contract_abi(const abi_def& eosio_system_abi);
} } /// namespace eosio::chain } } /// namespace eosio::chain
...@@ -167,7 +167,7 @@ class privileged_api : public context_aware_api { ...@@ -167,7 +167,7 @@ class privileged_api : public context_aware_api {
datastream<const char*> ds( packed_blockchain_parameters, datalen ); datastream<const char*> ds( packed_blockchain_parameters, datalen );
chain::chain_config cfg; chain::chain_config cfg;
fc::raw::unpack(ds, cfg); fc::raw::unpack(ds, cfg);
context.mutable_db.modify( context.control.get_global_properties(), context.db.modify( context.control.get_global_properties(),
[&]( auto& gprops ) { [&]( auto& gprops ) {
gprops.configuration = cfg; gprops.configuration = cfg;
}); });
...@@ -179,7 +179,7 @@ class privileged_api : public context_aware_api { ...@@ -179,7 +179,7 @@ class privileged_api : public context_aware_api {
void set_privileged( account_name n, bool is_priv ) { void set_privileged( account_name n, bool is_priv ) {
const auto& a = context.db.get<account_object, by_name>( n ); const auto& a = context.db.get<account_object, by_name>( n );
context.mutable_db.modify( a, [&]( auto& ma ){ context.db.modify( a, [&]( auto& ma ){
ma.privileged = is_priv; ma.privileged = is_priv;
}); });
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册