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

Merge branch 'master' into dan

......@@ -1297,7 +1297,12 @@ void chain_controller::update_last_irreversible_block()
return a->last_confirmed_block_num < b->last_confirmed_block_num;
});
uint32_t new_last_irreversible_block_num = producer_objs[offset]->last_confirmed_block_num - 1;
uint32_t new_last_irreversible_block_num = producer_objs[offset]->last_confirmed_block_num;
// TODO: right now the code cannot handle the head block being irreversible for reasons that are purely
// implementation details. We can and should remove this special case once the rest of the logic is fixed.
if (producer_objs.size() == 1) {
new_last_irreversible_block_num -= 1;
}
if (new_last_irreversible_block_num > dpo.last_irreversible_block_num) {
......
......@@ -116,6 +116,10 @@ void apply_eosio_setcode(apply_context& context) {
auto code_id = fc::sha256::hash( act.code.data(), act.code.size() );
// TODO: remove this compilation step in favor of validation without compilation
auto& code = context.mutable_controller.get_wasm_cache().checkout(code_id, act.code.data(), act.code.size());
context.mutable_controller.get_wasm_cache().checkin(code_id, code);
const auto& account = db.get<account_object,by_name>(act.account);
// wlog( "set code: ${size}", ("size",act.code.size()));
db.modify( account, [&]( auto& a ) {
......
......@@ -33,6 +33,7 @@ namespace eosio { namespace chain {
shared_producer_schedule_type& operator=( const producer_schedule_type& a ) {
version = a.version;
producers.clear();
producers.reserve( a.producers.size() );
for( const auto& p : a.producers )
producers.push_back(p);
......@@ -55,6 +56,7 @@ namespace eosio { namespace chain {
inline bool operator == ( const producer_schedule_type& a, const producer_schedule_type& b )
{
if( a.version != b.version ) return false;
if ( a.producers.size() != b.producers.size() ) return false;
for( uint32_t i = 0; i < a.producers.size(); ++i )
if( a.producers[i] != b.producers[i] ) return false;
return true;
......
......@@ -186,8 +186,10 @@ public:
{}
void addCall(const Module& module, Serialization::OutputStream& inByteStream)
void addCall(Module& module, Serialization::OutputStream& inByteStream)
{
// make sure the import is added
addImport(module);
OpcodeAndImm<CallImm>* encodedOperator = (OpcodeAndImm<CallImm>*)inByteStream.advance(sizeof(OpcodeAndImm<CallImm>));
encodedOperator->opcode = Opcode::call;
// checktime will be the last defined import
......@@ -217,11 +219,17 @@ public:
void addImport(Module& module)
{
const U32 functionTypeIndex = typeSlot;
module.functions.imports.push_back({{functionTypeIndex},std::move(u8"env"),std::move(u8"checktime")});
if (module.functions.imports.size() == 0 || module.functions.imports.back().exportName.compare(u8"checktime") != 0) {
if (typeSlot < 0) {
addTypeSlot(module);
}
const U32 functionTypeIndex = typeSlot;
module.functions.imports.push_back({{functionTypeIndex}, std::move(u8"env"), std::move(u8"checktime")});
}
}
void conditionallyAddCall(Opcode opcode, const ControlStructureImm& imm, const Module& module, Serialization::OutputStream& inByteStream)
void conditionallyAddCall(Opcode opcode, const ControlStructureImm& imm, Module& module, Serialization::OutputStream& inByteStream)
{
switch(opcode)
{
......@@ -234,7 +242,7 @@ public:
}
template<typename Imm>
void conditionallyAddCall(Opcode , const Imm& , const Module& , Serialization::OutputStream& )
void conditionallyAddCall(Opcode , const Imm& , Module& , Serialization::OutputStream& )
{
}
......@@ -270,12 +278,12 @@ private:
struct NoOpInjection
{
void addCall(const Module& , Serialization::OutputStream& ) {}
void addCall(Module& , Serialization::OutputStream& ) {}
void setTypeSlot(const Module& , ResultType , const std::vector<ValueType>& ) {}
void addTypeSlot(Module& ) {}
void addImport(Module& ) {}
template<typename Imm>
void conditionallyAddCall(Opcode , const Imm& , const Module& , Serialization::OutputStream& ) {}
void conditionallyAddCall(Opcode , const Imm& , Module& , Serialization::OutputStream& ) {}
void adjustIfFunctionIndex(Uptr& , ObjectKind ) {}
void adjustExportIndex(Module& ) {}
template<typename Imm>
......
......@@ -178,12 +178,12 @@ BOOST_AUTO_TEST_CASE( transfer_delegation ) { try {
("name", "transfer")
("authorization", variants({
mutable_variant_object()
("actor", "bart")
("actor", "dan")
("permission", name(config::active_name).to_string())
}))
("data", mutable_variant_object()
("from", "bart")
("to", "dan")
("from", "dan")
("to", "trust")
("quantity", amount)
("memo", "memo")
)
......
......@@ -58,12 +58,17 @@ BOOST_AUTO_TEST_SUITE(database_tests)
}
// Utility function to check expected irreversible block
auto calc_exp_last_irr_block_num = [&](uint32_t head_block_num) {
auto calc_exp_last_irr_block_num = [&](uint32_t head_block_num) -> uint32_t {
const global_property_object &gpo = test.control->get_global_properties();
const auto producers_size = gpo.active_producers.producers.size();
const auto min_producers = EOS_PERCENT(producers_size, config::irreversible_threshold_percent);
return head_block_num - (((min_producers - 1) * config::producer_repititions) + 1 +
(head_block_num % config::producer_repititions));
const auto max_reversible_rounds = EOS_PERCENT(producers_size, config::percent_100 - config::irreversible_threshold_percent);
if( max_reversible_rounds == 0) {
return head_block_num - 1;
} else {
const auto current_round = head_block_num / config::producer_repititions;
const auto irreversible_round = current_round - max_reversible_rounds;
return (irreversible_round + 1) * config::producer_repititions - 1;
}
};
// Check the last irreversible block number is set correctly
......
......@@ -522,33 +522,9 @@ BOOST_FIXTURE_TEST_CASE( memory_operators, tester ) try {
BOOST_CHECK_THROW(set_code(N(current_memory), current_memory_wast), eosio::chain::wasm_execution_error);
produce_blocks(1);
{
signed_transaction trx;
action act;
act.account = N(current_memory);
act.authorization = vector<permission_level>{{N(current_memory),config::active_name}};
trx.actions.push_back(act);
set_tapos(trx);
trx.sign(get_private_key( N(current_memory), "active" ), chain_id_type());
BOOST_CHECK_THROW(push_transaction(trx), fc::unhandled_exception);
}
produce_blocks(1);
set_code(N(current_memory), grow_memory_wast);
BOOST_CHECK_THROW(set_code(N(current_memory), grow_memory_wast), eosio::chain::wasm_execution_error);
produce_blocks(1);
{
signed_transaction trx;
action act;
act.account = N(current_memory);
act.authorization = vector<permission_level>{{N(current_memory),config::active_name}};
trx.actions.push_back(act);
set_tapos(trx);
trx.sign(get_private_key( N(current_memory), "active" ), chain_id_type());
BOOST_CHECK_THROW(push_transaction(trx), fc::unhandled_exception);
produce_blocks(1);
}
} FC_LOG_AND_RETHROW()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册