Merge branch 'master' into fee_refactor

This commit is contained in:
Daniel Larimer 2015-07-09 16:34:56 -04:00
commit 04b8820b3b
12 changed files with 13 additions and 421 deletions

View file

@ -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)

View file

@ -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() }
} }

View file

@ -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 <graphene/chain/db_reflect_cmp.hpp>
#include <graphene/chain/db_reflect_cmp_impl.hpp>
#include <graphene/chain/wild_object.hpp>
#include <graphene/db/object_database.hpp>
namespace graphene { namespace chain { namespace impl {
bool cmp_attr_impl(
const object& obj,
uint16_t field_num,
const vector<char>& lit,
uint8_t opc
)
{
${cmp_attr_impl_body}
}
} } } // graphene::chain::detail

View file

@ -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) ) }

View file

@ -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 <vector>
#include <graphene/db/object.hpp>
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<char>& lit,
uint8_t opc
);
}
} }

View file

@ -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 <fc/io/raw.hpp>
#include <cstdint>
#include <vector>
//
// 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<char>& 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<char>& b, uint8_t opc )
{
return _ser_eq_cmp( a, b, opc );
}
} } } // graphene::chain::detail

View file

@ -20,11 +20,12 @@
#include <fc/exception/exception.hpp>
#include <graphene/chain/protocol/protocol.hpp>
#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( \

View file

@ -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 <fc/exception/exception.hpp>
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

View file

@ -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 <graphene/net/stcp_socket.hpp>
#include <graphene/net/message.hpp>
#include <fc/exception/exception.hpp>
#include <graphene/db/level_map.hpp>
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> 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<chain_connection>
{
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<detail::chain_connection_impl> my;
};
} } // graphene::net

View file

@ -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 <graphene/net/stcp_socket.hpp>
#include <graphene/net/message.hpp>
#include <fc/exception/exception.hpp>
#include <graphene/db/level_map.hpp>
namespace graphene { namespace net {
namespace detail { class connection_impl; }
class connection;
struct message;
struct message_header;
typedef std::shared_ptr<connection> 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<connection>
{
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<detail::connection_impl> my;
};
} } // graphene::net

View file

@ -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 {

View file

@ -29,7 +29,6 @@
#include <graphene/chain/vesting_balance_object.hpp>
#include <graphene/chain/withdraw_permission_object.hpp>
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/db_reflect_cmp.hpp>
#include <fc/crypto/digest.hpp>