提交 feb3a778 编写于 作者: B Bill Hamilton

Merge branch 'master' into eosio_build_darwin

Merging master prior to latest eosio_build_darwin PR
......@@ -108,7 +108,7 @@ extern "C" {
/**
* Send an inline action in the context of this action's parent transaction
* @param serialized_action - serialized action
* @param serialized_action - serialized action
* @param size - size of serialized action in bytes
*/
void send_inline(char *serialized_action, size_t size);
......@@ -147,5 +147,12 @@ extern "C" {
* @return the account which specifies the sender of the action
*/
account_name current_sender();
/**
* Get the current receiver of the action
* @brief Get the current receiver of the action
* @return the account which specifies the current receiver of the action
*/
account_name current_receiver();
///@ } actioncapi
}
此差异已折叠。
......@@ -1486,20 +1486,25 @@ void chain_controller::update_global_properties(const signed_block& b) { try {
}
});
auto active_producers_authority = authority(config::producers_authority_threshold, {}, {});
for(auto& name : gpo.active_producers.producers ) {
active_producers_authority.accounts.push_back({{name.producer_name, config::active_name}, 1});
}
auto& po = _db.get<permission_object, by_owner>( boost::make_tuple(config::producers_account_name,
config::active_name ) );
_db.modify(po,[active_producers_authority] (permission_object& po) {
po.auth = active_producers_authority;
});
_update_producers_authority();
}
} FC_CAPTURE_AND_RETHROW() }
void chain_controller::_update_producers_authority() {
const auto& gpo = get_global_properties();
uint32_t authority_threshold = EOS_PERCENT_CEIL(gpo.active_producers.producers.size(), config::producers_authority_threshold_pct);
auto active_producers_authority = authority(authority_threshold, {}, {});
for(auto& name : gpo.active_producers.producers ) {
active_producers_authority.accounts.push_back({{name.producer_name, config::active_name}, 1});
}
auto& po = _db.get<permission_object, by_owner>( boost::make_tuple(config::producers_account_name,
config::active_name ) );
_db.modify(po,[active_producers_authority] (permission_object& po) {
po.auth = active_producers_authority;
});
}
void chain_controller::add_checkpoints( const flat_map<uint32_t,block_id_type>& checkpts ) {
for (const auto& i : checkpts)
_checkpoints[i.first] = i.second;
......@@ -1606,6 +1611,7 @@ void chain_controller::_initialize_chain(contracts::chain_initializer& starter)
_db.create<block_summary_object>([&](block_summary_object&) {});
starter.prepare_database(*this, _db);
_update_producers_authority();
});
}
} FC_CAPTURE_AND_RETHROW() }
......
......@@ -391,7 +391,7 @@ void chain_initializer::prepare_database( chain_controller& chain,
};
auto empty_authority = authority(0, {}, {});
auto active_producers_authority = authority(config::producers_authority_threshold, {}, {});
auto active_producers_authority = authority(0, {}, {});
active_producers_authority.accounts.push_back({{config::system_account_name, config::active_name}, 1});
create_special_account(config::nobody_account_name, empty_authority, empty_authority);
......
......@@ -345,6 +345,7 @@ namespace eosio { namespace chain {
/// Reset the object graph in-memory
void _initialize_indexes();
void _initialize_chain(contracts::chain_initializer& starter);
void _update_producers_authority();
producer_schedule_type _calculate_producer_schedule()const;
const shared_producer_schedule_type& _head_producer_schedule()const;
......
......@@ -58,9 +58,10 @@ const static uint16_t default_max_inline_depth = 4;
const static uint32_t default_max_inline_action_size = 4 * 1024;
const static uint32_t default_max_gen_trx_size = 64 * 1024; ///
const static uint32_t default_max_gen_trx_count = 16; ///< the number of generated transactions per action
const static uint32_t producers_authority_threshold = 14;
const static uint32_t rate_limiting_precision = 1000*1000;
const static uint32_t producers_authority_threshold_pct = 66 * config::percent_1;
const static uint16_t max_recursion_depth = 6;
const static uint32_t default_base_per_transaction_net_usage = 100; // 100 bytes minimum (for signature and misc overhead)
......@@ -108,3 +109,8 @@ template<typename Number>
Number EOS_PERCENT(Number value, uint32_t percentage) {
return value * percentage / eosio::chain::config::percent_100;
}
template<typename Number>
Number EOS_PERCENT_CEIL(Number value, uint32_t percentage) {
return ((value * percentage) + eosio::chain::config::percent_100 - eosio::chain::config::percent_1) / eosio::chain::config::percent_100;
}
......@@ -835,6 +835,10 @@ class action_api : public context_aware_api {
return name();
}
}
name current_receiver() {
return context.receiver;
}
};
class console_api : public context_aware_api {
......@@ -1542,6 +1546,7 @@ REGISTER_INTRINSICS(action_api,
(action_data_size, int() )
(publication_time, int32_t() )
(current_sender, int64_t() )
(current_receiver, int64_t() )
);
REGISTER_INTRINSICS(apply_context,
......
......@@ -823,20 +823,22 @@ int main( int argc, char** argv ) {
std::string wast;
std::cout << localized("Reading WAST...") << std::endl;
fc::path cpath(contractPath);
if( cpath.filename().generic_string() == "." ) cpath = cpath.parent_path();
if( wastPath == string() )
if( wastPath.empty() )
{
wastPath = (cpath / (cpath.filename().generic_string()+".wast")).generic_string();
}
if( abiPath == string() )
if( abiPath.empty() )
{
abiPath = (cpath / (cpath.filename().generic_string()+".abi")).generic_string();
}
fc::read_file_contents(wastPath, wast);
FC_ASSERT( !wast.empty(), "no wast file found ${f}", ("f", wastPath) );
vector<uint8_t> wasm;
const string binary_wasm_header("\x00\x61\x73\x6d", 4);
if(wast.compare(0, 4, binary_wasm_header) == 0) {
......
......@@ -107,7 +107,7 @@
printf "\tInstalling CMAKE\n"
mkdir -p ${HOME}/opt/ 2>/dev/null
cd ${HOME}/opt
STATUS=$(curl -LO -w '%{http_code}' https://cmake.org/files/v3.10/cmake-3.10.2.tar.gz)
STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 https://cmake.org/files/v3.10/cmake-3.10.2.tar.gz)
if [ $STATUS -ne 200 ]; then
printf "\tUnable to download CMAKE at this time.\n"
printf "\tExiting now.\n\n"
......@@ -137,7 +137,7 @@
if [ ! -d ${HOME}/opt/boost_1_66_0 ]; then
printf "\tInstalling boost libraries.\n"
cd ${TEMP_DIR}
STATUS=$(curl -LO -w '%{http_code}' https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.bz2)
STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.bz2)
if [ $STATUS -ne 200 ]; then
printf "\tUnable to download Boost libraries at this time.\n"
printf "\tExiting now.\n\n"
......@@ -157,7 +157,7 @@
if [ ! -e ${MONGOD_CONF} ]; then
printf "\n\tInstalling MongoDB 3.6.3.\n"
cd ${HOME}/opt
STATUS=$(curl -LO -w '%{http_code}' https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-3.6.3.tgz)
STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-3.6.3.tgz)
if [ $STATUS -ne 200 ]; then
printf "\tUnable to download MongoDB at this time.\n"
printf "\tExiting now.\n\n"
......@@ -190,7 +190,7 @@ mongodconf
printf "\n\tChecking MongoDB C++ driver installation.\n"
if [ ! -e /usr/local/lib/libmongocxx-static.a ]; then
cd ${TEMP_DIR}
STATUS=$(curl -LO -w '%{http_code}' https://github.com/mongodb/mongo-c-driver/releases/download/1.9.3/mongo-c-driver-1.9.3.tar.gz)
STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 https://github.com/mongodb/mongo-c-driver/releases/download/1.9.3/mongo-c-driver-1.9.3.tar.gz)
if [ $STATUS -ne 200 ]; then
rm -f ${TEMP_DIR}/mongo-c-driver-1.9.3.tar.gz
printf "\tUnable to download MongoDB C driver at this time.\n"
......@@ -284,32 +284,6 @@ mongodconf
printf "\tsecp256k1 found.\n"
fi
printf "\n\tChecking for SoftFloat\n"
if [ ! -d ${HOME}/opt/berkeley-softfloat-3 ]; then
cd ${TEMP_DIR}
mkdir softfloat
cd softfloat
git clone --depth 1 --single-branch --branch master https://github.com/ucb-bar/berkeley-softfloat-3.git
if [ $? -ne 0 ]; then
printf "\tUnable to clone repo SoftFloat @ https://github.com/ucb-bar/berkeley-softfloat-3.git.\n"
printf "\tExiting now.\n\n"
exit;
fi
cd berkeley-softfloat-3/build/Linux-x86_64-GCC
make -j${CPU_CORE} SPECIALIZE_TYPE="8086-SSE" SOFTFLOAT_OPS="-DSOFTFLOAT_ROUND_EVEN -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV32TO16 -DSOFTFLOAT_FAST_DIV64TO32"
if [ $? -ne 0 ]; then
printf "\tError compiling softfloat.\n"
printf "\tExiting now.\n\n"
exit;
fi
mkdir -p ${HOME}/opt/berkeley-softfloat-3
cp softfloat.a ${HOME}/opt/berkeley-softfloat-3/libsoftfloat.a
mv ${TEMP_DIR}/softfloat/berkeley-softfloat-3/source/include ${HOME}/opt/berkeley-softfloat-3/include
rm -rf ${TEMP_DIR}/softfloat
else
printf "\tsoftfloat found at /usr/local/berkeley-softfloat-3/.\n"
fi
printf "\n\tChecking LLVM with WASM support.\n"
if [ ! -d ${HOME}/opt/wasm/bin ]; then
printf "\tInstalling LLVM & WASM\n"
......
......@@ -104,7 +104,12 @@
# install boost
printf "\tInstalling boost libraries.\n"
cd ${TEMP_DIR}
curl -L https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.bz2 > boost_1.66.0.tar.bz2
STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.bz2)
if [ $STATUS -ne 200 ]; then
printf "\tUnable to download Boost libraries at this time.\n"
printf "\tExiting now.\n\n"
exit;
fi
tar xf boost_1.66.0.tar.bz2
cd boost_1_66_0/
./bootstrap.sh "--prefix=$BOOST_ROOT"
......@@ -119,8 +124,8 @@
if [ ! -e ${MONGOD_CONF} ]; then
printf "\n\tInstalling MongoDB 3.6.3.\n"
cd ${HOME}/opt
curl -OL https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.3.tgz
if [ $? -ne 0 ]; then
STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.3.tgz)
if [ $STATUS -ne 200 ]; then
printf "\tUnable to download MongoDB at this time.\n"
printf "\tExiting now.\n\n"
exit;
......@@ -153,9 +158,9 @@ mongodconf
if [ ! -e /usr/local/lib/libmongocxx-static.a ]; then
printf "\n\tInstalling MongoDB C & C++ drivers.\n"
cd ${TEMP_DIR}
curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/1.9.3/mongo-c-driver-1.9.3.tar.gz
if [ $? -ne 0 ]; then
rm -f ${TEMP_DIR}/mongo-c-driver-1.9.3.tar.gz 2>/dev/null
STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 https://github.com/mongodb/mongo-c-driver/releases/download/1.9.3/mongo-c-driver-1.9.3.tar.gz)
if [ $STATUS -ne 200 ]; then
rm -f ${TEMP_DIR}/mongo-c-driver-1.9.3.tar.gz
printf "\tUnable to download MongoDB C driver at this time.\n"
printf "\tExiting now.\n\n"
exit;
......@@ -222,6 +227,11 @@ mongodconf
printf "\tInstalling secp256k1-zkp (Cryptonomex branch)\n"
cd ${TEMP_DIR}
git clone https://github.com/cryptonomex/secp256k1-zkp.git
if [ $? -ne 0 ]; then
printf "\tUnable to clone repo secp256k1-zkp @ https://github.com/cryptonomex/secp256k1-zkp.git.\n"
printf "\tExiting now.\n\n"
exit;
fi
cd secp256k1-zkp
./autogen.sh
if [ $? -ne 0 ]; then
......@@ -250,8 +260,18 @@ mongodconf
mkdir llvm-compiler 2>/dev/null
cd llvm-compiler
git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git
if [ $? -ne 0 ]; then
printf "\tUnable to clone llvm repo @ https://github.com/llvm-mirror/llvm.git.\n"
printf "\tExiting now.\n\n"
exit;
fi
cd llvm/tools
git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git
if [ $? -ne 0 ]; then
printf "\tUnable to clone clang repo @ https://github.com/llvm-mirror/clang.git.\n"
printf "\tExiting now.\n\n"
exit;
fi
cd ..
mkdir build
cd build
......
......@@ -913,4 +913,46 @@ BOOST_AUTO_TEST_CASE(block_id_sig_independent)
BOOST_TEST(block_id_act_sig == block_id_othr_sig);
} FC_LOG_AND_RETHROW() }
// Test transaction signature chain_controller::get_required_keys
BOOST_AUTO_TEST_CASE(get_required_keys)
{ try {
validating_tester chain;
account_name a = N(kevin);
account_name creator = config::system_account_name;
signed_transaction trx;
authority owner_auth = authority( chain.get_public_key( a, "owner" ) );
// any transaction will do
trx.actions.emplace_back( std::vector<permission_level>{{creator,config::active_name}},
contracts::newaccount{
.creator = creator,
.name = a,
.owner = owner_auth,
.active = authority( chain.get_public_key( a, "active" ) ),
.recovery = authority( chain.get_public_key( a, "recovery" ) ),
});
chain.set_transaction_headers(trx);
BOOST_REQUIRE_THROW(chain.push_transaction(trx), tx_missing_sigs);
const auto priv_key_not_needed_1 = chain.get_private_key("alice", "blah");
const auto priv_key_not_needed_2 = chain.get_private_key("alice", "owner");
const auto priv_key_needed = chain.get_private_key(creator, "active");
flat_set<public_key_type> available_keys = { priv_key_not_needed_1.get_public_key(),
priv_key_not_needed_2.get_public_key(),
priv_key_needed.get_public_key() };
auto required_keys = chain.validating_node->get_required_keys(trx, available_keys);
BOOST_TEST( required_keys.size() == 1 );
BOOST_TEST( *required_keys.begin() == priv_key_needed.get_public_key() );
trx.sign( priv_key_needed, chain_id_type() );
chain.push_transaction(trx);
chain.produce_blocks();
} FC_LOG_AND_RETHROW() }
BOOST_AUTO_TEST_SUITE_END()
......@@ -54,7 +54,8 @@ BOOST_FIXTURE_TEST_CASE(accounts_exists, tester)
auto& gpo = chain1_db.get<global_property_object>();
const auto& producers_active_authority = chain1_db.get<permission_object, by_owner>(boost::make_tuple(config::producers_account_name, config::active_name));
BOOST_CHECK_EQUAL(producers_active_authority.auth.threshold, config::producers_authority_threshold);
auto expected_threshold = EOS_PERCENT_CEIL(gpo.active_producers.producers.size(), config::producers_authority_threshold_pct);
BOOST_CHECK_EQUAL(producers_active_authority.auth.threshold, expected_threshold);
BOOST_CHECK_EQUAL(producers_active_authority.auth.accounts.size(), gpo.active_producers.producers.size());
BOOST_CHECK_EQUAL(producers_active_authority.auth.keys.size(), 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册