Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #5550 from EOSIO/release/1.2.x
Browse files Browse the repository at this point in the history
Version 1.2.4
  • Loading branch information
b1bart authored Sep 5, 2018
2 parents e87d245 + 0e8dd01 commit cc9decf
Show file tree
Hide file tree
Showing 14 changed files with 208 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set( CXX_STANDARD_REQUIRED ON)

set(VERSION_MAJOR 1)
set(VERSION_MINOR 2)
set(VERSION_PATCH 3)
set(VERSION_PATCH 4)

set( CLI_CLIENT_EXECUTABLE_NAME cleos )
set( NODE_EXECUTABLE_NAME nodeos )
Expand Down
4 changes: 2 additions & 2 deletions Docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ cd eos/Docker
docker build . -t eosio/eos
```

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:
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:

```bash
docker build -t eosio/eos:v1.2.3 --build-arg branch=v1.2.3 .
docker build -t eosio/eos:v1.2.4 --build-arg branch=v1.2.4 .
```

By default, the symbol in eosio.system is set to SYS. You can override this using the symbol argument while building the docker image.
Expand Down
6 changes: 5 additions & 1 deletion eosio_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
#
# https://github.com/EOSIO/eos/blob/master/LICENSE.txt
##########################################################################


if [ "$(id -u)" -ne 0 ]; then
printf "\n\tThis requires sudo. Please run with sudo.\n\n"
exit -1
fi

CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ "${CWD}" != "${PWD}" ]; then
Expand Down
7 changes: 6 additions & 1 deletion eosio_uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ if [ -d "/usr/local/eosio" ]; then
for binary in ${binaries[@]}; do
rm ${binary}
done
# Handle cleanup of directories created from installation
if [ "$1" == "--full" ]; then
if [ -d ~/Library/Application\ Support/eosio ]; then rm -rf ~/Library/Application\ Support/eosio; fi # Mac OS
if [ -d ~/.local/share/eosio ]; then rm -rf ~/.local/share/eosio; fi # Linux
fi
popd &> /dev/null
break;;
[Nn]* )
[Nn]* )
printf "\tAborting uninstall\n\n"
exit -1;;
esac
Expand Down
24 changes: 14 additions & 10 deletions libraries/chain/include/eosio/chain/abi_serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,25 @@ namespace impl {
mvo("name", act.name);
mvo("authorization", act.authorization);

auto abi = resolver(act.account);
if (abi.valid()) {
auto type = abi->get_action_type(act.name);
if (!type.empty()) {
try {
mvo( "data", abi->_binary_to_variant( type, act.data, recursion_depth, deadline, max_serialization_time ));
mvo("hex_data", act.data);
} catch(...) {
// any failure to serialize data, then leave as not serailzed
try {
auto abi = resolver(act.account);
if (abi.valid()) {
auto type = abi->get_action_type(act.name);
if (!type.empty()) {
try {
mvo( "data", abi->_binary_to_variant( type, act.data, recursion_depth, deadline, max_serialization_time ));
mvo("hex_data", act.data);
} catch(...) {
// any failure to serialize data, then leave as not serailzed
mvo("data", act.data);
}
} else {
mvo("data", act.data);
}
} else {
mvo("data", act.data);
}
} else {
} catch(...) {
mvo("data", act.data);
}
out(name, std::move(mvo));
Expand Down
2 changes: 1 addition & 1 deletion libraries/chainbase
Submodule chainbase updated 1 files
+23 −12 src/chainbase.cpp
2 changes: 1 addition & 1 deletion plugins/history_plugin/history_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ namespace eosio {
"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.")
;
cfg.add_options()
("filter-out,f", bpo::value<vector<string>>()->composing(),
("filter-out,F", bpo::value<vector<string>>()->composing(),
"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.")
;
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool
} else {
// attempt to apply any pending incoming transactions
_incoming_trx_weight = 0.0;
if (orig_pending_txn_size && _pending_incoming_transactions.size()) {
while (orig_pending_txn_size && _pending_incoming_transactions.size()) {
auto e = _pending_incoming_transactions.front();
_pending_incoming_transactions.pop_front();
--orig_pending_txn_size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <eosio/chain/transaction.hpp>
#include <eosio/wallet_plugin/wallet_api.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/interprocess/sync/file_lock.hpp>
#include <chrono>

namespace fc { class variant; }
Expand All @@ -24,11 +25,14 @@ class wallet_manager {
wallet_manager(wallet_manager&&) = delete;
wallet_manager& operator=(const wallet_manager&) = delete;
wallet_manager& operator=(wallet_manager&&) = delete;
~wallet_manager() = default;
~wallet_manager();

/// Set the path for location of wallet files.
/// @param p path to override default ./ location of wallet files.
void set_dir(const boost::filesystem::path& p) { dir = p; }
void set_dir(const boost::filesystem::path& p) {
dir = p;
initialize_lock();
}

/// Set the timeout for locking all wallets.
/// If set then after t seconds of inactivity then lock_all().
Expand Down Expand Up @@ -135,6 +139,10 @@ class wallet_manager {
std::chrono::seconds timeout = std::chrono::seconds::max(); ///< how long to wait before calling lock_all()
mutable timepoint_t timeout_time = timepoint_t::max(); ///< when to call lock_all()
boost::filesystem::path dir = ".";
boost::filesystem::path lock_path = dir / "wallet.lock";
std::unique_ptr<boost::interprocess::file_lock> wallet_dir_lock;

void initialize_lock();
};

} // namespace wallet
Expand Down
21 changes: 21 additions & 0 deletions plugins/wallet_plugin/wallet_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ wallet_manager::wallet_manager() {
#endif
}

wallet_manager::~wallet_manager() {
//not really required, but may spook users
if(wallet_dir_lock)
boost::filesystem::remove(lock_path);
}

void wallet_manager::set_timeout(const std::chrono::seconds& t) {
timeout = t;
auto now = std::chrono::system_clock::now();
Expand Down Expand Up @@ -269,5 +275,20 @@ void wallet_manager::own_and_use_wallet(const string& name, std::unique_ptr<wall
wallets.emplace(name, std::move(wallet));
}

void wallet_manager::initialize_lock() {
//This is technically somewhat racy in here -- if multiple keosd are in this function at once.
//I've considered that an acceptable tradeoff to maintain cross-platform boost constructs here
lock_path = dir / "wallet.lock";
{
std::ofstream x(lock_path.string());
EOS_ASSERT(!x.fail(), wallet_exception, "Failed to open wallet lock file at ${f}", ("f", lock_path.string()));
}
wallet_dir_lock = std::make_unique<boost::interprocess::file_lock>(lock_path.string().c_str());
if(!wallet_dir_lock->try_lock()) {
wallet_dir_lock.reset();
EOS_THROW(wallet_exception, "Failed to lock access to wallet directory; is another keosd running?");
}
}

} // namespace wallet
} // namespace eosio
2 changes: 1 addition & 1 deletion programs/eosio-launcher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ launcher_def::initialize (const variables_map &vmap) {

stage = bfs::path(erd);
if (!bfs::exists(stage)) {
cerr << erd << " is not a valid path" << endl;
cerr << "\"" << erd << "\" is not a valid path. Please ensure environment variable EOSIO_HOME is set to the build path." << endl;
exit (-1);
}
stage /= bfs::path("staging");
Expand Down
8 changes: 5 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ set( CMAKE_CXX_STANDARD 14 )

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

file(GLOB UNIT_TESTS "wallet_tests.cpp")
file(GLOB UNIT_TESTS "*.cpp")

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

target_include_directories( plugin_test PUBLIC ${CMAKE_SOURCE_DIR}/plugins/net_plugin/include )
target_include_directories( plugin_test PUBLIC
${CMAKE_SOURCE_DIR}/plugins/net_plugin/include
${CMAKE_SOURCE_DIR}/plugins/chain_plugin/include )
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)

#
Expand Down
12 changes: 8 additions & 4 deletions tests/Cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,13 @@ def launch(self, pnodes=1, totalNodes=1, prodCount=1, topo="mesh", p2pPlugin="ne
assert(isinstance(totalProducers, (str,int)))
producerFlag="--producers %s" % (totalProducers)

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

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

self.nodes=list(range(totalNodes)) # placeholder for cleanup purposes only
Expand Down
132 changes: 132 additions & 0 deletions tests/chain_plugin_tests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#include <boost/test/unit_test.hpp>
#include <boost/algorithm/string/predicate.hpp>

#include <eosio/testing/tester.hpp>
#include <eosio/chain/abi_serializer.hpp>
#include <eosio/chain/wasm_eosio_constraints.hpp>
#include <eosio/chain/resource_limits.hpp>
#include <eosio/chain/exceptions.hpp>
#include <eosio/chain/wast_to_wasm.hpp>
#include <eosio/chain_plugin/chain_plugin.hpp>

#include <asserter/asserter.wast.hpp>
#include <asserter/asserter.abi.hpp>

#include <stltest/stltest.wast.hpp>
#include <stltest/stltest.abi.hpp>

#include <noop/noop.wast.hpp>
#include <noop/noop.abi.hpp>

#include <eosio.system/eosio.system.wast.hpp>
#include <eosio.system/eosio.system.abi.hpp>

#include <fc/io/fstream.hpp>

#include <Runtime/Runtime.h>

#include <fc/variant_object.hpp>
#include <fc/io/json.hpp>

#include <array>
#include <utility>

#ifdef NON_VALIDATING_TEST
#define TESTER tester
#else
#define TESTER validating_tester
#endif

using namespace eosio;
using namespace eosio::chain;
using namespace eosio::testing;
using namespace fc;

BOOST_AUTO_TEST_SUITE(chain_plugin_tests)

BOOST_FIXTURE_TEST_CASE( get_block_with_invalid_abi, TESTER ) try {
produce_blocks(2);

create_accounts( {N(asserter)} );
produce_block();

// setup contract and abi
set_code(N(asserter), asserter_wast);
set_abi(N(asserter), asserter_abi);
produce_blocks(1);

auto resolver = [&,this]( const account_name& name ) -> optional<abi_serializer> {
try {
const auto& accnt = this->control->db().get<account_object,by_name>( name );
abi_def abi;
if (abi_serializer::to_abi(accnt.abi, abi)) {
return abi_serializer(abi, abi_serializer_max_time);
}
return optional<abi_serializer>();
} FC_RETHROW_EXCEPTIONS(error, "resolver failed at chain_plugin_tests::abi_invalid_type");
};

// abi should be resolved
BOOST_REQUIRE_EQUAL(true, resolver(N(asserter)).valid());

// make an action using the valid contract & abi
variant pretty_trx = mutable_variant_object()
("actions", variants({
mutable_variant_object()
("account", "asserter")
("name", "procassert")
("authorization", variants({
mutable_variant_object()
("actor", "asserter")
("permission", name(config::active_name).to_string())
}))
("data", mutable_variant_object()
("condition", 1)
("message", "Should Not Assert!")
)
})
);
signed_transaction trx;
abi_serializer::from_variant(pretty_trx, trx, resolver, abi_serializer_max_time);
set_transaction_headers(trx);
trx.sign( get_private_key( N(asserter), "active" ), control->get_chain_id() );
push_transaction( trx );
produce_blocks(1);

// retrieve block num
uint32_t headnum = this->control->head_block_num();

char headnumstr[20];
sprintf(headnumstr, "%d", headnum);
chain_apis::read_only::get_block_params param{headnumstr};
chain_apis::read_only plugin(*(this->control), fc::microseconds(INT_MAX));

// block should be decoded successfully
std::string block_str = json::to_pretty_string(plugin.get_block(param));
BOOST_TEST(block_str.find("procassert") != std::string::npos);
BOOST_TEST(block_str.find("condition") != std::string::npos);
BOOST_TEST(block_str.find("Should Not Assert!") != std::string::npos);
BOOST_TEST(block_str.find("011253686f756c64204e6f742041737365727421") != std::string::npos); //action data

// set an invalid abi (int8->xxxx)
std::string abi2 = asserter_abi;
auto pos = abi2.find("int8");
BOOST_TEST(pos != std::string::npos);
abi2.replace(pos, 4, "xxxx");
set_abi(N(asserter), abi2.c_str());
produce_blocks(1);

// resolving the invalid abi result in exception
BOOST_CHECK_THROW(resolver(N(asserter)), invalid_type_inside_abi);

// get the same block as string, results in decode failed(invalid abi) but not exception
std::string block_str2 = json::to_pretty_string(plugin.get_block(param));
BOOST_TEST(block_str2.find("procassert") != std::string::npos);
BOOST_TEST(block_str2.find("condition") == std::string::npos); // decode failed
BOOST_TEST(block_str2.find("Should Not Assert!") == std::string::npos); // decode failed
BOOST_TEST(block_str2.find("011253686f756c64204e6f742041737365727421") != std::string::npos); //action data

} FC_LOG_AND_RETHROW() /// get_block_with_invalid_abi

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit cc9decf

Please sign in to comment.