diff --git a/libraries/app/CMakeLists.txt b/libraries/app/CMakeLists.txt index 07d1d43b..4e798712 100644 --- a/libraries/app/CMakeLists.txt +++ b/libraries/app/CMakeLists.txt @@ -11,5 +11,5 @@ target_include_directories( graphene_app PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) if(MSVC) - set_source_files_properties( application.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) + set_source_files_properties( application.cpp api.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) endif(MSVC) diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index d692f5f0..00c59bf9 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -534,6 +534,6 @@ void database::init_genesis(const genesis_state_type& genesis_state) }); _undo_db.enable(); -} FC_CAPTURE_AND_RETHROW(()) } +} FC_CAPTURE_AND_RETHROW() } } } diff --git a/libraries/chain/db_reflect_cmp.tmpl b/libraries/chain/db_reflect_cmp.tmpl deleted file mode 100644 index c4522b10..00000000 --- a/libraries/chain/db_reflect_cmp.tmpl +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2015, Cryptonomex, Inc. - * All rights reserved. - * - * This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and - * the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification, - * are permitted until September 8, 2015, provided that the following conditions are met: - * - * 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -${generated_file_banner} - -/* -object_descriptor = ${object_descriptor} -*/ - -#include -#include -#include - -#include - -namespace graphene { namespace chain { namespace impl { - -bool cmp_attr_impl( - const object& obj, - uint16_t field_num, - const vector& lit, - uint8_t opc - ) -{ -${cmp_attr_impl_body} -} - -} } } // graphene::chain::detail diff --git a/libraries/chain/evaluator.cpp b/libraries/chain/evaluator.cpp index 94b00765..e4922858 100644 --- a/libraries/chain/evaluator.cpp +++ b/libraries/chain/evaluator.cpp @@ -91,24 +91,30 @@ database& generic_evaluator::db()const { return trx_state->db(); } operation_get_required_authorities( op, active_auths, owner_auths, other_auths ); for( auto id : active_auths ) + { GRAPHENE_ASSERT( verify_authority(id(db()), authority::active) || verify_authority(id(db()), authority::owner), tx_missing_active_auth, "missing required active authority ${id}", ("id", id)); + } for( auto id : owner_auths ) + { GRAPHENE_ASSERT( verify_authority(id(db()), authority::owner), tx_missing_owner_auth, "missing required owner authority ${id}", ("id", id)); + } for( const auto& auth : other_auths ) + { GRAPHENE_ASSERT( trx_state->check_authority(auth), tx_missing_other_auth, "missing required authority ${auth}", ("auth",auth)("sigs",trx_state->_sigs)); + } } FC_CAPTURE_AND_RETHROW( (op) ) } diff --git a/libraries/chain/include/graphene/chain/db_reflect_cmp.hpp b/libraries/chain/include/graphene/chain/db_reflect_cmp.hpp deleted file mode 100644 index b18f49c3..00000000 --- a/libraries/chain/include/graphene/chain/db_reflect_cmp.hpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015, Cryptonomex, Inc. - * All rights reserved. - * - * This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and - * the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification, - * are permitted until September 8, 2015, provided that the following conditions are met: - * - * 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include - -#include - -namespace graphene { namespace chain { - -enum comparison_opcode -{ - opc_equal_to, - opc_not_equal_to, - opc_greater, - opc_less, - opc_greater_equal, - opc_less_equal -}; - -namespace impl { - -/** - * Compare the given field of the given object to the literal string. - * The comparison opcode is specified by opc, which should be one - * of comparison_opcode. - * - * The default behavior is to only allow opc_equal_to or - * opc_not_equal_to, and implement these based on comparing the - * serialized field to the given bytes. - * - * To override the default behavior, provide a template override - * for _cmp() in db_reflect_cmp_impl.hpp. Beware adding such an - * override will create a witness-only hardfork! - */ -bool cmp_attr_impl( - const graphene::db::object& obj, - uint16_t field_num, - const std::vector& lit, - uint8_t opc - ); -} - -} } diff --git a/libraries/chain/include/graphene/chain/db_reflect_cmp_impl.hpp b/libraries/chain/include/graphene/chain/db_reflect_cmp_impl.hpp deleted file mode 100644 index 68450e25..00000000 --- a/libraries/chain/include/graphene/chain/db_reflect_cmp_impl.hpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2015, Cryptonomex, Inc. - * All rights reserved. - * - * This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and - * the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification, - * are permitted until September 8, 2015, provided that the following conditions are met: - * - * 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include - -#include -#include - -// -// This file implements the comparison used by the assert op. -// The entry point for comparison is _cmp(), it can be specialized for -// different types. The default implementation defers to _ser_eq_cmp() -// which only allows equality comparisons, and asserts -// - -namespace graphene { namespace chain { namespace impl { - -// useful for types which have all comparison ops implemented -template< typename T > -static bool _full_cmp( const T& a, const T& b, uint8_t opc ) -{ - switch( opc ) - { - case opc_equal_to: - return (a == b); - case opc_not_equal_to: - return (a != b); - case opc_greater: - return (a > b); - case opc_less: - return (a < b); - case opc_greater_equal: - return (a >= b); - case opc_less_equal: - return (a <= b); - default: - FC_ASSERT( false, "unknown comparison operator" ); - } -} - -// useful for types which have operator== implemented -template< typename T > -static bool _eq_cmp( const T& a, const T& b, uint8_t opc ) -{ - switch( opc ) - { - case opc_equal_to: - return (a == b); - case opc_not_equal_to: - return !(a == b); - default: - FC_ASSERT( false, "unknown comparison operator" ); - } -} - -// works for every serializable type -template< typename T > -static bool _ser_eq_cmp( const T& a, const std::vector& b, uint8_t opc ) -{ - std::vector< char > _a = fc::raw::pack( a ); - return _eq_cmp( _a, b, opc ); -} - -/* -static bool _cmp( const fc::sha224& a, const fc::sha224& b, uint8_t opc ) -{ - assert( a.data_size() == b.data_size() ); - int result = memcmp( a.data(), b.data(), a.data_size() ); - switch( opc ) - { - case opc_equal_to: - return (result == 0); - case opc_not_equal_to: - return (result != 0); - case opc_greater: - return (result > 0); - case opc_less: - return (result < 0); - case opc_greater_equal: - return (result >= 0); - case opc_less_equal: - return (result <= 0); - default: - FC_ASSERT( false, "unknown comparison operator" ); - } -} -*/ - -// _cmp needs to be specialized for types which don't have overloads -// for all comparison operators - -template< typename T > -static bool _cmp( const T& a, const std::vector& b, uint8_t opc ) -{ - return _ser_eq_cmp( a, b, opc ); -} - -} } } // graphene::chain::detail diff --git a/libraries/chain/include/graphene/chain/exceptions.hpp b/libraries/chain/include/graphene/chain/exceptions.hpp index 19ef93df..abc5a507 100644 --- a/libraries/chain/include/graphene/chain/exceptions.hpp +++ b/libraries/chain/include/graphene/chain/exceptions.hpp @@ -20,11 +20,12 @@ #include #include -#define GRAPHENE_ASSERT( expr, exc_type, ... ) \ +#define GRAPHENE_ASSERT( expr, exc_type, FORMAT, ... ) \ + FC_MULTILINE_MACRO_BEGIN \ if( !(expr) ) \ - { \ - FC_THROW_EXCEPTION( exc_type, __VA_ARGS__ ); \ - } + FC_THROW_EXCEPTION( exc_type, FORMAT, __VA_ARGS__ ); \ + FC_MULTILINE_MACRO_END + #define GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( op_name ) \ FC_DECLARE_DERIVED_EXCEPTION( \ diff --git a/libraries/db/include/graphene/db/exception.hpp b/libraries/db/include/graphene/db/exception.hpp deleted file mode 100644 index 0fdeed23..00000000 --- a/libraries/db/include/graphene/db/exception.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2015, Cryptonomex, Inc. - * All rights reserved. - * - * This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and - * the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification, - * are permitted until September 8, 2015, provided that the following conditions are met: - * - * 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#pragma once -#include - -namespace graphene { namespace db { - -FC_DECLARE_EXCEPTION( level_map_failure, 10000, "level_map failure" ); -FC_DECLARE_EXCEPTION( level_map_open_failure, 10001, "level_map open failure" ); - -FC_DECLARE_EXCEPTION( level_pod_map_failure, 11000, "level_pod_map failure" ); -FC_DECLARE_EXCEPTION( level_pod_map_open_failure, 11001, "level_pod_map open failure" ); - -} } // graphene::db diff --git a/libraries/net/include/graphene/net/chain_connection.hpp b/libraries/net/include/graphene/net/chain_connection.hpp deleted file mode 100644 index 5879d3c2..00000000 --- a/libraries/net/include/graphene/net/chain_connection.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2015, Cryptonomex, Inc. - * All rights reserved. - * - * This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and - * the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification, - * are permitted until September 8, 2015, provided that the following conditions are met: - * - * 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#pragma once -#include -#include -#include -#include - -using namespace graphene::blockchain; -using namespace graphene::net; - -namespace graphene { namespace net { - - namespace detail { class chain_connection_impl; } - - class chain_connection; - typedef std::shared_ptr chain_connection_ptr; - - /** - * @brief defines callback interface for chain_connections - */ - class chain_connection_delegate - { - public: - virtual ~chain_connection_delegate(){} - virtual void on_connection_message( chain_connection& c, const message& m ){} - virtual void on_connection_disconnected( chain_connection& c ){} - }; - - - - /** - * Manages a connection to a remote p2p node. A connection - * processes a stream of messages that have a common header - * and ensures everything is properly encrypted. - * - * A connection also allows arbitrary data to be attached to it - * for use by other protocols built at higher levels. - */ - class chain_connection : public std::enable_shared_from_this - { - public: - chain_connection( const stcp_socket_ptr& c, chain_connection_delegate* d); - chain_connection( chain_connection_delegate* d ); - ~chain_connection(); - - stcp_socket_ptr get_socket()const; - fc::ip::endpoint remote_endpoint()const; - - void send( const message& m ); - - void connect( const std::string& host_port ); - void connect( const fc::ip::endpoint& ep ); - void close(); - - graphene::blockchain::block_id_type get_last_block_id()const; - void set_last_block_id( const graphene::blockchain::block_id_type& t ); - - void exec_sync_loop(); - void set_database( graphene::blockchain::chain_database* ); - - private: - std::unique_ptr my; - }; - -} } // graphene::net diff --git a/libraries/net/include/graphene/net/connection.hpp b/libraries/net/include/graphene/net/connection.hpp deleted file mode 100644 index 03412096..00000000 --- a/libraries/net/include/graphene/net/connection.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2015, Cryptonomex, Inc. - * All rights reserved. - * - * This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and - * the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification, - * are permitted until September 8, 2015, provided that the following conditions are met: - * - * 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#pragma once -#include -#include -#include -#include - -namespace graphene { namespace net { - - namespace detail { class connection_impl; } - - class connection; - struct message; - struct message_header; - - typedef std::shared_ptr connection_ptr; - - /** - * @brief defines callback interface for connections - */ - class connection_delegate - { - public: - /** Called when given network connection has completed receiving a message and it is ready - for further processing. - */ - virtual void on_connection_message( connection& c, const message& m ) = 0; - /// Called when connection has been lost. - virtual void on_connection_disconnected( connection& c ) = 0; - - protected: - /// Only implementation is responsible for this object lifetime. - virtual ~connection_delegate() {} - }; - - - - /** - * Manages a connection to a remote p2p node. A connection - * processes a stream of messages that have a common header - * and ensures everything is properly encrypted. - * - * A connection also allows arbitrary data to be attached to it - * for use by other protocols built at higher levels. - */ - class connection : public std::enable_shared_from_this - { - public: - connection( const stcp_socket_ptr& c, connection_delegate* d); - connection( connection_delegate* d ); - ~connection(); - - stcp_socket_ptr get_socket()const; - fc::ip::endpoint remote_endpoint()const; - - void send( const message& m ); - - void connect( const std::string& host_port ); - void connect( const fc::ip::endpoint& ep ); - void close(); - - void exec_sync_loop(); - - private: - std::unique_ptr my; - }; - - -} } // graphene::net diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index 44af38f5..f3ebf58c 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -26,7 +26,6 @@ using namespace graphene::chain; BOOST_FIXTURE_TEST_SUITE( fee_tests, database_fixture ) -#define CORE uint64_t(GRAPHENE_BLOCKCHAIN_PRECISION) BOOST_AUTO_TEST_CASE( cashback_test ) { try { diff --git a/tests/tests/operation_tests2.cpp b/tests/tests/operation_tests2.cpp index 23d41831..82cb5675 100644 --- a/tests/tests/operation_tests2.cpp +++ b/tests/tests/operation_tests2.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include