Skip to content

Commit cc9decf

Browse files
authored
Merge pull request #5550 from EOSIO/release/1.2.x
Version 1.2.4
2 parents e87d245 + 0e8dd01 commit cc9decf

File tree

14 files changed

+208
-28
lines changed

14 files changed

+208
-28
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 4)
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.4 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.4 --build-arg branch=v1.2.4 .
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.

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/include/eosio/chain/abi_serializer.hpp

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

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

libraries/chainbase

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool
11121112
} else {
11131113
// attempt to apply any pending incoming transactions
11141114
_incoming_trx_weight = 0.0;
1115-
if (orig_pending_txn_size && _pending_incoming_transactions.size()) {
1115+
while (orig_pending_txn_size && _pending_incoming_transactions.size()) {
11161116
auto e = _pending_incoming_transactions.front();
11171117
_pending_incoming_transactions.pop_front();
11181118
--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
@@ -596,7 +596,7 @@ launcher_def::initialize (const variables_map &vmap) {
596596

597597
stage = bfs::path(erd);
598598
if (!bfs::exists(stage)) {
599-
cerr << erd << " is not a valid path" << endl;
599+
cerr << "\"" << erd << "\" is not a valid path. Please ensure environment variable EOSIO_HOME is set to the build path." << endl;
600600
exit (-1);
601601
}
602602
stage /= bfs::path("staging");

tests/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ set( CMAKE_CXX_STANDARD 14 )
1313

1414
include_directories("${CMAKE_SOURCE_DIR}/plugins/wallet_plugin/include")
1515

16-
file(GLOB UNIT_TESTS "wallet_tests.cpp")
16+
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 exchange proxy identity identity_test stltest infinite eosio.system eosio.token eosio.bios test.inline multi_index_test noop dice eosio.msig)
2325

2426
#

tests/Cluster.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,13 @@ def launch(self, pnodes=1, totalNodes=1, prodCount=1, topo="mesh", p2pPlugin="ne
118118
assert(isinstance(totalProducers, (str,int)))
119119
producerFlag="--producers %s" % (totalProducers)
120120

121-
if not Cluster.arePortsAvailable(set(range(self.port, self.port+totalNodes+1))):
122-
Utils.Print("ERROR: Another process is listening on nodeos default port.")
123-
return False
121+
tries = 30
122+
while not Cluster.arePortsAvailable(set(range(self.port, self.port+totalNodes+1))):
123+
Utils.Print("ERROR: Another process is listening on nodeos default port. wait...")
124+
if tries == 0:
125+
return False
126+
tries = tries - 1
127+
time.sleep(2)
124128

125129
cmd="%s -p %s -n %s -s %s -d %s -i %s -f --p2p-plugin %s %s" % (
126130
Utils.EosLauncherPath, pnodes, totalNodes, topo, delay, datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3],
@@ -147,7 +151,7 @@ def launch(self, pnodes=1, totalNodes=1, prodCount=1, topo="mesh", p2pPlugin="ne
147151
s=" ".join(cmdArr)
148152
if Utils.Debug: Utils.Print("cmd: %s" % (s))
149153
if 0 != subprocess.call(cmdArr):
150-
Utils.Print("ERROR: Launcher failed to launch.")
154+
Utils.Print("ERROR: Launcher failed to launch. failed cmd: %s" % (s))
151155
return False
152156

153157
self.nodes=list(range(totalNodes)) # placeholder for cleanup purposes only

tests/chain_plugin_tests.cpp

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#include <boost/test/unit_test.hpp>
2+
#include <boost/algorithm/string/predicate.hpp>
3+
4+
#include <eosio/testing/tester.hpp>
5+
#include <eosio/chain/abi_serializer.hpp>
6+
#include <eosio/chain/wasm_eosio_constraints.hpp>
7+
#include <eosio/chain/resource_limits.hpp>
8+
#include <eosio/chain/exceptions.hpp>
9+
#include <eosio/chain/wast_to_wasm.hpp>
10+
#include <eosio/chain_plugin/chain_plugin.hpp>
11+
12+
#include <asserter/asserter.wast.hpp>
13+
#include <asserter/asserter.abi.hpp>
14+
15+
#include <stltest/stltest.wast.hpp>
16+
#include <stltest/stltest.abi.hpp>
17+
18+
#include <noop/noop.wast.hpp>
19+
#include <noop/noop.abi.hpp>
20+
21+
#include <eosio.system/eosio.system.wast.hpp>
22+
#include <eosio.system/eosio.system.abi.hpp>
23+
24+
#include <fc/io/fstream.hpp>
25+
26+
#include <Runtime/Runtime.h>
27+
28+
#include <fc/variant_object.hpp>
29+
#include <fc/io/json.hpp>
30+
31+
#include <array>
32+
#include <utility>
33+
34+
#ifdef NON_VALIDATING_TEST
35+
#define TESTER tester
36+
#else
37+
#define TESTER validating_tester
38+
#endif
39+
40+
using namespace eosio;
41+
using namespace eosio::chain;
42+
using namespace eosio::testing;
43+
using namespace fc;
44+
45+
BOOST_AUTO_TEST_SUITE(chain_plugin_tests)
46+
47+
BOOST_FIXTURE_TEST_CASE( get_block_with_invalid_abi, TESTER ) try {
48+
produce_blocks(2);
49+
50+
create_accounts( {N(asserter)} );
51+
produce_block();
52+
53+
// setup contract and abi
54+
set_code(N(asserter), asserter_wast);
55+
set_abi(N(asserter), asserter_abi);
56+
produce_blocks(1);
57+
58+
auto resolver = [&,this]( const account_name& name ) -> optional<abi_serializer> {
59+
try {
60+
const auto& accnt = this->control->db().get<account_object,by_name>( name );
61+
abi_def abi;
62+
if (abi_serializer::to_abi(accnt.abi, abi)) {
63+
return abi_serializer(abi, abi_serializer_max_time);
64+
}
65+
return optional<abi_serializer>();
66+
} FC_RETHROW_EXCEPTIONS(error, "resolver failed at chain_plugin_tests::abi_invalid_type");
67+
};
68+
69+
// abi should be resolved
70+
BOOST_REQUIRE_EQUAL(true, resolver(N(asserter)).valid());
71+
72+
// make an action using the valid contract & abi
73+
variant pretty_trx = mutable_variant_object()
74+
("actions", variants({
75+
mutable_variant_object()
76+
("account", "asserter")
77+
("name", "procassert")
78+
("authorization", variants({
79+
mutable_variant_object()
80+
("actor", "asserter")
81+
("permission", name(config::active_name).to_string())
82+
}))
83+
("data", mutable_variant_object()
84+
("condition", 1)
85+
("message", "Should Not Assert!")
86+
)
87+
})
88+
);
89+
signed_transaction trx;
90+
abi_serializer::from_variant(pretty_trx, trx, resolver, abi_serializer_max_time);
91+
set_transaction_headers(trx);
92+
trx.sign( get_private_key( N(asserter), "active" ), control->get_chain_id() );
93+
push_transaction( trx );
94+
produce_blocks(1);
95+
96+
// retrieve block num
97+
uint32_t headnum = this->control->head_block_num();
98+
99+
char headnumstr[20];
100+
sprintf(headnumstr, "%d", headnum);
101+
chain_apis::read_only::get_block_params param{headnumstr};
102+
chain_apis::read_only plugin(*(this->control), fc::microseconds(INT_MAX));
103+
104+
// block should be decoded successfully
105+
std::string block_str = json::to_pretty_string(plugin.get_block(param));
106+
BOOST_TEST(block_str.find("procassert") != std::string::npos);
107+
BOOST_TEST(block_str.find("condition") != std::string::npos);
108+
BOOST_TEST(block_str.find("Should Not Assert!") != std::string::npos);
109+
BOOST_TEST(block_str.find("011253686f756c64204e6f742041737365727421") != std::string::npos); //action data
110+
111+
// set an invalid abi (int8->xxxx)
112+
std::string abi2 = asserter_abi;
113+
auto pos = abi2.find("int8");
114+
BOOST_TEST(pos != std::string::npos);
115+
abi2.replace(pos, 4, "xxxx");
116+
set_abi(N(asserter), abi2.c_str());
117+
produce_blocks(1);
118+
119+
// resolving the invalid abi result in exception
120+
BOOST_CHECK_THROW(resolver(N(asserter)), invalid_type_inside_abi);
121+
122+
// get the same block as string, results in decode failed(invalid abi) but not exception
123+
std::string block_str2 = json::to_pretty_string(plugin.get_block(param));
124+
BOOST_TEST(block_str2.find("procassert") != std::string::npos);
125+
BOOST_TEST(block_str2.find("condition") == std::string::npos); // decode failed
126+
BOOST_TEST(block_str2.find("Should Not Assert!") == std::string::npos); // decode failed
127+
BOOST_TEST(block_str2.find("011253686f756c64204e6f742041737365727421") != std::string::npos); //action data
128+
129+
} FC_LOG_AND_RETHROW() /// get_block_with_invalid_abi
130+
131+
BOOST_AUTO_TEST_SUITE_END()
132+

0 commit comments

Comments
 (0)