Skip to content

Commit 2516366

Browse files
committed
Merge tag 'v1.2.5' into port/v1.2.4-and-v1.2.5
2 parents 45e609f + 08819aa commit 2516366

File tree

16 files changed

+269
-98
lines changed

16 files changed

+269
-98
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ set( CXX_STANDARD_REQUIRED ON)
2727

2828
set(VERSION_MAJOR 1)
2929
set(VERSION_MINOR 2)
30-
set(VERSION_PATCH 3)
30+
set(VERSION_PATCH 5)
3131

3232
set( CLI_CLIENT_EXECUTABLE_NAME cleos )
3333
set( NODE_EXECUTABLE_NAME nodeos )

Docker/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ cd eos/Docker
2020
docker build . -t eosio/eos
2121
```
2222

23-
The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v1.2.3 tag, you could do the following:
23+
The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v1.2.5 tag, you could do the following:
2424

2525
```bash
26-
docker build -t eosio/eos:v1.2.3 --build-arg branch=v1.2.3 .
26+
docker build -t eosio/eos:v1.2.5 --build-arg branch=v1.2.5 .
2727
```
2828

2929
By default, the symbol in eosio.system is set to SYS. You can override this using the symbol argument while building the docker image.

Docker/builder/Dockerfile

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,9 @@ RUN git clone --depth 1 --single-branch --branch release_40 https://github.com/l
5050
&& cmake --build build --target install \
5151
&& cd .. && rm -rf llvm
5252

53-
RUN wget https://github.com/WebAssembly/binaryen/archive/1.37.21.tar.gz -O - | tar -xz \
54-
&& cd binaryen-1.37.21 \
55-
&& cmake -H. -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release \
56-
&& cmake --build build --target install \
57-
&& cd .. && rm -rf binaryen-1.37.21
58-
5953
RUN git clone --depth 1 -b releases/v3.3 https://github.com/mongodb/mongo-cxx-driver \
6054
&& cd mongo-cxx-driver/build \
6155
&& cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. \
6256
&& make -j$(nproc) \
6357
&& make install \
6458
&& cd ../../ && rm -rf mongo-cxx-driver
65-
66-
RUN git clone --depth 1 --single-branch --branch master https://github.com/ucb-bar/berkeley-softfloat-3.git \
67-
&& cd berkeley-softfloat-3/build/Linux-x86_64-GCC \
68-
&& make -j${nproc} SPECIALIZE_TYPE="8086-SSE" SOFTFLOAT_OPS="-DSOFTFLOAT_ROUND_EVEN -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV32TO16 -DSOFTFLOAT_FAST_DIV64TO32" \
69-
&& mkdir -p /opt/berkeley-softfloat-3 && cp softfloat.a /opt/berkeley-softfloat-3/libsoftfloat.a \
70-
&& mv ../../source/include /opt/berkeley-softfloat-3/include && cd - && rm -rf berkeley-softfloat-3
71-
72-
ENV SOFTFLOAT_ROOT /opt/berkeley-softfloat-3

eosio_install.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929
#
3030
# https://github.com/EOSIO/eos/blob/master/LICENSE.txt
3131
##########################################################################
32-
32+
33+
if [ "$(id -u)" -ne 0 ]; then
34+
printf "\n\tThis requires sudo. Please run with sudo.\n\n"
35+
exit -1
36+
fi
3337

3438
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3539
if [ "${CWD}" != "${PWD}" ]; then

eosio_uninstall.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ if [ -d "/usr/local/eosio" ]; then
2626
for binary in ${binaries[@]}; do
2727
rm ${binary}
2828
done
29+
# Handle cleanup of directories created from installation
30+
if [ "$1" == "--full" ]; then
31+
if [ -d ~/Library/Application\ Support/eosio ]; then rm -rf ~/Library/Application\ Support/eosio; fi # Mac OS
32+
if [ -d ~/.local/share/eosio ]; then rm -rf ~/.local/share/eosio; fi # Linux
33+
fi
2934
popd &> /dev/null
3035
break;;
31-
[Nn]* )
36+
[Nn]* )
3237
printf "\tAborting uninstall\n\n"
3338
exit -1;;
3439
esac

libraries/chain/controller.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,10 @@ void controller::drop_unapplied_transaction(const transaction_metadata_ptr& trx)
17681768
my->unapplied_transactions.erase(trx->signed_id);
17691769
}
17701770

1771+
void controller::drop_all_unapplied_transactions() {
1772+
my->unapplied_transactions.clear();
1773+
}
1774+
17711775
vector<transaction_id_type> controller::get_scheduled_transactions() const {
17721776
const auto& idx = db().get_index<generated_transaction_multi_index,by_delay>();
17731777

libraries/chain/include/eosio/chain/abi_serializer.hpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,21 +288,25 @@ namespace impl {
288288
mvo("name", act.name);
289289
mvo("authorization", act.authorization);
290290

291-
auto abi = resolver(act.account);
292-
if (abi.valid()) {
293-
auto type = abi->get_action_type(act.name);
294-
if (!type.empty()) {
295-
try {
296-
mvo( "data", abi->_binary_to_variant( type, act.data, recursion_depth, deadline, max_serialization_time ));
297-
mvo("hex_data", act.data);
298-
} catch(...) {
299-
// any failure to serialize data, then leave as not serailzed
291+
try {
292+
auto abi = resolver(act.account);
293+
if (abi.valid()) {
294+
auto type = abi->get_action_type(act.name);
295+
if (!type.empty()) {
296+
try {
297+
mvo( "data", abi->_binary_to_variant( type, act.data, recursion_depth, deadline, max_serialization_time ));
298+
mvo("hex_data", act.data);
299+
} catch(...) {
300+
// any failure to serialize data, then leave as not serailzed
301+
mvo("data", act.data);
302+
}
303+
} else {
300304
mvo("data", act.data);
301305
}
302306
} else {
303307
mvo("data", act.data);
304308
}
305-
} else {
309+
} catch(...) {
306310
mvo("data", act.data);
307311
}
308312
out(name, std::move(mvo));

libraries/chain/include/eosio/chain/controller.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ namespace eosio { namespace chain {
108108
*/
109109
vector<transaction_metadata_ptr> get_unapplied_transactions() const;
110110
void drop_unapplied_transaction(const transaction_metadata_ptr& trx);
111+
void drop_all_unapplied_transactions();
111112

112113
/**
113114
* These transaction IDs represent transactions available in the head chain state as scheduled

plugins/history_plugin/history_plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ namespace eosio {
303303
"Track actions which match receiver:action:actor. Actor may be blank to include all. Action and Actor both blank allows all from Recieiver. Receiver may not be blank.")
304304
;
305305
cfg.add_options()
306-
("filter-out,f", bpo::value<vector<string>>()->composing(),
306+
("filter-out,F", bpo::value<vector<string>>()->composing(),
307307
"Do not track actions which match receiver:action:actor. Action and Actor both blank excludes all from Reciever. Actor blank excludes all from reciever:action. Receiver may not be blank.")
308308
;
309309
}

plugins/producer_plugin/producer_plugin.cpp

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ using transaction_id_with_expiry_index = multi_index_container<
8181
>
8282
>;
8383

84-
85-
8684
enum class pending_block_mode {
8785
producing,
8886
speculating
@@ -885,6 +883,13 @@ fc::time_point producer_plugin_impl::calculate_pending_block_time() const {
885883
return block_time;
886884
}
887885

886+
enum class tx_category {
887+
PERSISTED,
888+
UNEXPIRED_UNPERSISTED,
889+
EXPIRED,
890+
};
891+
892+
888893
producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool &last_block) {
889894
chain::controller& chain = app().get_plugin<chain_plugin>().chain();
890895

@@ -985,71 +990,66 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool
985990
try {
986991
size_t orig_pending_txn_size = _pending_incoming_transactions.size();
987992

988-
if (!persisted_by_expiry.empty() || _pending_block_mode == pending_block_mode::producing) {
989-
auto unapplied_trxs = chain.get_unapplied_transactions();
990-
991-
if (!persisted_by_expiry.empty()) {
992-
for (auto itr = unapplied_trxs.begin(); itr != unapplied_trxs.end(); ++itr) {
993-
const auto& trx = *itr;
994-
if (persisted_by_id.find(trx->id) != persisted_by_id.end()) {
995-
// this is a persisted transaction, push it into the block (even if we are speculating) with
996-
// no deadline as it has already passed the subjective deadlines once and we want to represent
997-
// the state of the chain including this transaction
998-
try {
999-
chain.push_transaction(trx, fc::time_point::maximum());
1000-
} catch ( const guard_exception& e ) {
1001-
app().get_plugin<chain_plugin>().handle_guard_exception(e);
1002-
return start_block_result::failed;
1003-
} FC_LOG_AND_DROP();
1004-
1005-
// remove it from further consideration as it is applied
1006-
*itr = nullptr;
1007-
}
1008-
}
1009-
}
1010-
1011-
if (_pending_block_mode == pending_block_mode::producing) {
1012-
for (const auto& trx : unapplied_trxs) {
1013-
if (block_time <= fc::time_point::now()) exhausted = true;
1014-
if (exhausted) {
1015-
break;
1016-
}
993+
// Processing unapplied transactions...
994+
//
995+
if (_producers.empty() && persisted_by_id.empty()) {
996+
// if this node can never produce and has no persisted transactions,
997+
// there is no need for unapplied transactions they can be dropped
998+
chain.drop_all_unapplied_transactions();
999+
} else {
1000+
std::vector<transaction_metadata_ptr> apply_trxs;
1001+
{ // derive appliable transactions from unapplied_transactions and drop droppable transactions
1002+
auto unapplied_trxs = chain.get_unapplied_transactions();
1003+
apply_trxs.reserve(unapplied_trxs.size());
10171004

1018-
if (!trx) {
1019-
// nulled in the loop above, skip it
1020-
continue;
1005+
auto calculate_transaction_category = [&](const transaction_metadata_ptr& trx) {
1006+
if (trx->packed_trx.expiration() < pbs->header.timestamp.to_time_point()) {
1007+
return tx_category::EXPIRED;
1008+
} else if (persisted_by_id.find(trx->id) != persisted_by_id.end()) {
1009+
return tx_category::PERSISTED;
1010+
} else {
1011+
return tx_category::UNEXPIRED_UNPERSISTED;
10211012
}
1013+
};
10221014

1023-
if (trx->packed_trx.expiration() < pbs->header.timestamp.to_time_point()) {
1024-
// expired, drop it
1015+
for (auto& trx: unapplied_trxs) {
1016+
auto category = calculate_transaction_category(trx);
1017+
if (category == tx_category::EXPIRED || (category == tx_category::UNEXPIRED_UNPERSISTED && _producers.empty())) {
10251018
chain.drop_unapplied_transaction(trx);
1026-
continue;
1019+
} else if (category == tx_category::PERSISTED || (category == tx_category::UNEXPIRED_UNPERSISTED && _pending_block_mode == pending_block_mode::producing)) {
1020+
apply_trxs.emplace_back(std::move(trx));
10271021
}
1022+
}
1023+
}
10281024

1029-
try {
1030-
auto deadline = fc::time_point::now() + fc::milliseconds(_max_transaction_time_ms);
1031-
bool deadline_is_subjective = false;
1032-
if (_max_transaction_time_ms < 0 || (_pending_block_mode == pending_block_mode::producing && block_time < deadline)) {
1033-
deadline_is_subjective = true;
1034-
deadline = block_time;
1035-
}
1025+
for (const auto& trx: apply_trxs) {
1026+
if (block_time <= fc::time_point::now()) exhausted = true;
1027+
if (exhausted) {
1028+
break;
1029+
}
10361030

1037-
auto trace = chain.push_transaction(trx, deadline);
1038-
if (trace->except) {
1039-
if (failure_is_subjective(*trace->except, deadline_is_subjective)) {
1040-
exhausted = true;
1041-
} else {
1042-
// this failed our configured maximum transaction time, we don't want to replay it
1043-
chain.drop_unapplied_transaction(trx);
1044-
}
1031+
try {
1032+
auto deadline = fc::time_point::now() + fc::milliseconds(_max_transaction_time_ms);
1033+
bool deadline_is_subjective = false;
1034+
if (_max_transaction_time_ms < 0 || (_pending_block_mode == pending_block_mode::producing && block_time < deadline)) {
1035+
deadline_is_subjective = true;
1036+
deadline = block_time;
1037+
}
1038+
1039+
auto trace = chain.push_transaction(trx, deadline);
1040+
if (trace->except) {
1041+
if (failure_is_subjective(*trace->except, deadline_is_subjective)) {
1042+
exhausted = true;
1043+
} else {
1044+
// this failed our configured maximum transaction time, we don't want to replay it
1045+
chain.drop_unapplied_transaction(trx);
10451046
}
1046-
} catch ( const guard_exception& e ) {
1047-
app().get_plugin<chain_plugin>().handle_guard_exception(e);
1048-
return start_block_result::failed;
1049-
} FC_LOG_AND_DROP();
1050-
}
1047+
}
1048+
} catch ( const guard_exception& e ) {
1049+
app().get_plugin<chain_plugin>().handle_guard_exception(e);
1050+
return start_block_result::failed;
1051+
} FC_LOG_AND_DROP();
10511052
}
1052-
10531053
}
10541054

10551055
if (_pending_block_mode == pending_block_mode::producing) {
@@ -1119,7 +1119,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool
11191119
} else {
11201120
// attempt to apply any pending incoming transactions
11211121
_incoming_trx_weight = 0.0;
1122-
if (orig_pending_txn_size && _pending_incoming_transactions.size()) {
1122+
while (orig_pending_txn_size && _pending_incoming_transactions.size()) {
11231123
auto e = _pending_incoming_transactions.front();
11241124
_pending_incoming_transactions.pop_front();
11251125
--orig_pending_txn_size;

plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_manager.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <eosio/chain/transaction.hpp>
77
#include <eosio/wallet_plugin/wallet_api.hpp>
88
#include <boost/filesystem/path.hpp>
9+
#include <boost/interprocess/sync/file_lock.hpp>
910
#include <chrono>
1011

1112
namespace fc { class variant; }
@@ -24,11 +25,14 @@ class wallet_manager {
2425
wallet_manager(wallet_manager&&) = delete;
2526
wallet_manager& operator=(const wallet_manager&) = delete;
2627
wallet_manager& operator=(wallet_manager&&) = delete;
27-
~wallet_manager() = default;
28+
~wallet_manager();
2829

2930
/// Set the path for location of wallet files.
3031
/// @param p path to override default ./ location of wallet files.
31-
void set_dir(const boost::filesystem::path& p) { dir = p; }
32+
void set_dir(const boost::filesystem::path& p) {
33+
dir = p;
34+
initialize_lock();
35+
}
3236

3337
/// Set the timeout for locking all wallets.
3438
/// If set then after t seconds of inactivity then lock_all().
@@ -135,6 +139,10 @@ class wallet_manager {
135139
std::chrono::seconds timeout = std::chrono::seconds::max(); ///< how long to wait before calling lock_all()
136140
mutable timepoint_t timeout_time = timepoint_t::max(); ///< when to call lock_all()
137141
boost::filesystem::path dir = ".";
142+
boost::filesystem::path lock_path = dir / "wallet.lock";
143+
std::unique_ptr<boost::interprocess::file_lock> wallet_dir_lock;
144+
145+
void initialize_lock();
138146
};
139147

140148
} // namespace wallet

plugins/wallet_plugin/wallet_manager.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ wallet_manager::wallet_manager() {
3333
#endif
3434
}
3535

36+
wallet_manager::~wallet_manager() {
37+
//not really required, but may spook users
38+
if(wallet_dir_lock)
39+
boost::filesystem::remove(lock_path);
40+
}
41+
3642
void wallet_manager::set_timeout(const std::chrono::seconds& t) {
3743
timeout = t;
3844
auto now = std::chrono::system_clock::now();
@@ -269,5 +275,20 @@ void wallet_manager::own_and_use_wallet(const string& name, std::unique_ptr<wall
269275
wallets.emplace(name, std::move(wallet));
270276
}
271277

278+
void wallet_manager::initialize_lock() {
279+
//This is technically somewhat racy in here -- if multiple keosd are in this function at once.
280+
//I've considered that an acceptable tradeoff to maintain cross-platform boost constructs here
281+
lock_path = dir / "wallet.lock";
282+
{
283+
std::ofstream x(lock_path.string());
284+
EOS_ASSERT(!x.fail(), wallet_exception, "Failed to open wallet lock file at ${f}", ("f", lock_path.string()));
285+
}
286+
wallet_dir_lock = std::make_unique<boost::interprocess::file_lock>(lock_path.string().c_str());
287+
if(!wallet_dir_lock->try_lock()) {
288+
wallet_dir_lock.reset();
289+
EOS_THROW(wallet_exception, "Failed to lock access to wallet directory; is another keosd running?");
290+
}
291+
}
292+
272293
} // namespace wallet
273294
} // namespace eosio

programs/eosio-launcher/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ launcher_def::initialize (const variables_map &vmap) {
619619

620620
stage = bfs::path(erd);
621621
if (!bfs::exists(stage)) {
622-
cerr << erd << " is not a valid path" << endl;
622+
cerr << "\"" << erd << "\" is not a valid path. Please ensure environment variable EOSIO_HOME is set to the build path." << endl;
623623
exit (-1);
624624
}
625625
stage /= bfs::path("staging");

tests/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ include_directories("${CMAKE_SOURCE_DIR}/plugins/wallet_plugin/include")
1515

1616
file(GLOB UNIT_TESTS "*.cpp")
1717

18-
add_executable( plugin_test ${UNIT_TESTS} ${WASM_UNIT_TESTS} main.cpp)
18+
add_executable( plugin_test ${UNIT_TESTS} ${WASM_UNIT_TESTS} )
1919
target_link_libraries( plugin_test eosio_testing eosio_chain chainbase eos_utilities chain_plugin wallet_plugin abi_generator fc ${PLATFORM_SPECIFIC_LIBS} )
2020

21-
target_include_directories( plugin_test PUBLIC ${CMAKE_SOURCE_DIR}/plugins/net_plugin/include )
21+
target_include_directories( plugin_test PUBLIC
22+
${CMAKE_SOURCE_DIR}/plugins/net_plugin/include
23+
${CMAKE_SOURCE_DIR}/plugins/chain_plugin/include )
2224
add_dependencies(plugin_test asserter test_api test_api_mem test_api_db test_api_multi_index proxy identity identity_test stltest infinite eosio.system eosio.token eosio.bios test.inline multi_index_test noop dice eosio.msig)
2325

2426
#

0 commit comments

Comments
 (0)