Compare commits

...

84 commits

Author SHA1 Message Date
Nathaniel
f9fcffbb4d
Safety Check: Part 2 -- Implement and Integrate Checks
Implement a safety check mechanism on object_database, based on the
safety_check_policy abstract interface. Create two standard
implementations of the safety_check_policy interface, one
(null_safety_check) which allows all modifications unconditionally, and
the other (database_lock_safety_check) which allows modifications only
when unlocked.

Integrate these safety checks into chain::database and plugins, so that
the consensus databases are locked at all times except during core
consensus code pathways. Also ensures that databases are re-locked when
calling code outside of consensus pathways from consensus pathways.

To make this work, it was necessary to move two objects from the
consensus object spaces to a new API object space. The
operation_history_object and account_transaction_history_object were
moved to the API object space, as they are not actually used by
consensus and are maintained by a plugin (which can no longer modify the
consensus object spaces, due to the safety checks).

Finally, add a mechanism to application and chain::database, which
allows the chain to start in "unit testing mode" and allows unchecked
actions upon the database within delimited scopes. This was necessary
because many tests edit the database directly to set up the environment
for their respective tests. This mode is activated by database_fixture so
tests can utilize it conveniently, but it is architecturally difficult to
enable this mode in production, i.e. from a plugin.
2022-03-12 14:04:08 -06:00
Nathaniel
e8b432c19f
Safety Check: Part 1 -- Evaluator Tagging
Pursuant to the requested safety checks on the database, to ensure that
plugin code (i.e., third party code) cannot modify the database, we
implement evaluator tagging so the chain can distinguish between
consensus evaluators and third party evaluators. Also, define a new kind
of evaluator base class, third_party_evaluator, so that fees are not
charged multiple times for operations with multiple evaluators.

Next step, implement the actual safety check mechanism on the database.
2022-03-07 16:37:53 -06:00
Nathaniel
659d135b9b
Merge remote-tracking branch 'glu/develop' into dapp-support 2022-02-13 14:25:06 -06:00
Nathaniel
2da369453e
Merge branch 'develop' into dapp-support 2022-02-08 13:15:07 -06:00
Nathaniel
d2ced50bbf
Bump FC 2022-02-08 11:27:26 -06:00
serkixenos
c456d4ec6b
Update README.md 2022-02-08 11:26:34 -06:00
serkixenos
f46a223dce
Update README for Ubuntu 20.04 2022-02-08 11:26:34 -06:00
serkixenos
7c7f768ce4
Replace vulnerable XML library 2022-02-08 11:26:34 -06:00
Vlad Dobromyslov
3a7187baba
bug #245 exception seen in witness logs 2022-02-08 11:26:34 -06:00
Vlad Dobromyslov
45e501b916
Resolve "port ES changes from Bitshares" 2022-02-08 11:26:34 -06:00
Vlad Dobromyslov
62a553ab5f
bug #267 Fix error in chain_test in gitlab autobuild 2022-02-08 11:26:34 -06:00
serkixenos
8c402d2e70
Fix list_active_son command output on deregistered SONs 2022-02-08 11:26:34 -06:00
serkixenos
dcdf406a2d
Fix cli wallet memo displaying 2022-02-08 11:26:34 -06:00
Nathaniel Hourt
ee0d2b21e0
Fix build
In some environments, build fails here due to `curl` dependency not being linked in time for `utilities` to see it.
2022-01-29 16:21:13 -06:00
Nathaniel Hourt
2a37d8a0a1
Fix build
In some environments, this fails to build without this header.
2022-01-27 15:29:23 -06:00
Nathaniel
f667fda2e4
Merge remote-tracking branch 'origin/beatrice' into to-upstream 2022-01-26 13:16:02 -06:00
Nathaniel
d17eb5ec72
Add wallet command for custom_operation
Create a new cli_wallet command, run_custom_operation, which makes it
convenient to run custom_operation transactions which invoke third party
contracts (i.e., dapps)
2022-01-14 20:10:16 -06:00
Nathaniel
de87e1b82c
Canonicalize chain ID calculation
When using an external genesis file, it doesn't make sense to calculate
the chain ID as the literal text contents of the file, which are quite
volatile. Rather, it should be calculated based on the logical content
of the file. Serialize the genesis object to get a canonical
representation, and calculate the chain ID off of that.
2022-01-12 16:55:45 -06:00
Nathaniel
c833ca646f
Set CMAKE_INSTALL_RPATH for dynamic builds
When building dynamic libraries, set the RPATH so that binaries know
where to find their libraries.
2022-01-12 16:55:01 -06:00
Nathaniel
fe02a13685
Replace count_objects_in_space with inspect_all_indexes
The count_objects_in_space function, while providing the necessary
functionality, was clumsy and inconvenient, and was not idiomatic.
Replace it with inspect_all_indexes which resolves these shortcomings.
2022-01-05 17:27:52 -06:00
Nathaniel Hourt
25faf9b084
Merge pull request #2 from MichelSantos/graphene-dapp-support
Adjustments for snapshot validation
2022-01-04 13:06:42 -06:00
Michel Santos
4fea001586 Fix Bookie plugin to provide a consistent data state
even when the node is started in replay mode
2022-01-03 10:24:32 -05:00
Michel Santos
8ec87b404f Enhance secondary_index
Enhance secondary_index by distinguishing between
previous objects loaded from persistence versus
new objects created during the session
2022-01-03 09:49:44 -05:00
Michel Santos
8325b25d0e Harmonize the activation date of GPOS 2022-01-03 09:49:44 -05:00
Michel Santos
c2675b4423 Re-allow build of programs for compatibility with Commit 082df7 2022-01-03 09:49:44 -05:00
Nathaniel
5fe3408893
Allow querying number of objects in object space
Previously, there was no good way to determine how many objects are in
an object space. Add a way to do so.
2022-01-02 14:50:17 -06:00
Nathaniel
d2dedbc4e4
Remove database unity build
Upstream dropped it and it was causing problems, so let it go!
2022-01-02 14:32:56 -06:00
Nathaniel
8df442a65f
Add secondary_index concerns
Add a way to create a secondary index with the space/type ID of the
object rather than the compile-time type, which may not always be
available.

Also, add a way to delete a secondary index (whether by compile-time
type or by object space/type ID).
2022-01-02 14:22:03 -06:00
Michel Santos
a5a78dacf1 Update fc to merger of latest-fc into dapp-support-fc 2021-11-13 08:42:42 -05:00
Michel Santos
c8cfaeb529 Fix test by reverting to the original timestamp used for the genesis 2021-11-11 18:48:49 -05:00
Michel Santos
ec66970d78 Add missing header 2021-11-11 18:48:43 -05:00
Nathan Hourt
906ffa6351 Fix tests better
The solution being used for initializing the boost test modules is
now deprecated, so update it to use the global test fixture instead
2021-11-11 14:38:36 -05:00
Nathan Hourt
8a6bae6006 Fix tests
These tests did not properly define their BOOST_TEST_MODULE macro,
causing linking to fail in some environments.
2021-11-11 14:35:53 -05:00
Nathan Hourt
0c320fdc71 Add missing header 2021-11-11 14:35:53 -05:00
Nathan Hourt
0d18523d8f Fix dynamic build
In some environments, dynamic linking fails if Boost is static
2021-11-11 14:32:47 -05:00
Nathan Hourt
95afb342c3 Fix to dynamic builds
FC wasn't always getting the memo that it should build dynamically
if Graphene is.
2021-11-11 14:31:47 -05:00
Nathan Hourt
e168d2d830 Fix install of hardfork.hpp 2021-11-11 14:29:34 -05:00
Nathan Hourt
3f50447013 Fix dynamic libs build 2021-11-11 14:29:34 -05:00
Nathan Hourt
c76e1f3157 Toward dynamically reloading contracts...
Add the ability to dynamically unload an auxiliary evaluator (any
evaluator for a given operation type except the first one registered for
that operation type), and as an added convenience, add an idiomatically
consistent way to check if a given index is already registered or not.
2021-11-11 14:27:50 -05:00
Nathan Hourt
082df7ab4a Allow build of dynamic libraries
In order to support dynamically linked nodes based on Graphene, add
support for building dynamic libraries for the core Graphene
modules: chain, db, protocol, net, and utilities.
2021-11-11 14:20:40 -05:00
Nathan Hourt
95d4cbdf4a Add build/IDE artifacts to gitignore 2021-11-11 11:25:47 -05:00
Nathan Hourt
ab113b2fc4 Add support for multiple evaluators per operation type
This commit adds the ability to register multiple evaluator types for a
given operation type. This will be used to allow plug-ins to define their
own evaluators for various operation types (most notably, custom
operations) so that they may be used to carry app-specific data which can
be parsed by a plug-in.
2021-11-11 11:25:47 -05:00
Nathan Hourt
4d836dacb9 Ref !3/#376: Graphene Updates
This adds the most important updates to Graphene from BitShares. Most notably,
https://github.com/bitshares/bitshares-core/issues/1506

Second most notably, it updates Peerplays' FC to be in sync with BitShares FC.

This is a squash commit of several subcommits. The subcommit messages are
reproduced below:

Replace fc::uint128 with boost::multiprecision::uint128_t

replace smart_ref with shared_ptr

Fixes/Remove Unused

Remove NTP time

Remove old macro

This macro is now in FC, so no need to define it here anymore

Replaced fc::array with std::array

Separate exception declaration and implementation

Adapted to fc promise changes

Fixes

Add back in some of Peter's fixes that got lost in the cherry pick

_hash endianness fixes

Remove all uses of fc/smart_ref

It's gone, can't use it anymore

Replace improper static_variant operator overloads with comparators

Fixes

Remove boost::signals from build system; it's header-only so it's not
listed in cmake anymore.

Also remove some unused hashing code

Impl. pack/unpack functions for extension class

Ref #1506: Isolate chain/protocol to its own library

Ref #1506: Add object_downcast_t

Allows the more concise expression `object_downcast_t<xyz>` instead of
the old `typename object_downcast<xyz>::type`

Ref #1506: Move ID types from db to protocol

The ID types, object_id and object_id_type, were defined in the db
library, and the protocol library depends on db to get these types.
Technically, the ID types are defined by the protocol and used by the
database, and not vice versa. Therefore these types should be in the
protocol library, and db should depend on protocol to get them.

This commit makes it so.

Ref #1506: Isolate chain/protocol to its own library

Remove commented-out index code

Wrap overlength line

Remove unused key types

Probably fix Docker build

Fix build after rebase

Ref #1506/#1737: Some requested changes

Ref #1506/#1737: Macro-fy ID type definitions

Define macros to fully de-boilerplate ID type definitions.

Externalities:
 - Rename transaction_object -> transaction_history_object
 - Rename impl_asset_dynamic_data_type ->
impl_asset_dynamic_data_object_type
 - Rename impl_asset_bitasset_data_type ->
impl_asset_bitasset_data_object_type

The first is to avoid a naming collision on transaction_id_type, and the
other two are to maintain consistency with the naming of the other
types.

Ref #1506/#1737: Fix clean_name()

Ref #1506/#1737: Oops

Fix .gitignore

Externalized serialization in protocol library

Fix compile sets

Delete a couple of ghost files that were in the tree but not part
of the project (I accidentally added them to CMakeLists while
merging, but they're broken and not part of the Peerplays code), and
add several files that got dropped from the build during merge.

General fixes

Fix warnings, build issues, unused code, etc.

Fix #1772 by decprecating cli_wallet -H

More fixes

Fix errors and warnings and generally coax it to build

Fix test

I'm pretty sure this didn't break from what I did... But I can't build
the original code, so I can't tell. Anyways, this one now passes...
Others still fail...

Small fix

Fix crash in auth checks

Final fixes

Last round of fixes following the rebase to Beatrice

Rename project in CMakeLists.txt

The CMakeLists.txt declared this project as BitShares and not Peerplays,
which makes it confusing in IDEs. Rename it to be clear which project is
open.

Resolve #374

Replace all object refs in macros with IDs, and fix affected tests to look
up objects by ID rather than using invalidated refs.

A full audit of all tests should be performed to eliminate any further
usage of invalidated object references.

Resolve #373: Add object notifiers

Various fixes

Fixes to various issues, primarily reflections, that cropped up
during merge conflict resolution

Fix startup bug in Bookie plugin

Bookie plugin was preventing the node from starting up because it
registered its secondary indexes to create objects in its own primary
indexes to track objects being created in other primary indexes, and did
so during its `initialize()` step, which is to say, before the database
was loaded from disk at startup. This caused the secondary indexes to
create tracker objects when the observed indexes were loading objects
from disk. This then caused a failure when these tracker indexes were
later loaded from disk, and the first object IDs collided.

This is fixed by refraining from defining secondary indexes until the
`startup()` stage rather than the `initialize()` stage. Primary indexes
are registered in `initialize()`, secondary indexes are registered in
`startup()`.

This also involved adding a new method, "add_secondary_index()", to
`object_database`, as before there was no way to do this because you
couldn't get a non-const index from a non-const database.

I have no idea how this was working before I got here...

Fix egenesis install

Fixes after updates

Rebase on updated develop branch and fix conflicts
2021-11-11 11:25:47 -05:00
Michel Santos
111ac16e92 Merge branch master into graphene-updates 2021-11-09 16:24:26 -05:00
Nathan Hourt
ed7b8b60e0
Resolve #373: Add object notifiers 2020-08-27 20:07:36 -05:00
Nathan Hourt
f2d4bce003
Resolve #374
Replace all object refs in macros with IDs, and fix affected tests to look
up objects by ID rather than using invalidated refs.

A full audit of all tests should be performed to eliminate any further
usage of invalidated object references.
2020-08-27 18:55:37 -05:00
Nathan Hourt
6b59f8269f
Rename project in CMakeLists.txt
The CMakeLists.txt declared this project as BitShares and not Peerplays,
which makes it confusing in IDEs. Rename it to be clear which project is
open.
2020-08-25 13:02:45 -05:00
Nathan Hourt
4e3e0e010a
Final fixes
Last round of fixes following the rebase to Beatrice
2020-08-25 13:01:51 -05:00
Nathan Hourt
a9135cbdd2
Fix crash in auth checks 2020-08-23 19:31:38 -05:00
Nathan Hourt
3dd78de312
Small fix 2020-08-23 14:51:47 -05:00
Nathan Hourt
ce8caae327
Fix test
I'm pretty sure this didn't break from what I did... But I can't build
the original code, so I can't tell. Anyways, this one now passes...
Others still fail...
2020-08-23 14:51:47 -05:00
Nathan Hourt
b8c3e63f1b
More fixes
Fix errors and warnings and generally coax it to build
2020-08-23 14:51:47 -05:00
Peter Conrad
a31e56f531
Fix #1772 by decprecating cli_wallet -H 2020-08-23 14:51:47 -05:00
Nathan Hourt
1c0de74aa7
General fixes
Fix warnings, build issues, unused code, etc.
2020-08-23 14:51:45 -05:00
Nathan Hourt
2af062e7cf
Fix compile sets
Delete a couple of ghost files that were in the tree but not part
of the project (I accidentally added them to CMakeLists while
merging, but they're broken and not part of the Peerplays code), and
add several files that got dropped from the build during merge.
2020-08-23 14:43:21 -05:00
Peter Conrad
9ae796c0a2
Externalized serialization in protocol library 2020-08-23 14:43:21 -05:00
Nathan Hourt
841c6319f9
Fix .gitignore 2020-08-23 14:43:21 -05:00
Nathan Hourt
d02bea9ef0
Ref #1506/#1737: Oops 2020-08-23 14:43:21 -05:00
Nathan Hourt
f2814a451c
Ref #1506/#1737: Fix clean_name() 2020-08-23 14:43:21 -05:00
Nathan Hourt
c94e46f451
Ref #1506/#1737: Macro-fy ID type definitions
Define macros to fully de-boilerplate ID type definitions.

Externalities:
 - Rename transaction_object -> transaction_history_object
 - Rename impl_asset_dynamic_data_type ->
impl_asset_dynamic_data_object_type
 - Rename impl_asset_bitasset_data_type ->
impl_asset_bitasset_data_object_type

The first is to avoid a naming collision on transaction_id_type, and the
other two are to maintain consistency with the naming of the other
types.
2020-08-23 14:43:19 -05:00
Nathan Hourt
6074749813
Ref #1506/#1737: Some requested changes 2020-08-23 14:37:35 -05:00
Nathan Hourt
ad670ecde1
Fix build after rebase 2020-08-23 14:37:02 -05:00
Nathan Hourt
f57dc27f55
Probably fix Docker build 2020-08-23 14:37:02 -05:00
Nathan Hourt
35d864e269
Remove unused key types 2020-08-23 14:37:02 -05:00
Nathan Hourt
3a15577617
Wrap overlength line 2020-08-23 14:37:02 -05:00
Nathan Hourt
9a52c29023
Remove commented-out index code 2020-08-23 14:37:02 -05:00
Nathan Hourt
9c71579d6e
Ref #1506: Isolate chain/protocol to its own library 2020-08-23 14:37:02 -05:00
Nathan Hourt
f076bb2586
Ref #1506: Move ID types from db to protocol
The ID types, object_id and object_id_type, were defined in the db
library, and the protocol library depends on db to get these types.
Technically, the ID types are defined by the protocol and used by the
database, and not vice versa. Therefore these types should be in the
protocol library, and db should depend on protocol to get them.

This commit makes it so.
2020-08-23 14:37:02 -05:00
Nathan Hourt
9bada13735
Ref #1506: Add object_downcast_t
Allows the more concise expression `object_downcast_t<xyz>` instead of
the old `typename object_downcast<xyz>::type`
2020-08-23 14:37:02 -05:00
Nathan Hourt
14f627c014
Ref #1506: Isolate chain/protocol to its own library 2020-08-23 14:37:00 -05:00
abitmore
d54cc47a4f
Impl. pack/unpack functions for extension class 2020-08-23 14:18:59 -05:00
Nathan Hourt
9ac63ce0b3
Fixes
Remove boost::signals from build system; it's header-only so it's not
listed in cmake anymore.

Also remove some unused hashing code
2020-08-23 14:18:59 -05:00
Nathan Hourt
13a76d25ac
Replace improper static_variant operator overloads with comparators 2020-08-23 14:18:59 -05:00
Nathan Hourt
54ce371a4a
Remove all uses of fc/smart_ref
It's gone, can't use it anymore
2020-08-23 14:18:59 -05:00
Peter Conrad
68c57a7414
_hash endianness fixes 2020-08-23 14:18:59 -05:00
Nathan Hourt
cc77a08891
Fixes
Add back in some of Peter's fixes that got lost in the cherry pick
2020-08-23 14:18:59 -05:00
Peter Conrad
7eb3729cc0
Adapted to fc promise changes 2020-08-23 14:18:59 -05:00
Peter Conrad
784221986a
Separate exception declaration and implementation 2020-08-23 14:18:59 -05:00
Peter Conrad
0569efc068
Replaced fc::array with std::array 2020-08-23 14:18:59 -05:00
Nathan Hourt
ced4380664
Remove old macro
This macro is now in FC, so no need to define it here anymore
2020-08-23 14:18:55 -05:00
Vikram Rajkumar
10adf05881
Remove NTP time 2020-08-23 14:18:24 -05:00
Nathan Hourt
953a1314a3
Fixes/Remove Unused 2020-08-23 14:18:24 -05:00
John Jones
a24a6bfc68
replace smart_ref with shared_ptr 2020-08-23 14:18:22 -05:00
Peter Conrad
f25c4f6ae6
Replace fc::uint128 with boost::multiprecision::uint128_t 2020-08-23 14:16:41 -05:00
376 changed files with 5178 additions and 3984 deletions

4
.gitignore vendored
View file

@ -1,6 +1,10 @@
*.a
*.sw*
/build
/build-*
CMakeLists.txt.user
*.cmake
CMakeCache.txt
CMakeFiles

2
.gitmodules vendored
View file

@ -5,5 +5,5 @@
[submodule "libraries/fc"]
path = libraries/fc
url = https://gitlab.com/PBSA/tools-libs/peerplays-fc.git
branch = latest-fc
branch = dapp-support
ignore = dirty

View file

@ -8,6 +8,15 @@ set( CLI_CLIENT_EXECUTABLE_NAME graphene_client )
set( GUI_CLIENT_EXECUTABLE_NAME Peerplays )
set( CUSTOM_URL_SCHEME "gcs" )
set( INSTALLER_APP_ID "68ad7005-8eee-49c9-95ce-9eed97e5b347" )
set( CMAKE_CXX_STANDARD 14 )
set( GRAPHENE_BUILD_DYNAMIC_LIBRARIES OFF CACHE BOOL
"Whether to build dynamic libraries instead of static. Applies only to chain, db, protocol, net, and utilities" )
if( GRAPHENE_BUILD_DYNAMIC_LIBRARIES )
set( CMAKE_POSITION_INDEPENDENT_CODE ON )
set( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" )
endif()
set( FC_BUILD_DYNAMIC_LIBRARIES ${GRAPHENE_BUILD_DYNAMIC_LIBRARIES} CACHE BOOL "Whether FC should build as a dynamic library rather than static" )
# http://stackoverflow.com/a/18369825
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
@ -83,13 +92,17 @@ LIST(APPEND BOOST_COMPONENTS thread
system
filesystem
program_options
signals
serialization
chrono
unit_test_framework
context
locale)
SET( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" )
IF( ${GRAPHENE_BUILD_DYNAMIC_LIBRARIES} )
SET( Boost_USE_STATIC_LIBS OFF CACHE STRING "ON or OFF" )
ELSE()
SET( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" )
ENDIF()
IF( WIN32 )
SET(BOOST_ROOT $ENV{BOOST_ROOT})
@ -143,11 +156,11 @@ else( WIN32 ) # Apple AND Linux
if( APPLE )
# Apple Specific Options Here
message( STATUS "Configuring Peerplays on OS X" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -stdlib=libc++ -Wall" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -stdlib=libc++ -Wall" )
else( APPLE )
# Linux Specific Options Here
message( STATUS "Configuring Peerplays on Linux" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall" )
set( rt_library rt )
#set( pthread_library pthread)
set(CMAKE_LINKER_FLAGS "-pthread" CACHE STRING "Linker Flags" FORCE)

View file

@ -5,6 +5,6 @@ add_subdirectory( egenesis )
add_subdirectory( fc )
add_subdirectory( net )
add_subdirectory( plugins )
add_subdirectory( time )
add_subdirectory( utilities )
add_subdirectory( wallet )
add_subdirectory( protocol )

View file

@ -12,10 +12,11 @@ add_library( graphene_app
)
# need to link graphene_debug_witness because plugins aren't sufficiently isolated #246
#target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_chain fc graphene_db graphene_net graphene_utilities graphene_debug_witness )
target_link_libraries( graphene_app
PUBLIC graphene_net graphene_utilities
graphene_account_history graphene_accounts_list graphene_affiliate_stats graphene_bookie graphene_debug_witness graphene_elasticsearch graphene_es_objects graphene_generate_genesis graphene_market_history )
PUBLIC graphene_chain graphene_net graphene_utilities
fc graphene_db peerplays_sidechain
graphene_account_history graphene_accounts_list graphene_affiliate_stats graphene_bookie graphene_debug_witness graphene_elasticsearch
graphene_es_objects graphene_generate_genesis graphene_market_history )
target_include_directories( graphene_app
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
@ -43,7 +44,7 @@ add_library( graphene_plugin
)
target_link_libraries( graphene_plugin
PUBLIC graphene_net graphene_utilities )
PUBLIC graphene_chain graphene_net graphene_utilities )
target_include_directories( graphene_plugin
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )

View file

@ -29,14 +29,16 @@
#include <graphene/chain/confidential_object.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/get_config.hpp>
#include <graphene/utilities/key_conversion.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <graphene/chain/confidential_object.hpp>
#include <graphene/chain/market_object.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/chain/tournament_object.hpp>
#include <graphene/chain/transaction_object.hpp>
#include <graphene/chain/transaction_history_object.hpp>
#include <graphene/chain/withdraw_permission_object.hpp>
#include <graphene/chain/worker_object.hpp>
#include <graphene/utilities/key_conversion.hpp>
#include <fc/crypto/base64.hpp>
#include <fc/crypto/hex.hpp>
#include <fc/rpc/api_connection.hpp>
#include <fc/thread/future.hpp>
@ -144,7 +146,7 @@ void network_broadcast_api::on_applied_block(const signed_block &b) {
if (itr != _callbacks.end()) {
auto block_num = b.block_num();
auto &callback = _callbacks.find(id)->second;
fc::async([capture_this, this, id, block_num, trx_num, trx, callback]() {
fc::async([capture_this, id, block_num, trx_num, trx, callback]() {
callback(fc::variant(transaction_confirmation{id, block_num, trx_num, trx},
GRAPHENE_MAX_NESTED_OBJECTS));
});
@ -164,7 +166,7 @@ void network_broadcast_api::broadcast_transaction(const signed_transaction &trx)
fc::variant network_broadcast_api::broadcast_transaction_synchronous(const signed_transaction &trx) {
_app.chain_database()->check_transaction_for_duplicated_operations(trx);
fc::promise<fc::variant>::ptr prom(new fc::promise<fc::variant>());
fc::promise<fc::variant>::ptr prom(fc::promise<fc::variant>::create());
broadcast_transaction_with_callback([=](const fc::variant &v) {
prom->set_value(v);
},

View file

@ -26,8 +26,10 @@
#include <graphene/app/application.hpp>
#include <graphene/app/plugin.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/db_with.hpp>
#include <graphene/chain/genesis_state.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <graphene/protocol/types.hpp>
#include <graphene/egenesis/egenesis.hpp>
@ -289,6 +291,10 @@ public:
_self(self),
_chain_db(std::make_shared<chain::database>()) {
}
explicit application_impl(application *self, application::TESTING_MODE) :
_self(self),
_chain_db(std::make_shared<chain::database>(true)) {
}
~application_impl() {
}
@ -306,10 +312,10 @@ public:
auto initial_state = [this] {
ilog("Initializing database...");
if (_options->count("genesis-json")) {
std::string genesis_str;
fc::read_file_contents(_options->at("genesis-json").as<boost::filesystem::path>(), genesis_str);
genesis_state_type genesis = fc::json::from_string(genesis_str).as<genesis_state_type>(20);
if( _options->count("genesis-json") )
{
genesis_state_type genesis = fc::json::from_file( _options->at("genesis-json").as<boost::filesystem::path>()).as<genesis_state_type>( 20 );
std::string genesis_str = fc::json::to_string(genesis) + "\n";
bool modified_genesis = false;
if (_options->count("genesis-timestamp")) {
genesis.initial_timestamp = fc::time_point_sec(fc::time_point::now()) + genesis.initial_parameters.block_interval + _options->at("genesis-timestamp").as<uint32_t>();
@ -359,7 +365,7 @@ public:
if (_options->count("enable-standby-votes-tracking")) {
_chain_db->enable_standby_votes_tracking(_options->at("enable-standby-votes-tracking").as<bool>());
}
std::string replay_reason = "reason not provided";
if (_options->count("replay-blockchain"))
@ -844,7 +850,11 @@ public:
} // namespace detail
application::application() :
my(new detail::application_impl(this)) {
my(new detail::application_impl(this)) {
}
application::application(TESTING_MODE) :
my(new detail::application_impl(this, TESTING_MODE())) {
}
application::~application() {

View file

@ -198,7 +198,7 @@ static void load_config_file(const fc::path &config_ini_path, const bpo::options
bpo::variables_map &options) {
deduplicator dedup;
bpo::options_description unique_options("Graphene Witness Node");
for (const boost::shared_ptr<bpo::option_description> opt : cfg_options.options()) {
for( const boost::shared_ptr<bpo::option_description>& opt : cfg_options.options() ) {
const boost::shared_ptr<bpo::option_description> od = dedup.next(opt);
if (!od)
continue;
@ -241,8 +241,8 @@ static void create_new_config_file(const fc::path &config_ini_path, const fc::pa
};
deduplicator dedup(modify_option_defaults);
std::ofstream out_cfg(config_ini_path.preferred_string());
std::string plugin_header_surrounding(78, '=');
for (const boost::shared_ptr<bpo::option_description> opt : cfg_options.options()) {
std::string plugin_header_surrounding( 78, '=' );
for( const boost::shared_ptr<bpo::option_description>& opt : cfg_options.options() ) {
const boost::shared_ptr<bpo::option_description> od = dedup.next(opt);
if (!od)
continue;

View file

@ -23,11 +23,14 @@
*/
#include <graphene/app/database_api.hpp>
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/get_config.hpp>
#include <graphene/chain/protocol/address.hpp>
#include <graphene/chain/pts_address.hpp>
#include <graphene/chain/hardfork.hpp>
#include <graphene/chain/tournament_object.hpp>
#include <graphene/chain/get_config.hpp>
#include <graphene/protocol/address.hpp>
#include <graphene/protocol/pts_address.hpp>
#include <fc/bloom_filter.hpp>
@ -427,9 +430,9 @@ fc::variants database_api::get_objects(const vector<object_id_type> &ids) const
fc::variants database_api_impl::get_objects(const vector<object_id_type> &ids) const {
if (_subscribe_callback) {
for (auto id : ids) {
if (id.type() == operation_history_object_type && id.space() == protocol_ids)
if (id.type() == api_operation_history_object_type && id.space() == api_ids)
continue;
if (id.type() == impl_account_transaction_history_object_type && id.space() == implementation_ids)
if (id.type() == api_account_transaction_history_object_type && id.space() == api_ids)
continue;
this->subscribe_to_item(id);
@ -2802,10 +2805,9 @@ graphene::app::gpos_info database_api_impl::get_gpos_info(const account_id_type
}
vector<vesting_balance_object> account_vbos;
const time_point_sec now = _db.head_block_time();
auto vesting_range = _db.get_index_type<vesting_balance_index>().indices().get<by_account>().equal_range(account);
std::for_each(vesting_range.first, vesting_range.second,
[&account_vbos, now](const vesting_balance_object &balance) {
[&account_vbos](const vesting_balance_object &balance) {
if (balance.balance.amount > 0 && balance.balance_type == vesting_balance_type::gpos && balance.balance.asset_id == asset_id_type())
account_vbos.emplace_back(balance);
});

View file

@ -25,8 +25,8 @@
#include <graphene/app/database_api.hpp>
#include <graphene/chain/protocol/confidential.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/types.hpp>
#include <graphene/protocol/confidential.hpp>
#include <graphene/accounts_list/accounts_list_plugin.hpp>
#include <graphene/market_history/market_history_plugin.hpp>

View file

@ -39,7 +39,10 @@ class abstract_plugin;
class application {
public:
struct TESTING_MODE {};
application();
application(TESTING_MODE);
~application();
void set_program_options(boost::program_options::options_description &cli,

View file

@ -25,7 +25,7 @@
#include <graphene/app/full_account.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/types.hpp>
#include <graphene/chain/database.hpp>

View file

@ -24,9 +24,11 @@
#pragma once
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/market_object.hpp>
#include <graphene/chain/market_evaluator.hpp>
#include <graphene/chain/vesting_balance_object.hpp>
#include <graphene/chain/withdraw_permission_object.hpp>
#include <graphene/chain/proposal_object.hpp>
namespace graphene { namespace app {
using namespace graphene::chain;

View file

@ -23,7 +23,7 @@
*/
#include <graphene/app/plugin.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/protocol/fee_schedule.hpp>
namespace graphene { namespace app {

View file

@ -6,31 +6,33 @@ set_source_files_properties( "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain
add_dependencies( build_hardfork_hpp cat-parts )
file(GLOB HEADERS "include/graphene/chain/*.hpp")
file(GLOB PROTOCOL_HEADERS "include/graphene/chain/protocol/*.hpp")
list(APPEND HEADERS "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp")
file(GLOB CPP_FILES "*.cpp")
file(GLOB PROTOCOL_CPP_FILES "protocol/*.cpp")
#if( GRAPHENE_DISABLE_UNITY_BUILD )
list(FILTER CPP_FILES EXCLUDE REGEX "[/]database[.]cpp$")
#message ("--- ${CPP_FILES}")
message( STATUS "Graphene database unity build disabled" )
#else( GRAPHENE_DISABLE_UNITY_BUILD )
# list(FILTER CPP_FILES EXCLUDE REGEX ".*db_.*[.]cpp$")
# #message ("--- ${CPP_FILES}")
# set( GRAPHENE_DB_FILES
# database.cpp )
# message( STATUS "Graphene database unity build enabled" )
#endif( GRAPHENE_DISABLE_UNITY_BUILD )
add_library( graphene_chain
${CPP_FILES}
${PROTOCOL_CPP_FILES}
${HEADERS}
${PROTOCOL_HEADERS}
"${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp"
)
set( GRAPHENE_CHAIN_FILES
${CPP_FILES}
${HEADERS}
"${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp"
)
if (NOT ${GRAPHENE_BUILD_DYNAMIC_LIBRARIES})
add_library( graphene_chain ${GRAPHENE_CHAIN_FILES} )
else()
add_library( graphene_chain SHARED ${GRAPHENE_CHAIN_FILES} )
endif()
add_dependencies( graphene_chain build_hardfork_hpp )
target_link_libraries( graphene_chain graphene_db )
target_link_libraries( graphene_chain fc graphene_db graphene_protocol )
target_include_directories( graphene_chain
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include" )
@ -46,4 +48,3 @@ INSTALL( TARGETS
ARCHIVE DESTINATION lib
)
INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/chain" )
INSTALL( FILES ${PROTOCOL_HEADERS} DESTINATION "include/graphene/chain/protocol" )

View file

@ -214,7 +214,7 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio
if( dynamic_properties.accounts_registered_this_interval % global_properties.parameters.accounts_per_fee_scale == 0
&& global_properties.parameters.account_fee_scale_bitshifts != 0 )
{
d.modify(global_properties, [&dynamic_properties](global_property_object& p) {
d.modify(global_properties, [](global_property_object& p) {
p.parameters.current_fees->get<account_create_operation>().basic_fee <<= p.parameters.account_fee_scale_bitshifts;
});
}

View file

@ -36,10 +36,10 @@ share_type cut_fee(share_type a, uint16_t p)
if( p == GRAPHENE_100_PERCENT )
return a;
fc::uint128 r(a.value);
fc::uint128_t r = a.value;
r *= p;
r /= GRAPHENE_100_PERCENT;
return r.to_uint64();
return r;
}
void account_balance_object::adjust_balance(const asset& delta)
@ -142,7 +142,12 @@ set<address> account_member_index::get_address_members(const account_object& a)c
return result;
}
void account_member_index::object_inserted(const object& obj)
void account_member_index::object_loaded(const object& obj)
{
object_created(obj);
}
void account_member_index::object_created(const object& obj)
{
assert( dynamic_cast<const account_object*>(&obj) ); // for debug only
const account_object& a = static_cast<const account_object&>(obj);
@ -256,7 +261,10 @@ void account_member_index::object_modified(const object& after)
}
void account_referrer_index::object_inserted( const object& obj )
void account_referrer_index::object_loaded( const object& obj )
{
}
void account_referrer_index::object_created( const object& obj )
{
}
void account_referrer_index::object_removed( const object& obj )
@ -272,7 +280,12 @@ void account_referrer_index::object_modified( const object& after )
const uint8_t balances_by_account_index::bits = 20;
const uint64_t balances_by_account_index::mask = (1ULL << balances_by_account_index::bits) - 1;
void balances_by_account_index::object_inserted( const object& obj )
void balances_by_account_index::object_loaded( const object& obj )
{
object_created(obj);
}
void balances_by_account_index::object_created( const object& obj )
{
const auto& abo = dynamic_cast< const account_balance_object& >( obj );
while( balances.size() < (abo.owner.instance.value >> bits) + 1 )

View file

@ -62,15 +62,15 @@ namespace graphene { namespace chain {
//ilog("Paying ${p} of ${P} for ${s} of ${r}", ("p",payout.to_uint64())("P",to_pay.value)("s",share)("r",remaining) );
remaining -= share;
}
FC_ASSERT( payout.to_uint64() <= to_pay );
FC_ASSERT( payout <= to_pay );
if( payout > 0 )
{
if ( accumulator.find(affiliate) == accumulator.end() )
accumulator[affiliate] = payout.to_uint64();
accumulator[affiliate] = payout;
else
accumulator[affiliate] += payout.to_uint64();
to_pay -= payout.to_uint64();
paid += payout.to_uint64();
accumulator[affiliate] += payout;
to_pay -= payout;
paid += payout;
}
}
FC_ASSERT( to_pay == 0 );

View file

@ -130,7 +130,7 @@ void asset_create_evaluator::pay_fee()
{
fee_is_odd = core_fee_paid.value & 1;
core_fee_paid -= core_fee_paid.value/2;
generic_evaluator::pay_fee();
consensus_evaluator::pay_fee();
}
object_id_type asset_create_evaluator::do_apply( const asset_create_operation& op )
@ -283,7 +283,7 @@ void lottery_asset_create_evaluator::pay_fee()
{
fee_is_odd = core_fee_paid.value & 1;
core_fee_paid -= core_fee_paid.value/2;
generic_evaluator::pay_fee();
consensus_evaluator::pay_fee();
}
object_id_type lottery_asset_create_evaluator::do_apply( const lottery_asset_create_operation& op )

View file

@ -38,10 +38,11 @@ share_type asset_bitasset_data_object::max_force_settlement_volume(share_type cu
if( options.maximum_force_settlement_volume == GRAPHENE_100_PERCENT )
return current_supply + force_settled_volume;
fc::uint128 volume = current_supply.value + force_settled_volume.value;
fc::uint128_t volume = current_supply.value;
volume += force_settled_volume.value;
volume *= options.maximum_force_settlement_volume;
volume /= GRAPHENE_100_PERCENT;
return volume.to_uint64();
return volume;
}
void asset_bitasset_data_object::update_median_feeds(time_point_sec current_time)

View file

@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
#include <graphene/chain/balance_evaluator.hpp>
#include <graphene/chain/pts_address.hpp>
#include <graphene/protocol/pts_address.hpp>
namespace graphene { namespace chain {

View file

@ -75,7 +75,7 @@ namespace mpl = boost::mpl;
amount_to_match_128 += backer_multiplier - GRAPHENE_BETTING_ODDS_PRECISION - 1;
amount_to_match_128 /= backer_multiplier - GRAPHENE_BETTING_ODDS_PRECISION;
}
return amount_to_match_128.to_uint64();
return amount_to_match_128;
}
share_type bet_object::get_approximate_matching_amount(bool round_up /* = false */) const

View file

@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
#include <graphene/chain/block_database.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <fc/io/raw.hpp>
namespace graphene { namespace chain {

View file

@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
#include <graphene/chain/protocol/buyback.hpp>
#include <graphene/protocol/buyback.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/hardfork.hpp>

View file

@ -25,9 +25,8 @@
#include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/hardfork.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/chain/protocol/vote.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <graphene/protocol/vote.hpp>
#include <graphene/chain/transaction_evaluation_state.hpp>
namespace graphene { namespace chain {
@ -42,7 +41,7 @@ object_id_type committee_member_create_evaluator::do_apply( const committee_memb
{ try {
vote_id_type vote_id;
db().modify(db().get_global_properties(), [&vote_id](global_property_object& p) {
vote_id = get_next_vote_id(p, vote_id_type::committee);
vote_id = vote_id_type(vote_id_type::committee, p.next_available_vote_id++);
});
const auto& new_del_object = db().create<committee_member_object>( [&]( committee_member_object& obj ){

View file

@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/protocol/confidential.hpp>
#include <graphene/protocol/confidential.hpp>
#include <graphene/chain/confidential_evaluator.hpp>
#include <graphene/chain/confidential_object.hpp>
#include <graphene/chain/database.hpp>
@ -74,7 +74,7 @@ void transfer_to_blind_evaluator::pay_fee()
if( db().head_block_time() >= HARDFORK_563_TIME )
pay_fba_fee( fba_accumulator_id_transfer_to_blind );
else
generic_evaluator::pay_fee();
consensus_evaluator::pay_fee();
}
void_result transfer_from_blind_evaluator::do_evaluate( const transfer_from_blind_operation& o )
@ -118,7 +118,7 @@ void transfer_from_blind_evaluator::pay_fee()
if( db().head_block_time() >= HARDFORK_563_TIME )
pay_fba_fee( fba_accumulator_id_transfer_from_blind );
else
generic_evaluator::pay_fee();
consensus_evaluator::pay_fee();
}
void_result blind_transfer_evaluator::do_evaluate( const blind_transfer_operation& o )
@ -175,7 +175,7 @@ void blind_transfer_evaluator::pay_fee()
if( db().head_block_time() >= HARDFORK_563_TIME )
pay_fba_fee( fba_accumulator_id_blind_transfer );
else
generic_evaluator::pay_fee();
consensus_evaluator::pay_fee();
}
} } // graphene::chain

View file

@ -126,3 +126,4 @@ void_result delete_custom_account_authority_evaluator::do_apply(const custom_acc
} // namespace chain
} // namespace graphene

View file

@ -29,6 +29,8 @@
#include <graphene/chain/betting_market_object.hpp>
#include <graphene/chain/event_object.hpp>
#include <fc/log/logger.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/combine.hpp>
#include <boost/range/join.hpp>
@ -132,7 +134,7 @@ void database::resolve_betting_market_group(const betting_market_group_object& b
bool group_was_canceled = resolutions.begin()->second == betting_market_resolution_type::cancel;
if (group_was_canceled)
modify(betting_market_group, [group_was_canceled,this](betting_market_group_object& betting_market_group_obj) {
modify(betting_market_group, [this](betting_market_group_object& betting_market_group_obj) {
betting_market_group_obj.on_canceled_event(*this, false); // this cancels the betting markets
});
else {
@ -149,7 +151,7 @@ void database::resolve_betting_market_group(const betting_market_group_object& b
});
}
modify(betting_market_group, [group_was_canceled,this](betting_market_group_object& betting_market_group_obj) {
modify(betting_market_group, [this](betting_market_group_object& betting_market_group_obj) {
betting_market_group_obj.on_graded_event(*this);
});
}
@ -263,7 +265,7 @@ void database::settle_betting_market_group(const betting_market_group_object& be
share_type rake_amount;
if (net_profits.value > 0 && rake_account_id)
{
rake_amount = ((fc::uint128_t(net_profits.value) * rake_fee_percentage + GRAPHENE_100_PERCENT - 1) / GRAPHENE_100_PERCENT).to_uint64();
rake_amount = ((fc::uint128_t(net_profits.value) * rake_fee_percentage + GRAPHENE_100_PERCENT - 1) / GRAPHENE_100_PERCENT);
share_type affiliates_share;
if (rake_amount.value)
affiliates_share = payout_helper.payout( bettor_id, rake_amount );
@ -490,7 +492,7 @@ int match_bet(database& db, const bet_object& taker_bet, const bet_object& maker
payout_128 += taker_amount_to_match.value;
payout_128 *= GRAPHENE_BETTING_ODDS_PRECISION;
payout_128 /= maker_bet.back_or_lay == bet_type::back ? maker_amount_to_match.value : taker_amount_to_match.value;
assert(payout_128.to_uint64() == maker_bet.backer_multiplier);
assert(payout_128 == maker_bet.backer_multiplier);
}
#endif

View file

@ -26,22 +26,23 @@
#include <graphene/chain/db_with.hpp>
#include <graphene/chain/hardfork.hpp>
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/protocol/betting_market.hpp>
#include <graphene/chain/block_summary_object.hpp>
#include <graphene/chain/global_property_object.hpp>
#include <graphene/chain/operation_history_object.hpp>
#include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/transaction_object.hpp>
#include <graphene/chain/transaction_history_object.hpp>
#include <graphene/chain/witness_object.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/witness_schedule_object.hpp>
#include <fc/crypto/digest.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/protocol/betting_market.hpp>
#include <fc/crypto/digest.hpp>
#include <fc/thread/non_preemptable_scope_check.hpp>
namespace {
@ -380,6 +381,7 @@ processed_transaction database::push_transaction( const signed_transaction& trx,
processed_transaction database::_push_transaction( const signed_transaction& trx )
{
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
// If this is the first transaction pushed after applying a block, start a new undo session.
// This allows us to quickly rewind to the clean state of the head block, in case a new block arrives.
if( !_pending_tx_session.valid() )
@ -411,6 +413,7 @@ processed_transaction database::validate_transaction( const signed_transaction&
processed_transaction database::push_proposal(const proposal_object& proposal)
{ try {
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
transaction_evaluation_state eval_state(this);
eval_state._is_proposed_trx = true;
@ -456,6 +459,7 @@ signed_block database::generate_block(
uint32_t skip /* = 0 */
)
{ try {
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
signed_block result;
detail::with_skip_flags( *this, skip, [&]()
{
@ -587,6 +591,7 @@ signed_block database::_generate_block(
*/
void database::pop_block()
{ try {
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
_pending_tx_session.reset();
auto head_id = head_block_id();
optional<signed_block> head_block = fetch_block_by_id( head_id );
@ -601,6 +606,7 @@ void database::pop_block()
void database::clear_pending()
{ try {
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
assert( (_pending_tx.size() == 0) || _pending_tx_session.valid() );
_pending_tx.clear();
_pending_tx_session.reset();
@ -660,6 +666,7 @@ void database::apply_block( const signed_block& next_block, uint32_t skip )
void database::_apply_block( const signed_block& next_block )
{ try {
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
uint32_t next_block_num = next_block.block_num();
uint32_t skip = get_node_properties().skip_flags;
_applied_ops.clear();
@ -779,6 +786,7 @@ class undo_size_restorer {
processed_transaction database::_apply_transaction(const signed_transaction& trx)
{ try {
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
uint32_t skip = get_node_properties().skip_flags;
if( true || !(skip&skip_validate) ) /* issue #505 explains why this skip_flag is disabled */
@ -819,7 +827,7 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
const auto& tapos_block_summary = block_summary_id_type( trx.ref_block_num )(*this);
//Verify TaPoS block summary has correct ID prefix, and that this block's time is not past the expiration
FC_ASSERT( trx.ref_block_prefix == tapos_block_summary.block_id._hash[1] );
FC_ASSERT( trx.ref_block_prefix == tapos_block_summary.block_id._hash[1].value() );
}
fc::time_point_sec now = head_block_time();
@ -832,8 +840,8 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
//Insert transaction into unique transactions database.
if( !(skip & skip_transaction_dupe_check) )
{
create<transaction_object>([&trx_id,&trx](transaction_object& transaction) {
transaction.trx_id = trx_id;
create<transaction_history_object>([&trx](transaction_history_object& transaction) {
transaction.trx_id = trx.id();
transaction.trx = trx;
});
}
@ -863,15 +871,26 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
operation_result database::apply_operation(transaction_evaluation_state& eval_state, const operation& op)
{ try {
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
int i_which = op.which();
uint64_t u_which = uint64_t( i_which );
FC_ASSERT( i_which >= 0, "Negative operation tag in operation ${op}", ("op",op) );
FC_ASSERT( u_which < _operation_evaluators.size(), "No registered evaluator for operation ${op}", ("op",op) );
unique_ptr<op_evaluator>& eval = _operation_evaluators[ u_which ];
FC_ASSERT( u_which < _consensus_operation_evaluators.size(), "No registered evaluator for operation ${op}", ("op",op) );
unique_ptr<op_evaluator>& eval = _consensus_operation_evaluators[ u_which ];
FC_ASSERT( eval, "No registered evaluator for operation ${op}", ("op",op) );
auto op_id = push_applied_operation( op );
auto result = eval->evaluate( eval_state, op, true );
set_applied_operation_result( op_id, result );
// Run third party evaluator chain. Check that they don't yield, and lock consensus databases while they run.
if (_third_party_operation_evaluators.size() > u_which && _third_party_operation_evaluators[u_which]) {
ASSERT_TASK_NOT_PREEMPTED();
_check_policy_1->lock();
_check_policy_2->lock();
_third_party_operation_evaluators[u_which]->evaluate( eval_state, op, true );
_check_policy_1->unlock();
_check_policy_2->unlock();
}
return result;
} FC_CAPTURE_AND_RETHROW( (op) ) }

View file

@ -113,13 +113,15 @@ std::vector<uint32_t> database::get_seeds( asset_id_type for_asset, uint8_t coun
{
FC_ASSERT( count_winners <= 64 );
std::string salted_string = std::string(_random_number_generator._seed) + std::to_string(for_asset.instance.value);
uint32_t* seeds = (uint32_t*)(fc::sha256::hash(salted_string)._hash);
auto seeds_hash = fc::sha256::hash(salted_string);
uint32_t* seeds = (uint32_t*)(seeds_hash._hash);
std::vector<uint32_t> result;
result.reserve(64);
for( int s = 0; s < 8; ++s ) {
uint32_t* sub_seeds = ( uint32_t* ) fc::sha256::hash( std::to_string( seeds[s] ) + std::to_string( for_asset.instance.value ) )._hash;
auto sub_seeds_hash = fc::sha256::hash(std::to_string(seeds[s]) + std::to_string(for_asset.instance.value));
uint32_t* sub_seeds = (uint32_t*) sub_seeds_hash._hash;
for( int ss = 0; ss < 8; ++ss ) {
result.push_back(sub_seeds[ss]);
}
@ -224,7 +226,8 @@ std::set<son_id_type> database::get_sons_to_be_deregistered()
{
if(son.status == son_status::in_maintenance)
{
auto stats = son.statistics(*this);
auto& stats = son.statistics(*this);
// TODO : We need to add a function that returns if we can deregister SON
// i.e. with introduction of PW code, we have to make a decision if the SON
// is needed for release of funds from the PW

View file

@ -40,7 +40,7 @@
#include <graphene/chain/operation_history_object.hpp>
#include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/special_authority_object.hpp>
#include <graphene/chain/transaction_object.hpp>
#include <graphene/chain/transaction_history_object.hpp>
#include <graphene/chain/vesting_balance_object.hpp>
#include <graphene/chain/withdraw_permission_object.hpp>
#include <graphene/chain/witness_object.hpp>
@ -104,7 +104,7 @@
#include <graphene/chain/sidechain_transaction_evaluator.hpp>
#include <graphene/chain/random_number_evaluator.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <fc/uint128.hpp>
#include <fc/crypto/digest.hpp>
@ -152,8 +152,8 @@ const uint8_t operation_history_object::type_id;
const uint8_t proposal_object::space_id;
const uint8_t proposal_object::type_id;
const uint8_t transaction_object::space_id;
const uint8_t transaction_object::type_id;
const uint8_t transaction_history_object::space_id;
const uint8_t transaction_history_object::type_id;
const uint8_t vesting_balance_object::space_id;
const uint8_t vesting_balance_object::type_id;
@ -214,119 +214,120 @@ const uint8_t random_number_object::type_id;
void database::initialize_evaluators()
{
_operation_evaluators.resize(255);
register_evaluator<account_create_evaluator>();
register_evaluator<account_update_evaluator>();
register_evaluator<account_upgrade_evaluator>();
register_evaluator<account_whitelist_evaluator>();
register_evaluator<committee_member_create_evaluator>();
register_evaluator<committee_member_update_evaluator>();
register_evaluator<committee_member_update_global_parameters_evaluator>();
register_evaluator<custom_evaluator>();
register_evaluator<asset_create_evaluator>();
register_evaluator<asset_issue_evaluator>();
register_evaluator<asset_reserve_evaluator>();
register_evaluator<asset_update_evaluator>();
register_evaluator<asset_update_bitasset_evaluator>();
register_evaluator<asset_update_dividend_evaluator>();
register_evaluator<asset_update_feed_producers_evaluator>();
register_evaluator<asset_settle_evaluator>();
register_evaluator<asset_global_settle_evaluator>();
register_evaluator<assert_evaluator>();
register_evaluator<limit_order_create_evaluator>();
register_evaluator<limit_order_cancel_evaluator>();
register_evaluator<call_order_update_evaluator>();
register_evaluator<transfer_evaluator>();
register_evaluator<override_transfer_evaluator>();
register_evaluator<asset_fund_fee_pool_evaluator>();
register_evaluator<asset_publish_feeds_evaluator>();
register_evaluator<proposal_create_evaluator>();
register_evaluator<proposal_update_evaluator>();
register_evaluator<proposal_delete_evaluator>();
register_evaluator<vesting_balance_create_evaluator>();
register_evaluator<vesting_balance_withdraw_evaluator>();
register_evaluator<witness_create_evaluator>();
register_evaluator<witness_update_evaluator>();
register_evaluator<withdraw_permission_create_evaluator>();
register_evaluator<withdraw_permission_claim_evaluator>();
register_evaluator<withdraw_permission_update_evaluator>();
register_evaluator<withdraw_permission_delete_evaluator>();
register_evaluator<worker_create_evaluator>();
register_evaluator<balance_claim_evaluator>();
register_evaluator<transfer_to_blind_evaluator>();
register_evaluator<transfer_from_blind_evaluator>();
register_evaluator<blind_transfer_evaluator>();
register_evaluator<asset_claim_fees_evaluator>();
register_evaluator<sport_create_evaluator>();
register_evaluator<sport_update_evaluator>();
register_evaluator<sport_delete_evaluator>();
register_evaluator<event_group_create_evaluator>();
register_evaluator<event_group_update_evaluator>();
register_evaluator<event_group_delete_evaluator>();
register_evaluator<event_create_evaluator>();
register_evaluator<event_update_evaluator>();
register_evaluator<event_update_status_evaluator>();
register_evaluator<betting_market_rules_create_evaluator>();
register_evaluator<betting_market_rules_update_evaluator>();
register_evaluator<betting_market_group_create_evaluator>();
register_evaluator<betting_market_group_update_evaluator>();
register_evaluator<betting_market_create_evaluator>();
register_evaluator<betting_market_update_evaluator>();
register_evaluator<bet_place_evaluator>();
register_evaluator<bet_cancel_evaluator>();
register_evaluator<betting_market_group_resolve_evaluator>();
register_evaluator<betting_market_group_cancel_unmatched_bets_evaluator>();
register_evaluator<tournament_create_evaluator>();
register_evaluator<tournament_join_evaluator>();
register_evaluator<game_move_evaluator>();
register_evaluator<tournament_leave_evaluator>();
register_evaluator<lottery_asset_create_evaluator>();
register_evaluator<ticket_purchase_evaluator>();
register_evaluator<lottery_reward_evaluator>();
register_evaluator<lottery_end_evaluator>();
register_evaluator<sweeps_vesting_claim_evaluator>();
register_evaluator<create_custom_permission_evaluator>();
register_evaluator<update_custom_permission_evaluator>();
register_evaluator<delete_custom_permission_evaluator>();
register_evaluator<create_custom_account_authority_evaluator>();
register_evaluator<update_custom_account_authority_evaluator>();
register_evaluator<delete_custom_account_authority_evaluator>();
register_evaluator<offer_evaluator>();
register_evaluator<bid_evaluator>();
register_evaluator<cancel_offer_evaluator>();
register_evaluator<finalize_offer_evaluator>();
register_evaluator<nft_metadata_create_evaluator>();
register_evaluator<nft_metadata_update_evaluator>();
register_evaluator<nft_mint_evaluator>();
register_evaluator<nft_safe_transfer_from_evaluator>();
register_evaluator<nft_approve_evaluator>();
register_evaluator<nft_set_approval_for_all_evaluator>();
register_evaluator<account_role_create_evaluator>();
register_evaluator<account_role_update_evaluator>();
register_evaluator<account_role_delete_evaluator>();
register_evaluator<nft_lottery_token_purchase_evaluator>();
register_evaluator<nft_lottery_reward_evaluator>();
register_evaluator<nft_lottery_end_evaluator>();
register_evaluator<create_son_evaluator>();
register_evaluator<update_son_evaluator>();
register_evaluator<deregister_son_evaluator>();
register_evaluator<son_heartbeat_evaluator>();
register_evaluator<son_report_down_evaluator>();
register_evaluator<son_maintenance_evaluator>();
register_evaluator<recreate_son_wallet_evaluator>();
register_evaluator<update_son_wallet_evaluator>();
register_evaluator<create_son_wallet_deposit_evaluator>();
register_evaluator<process_son_wallet_deposit_evaluator>();
register_evaluator<create_son_wallet_withdraw_evaluator>();
register_evaluator<process_son_wallet_withdraw_evaluator>();
register_evaluator<add_sidechain_address_evaluator>();
register_evaluator<update_sidechain_address_evaluator>();
register_evaluator<delete_sidechain_address_evaluator>();
register_evaluator<sidechain_transaction_create_evaluator>();
register_evaluator<sidechain_transaction_sign_evaluator>();
register_evaluator<sidechain_transaction_send_evaluator>();
register_evaluator<sidechain_transaction_settle_evaluator>();
register_evaluator<random_number_store_evaluator>();
_consensus_operation_evaluators.resize(255);
_third_party_operation_evaluators.resize(255);
register_consensus_evaluator<account_create_evaluator>();
register_consensus_evaluator<account_update_evaluator>();
register_consensus_evaluator<account_upgrade_evaluator>();
register_consensus_evaluator<account_whitelist_evaluator>();
register_consensus_evaluator<committee_member_create_evaluator>();
register_consensus_evaluator<committee_member_update_evaluator>();
register_consensus_evaluator<committee_member_update_global_parameters_evaluator>();
register_consensus_evaluator<custom_evaluator>();
register_consensus_evaluator<asset_create_evaluator>();
register_consensus_evaluator<asset_issue_evaluator>();
register_consensus_evaluator<asset_reserve_evaluator>();
register_consensus_evaluator<asset_update_evaluator>();
register_consensus_evaluator<asset_update_bitasset_evaluator>();
register_consensus_evaluator<asset_update_dividend_evaluator>();
register_consensus_evaluator<asset_update_feed_producers_evaluator>();
register_consensus_evaluator<asset_settle_evaluator>();
register_consensus_evaluator<asset_global_settle_evaluator>();
register_consensus_evaluator<assert_evaluator>();
register_consensus_evaluator<limit_order_create_evaluator>();
register_consensus_evaluator<limit_order_cancel_evaluator>();
register_consensus_evaluator<call_order_update_evaluator>();
register_consensus_evaluator<transfer_evaluator>();
register_consensus_evaluator<override_transfer_evaluator>();
register_consensus_evaluator<asset_fund_fee_pool_evaluator>();
register_consensus_evaluator<asset_publish_feeds_evaluator>();
register_consensus_evaluator<proposal_create_evaluator>();
register_consensus_evaluator<proposal_update_evaluator>();
register_consensus_evaluator<proposal_delete_evaluator>();
register_consensus_evaluator<vesting_balance_create_evaluator>();
register_consensus_evaluator<vesting_balance_withdraw_evaluator>();
register_consensus_evaluator<witness_create_evaluator>();
register_consensus_evaluator<witness_update_evaluator>();
register_consensus_evaluator<withdraw_permission_create_evaluator>();
register_consensus_evaluator<withdraw_permission_claim_evaluator>();
register_consensus_evaluator<withdraw_permission_update_evaluator>();
register_consensus_evaluator<withdraw_permission_delete_evaluator>();
register_consensus_evaluator<worker_create_evaluator>();
register_consensus_evaluator<balance_claim_evaluator>();
register_consensus_evaluator<transfer_to_blind_evaluator>();
register_consensus_evaluator<transfer_from_blind_evaluator>();
register_consensus_evaluator<blind_transfer_evaluator>();
register_consensus_evaluator<asset_claim_fees_evaluator>();
register_consensus_evaluator<sport_create_evaluator>();
register_consensus_evaluator<sport_update_evaluator>();
register_consensus_evaluator<sport_delete_evaluator>();
register_consensus_evaluator<event_group_create_evaluator>();
register_consensus_evaluator<event_group_update_evaluator>();
register_consensus_evaluator<event_group_delete_evaluator>();
register_consensus_evaluator<event_create_evaluator>();
register_consensus_evaluator<event_update_evaluator>();
register_consensus_evaluator<event_update_status_evaluator>();
register_consensus_evaluator<betting_market_rules_create_evaluator>();
register_consensus_evaluator<betting_market_rules_update_evaluator>();
register_consensus_evaluator<betting_market_group_create_evaluator>();
register_consensus_evaluator<betting_market_group_update_evaluator>();
register_consensus_evaluator<betting_market_create_evaluator>();
register_consensus_evaluator<betting_market_update_evaluator>();
register_consensus_evaluator<bet_place_evaluator>();
register_consensus_evaluator<bet_cancel_evaluator>();
register_consensus_evaluator<betting_market_group_resolve_evaluator>();
register_consensus_evaluator<betting_market_group_cancel_unmatched_bets_evaluator>();
register_consensus_evaluator<tournament_create_evaluator>();
register_consensus_evaluator<tournament_join_evaluator>();
register_consensus_evaluator<game_move_evaluator>();
register_consensus_evaluator<tournament_leave_evaluator>();
register_consensus_evaluator<lottery_asset_create_evaluator>();
register_consensus_evaluator<ticket_purchase_evaluator>();
register_consensus_evaluator<lottery_reward_evaluator>();
register_consensus_evaluator<lottery_end_evaluator>();
register_consensus_evaluator<sweeps_vesting_claim_evaluator>();
register_consensus_evaluator<create_custom_permission_evaluator>();
register_consensus_evaluator<update_custom_permission_evaluator>();
register_consensus_evaluator<delete_custom_permission_evaluator>();
register_consensus_evaluator<create_custom_account_authority_evaluator>();
register_consensus_evaluator<update_custom_account_authority_evaluator>();
register_consensus_evaluator<delete_custom_account_authority_evaluator>();
register_consensus_evaluator<offer_evaluator>();
register_consensus_evaluator<bid_evaluator>();
register_consensus_evaluator<cancel_offer_evaluator>();
register_consensus_evaluator<finalize_offer_evaluator>();
register_consensus_evaluator<nft_metadata_create_evaluator>();
register_consensus_evaluator<nft_metadata_update_evaluator>();
register_consensus_evaluator<nft_mint_evaluator>();
register_consensus_evaluator<nft_safe_transfer_from_evaluator>();
register_consensus_evaluator<nft_approve_evaluator>();
register_consensus_evaluator<nft_set_approval_for_all_evaluator>();
register_consensus_evaluator<account_role_create_evaluator>();
register_consensus_evaluator<account_role_update_evaluator>();
register_consensus_evaluator<account_role_delete_evaluator>();
register_consensus_evaluator<nft_lottery_token_purchase_evaluator>();
register_consensus_evaluator<nft_lottery_reward_evaluator>();
register_consensus_evaluator<nft_lottery_end_evaluator>();
register_consensus_evaluator<create_son_evaluator>();
register_consensus_evaluator<update_son_evaluator>();
register_consensus_evaluator<deregister_son_evaluator>();
register_consensus_evaluator<son_heartbeat_evaluator>();
register_consensus_evaluator<son_report_down_evaluator>();
register_consensus_evaluator<son_maintenance_evaluator>();
register_consensus_evaluator<recreate_son_wallet_evaluator>();
register_consensus_evaluator<update_son_wallet_evaluator>();
register_consensus_evaluator<create_son_wallet_deposit_evaluator>();
register_consensus_evaluator<process_son_wallet_deposit_evaluator>();
register_consensus_evaluator<create_son_wallet_withdraw_evaluator>();
register_consensus_evaluator<process_son_wallet_withdraw_evaluator>();
register_consensus_evaluator<add_sidechain_address_evaluator>();
register_consensus_evaluator<update_sidechain_address_evaluator>();
register_consensus_evaluator<delete_sidechain_address_evaluator>();
register_consensus_evaluator<sidechain_transaction_create_evaluator>();
register_consensus_evaluator<sidechain_transaction_sign_evaluator>();
register_consensus_evaluator<sidechain_transaction_send_evaluator>();
register_consensus_evaluator<sidechain_transaction_settle_evaluator>();
register_consensus_evaluator<random_number_store_evaluator>();
}
void database::initialize_indexes()
@ -334,6 +335,12 @@ void database::initialize_indexes()
reset_indexes();
_undo_db.set_max_size( GRAPHENE_MIN_UNDO_HISTORY );
_check_policy_1 = allocate_object_space<database_lock_safety_check>(protocol_ids);
_check_policy_2 = allocate_object_space<database_lock_safety_check>(implementation_ids);
// No checks on API objects
allocate_object_space<null_safety_check>(api_ids);
FC_ASSERT(_check_policy_1 != nullptr && _check_policy_2 != nullptr, "Failed to allocate object spaces");
//Protocol object indexes
add_index< primary_index<asset_index, 13> >(); // 8192 assets per chunk
add_index< primary_index<force_settlement_index> >();
@ -420,6 +427,8 @@ void database::initialize_indexes()
add_index< primary_index<son_stats_index > >();
add_index< primary_index<random_number_index > >();
_check_policy_1->lock();
_check_policy_2->lock();
}
void database::init_genesis(const genesis_state_type& genesis_state)
@ -433,6 +442,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
"initial_active_witnesses is larger than the number of candidate witnesses.");
_undo_db.disable();
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
struct auth_inhibitor {
auth_inhibitor(database& db) : db(db), old_flags(db.node_properties().skip_flags)
{ db.node_properties().skip_flags |= skip_authority_check; }
@ -680,7 +690,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
p.time = genesis_state.initial_timestamp;
p.dynamic_flags = 0;
p.witness_budget = 0;
p.recent_slots_filled = fc::uint128::max_value();
p.recent_slots_filled = std::numeric_limits<fc::uint128_t>::max();
});
create<global_betting_statistics_object>([&](global_betting_statistics_object& betting_statistics) {
betting_statistics.number_of_active_events = 0;
@ -903,7 +913,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
for( const auto& handout : genesis_state.initial_balances )
{
const auto asset_id = get_asset_id(handout.asset_symbol);
create<balance_object>([&handout,&get_asset_id,total_allocation,asset_id](balance_object& b) {
create<balance_object>([&handout,total_allocation,asset_id](balance_object& b) {
b.balance = asset(handout.amount, asset_id);
b.owner = handout.owner;
});
@ -1049,7 +1059,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
_wso.last_scheduling_block = 0;
_wso.recent_slots_filled = fc::uint128::max_value();
_wso.recent_slots_filled = std::numeric_limits<fc::uint128_t>::max();
// for shuffled
for( const witness_id_type& wid : get_global_properties().active_witnesses )
@ -1076,7 +1086,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
_sso.last_scheduling_block = 0;
_sso.recent_slots_filled = fc::uint128::max_value();
_sso.recent_slots_filled = std::numeric_limits<fc::uint128_t>::max();
});
assert( sso.id == son_schedule_id_type() );

View file

@ -22,10 +22,6 @@
* THE SOFTWARE.
*/
#include <boost/multiprecision/integer.hpp>
#include <fc/uint128.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/fba_accumulator_id.hpp>
#include <graphene/chain/hardfork.hpp>
@ -51,6 +47,8 @@
#include <graphene/chain/witness_schedule_object.hpp>
#include <graphene/chain/worker_object.hpp>
#include <numeric>
namespace graphene { namespace chain {
template<class Index>
@ -427,7 +425,7 @@ void database::pay_workers( share_type& budget )
// worker with more votes is preferred
// if two workers exactly tie for votes, worker with lower ID is preferred
std::sort(active_workers.begin(), active_workers.end(), [this](const worker_object& wa, const worker_object& wb) {
std::sort(active_workers.begin(), active_workers.end(), [](const worker_object& wa, const worker_object& wb) {
share_type wa_vote = wa.approving_stake();
share_type wb_vote = wb.approving_stake();
if( wa_vote != wb_vote )
@ -447,10 +445,10 @@ void database::pay_workers( share_type& budget )
// Note: if there is a good chance that passed_time_count == day_count,
// for better performance, can avoid the 128 bit calculation by adding a check.
// Since it's not the case on BitShares mainnet, we're not using a check here.
fc::uint128 pay(requested_pay.value);
fc::uint128_t pay = requested_pay.value;
pay *= passed_time_count;
pay /= day_count;
requested_pay = pay.to_uint64();
requested_pay = pay;
share_type actual_pay = std::min(budget, requested_pay);
//ilog(" ==> Paying ${a} to worker ${w}", ("w", active_worker.id)("a", actual_pay));
@ -839,7 +837,7 @@ void database::initialize_budget_record( fc::time_point_sec now, budget_record&
budget_u128 >>= GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS;
share_type budget;
if( budget_u128 < reserve.value )
rec.total_budget = share_type(budget_u128.to_uint64());
rec.total_budget = share_type(budget_u128);
else
rec.total_budget = reserve;
@ -905,7 +903,7 @@ void database::process_budget()
if( worker_budget_u128 >= available_funds.value )
worker_budget = available_funds;
else
worker_budget = worker_budget_u128.to_uint64();
worker_budget = worker_budget_u128;
rec.worker_budget = worker_budget;
available_funds -= worker_budget;
@ -1050,12 +1048,12 @@ void split_fba_balance(
fc::uint128_t buyback_amount_128 = fba.accumulated_fba_fees.value;
buyback_amount_128 *= designated_asset_buyback_pct;
buyback_amount_128 /= GRAPHENE_100_PERCENT;
share_type buyback_amount = buyback_amount_128.to_uint64();
share_type buyback_amount = buyback_amount_128;
fc::uint128_t issuer_amount_128 = fba.accumulated_fba_fees.value;
issuer_amount_128 *= designated_asset_issuer_pct;
issuer_amount_128 /= GRAPHENE_100_PERCENT;
share_type issuer_amount = issuer_amount_128.to_uint64();
share_type issuer_amount = issuer_amount_128;
// this assert should never fail
FC_ASSERT( buyback_amount + issuer_amount <= fba.accumulated_fba_fees );
@ -1532,7 +1530,7 @@ void schedule_pending_dividend_balances(database& db,
minimum_amount_to_distribute *= 100 * GRAPHENE_1_PERCENT;
minimum_amount_to_distribute /= dividend_data.options.minimum_fee_percentage;
wdump((total_fee_per_asset_in_payout_asset)(dividend_data.options));
minimum_shares_to_distribute = minimum_amount_to_distribute.to_uint64();
minimum_shares_to_distribute = minimum_amount_to_distribute;
}
dlog("Processing dividend payments of asset type ${payout_asset_type}, delta balance is ${delta_balance}", ("payout_asset_type", payout_asset_type(db).symbol)("delta_balance", delta_balance));
@ -1594,7 +1592,7 @@ void schedule_pending_dividend_balances(database& db,
fc::uint128_t amount_to_credit(delta_balance.value);
amount_to_credit *= holder_balance.amount.value;
amount_to_credit /= total_balance_of_dividend_asset.value;
share_type full_shares_to_credit((int64_t) amount_to_credit.to_uint64());
share_type full_shares_to_credit((int64_t) amount_to_credit);
share_type shares_to_credit = (uint64_t) floor(full_shares_to_credit.value * vesting_factor);
if (shares_to_credit < full_shares_to_credit) {
@ -1631,7 +1629,7 @@ void schedule_pending_dividend_balances(database& db,
fc::uint128_t amount_to_credit(delta_balance.value);
amount_to_credit *= holder_balance.value;
amount_to_credit /= total_balance_of_dividend_asset.value;
share_type shares_to_credit((int64_t) amount_to_credit.to_uint64());
share_type shares_to_credit((int64_t) amount_to_credit);
remaining_amount_to_distribute = credit_account(db,
holder_balance_object.owner,
@ -1691,7 +1689,7 @@ void schedule_pending_dividend_balances(database& db,
fc::uint128_t amount_to_debit(remaining_amount_to_recover.value);
amount_to_debit *= pending_balance_object.pending_balance.value;
amount_to_debit /= remaining_pending_balances.value;
share_type shares_to_debit((int64_t)amount_to_debit.to_uint64());
share_type shares_to_debit((int64_t)amount_to_debit);
remaining_amount_to_recover -= shares_to_debit;
remaining_pending_balances -= pending_balance_object.pending_balance;

View file

@ -29,7 +29,8 @@
#include <graphene/chain/special_authority_object.hpp>
#include <graphene/chain/operation_history_object.hpp>
#include <graphene/chain/nft_object.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <fc/io/fstream.hpp>
@ -39,9 +40,12 @@
namespace graphene { namespace chain {
database::database() :
_random_number_generator(fc::ripemd160().data())
database::database(bool allow_testing_edits) :
_random_number_generator(fc::ripemd160().data()),
_allow_safety_check_bypass(allow_testing_edits)
{
if (allow_testing_edits)
elog("UNIT TESTING MODE ENABLED -- NOT FOR PRODUCTION USE");
initialize_indexes();
initialize_evaluators();
}

View file

@ -575,10 +575,10 @@ asset database::calculate_market_fee( const asset_object& trade_asset, const ass
if( trade_asset.options.market_fee_percent == 0 )
return trade_asset.amount(0);
fc::uint128 a(trade_amount.amount.value);
fc::uint128_t a(trade_amount.amount.value);
a *= trade_asset.options.market_fee_percent;
a /= GRAPHENE_100_PERCENT;
asset percent_fee = trade_asset.amount(a.to_uint64());
asset percent_fee = trade_asset.amount(a);
if( percent_fee.amount > trade_asset.options.max_market_fee )
percent_fee.amount = trade_asset.options.max_market_fee;

View file

@ -24,11 +24,11 @@
#include <fc/container/flat.hpp>
#include <graphene/protocol/authority.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/protocol/transaction.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/protocol/authority.hpp>
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/protocol/transaction.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/withdraw_permission_object.hpp>
#include <graphene/chain/worker_object.hpp>
#include <graphene/chain/confidential_object.hpp>
@ -39,14 +39,17 @@
#include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/operation_history_object.hpp>
#include <graphene/chain/vesting_balance_object.hpp>
#include <graphene/chain/transaction_object.hpp>
#include <graphene/chain/transaction_history_object.hpp>
#include <graphene/chain/impacted.hpp>
#include <graphene/chain/hardfork.hpp>
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/account_role_object.hpp>
#include <graphene/chain/son_object.hpp>
#include <graphene/chain/sidechain_address_object.hpp>
#include <graphene/chain/tournament_object.hpp>
#include <graphene/chain/custom_permission_object.hpp>
#include <graphene/chain/offer_object.hpp>
#include <graphene/chain/nft_object.hpp>
using namespace fc;
using namespace graphene::chain;
@ -450,7 +453,6 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
{
case null_object_type:
case base_object_type:
case OBJECT_TYPE_COUNT:
return;
case account_object_type:{
accounts.insert( obj->id );
@ -493,11 +495,7 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
transaction_get_impacted_accounts( aobj->proposed_transaction, accounts,
ignore_custom_operation_required_auths);
break;
} case operation_history_object_type:{
const auto& aobj = dynamic_cast<const operation_history_object*>(obj);
assert( aobj != nullptr );
operation_get_impacted_accounts( aobj->op, accounts,
ignore_custom_operation_required_auths);
} case reserved0_object_type:{
break;
} case withdraw_permission_object_type:{
const auto& aobj = dynamic_cast<const withdraw_permission_object*>(obj);
@ -518,7 +516,85 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
} case balance_object_type:{
/** these are free from any accounts */
break;
} case account_role_type:{
} case tournament_object_type:{
auto aobj = dynamic_cast<const tournament_object*>(obj);
assert(aobj != nullptr);
accounts.insert(aobj->creator);
accounts.insert(aobj->options.whitelist.begin(), aobj->options.whitelist.end());
break;
} case tournament_details_object_type:{
auto aobj = dynamic_cast<const tournament_details_object*>(obj);
assert(aobj != nullptr);
accounts.insert(aobj->registered_players.begin(), aobj->registered_players.end());
std::transform(aobj->payers.begin(), aobj->payers.end(), std::inserter(accounts, accounts.end()),
[](const auto& pair) { return pair.first; });
std::for_each(aobj->players_payers.begin(), aobj->players_payers.end(),
[&accounts](const auto& pair) {
accounts.insert(pair.first);
accounts.insert(pair.second);
});
break;
} case match_object_type:{
auto aobj = dynamic_cast<const match_object*>(obj);
assert(aobj != nullptr);
accounts.insert(aobj->players.begin(), aobj->players.end());
std::for_each(aobj->game_winners.begin(), aobj->game_winners.end(),
[&accounts](const auto& set) { accounts.insert(set.begin(), set.end()); });
accounts.insert(aobj->match_winners.begin(), aobj->match_winners.end());
break;
} case game_object_type:{
auto aobj = dynamic_cast<const game_object*>(obj);
assert(aobj != nullptr);
accounts.insert(aobj->players.begin(), aobj->players.end());
accounts.insert(aobj->winners.begin(), aobj->winners.end());
break;
} case sport_object_type:
break;
case event_group_object_type:
break;
case event_object_type:
break;
case betting_market_rules_object_type:
break;
case betting_market_group_object_type:
break;
case betting_market_object_type:
break;
case bet_object_type:{
auto aobj = dynamic_cast<const bet_object*>(obj);
assert(aobj != nullptr);
accounts.insert(aobj->bettor_id);
break;
} case custom_permission_object_type:{
auto aobj = dynamic_cast<const custom_permission_object*>(obj);
assert(aobj != nullptr);
accounts.insert(aobj->account);
add_authority_accounts(accounts, aobj->auth);
break;
} case custom_account_authority_object_type:
break;
case offer_object_type:{
auto aobj = dynamic_cast<const offer_object*>(obj);
assert(aobj != nullptr);
accounts.insert(aobj->issuer);
if (aobj->bidder.valid())
accounts.insert(*aobj->bidder);
break;
} case nft_metadata_object_type:{
auto aobj = dynamic_cast<const nft_metadata_object*>(obj);
assert(aobj != nullptr);
accounts.insert(aobj->owner);
if (aobj->revenue_partner.valid())
accounts.insert(*aobj->revenue_partner);
break;
} case nft_object_type:{
auto aobj = dynamic_cast<const nft_object*>(obj);
assert(aobj != nullptr);
accounts.insert(aobj->owner);
accounts.insert(aobj->approved);
accounts.insert(aobj->approved_operators.begin(), aobj->approved_operators.end());
break;
} case account_role_object_type:{
const auto& aobj = dynamic_cast<const account_role_object*>(obj);
assert( aobj != nullptr );
accounts.insert( aobj->owner );
@ -529,6 +605,8 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
assert( aobj != nullptr );
accounts.insert( aobj->son_account );
break;
} case son_proposal_object_type:{
break;
} case son_wallet_object_type:{
break;
} case son_wallet_deposit_object_type:{
@ -558,9 +636,9 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
break;
case impl_reserved0_object_type:
break;
case impl_asset_dynamic_data_type:
case impl_asset_dynamic_data_object_type:
break;
case impl_asset_bitasset_data_type:
case impl_asset_bitasset_data_object_type:
break;
case impl_account_balance_object_type:{
const auto& aobj = dynamic_cast<const account_balance_object*>(obj);
@ -572,11 +650,11 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
assert( aobj != nullptr );
accounts.insert( aobj->owner );
break;
} case impl_transaction_object_type:{
const auto& aobj = dynamic_cast<const transaction_object*>(obj);
assert( aobj != nullptr );
} case impl_transaction_history_object_type:{
const auto& aobj = dynamic_cast<const transaction_history_object*>(obj);
FC_ASSERT( aobj != nullptr );
transaction_get_impacted_accounts( aobj->trx, accounts,
ignore_custom_operation_required_auths);
ignore_custom_operation_required_auths );
break;
} case impl_blinded_balance_object_type:{
const auto& aobj = dynamic_cast<const blinded_balance_object*>(obj);
@ -586,7 +664,7 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
break;
} case impl_block_summary_object_type:
break;
case impl_account_transaction_history_object_type:
case impl_reserved1_object_type:
break;
case impl_chain_property_object_type:
break;
@ -600,11 +678,62 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
break;
case impl_fba_accumulator_object_type:
break;
case impl_asset_dividend_data_object_type:{
const auto& aobj = dynamic_cast<const asset_dividend_data_object*>(obj);
assert( aobj != nullptr );
accounts.insert(aobj->dividend_distribution_account);
break;
} case impl_pending_dividend_payout_balance_for_holder_object_type:{
const auto& aobj = dynamic_cast<const pending_dividend_payout_balance_for_holder_object*>(obj);
assert( aobj != nullptr );
accounts.insert(aobj->owner);
break;
} case impl_total_distributed_dividend_balance_object_type:
break;
case impl_betting_market_position_object_type:{
const auto& aobj = dynamic_cast<const betting_market_position_object*>(obj);
assert( aobj != nullptr );
accounts.insert(aobj->bettor_id);
break;
} case impl_global_betting_statistics_object_type:
break;
case impl_lottery_balance_object_type:
break;
case impl_sweeps_vesting_balance_object_type:{
const auto& aobj = dynamic_cast<const sweeps_vesting_balance_object*>(obj);
assert( aobj != nullptr );
accounts.insert(aobj->owner);
break;
} case impl_offer_history_object_type:{
const auto& aobj = dynamic_cast<const offer_history_object*>(obj);
assert( aobj != nullptr );
accounts.insert(aobj->issuer);
if (aobj->bidder.valid())
accounts.insert(*aobj->bidder);
break;
} case impl_son_statistics_object_type: {
break;
} case impl_son_schedule_object_type: {
break;
}
case impl_nft_lottery_balance_object_type:
break;
default:
break;
}
} else if( obj->id.space() == api_ids ) {
switch( (api_object_type)obj->id.type() )
{
case graphene::chain::api_operation_history_object_type: {
const auto& aobj = dynamic_cast<const operation_history_object*>(obj);
assert( aobj != nullptr );
operation_get_impacted_accounts( aobj->op, accounts,
ignore_custom_operation_required_auths);
break;
}
case api_account_transaction_history_object_type:
break;
}
}
} // end get_relevant_accounts( const object* obj, flat_set<account_id_type>& accounts )

View file

@ -35,13 +35,11 @@
#include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/son_proposal_object.hpp>
#include <graphene/chain/tournament_object.hpp>
#include <graphene/chain/transaction_object.hpp>
#include <graphene/chain/transaction_history_object.hpp>
#include <graphene/chain/withdraw_permission_object.hpp>
#include <graphene/chain/witness_object.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <fc/uint128.hpp>
#include <graphene/protocol/fee_schedule.hpp>
namespace graphene { namespace chain {
@ -156,7 +154,8 @@ void database::clear_expired_transactions()
{ try {
//Look for expired transactions in the deduplication list, and remove them.
//Transactions must have expired by at least two forking windows in order to be removed.
auto& transaction_idx = static_cast<transaction_index&>(get_mutable_index(implementation_ids, impl_transaction_object_type));
auto& transaction_idx = static_cast<transaction_index&>(get_mutable_index(implementation_ids,
impl_transaction_history_object_type));
const auto& dedupe_index = transaction_idx.indices().get<by_expiration>();
while( (!dedupe_index.empty()) && (head_block_time() > dedupe_index.begin()->trx.expiration) )
transaction_idx.remove(*dedupe_index.begin());
@ -427,7 +426,7 @@ void database::clear_expired_orders()
auto& pays = order.balance;
auto receives = (order.balance * mia.current_feed.settlement_price);
receives.amount = (fc::uint128_t(receives.amount.value) *
(GRAPHENE_100_PERCENT - mia.options.force_settlement_offset_percent) / GRAPHENE_100_PERCENT).to_uint64();
(GRAPHENE_100_PERCENT - mia.options.force_settlement_offset_percent) / GRAPHENE_100_PERCENT);
assert(receives <= order.balance * mia.current_feed.settlement_price);
price settlement_price = pays / receives;

View file

@ -22,12 +22,14 @@
* THE SOFTWARE.
*/
#include <graphene/protocol/son_info.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/global_property_object.hpp>
#include <graphene/chain/witness_object.hpp>
#include <graphene/chain/witness_schedule_object.hpp>
#include <graphene/chain/son_object.hpp>
#include <graphene/chain/son_info.hpp>
#include <fc/popcount.hpp>
namespace graphene { namespace chain {
@ -267,7 +269,7 @@ void database::update_witness_schedule(const signed_block& next_block)
modify(wso, [&](witness_schedule_object& _wso)
{
_wso.slots_since_genesis += schedule_slot;
witness_scheduler_rng rng(wso.rng_seed.data, _wso.slots_since_genesis);
witness_scheduler_rng rng(wso.rng_seed.data(), _wso.slots_since_genesis);
_wso.scheduler._min_token_count = std::max(int(gpo.active_witnesses.size()) / 2, 1);
@ -332,7 +334,7 @@ void database::update_son_schedule(const signed_block& next_block)
modify(sso, [&](son_schedule_object& _sso)
{
_sso.slots_since_genesis += schedule_slot;
witness_scheduler_rng rng(sso.rng_seed.data, _sso.slots_since_genesis);
witness_scheduler_rng rng(sso.rng_seed.data(), _sso.slots_since_genesis);
_sso.scheduler._min_token_count = std::max(int(gpo.active_sons.size()) / 2, 1);
@ -391,12 +393,12 @@ uint32_t database::witness_participation_rate()const
if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SHUFFLED_ALGORITHM)
{
const dynamic_global_property_object& dpo = get_dynamic_global_properties();
return uint64_t(GRAPHENE_100_PERCENT) * dpo.recent_slots_filled.popcount() / 128;
return uint64_t(GRAPHENE_100_PERCENT) * fc::popcount(dpo.recent_slots_filled) / 128;
}
if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM)
{
const witness_schedule_object& wso = get_witness_schedule_object();
return uint64_t(GRAPHENE_100_PERCENT) * wso.recent_slots_filled.popcount() / 128;
return uint64_t(GRAPHENE_100_PERCENT) * fc::popcount(wso.recent_slots_filled) / 128;
}
return 0;
}

View file

@ -33,14 +33,12 @@
#include <graphene/chain/fba_object.hpp>
#include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/market_evaluator.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <fc/uint128.hpp>
#include <graphene/protocol/fee_schedule.hpp>
namespace graphene { namespace chain {
database& generic_evaluator::db()const { return trx_state->db(); }
database& consensus_evaluator::db()const { return trx_state->db(); }
operation_result generic_evaluator::start_evaluate( transaction_evaluation_state& eval_state, const operation& op, bool apply )
operation_result consensus_evaluator::start_evaluate( transaction_evaluation_state& eval_state, const operation& op, bool apply )
{ try {
trx_state = &eval_state;
//check_required_authorities(op);
@ -50,7 +48,7 @@ database& generic_evaluator::db()const { return trx_state->db(); }
return result;
} FC_CAPTURE_AND_RETHROW() }
void generic_evaluator::prepare_fee(account_id_type account_id, asset fee)
void consensus_evaluator::prepare_fee(account_id_type account_id, asset fee)
{
const database& d = db();
fee_from_account = fee;
@ -79,7 +77,7 @@ database& generic_evaluator::db()const { return trx_state->db(); }
}
}
void generic_evaluator::convert_fee()
void consensus_evaluator::convert_fee()
{
if( !trx_state->skip_fee ) {
if( fee_asset->get_id() != asset_id_type() )
@ -92,7 +90,7 @@ database& generic_evaluator::db()const { return trx_state->db(); }
}
}
void generic_evaluator::pay_fee()
void consensus_evaluator::pay_fee()
{ try {
if( !trx_state->skip_fee ) {
database& d = db();
@ -104,13 +102,13 @@ database& generic_evaluator::db()const { return trx_state->db(); }
}
} FC_CAPTURE_AND_RETHROW() }
void generic_evaluator::pay_fba_fee( uint64_t fba_id )
void consensus_evaluator::pay_fba_fee( uint64_t fba_id )
{
database& d = db();
const fba_accumulator_object& fba = d.get< fba_accumulator_object >( fba_accumulator_id_type( fba_id ) );
if( !fba.is_configured(d) )
{
generic_evaluator::pay_fee();
consensus_evaluator::pay_fee();
return;
}
d.modify( fba, [&]( fba_accumulator_object& _fba )
@ -119,16 +117,16 @@ database& generic_evaluator::db()const { return trx_state->db(); }
} );
}
share_type generic_evaluator::calculate_fee_for_operation(const operation& op) const
share_type consensus_evaluator::calculate_fee_for_operation(const operation& op) const
{
return db().current_fee_schedule().calculate_fee( op ).amount;
}
void generic_evaluator::db_adjust_balance(const account_id_type& fee_payer, asset fee_from_account)
void consensus_evaluator::db_adjust_balance(const account_id_type& fee_payer, asset fee_from_account)
{
db().adjust_balance(fee_payer, fee_from_account);
}
object_id_type generic_evaluator::get_relative_id( object_id_type rel_id )const
object_id_type consensus_evaluator::get_relative_id( object_id_type rel_id )const
{
if (!is_relative(rel_id))
FC_THROW("get_relative_id() called for non-relative id ${id}", ("id", rel_id));

View file

@ -29,6 +29,7 @@
#include <graphene/chain/hardfork.hpp>
#include <graphene/chain/is_authorized_asset.hpp>
#include <graphene/chain/global_betting_statistics_object.hpp>
#include <graphene/chain/betting_market_object.hpp>
namespace graphene { namespace chain {

View file

@ -0,0 +1,135 @@
/*
* Copyright (c) 2019 BitShares Blockchain Foundation, and contributors.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/internal_exceptions.hpp>
namespace graphene { namespace chain {
// Internal exceptions
FC_IMPLEMENT_DERIVED_EXCEPTION( internal_exception, graphene::chain::chain_exception, 3990000, "internal exception" )
GRAPHENE_IMPLEMENT_INTERNAL_EXCEPTION( verify_auth_max_auth_exceeded, 1, "Exceeds max authority fan-out" )
GRAPHENE_IMPLEMENT_INTERNAL_EXCEPTION( verify_auth_account_not_found, 2, "Auth account not found" )
// Public exceptions
FC_IMPLEMENT_EXCEPTION( chain_exception, 3000000, "blockchain exception" )
FC_IMPLEMENT_DERIVED_EXCEPTION( database_query_exception, chain_exception, 3010000, "database query exception" )
FC_IMPLEMENT_DERIVED_EXCEPTION( block_validate_exception, chain_exception, 3020000, "block validation exception" )
FC_IMPLEMENT_DERIVED_EXCEPTION( operation_validate_exception, chain_exception, 3040000, "operation validation exception" )
FC_IMPLEMENT_DERIVED_EXCEPTION( operation_evaluate_exception, chain_exception, 3050000, "operation evaluation exception" )
FC_IMPLEMENT_DERIVED_EXCEPTION( utility_exception, chain_exception, 3060000, "utility method exception" )
FC_IMPLEMENT_DERIVED_EXCEPTION( undo_database_exception, chain_exception, 3070000, "undo database exception" )
FC_IMPLEMENT_DERIVED_EXCEPTION( unlinkable_block_exception, chain_exception, 3080000, "unlinkable block" )
FC_IMPLEMENT_DERIVED_EXCEPTION( black_swan_exception, chain_exception, 3090000, "black swan" )
FC_IMPLEMENT_DERIVED_EXCEPTION( plugin_exception, chain_exception, 3100000, "plugin exception" )
FC_IMPLEMENT_DERIVED_EXCEPTION( insufficient_feeds, chain_exception, 37006, "insufficient feeds" )
FC_IMPLEMENT_DERIVED_EXCEPTION( pop_empty_chain, undo_database_exception, 3070001, "there are no blocks to pop" )
GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( transfer );
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( from_account_not_whitelisted, transfer, 1, "owner mismatch" )
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( to_account_not_whitelisted, transfer, 2, "owner mismatch" )
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( restricted_transfer_asset, transfer, 3, "restricted transfer asset" )
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( limit_order_create );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( limit_order_cancel );
GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( call_order_update );
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( unfilled_margin_call, call_order_update, 1, "Updating call order would trigger a margin call that cannot be fully filled" )
GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_create );
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( max_auth_exceeded, account_create, 1, "Exceeds max authority fan-out" )
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( auth_account_not_found, account_create, 2, "Auth account not found" )
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( buyback_incorrect_issuer, account_create, 3, "Incorrect issuer specified for account" )
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( buyback_already_exists, account_create, 4, "Cannot create buyback for asset which already has buyback" )
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( buyback_too_many_markets, account_create, 5, "Too many buyback markets" )
GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_update );
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( max_auth_exceeded, account_update, 1, "Exceeds max authority fan-out" )
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( auth_account_not_found, account_update, 2, "Auth account not found" )
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_whitelist );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_upgrade );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_transfer );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_create );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update_bitasset );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update_feed_producers );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_issue );
GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_reserve );
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( invalid_on_mia, asset_reserve, 1, "invalid on mia" )
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_fund_fee_pool );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_settle );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_global_settle );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_publish_feed );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( committee_member_create );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( witness_create );
GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( proposal_create );
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( review_period_required, proposal_create, 1, "review_period required" )
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( review_period_insufficient, proposal_create, 2, "review_period insufficient" )
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( proposal_update );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( proposal_delete );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_create );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_update );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_claim );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_delete );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( fill_order );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( global_parameters_update );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( vesting_balance_create );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( vesting_balance_withdraw );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( worker_create );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( custom );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( assert );
GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( balance_claim );
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( claimed_too_often, balance_claim, 1, "balance claimed too often" )
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( invalid_claim_amount, balance_claim, 2, "invalid claim amount" )
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( owner_mismatch, balance_claim, 3, "owner mismatch" )
GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( override_transfer );
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( not_permitted, override_transfer, 1, "not permitted" )
GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( blind_transfer );
GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( unknown_commitment, blind_transfer, 1, "Attempting to claim an unknown prior commitment" );
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( transfer_from_blind_operation )
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_claim_fees_operation )
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( bid_collateral_operation )
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_claim_pool_operation )
//GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update_issuer_operation )
#define GRAPHENE_RECODE_EXC( cause_type, effect_type ) \
catch( const cause_type& e ) \
{ throw( effect_type( e.what(), e.get_log() ) ); }
} } // graphene::chain

View file

@ -23,7 +23,7 @@
*/
#include <graphene/chain/fork_database.hpp>
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/protocol/fee_schedule.hpp>
namespace graphene { namespace chain {
fork_database::fork_database()

View file

@ -24,8 +24,8 @@
#include <graphene/chain/genesis_state.hpp>
// these are required to serialize a genesis_state
#include <graphene/chain/protocol/fee_schedule.hpp>
// this is required to serialize a genesis_state
#include <graphene/protocol/fee_schedule.hpp>
namespace graphene { namespace chain {

View file

@ -24,7 +24,7 @@
#include <graphene/chain/get_config.hpp>
#include <graphene/chain/config.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/types.hpp>
namespace graphene { namespace chain {
@ -74,7 +74,6 @@ fc::variant_object get_config()
result[ "GRAPHENE_MAX_COLLATERAL_RATIO" ] = GRAPHENE_MAX_COLLATERAL_RATIO;
result[ "GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO" ] = GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO;
result[ "GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO" ] = GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO;
result[ "GRAPHENE_DEFAULT_MARGIN_PERIOD_SEC" ] = GRAPHENE_DEFAULT_MARGIN_PERIOD_SEC;
result[ "GRAPHENE_DEFAULT_MAX_WITNESSES" ] = GRAPHENE_DEFAULT_MAX_WITNESSES;
result[ "GRAPHENE_DEFAULT_MAX_COMMITTEE" ] = GRAPHENE_DEFAULT_MAX_COMMITTEE;
result[ "GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC" ] = GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC;

View file

@ -1,7 +1,7 @@
// #210 Check authorities on custom_operation
#ifndef HARDFORK_CORE_210_TIME
#ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_CORE_210_TIME (fc::time_point_sec::from_iso_string("2030-01-01T00:00:00")) // (Not yet scheduled)
#define HARDFORK_CORE_210_TIME (fc::time_point_sec::from_iso_string("2021-01-01T00:00:00"))
#else
#define HARDFORK_CORE_210_TIME (fc::time_point_sec::from_iso_string("2030-01-01T00:00:00")) // (Not yet scheduled)
#endif

View file

@ -1,3 +1,4 @@
// The value should be harmonized with the protcol constant named GPOS_PERIOD_START
#ifndef HARDFORK_GPOS_TIME
#ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_GPOS_TIME (fc::time_point_sec::from_iso_string("2020-01-06T01:00:00"))

View file

@ -27,7 +27,7 @@
namespace graphene { namespace chain {
class account_create_evaluator : public evaluator<account_create_evaluator>
class account_create_evaluator : public fee_handling_evaluator<account_create_evaluator>
{
public:
typedef account_create_operation operation_type;
@ -36,7 +36,7 @@ public:
object_id_type do_apply( const account_create_operation& o ) ;
};
class account_update_evaluator : public evaluator<account_update_evaluator>
class account_update_evaluator : public fee_handling_evaluator<account_update_evaluator>
{
public:
typedef account_update_operation operation_type;
@ -47,7 +47,7 @@ public:
const account_object* acnt;
};
class account_upgrade_evaluator : public evaluator<account_upgrade_evaluator>
class account_upgrade_evaluator : public fee_handling_evaluator<account_upgrade_evaluator>
{
public:
typedef account_upgrade_operation operation_type;
@ -58,7 +58,7 @@ public:
const account_object* account;
};
class account_whitelist_evaluator : public evaluator<account_whitelist_evaluator>
class account_whitelist_evaluator : public fee_handling_evaluator<account_whitelist_evaluator>
{
public:
typedef account_whitelist_operation operation_type;

View file

@ -22,13 +22,15 @@
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/db/generic_index.hpp>
#include <graphene/chain/protocol/account.hpp>
#include <graphene/chain/types.hpp>
#include <boost/multi_index/composite_key.hpp>
namespace graphene { namespace chain {
class database;
class account_object;
class vesting_balance_object;
/**
* @class account_statistics_object
@ -321,7 +323,8 @@ namespace graphene { namespace chain {
};
public:
virtual void object_inserted( const object& obj ) override;
virtual void object_loaded( const object& obj ) override;
virtual void object_created( const object& obj ) override;
virtual void object_removed( const object& obj ) override;
virtual void about_to_modify( const object& before ) override;
virtual void object_modified( const object& after ) override;
@ -352,7 +355,8 @@ namespace graphene { namespace chain {
class account_referrer_index : public secondary_index
{
public:
virtual void object_inserted( const object& obj ) override;
virtual void object_loaded( const object& obj ) override;
virtual void object_created( const object& obj ) override;
virtual void object_removed( const object& obj ) override;
virtual void about_to_modify( const object& before ) override;
virtual void object_modified( const object& after ) override;
@ -393,7 +397,8 @@ namespace graphene { namespace chain {
class balances_by_account_index : public secondary_index
{
public:
virtual void object_inserted( const object& obj ) override;
virtual void object_loaded( const object& obj ) override;
virtual void object_created( const object& obj ) override;
virtual void object_removed( const object& obj ) override;
virtual void about_to_modify( const object& before ) override;
virtual void object_modified( const object& after ) override;
@ -541,6 +546,10 @@ namespace graphene { namespace chain {
}}
MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_balance_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_statistics_object)
FC_REFLECT_DERIVED( graphene::chain::account_object,
(graphene::db::object),
(membership_expiration_date)(registrar)(referrer)(lifetime_referrer)

View file

@ -2,12 +2,12 @@
#include <graphene/chain/database.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/protocol/types.hpp>
namespace graphene { namespace chain {
class account_role_create_evaluator : public evaluator<account_role_create_evaluator>
class account_role_create_evaluator : public fee_handling_evaluator<account_role_create_evaluator>
{
public:
typedef account_role_create_operation operation_type;
@ -15,7 +15,7 @@ namespace graphene { namespace chain {
object_id_type do_apply( const account_role_create_operation& o );
};
class account_role_update_evaluator : public evaluator<account_role_update_evaluator>
class account_role_update_evaluator : public fee_handling_evaluator<account_role_update_evaluator>
{
public:
typedef account_role_update_operation operation_type;
@ -23,7 +23,7 @@ namespace graphene { namespace chain {
void_result do_apply( const account_role_update_operation& o );
};
class account_role_delete_evaluator : public evaluator<account_role_delete_evaluator>
class account_role_delete_evaluator : public fee_handling_evaluator<account_role_delete_evaluator>
{
public:
typedef account_role_delete_operation operation_type;

View file

@ -1,5 +1,5 @@
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/types.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp>
@ -13,7 +13,7 @@ namespace graphene
{
public:
static const uint8_t space_id = protocol_ids;
static const uint8_t type_id = account_role_type;
static const uint8_t type_id = account_role_object_type;
account_id_type owner;
std::string name;
@ -45,5 +45,7 @@ namespace graphene
} // namespace chain
} // namespace graphene
MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_role_object)
FC_REFLECT_DERIVED(graphene::chain::account_role_object, (graphene::db::object),
(owner)(name)(metadata)(allowed_operations)(whitelisted_accounts)(valid_to))

View file

@ -23,8 +23,8 @@
*/
#pragma once
#include <graphene/chain/protocol/asset.hpp>
#include <graphene/chain/protocol/affiliate.hpp>
#include <graphene/protocol/asset.hpp>
#include <graphene/protocol/affiliate.hpp>
#include <graphene/chain/betting_market_object.hpp>
#include <graphene/chain/tournament_object.hpp>

View file

@ -22,13 +22,13 @@
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/database.hpp>
namespace graphene { namespace chain {
class assert_evaluator : public evaluator<assert_evaluator>
class assert_evaluator : public fee_handling_evaluator<assert_evaluator>
{
public:
typedef assert_operation operation_type;

View file

@ -22,13 +22,13 @@
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/database.hpp>
namespace graphene { namespace chain {
class asset_create_evaluator : public evaluator<asset_create_evaluator>
class asset_create_evaluator : public fee_handling_evaluator<asset_create_evaluator>
{
public:
typedef asset_create_operation operation_type;
@ -44,7 +44,7 @@ namespace graphene { namespace chain {
bool fee_is_odd;
};
class lottery_asset_create_evaluator : public evaluator<lottery_asset_create_evaluator>
class lottery_asset_create_evaluator : public fee_handling_evaluator<lottery_asset_create_evaluator>
{
public:
typedef lottery_asset_create_operation operation_type;
@ -60,7 +60,7 @@ namespace graphene { namespace chain {
bool fee_is_odd;
};
class asset_issue_evaluator : public evaluator<asset_issue_evaluator>
class asset_issue_evaluator : public fee_handling_evaluator<asset_issue_evaluator>
{
public:
typedef asset_issue_operation operation_type;
@ -71,7 +71,7 @@ namespace graphene { namespace chain {
const account_object* to_account = nullptr;
};
class asset_reserve_evaluator : public evaluator<asset_reserve_evaluator>
class asset_reserve_evaluator : public fee_handling_evaluator<asset_reserve_evaluator>
{
public:
typedef asset_reserve_operation operation_type;
@ -83,7 +83,7 @@ namespace graphene { namespace chain {
};
class asset_update_evaluator : public evaluator<asset_update_evaluator>
class asset_update_evaluator : public fee_handling_evaluator<asset_update_evaluator>
{
public:
typedef asset_update_operation operation_type;
@ -94,7 +94,7 @@ namespace graphene { namespace chain {
const asset_object* asset_to_update = nullptr;
};
class asset_update_bitasset_evaluator : public evaluator<asset_update_bitasset_evaluator>
class asset_update_bitasset_evaluator : public fee_handling_evaluator<asset_update_bitasset_evaluator>
{
public:
typedef asset_update_bitasset_operation operation_type;
@ -105,7 +105,7 @@ namespace graphene { namespace chain {
const asset_bitasset_data_object* bitasset_to_update = nullptr;
};
class asset_update_dividend_evaluator : public evaluator<asset_update_dividend_evaluator>
class asset_update_dividend_evaluator : public fee_handling_evaluator<asset_update_dividend_evaluator>
{
public:
typedef asset_update_dividend_operation operation_type;
@ -117,7 +117,7 @@ namespace graphene { namespace chain {
const asset_dividend_data_object* asset_dividend_data_to_update = nullptr;
};
class asset_update_feed_producers_evaluator : public evaluator<asset_update_feed_producers_evaluator>
class asset_update_feed_producers_evaluator : public fee_handling_evaluator<asset_update_feed_producers_evaluator>
{
public:
typedef asset_update_feed_producers_operation operation_type;
@ -128,7 +128,7 @@ namespace graphene { namespace chain {
const asset_bitasset_data_object* bitasset_to_update = nullptr;
};
class asset_fund_fee_pool_evaluator : public evaluator<asset_fund_fee_pool_evaluator>
class asset_fund_fee_pool_evaluator : public fee_handling_evaluator<asset_fund_fee_pool_evaluator>
{
public:
typedef asset_fund_fee_pool_operation operation_type;
@ -139,7 +139,7 @@ namespace graphene { namespace chain {
const asset_dynamic_data_object* asset_dyn_data = nullptr;
};
class asset_global_settle_evaluator : public evaluator<asset_global_settle_evaluator>
class asset_global_settle_evaluator : public fee_handling_evaluator<asset_global_settle_evaluator>
{
public:
typedef asset_global_settle_operation operation_type;
@ -149,7 +149,7 @@ namespace graphene { namespace chain {
const asset_object* asset_to_settle = nullptr;
};
class asset_settle_evaluator : public evaluator<asset_settle_evaluator>
class asset_settle_evaluator : public fee_handling_evaluator<asset_settle_evaluator>
{
public:
typedef asset_settle_operation operation_type;
@ -160,7 +160,7 @@ namespace graphene { namespace chain {
const asset_object* asset_to_settle = nullptr;
};
class asset_publish_feeds_evaluator : public evaluator<asset_publish_feeds_evaluator>
class asset_publish_feeds_evaluator : public fee_handling_evaluator<asset_publish_feeds_evaluator>
{
public:
typedef asset_publish_feed_operation operation_type;
@ -171,7 +171,7 @@ namespace graphene { namespace chain {
std::map<std::pair<asset_id_type,asset_id_type>,price_feed> median_feed_values;
};
class asset_claim_fees_evaluator : public evaluator<asset_claim_fees_evaluator>
class asset_claim_fees_evaluator : public fee_handling_evaluator<asset_claim_fees_evaluator>
{
public:
typedef asset_claim_fees_operation operation_type;

View file

@ -22,11 +22,10 @@
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/db/generic_index.hpp>
#include <graphene/db/flat_index.hpp>
#include <graphene/chain/protocol/asset_ops.hpp>
#include <graphene/protocol/asset_ops.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <graphene/db/generic_index.hpp>
#include <graphene/chain/types.hpp>
/**
* @defgroup prediction_market Prediction Market
@ -39,6 +38,9 @@
*/
namespace graphene { namespace chain {
class account_object;
class asset_bitasset_data_object;
class asset_dividend_data_object;
class database;
class transaction_evaluation_state;
using namespace graphene::db;
@ -59,7 +61,7 @@ namespace graphene { namespace chain {
{
public:
static const uint8_t space_id = implementation_ids;
static const uint8_t type_id = impl_asset_dynamic_data_type;
static const uint8_t type_id = impl_asset_dynamic_data_object_type;
/// The number of shares currently in existence
share_type current_supply;
@ -111,13 +113,13 @@ namespace graphene { namespace chain {
string amount_to_string(share_type amount)const;
/// Convert an asset to a textual representation, i.e. "123.45"
string amount_to_string(const asset& amount)const
{ FC_ASSERT(amount.asset_id == id); return amount_to_string(amount.amount); }
{ FC_ASSERT(amount.asset_id == get_id()); return amount_to_string(amount.amount); }
/// Convert an asset to a textual representation with symbol, i.e. "123.45 USD"
string amount_to_pretty_string(share_type amount)const
{ return amount_to_string(amount) + " " + symbol; }
/// Convert an asset to a textual representation with symbol, i.e. "123.45 USD"
string amount_to_pretty_string(const asset &amount)const
{ FC_ASSERT(amount.asset_id == id); return amount_to_pretty_string(amount.amount); }
{ FC_ASSERT(amount.asset_id == get_id()); return amount_to_pretty_string(amount.amount); }
uint32_t get_issuer_num()const
{ return issuer.instance.value; }
@ -197,7 +199,7 @@ namespace graphene { namespace chain {
{
public:
static const uint8_t space_id = implementation_ids;
static const uint8_t type_id = impl_asset_bitasset_data_type;
static const uint8_t type_id = impl_asset_bitasset_data_object_type;
/// The asset this object belong to
asset_id_type asset_id;
@ -375,7 +377,7 @@ namespace graphene { namespace chain {
{
public:
static const uint8_t space_id = implementation_ids;
static const uint8_t type_id = impl_asset_dividend_data_type;
static const uint8_t type_id = impl_asset_dividend_data_object_type;
/// The tunable options for Dividend-paying assets are stored in this field.
dividend_asset_options options;
@ -419,7 +421,7 @@ namespace graphene { namespace chain {
{
public:
static const uint8_t space_id = implementation_ids;
static const uint8_t type_id = impl_distributed_dividend_balance_data_type;
static const uint8_t type_id = impl_total_distributed_dividend_balance_object_type;
asset_id_type dividend_holder_asset_type;
asset_id_type dividend_payout_asset_type;
@ -518,6 +520,14 @@ namespace graphene { namespace chain {
} } // graphene::chain
MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_dynamic_data_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_bitasset_data_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_dividend_data_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::total_distributed_dividend_balance_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::lottery_balance_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::sweeps_vesting_balance_object)
FC_REFLECT_DERIVED( graphene::chain::asset_dynamic_data_object, (graphene::db::object),
(current_supply)(sweeps_tickets_sold)(confidential_supply)(accumulated_fees)(fee_pool) )

View file

@ -23,7 +23,7 @@
*/
#pragma once
#include <graphene/chain/protocol/transaction.hpp>
#include <graphene/protocol/transaction.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/balance_object.hpp>
#include <graphene/chain/evaluator.hpp>
@ -31,7 +31,7 @@
namespace graphene { namespace chain {
class balance_claim_evaluator : public evaluator<balance_claim_evaluator>
class balance_claim_evaluator : public fee_handling_evaluator<balance_claim_evaluator>
{
public:
typedef balance_claim_operation operation_type;

View file

@ -71,6 +71,8 @@ namespace graphene { namespace chain {
using balance_index = generic_index<balance_object, balance_multi_index_type>;
} }
MAP_OBJECT_ID_TO_TYPE(graphene::chain::balance_object)
FC_REFLECT_DERIVED( graphene::chain::balance_object, (graphene::db::object),
(owner)(balance)(vesting_policy)(last_claim_date) )

View file

@ -23,13 +23,13 @@
*/
#pragma once
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/database.hpp>
namespace graphene { namespace chain {
class betting_market_rules_create_evaluator : public evaluator<betting_market_rules_create_evaluator>
class betting_market_rules_create_evaluator : public fee_handling_evaluator<betting_market_rules_create_evaluator>
{
public:
typedef betting_market_rules_create_operation operation_type;
@ -38,7 +38,7 @@ namespace graphene { namespace chain {
object_id_type do_apply( const betting_market_rules_create_operation& o );
};
class betting_market_rules_update_evaluator : public evaluator<betting_market_rules_update_evaluator>
class betting_market_rules_update_evaluator : public fee_handling_evaluator<betting_market_rules_update_evaluator>
{
public:
typedef betting_market_rules_update_operation operation_type;
@ -49,7 +49,7 @@ namespace graphene { namespace chain {
const betting_market_rules_object* _rules;
};
class betting_market_group_create_evaluator : public evaluator<betting_market_group_create_evaluator>
class betting_market_group_create_evaluator : public fee_handling_evaluator<betting_market_group_create_evaluator>
{
public:
typedef betting_market_group_create_operation operation_type;
@ -61,7 +61,7 @@ namespace graphene { namespace chain {
betting_market_rules_id_type _rules_id;
};
class betting_market_group_update_evaluator : public evaluator<betting_market_group_update_evaluator>
class betting_market_group_update_evaluator : public fee_handling_evaluator<betting_market_group_update_evaluator>
{
public:
typedef betting_market_group_update_operation operation_type;
@ -73,7 +73,7 @@ namespace graphene { namespace chain {
const betting_market_group_object* _betting_market_group;
};
class betting_market_create_evaluator : public evaluator<betting_market_create_evaluator>
class betting_market_create_evaluator : public fee_handling_evaluator<betting_market_create_evaluator>
{
public:
typedef betting_market_create_operation operation_type;
@ -84,7 +84,7 @@ namespace graphene { namespace chain {
betting_market_group_id_type _group_id;
};
class betting_market_update_evaluator : public evaluator<betting_market_update_evaluator>
class betting_market_update_evaluator : public fee_handling_evaluator<betting_market_update_evaluator>
{
public:
typedef betting_market_update_operation operation_type;
@ -96,7 +96,7 @@ namespace graphene { namespace chain {
betting_market_group_id_type _group_id;
};
class bet_place_evaluator : public evaluator<bet_place_evaluator>
class bet_place_evaluator : public fee_handling_evaluator<bet_place_evaluator>
{
public:
typedef bet_place_operation operation_type;
@ -111,7 +111,7 @@ namespace graphene { namespace chain {
share_type _stake_plus_fees;
};
class bet_cancel_evaluator : public evaluator<bet_cancel_evaluator>
class bet_cancel_evaluator : public fee_handling_evaluator<bet_cancel_evaluator>
{
public:
typedef bet_cancel_operation operation_type;
@ -122,7 +122,7 @@ namespace graphene { namespace chain {
const bet_object* _bet_to_cancel;
};
class betting_market_group_resolve_evaluator : public evaluator<betting_market_group_resolve_evaluator>
class betting_market_group_resolve_evaluator : public fee_handling_evaluator<betting_market_group_resolve_evaluator>
{
public:
typedef betting_market_group_resolve_operation operation_type;
@ -133,7 +133,7 @@ namespace graphene { namespace chain {
const betting_market_group_object* _betting_market_group;
};
class betting_market_group_cancel_unmatched_bets_evaluator : public evaluator<betting_market_group_cancel_unmatched_bets_evaluator>
class betting_market_group_cancel_unmatched_bets_evaluator : public fee_handling_evaluator<betting_market_group_cancel_unmatched_bets_evaluator>
{
public:
typedef betting_market_group_cancel_unmatched_bets_operation operation_type;

View file

@ -23,14 +23,17 @@
*/
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/types.hpp>
#include <graphene/protocol/betting_market.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp>
#include <graphene/chain/protocol/betting_market.hpp>
#include <sstream>
#include <boost/multi_index/composite_key.hpp>
#include <sstream>
namespace graphene { namespace chain {
class betting_market_object;
class betting_market_group_object;
@ -45,7 +48,7 @@ namespace fc {
namespace graphene { namespace chain {
FC_DECLARE_EXCEPTION(no_transition, 100000, "Invalid state transition");
FC_DECLARE_EXCEPTION(no_transition, 100000);
class database;
struct by_event_id;
@ -717,9 +720,16 @@ inline Stream& operator>>( Stream& s, betting_market_group_object& betting_marke
} } // graphene::chain
MAP_OBJECT_ID_TO_TYPE(graphene::chain::betting_market_rules_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::betting_market_group_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::betting_market_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::bet_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::betting_market_position_object)
FC_REFLECT_DERIVED( graphene::chain::betting_market_rules_object, (graphene::db::object), (name)(description) )
FC_REFLECT_DERIVED( graphene::chain::betting_market_group_object, (graphene::db::object), (description)(event_id)(rules_id)(asset_id)(total_matched_bets_amount)(never_in_play)(delay_before_settling)(settling_time) )
FC_REFLECT_DERIVED( graphene::chain::betting_market_object, (graphene::db::object), (group_id)(description)(payout_condition)(resolution) )
FC_REFLECT_DERIVED( graphene::chain::bet_object, (graphene::db::object), (bettor_id)(betting_market_id)(amount_to_bet)(backer_multiplier)(back_or_lay)(end_of_delay) )
FC_REFLECT_DERIVED( graphene::chain::betting_market_position_object, (graphene::db::object), (bettor_id)(betting_market_id)(pay_if_payout_condition)(pay_if_not_payout_condition)(pay_if_canceled)(pay_if_not_canceled)(fees_collected) )

View file

@ -23,12 +23,13 @@
*/
#pragma once
#include <fstream>
#include <graphene/chain/protocol/block.hpp>
#include <graphene/protocol/block.hpp>
#include <fc/filesystem.hpp>
namespace graphene { namespace chain {
class index_entry;
struct index_entry;
using namespace graphene::protocol;
class block_database
{

View file

@ -22,7 +22,8 @@
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/types.hpp>
#include <graphene/db/object.hpp>
namespace graphene { namespace chain {
@ -48,6 +49,7 @@ namespace graphene { namespace chain {
} }
MAP_OBJECT_ID_TO_TYPE(graphene::chain::block_summary_object)
FC_REFLECT_DERIVED( graphene::chain::block_summary_object, (graphene::db::object), (block_id) )

View file

@ -22,7 +22,9 @@
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/types.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp>
namespace graphene { namespace chain {
@ -67,6 +69,8 @@ class budget_record_object : public graphene::db::abstract_object<budget_record_
} }
MAP_OBJECT_ID_TO_TYPE(graphene::chain::budget_record_object)
FC_REFLECT(graphene::chain::budget_record,
(time_since_last_budget)
(from_initial_reserve)

View file

@ -23,7 +23,7 @@
*/
#pragma once
#include <graphene/chain/protocol/buyback.hpp>
#include <graphene/protocol/buyback.hpp>
namespace graphene { namespace chain {

View file

@ -23,7 +23,8 @@
*/
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/types.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp>
@ -64,6 +65,8 @@ typedef generic_index< buyback_object, buyback_multi_index_type > buyback_index;
} } // graphene::chain
MAP_OBJECT_ID_TO_TYPE(graphene::chain::buyback_object)
FC_REFLECT_DERIVED( graphene::chain::buyback_object, (graphene::db::object), (asset_to_buy) )
GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::buyback_object )

View file

@ -24,6 +24,7 @@
#pragma once
#include <graphene/chain/immutable_chain_parameters.hpp>
#include <graphene/chain/types.hpp>
namespace graphene { namespace chain {
@ -42,6 +43,8 @@ class chain_property_object : public abstract_object<chain_property_object>
} }
MAP_OBJECT_ID_TO_TYPE(graphene::chain::chain_property_object)
FC_REFLECT_DERIVED( graphene::chain::chain_property_object, (graphene::db::object),
(chain_id)
(immutable_parameters)

View file

@ -24,10 +24,11 @@
#pragma once
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/global_property_object.hpp>
namespace graphene { namespace chain {
class committee_member_create_evaluator : public evaluator<committee_member_create_evaluator>
class committee_member_create_evaluator : public fee_handling_evaluator<committee_member_create_evaluator>
{
public:
typedef committee_member_create_operation operation_type;
@ -36,7 +37,7 @@ namespace graphene { namespace chain {
object_id_type do_apply( const committee_member_create_operation& o );
};
class committee_member_update_evaluator : public evaluator<committee_member_update_evaluator>
class committee_member_update_evaluator : public fee_handling_evaluator<committee_member_update_evaluator>
{
public:
typedef committee_member_update_operation operation_type;
@ -45,7 +46,7 @@ namespace graphene { namespace chain {
void_result do_apply( const committee_member_update_operation& o );
};
class committee_member_update_global_parameters_evaluator : public evaluator<committee_member_update_global_parameters_evaluator>
class committee_member_update_global_parameters_evaluator : public fee_handling_evaluator<committee_member_update_global_parameters_evaluator>
{
public:
typedef committee_member_update_global_parameters_operation operation_type;

View file

@ -22,9 +22,10 @@
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp>
#include <graphene/protocol/vote.hpp>
#include <graphene/chain/types.hpp>
namespace graphene { namespace chain {
using namespace graphene::db;
@ -71,6 +72,7 @@ namespace graphene { namespace chain {
using committee_member_index = generic_index<committee_member_object, committee_member_multi_index_type>;
} } // graphene::chain
MAP_OBJECT_ID_TO_TYPE(graphene::chain::committee_member_object)
FC_REFLECT_DERIVED( graphene::chain::committee_member_object, (graphene::db::object),
(committee_member_account)(vote_id)(total_votes)(url) )

View file

@ -23,14 +23,11 @@
*/
#pragma once
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/types.hpp>
namespace graphene { namespace chain {
struct transfer_to_blind_operation;
struct transfer_from_blind_operation;
struct blind_transfer_operation;
class transfer_to_blind_evaluator : public evaluator<transfer_to_blind_evaluator>
class transfer_to_blind_evaluator : public fee_handling_evaluator<transfer_to_blind_evaluator>
{
public:
typedef transfer_to_blind_operation operation_type;
@ -41,7 +38,7 @@ class transfer_to_blind_evaluator : public evaluator<transfer_to_blind_evaluator
virtual void pay_fee() override;
};
class transfer_from_blind_evaluator : public evaluator<transfer_from_blind_evaluator>
class transfer_from_blind_evaluator : public fee_handling_evaluator<transfer_from_blind_evaluator>
{
public:
typedef transfer_from_blind_operation operation_type;
@ -52,7 +49,7 @@ class transfer_from_blind_evaluator : public evaluator<transfer_from_blind_evalu
virtual void pay_fee() override;
};
class blind_transfer_evaluator : public evaluator<blind_transfer_evaluator>
class blind_transfer_evaluator : public fee_handling_evaluator<blind_transfer_evaluator>
{
public:
typedef blind_transfer_operation operation_type;

View file

@ -23,8 +23,8 @@
*/
#pragma once
#include <graphene/chain/protocol/authority.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/authority.hpp>
#include <graphene/protocol/types.hpp>
#include <graphene/db/generic_index.hpp>
@ -65,6 +65,7 @@ typedef generic_index<blinded_balance_object, blinded_balance_object_multi_index
} } // graphene::chain
MAP_OBJECT_ID_TO_TYPE(graphene::chain::blinded_balance_object)
FC_REFLECT_DERIVED( graphene::chain::blinded_balance_object, (graphene::db::object),
(commitment)(asset_id)(owner) )

View file

@ -23,242 +23,16 @@
*/
#pragma once
#ifdef BUILD_PEERPLAYS_TESTNET
#define GRAPHENE_SYMBOL "TEST"
#define GRAPHENE_ADDRESS_PREFIX "TEST"
#else
#define GRAPHENE_SYMBOL "PPY"
#define GRAPHENE_ADDRESS_PREFIX "PPY"
#endif
#define GRAPHENE_MIN_ACCOUNT_NAME_LENGTH 1
#define GRAPHENE_MAX_ACCOUNT_NAME_LENGTH 63
#define GRAPHENE_MIN_ASSET_SYMBOL_LENGTH 3
#define GRAPHENE_MAX_ASSET_SYMBOL_LENGTH 16
#define GRAPHENE_MAX_SHARE_SUPPLY int64_t(1000000000000000ll)
#define GRAPHENE_MAX_PAY_RATE 10000 /* 100% */
#define GRAPHENE_MAX_SIG_CHECK_DEPTH 2
/**
* Don't allow the committee_members to publish a limit that would
* make the network unable to operate.
*/
#define GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT 1024
#define GRAPHENE_MIN_BLOCK_INTERVAL 1 /* seconds */
#define GRAPHENE_MAX_BLOCK_INTERVAL 30 /* seconds */
#define GRAPHENE_DEFAULT_BLOCK_INTERVAL 3 /* seconds */
#define GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE 2048
#define GRAPHENE_DEFAULT_MAX_BLOCK_SIZE (GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE*GRAPHENE_DEFAULT_BLOCK_INTERVAL*200000)
#define GRAPHENE_DEFAULT_MAX_TIME_UNTIL_EXPIRATION (60*60*24) // seconds, aka: 1 day
#define GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL (60*60*24) // seconds, aka: 1 day
#define GRAPHENE_DEFAULT_MAINTENANCE_SKIP_SLOTS 3 // number of slots to skip for maintenance interval
#include <graphene/protocol/config.hpp>
#define GRAPHENE_MIN_UNDO_HISTORY 10
#define GRAPHENE_MAX_UNDO_HISTORY 10000
#define GRAPHENE_MIN_BLOCK_SIZE_LIMIT (GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT*5) // 5 transactions per block
#define GRAPHENE_MIN_TRANSACTION_EXPIRATION_LIMIT (GRAPHENE_MAX_BLOCK_INTERVAL * 5) // 5 transactions per block
#define GRAPHENE_BLOCKCHAIN_PRECISION uint64_t( 100000 )
#define GRAPHENE_MAX_NESTED_OBJECTS (200)
#define GRAPHENE_BLOCKCHAIN_PRECISION_DIGITS 5
#define GRAPHENE_DEFAULT_TRANSFER_FEE (1*GRAPHENE_BLOCKCHAIN_PRECISION)
#define GRAPHENE_MAX_INSTANCE_ID (uint64_t(-1)>>16)
/** percentage fields are fixed point with a denominator of 10,000 */
#define GRAPHENE_100_PERCENT 10000
#define GRAPHENE_1_PERCENT (GRAPHENE_100_PERCENT/100)
/** NOTE: making this a power of 2 (say 2^15) would greatly accelerate fee calcs */
#define GRAPHENE_MAX_MARKET_FEE_PERCENT GRAPHENE_100_PERCENT
#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_DELAY (60*60*24) ///< 1 day
#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_OFFSET 0 ///< 1%
#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_MAX_VOLUME (20* GRAPHENE_1_PERCENT) ///< 20%
#define GRAPHENE_DEFAULT_PRICE_FEED_LIFETIME (60*60*24) ///< 1 day
#define GRAPHENE_MAX_FEED_PRODUCERS 200
#define GRAPHENE_DEFAULT_MAX_AUTHORITY_MEMBERSHIP 10
#define GRAPHENE_DEFAULT_MAX_ASSET_WHITELIST_AUTHORITIES 10
#define GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS 10
/**
* These ratios are fixed point numbers with a denominator of GRAPHENE_COLLATERAL_RATIO_DENOM, the
* minimum maitenance collateral is therefore 1.001x and the default
* maintenance ratio is 1.75x
*/
///@{
#define GRAPHENE_COLLATERAL_RATIO_DENOM 1000
#define GRAPHENE_MIN_COLLATERAL_RATIO 1001 ///< lower than this could result in divide by 0
#define GRAPHENE_MAX_COLLATERAL_RATIO 32000 ///< higher than this is unnecessary and may exceed int16 storage
#define GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO 1750 ///< Call when collateral only pays off 175% the debt
#define GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO 1500 ///< Stop calling when collateral only pays off 150% of the debt
///@}
#define GRAPHENE_DEFAULT_MARGIN_PERIOD_SEC (30*60*60*24)
#define GRAPHENE_DEFAULT_MIN_WITNESS_COUNT (11)
#define GRAPHENE_DEFAULT_MIN_COMMITTEE_MEMBER_COUNT (11)
#define GRAPHENE_DEFAULT_MIN_SON_COUNT (5)
#define GRAPHENE_DEFAULT_MAX_WITNESSES (1001) // SHOULD BE ODD
#define GRAPHENE_DEFAULT_MAX_COMMITTEE (1001) // SHOULD BE ODD
#define GRAPHENE_DEFAULT_MAX_SONS (15)
#define GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC (60*60*24*7*4) // Four weeks
#define GRAPHENE_DEFAULT_COMMITTEE_PROPOSAL_REVIEW_PERIOD_SEC (60*60*24*7*2) // Two weeks
#define GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE (20*GRAPHENE_1_PERCENT)
#define GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE (30*GRAPHENE_1_PERCENT)
#define GRAPHENE_DEFAULT_MAX_BULK_DISCOUNT_PERCENT (50*GRAPHENE_1_PERCENT)
#define GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MIN ( GRAPHENE_BLOCKCHAIN_PRECISION*int64_t(1000) )
#define GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MAX ( GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MIN*int64_t(100) )
#define GRAPHENE_DEFAULT_CASHBACK_VESTING_PERIOD_SEC (60*60*24*365) ///< 1 year
#define GRAPHENE_DEFAULT_CASHBACK_VESTING_THRESHOLD (GRAPHENE_BLOCKCHAIN_PRECISION*int64_t(100))
#define GRAPHENE_DEFAULT_BURN_PERCENT_OF_FEE (20*GRAPHENE_1_PERCENT)
#define GRAPHENE_WITNESS_PAY_PERCENT_PRECISION (1000000000)
#define GRAPHENE_DEFAULT_MAX_ASSERT_OPCODE 1
#define GRAPHENE_DEFAULT_FEE_LIQUIDATION_THRESHOLD GRAPHENE_BLOCKCHAIN_PRECISION * 100;
#define GRAPHENE_DEFAULT_ACCOUNTS_PER_FEE_SCALE 1000
#define GRAPHENE_DEFAULT_ACCOUNT_FEE_SCALE_BITSHIFTS 4
#define GRAPHENE_DEFAULT_MAX_BUYBACK_MARKETS 4
#define GRAPHENE_MAX_WORKER_NAME_LENGTH 63
#define GRAPHENE_MAX_URL_LENGTH 127
#define GRAPHENE_WITNESS_SHUFFLED_ALGORITHM 0
#define GRAPHENE_WITNESS_SCHEDULED_ALGORITHM 1
// counter initialization values used to derive near and far future seeds for shuffling witnesses
// we use the fractional bits of sqrt(2) in hex
#define GRAPHENE_NEAR_SCHEDULE_CTR_IV ( (uint64_t( 0x6a09 ) << 0x30) \
| (uint64_t( 0xe667 ) << 0x20) \
| (uint64_t( 0xf3bc ) << 0x10) \
| (uint64_t( 0xc908 ) ) )
// and the fractional bits of sqrt(3) in hex
#define GRAPHENE_FAR_SCHEDULE_CTR_IV ( (uint64_t( 0xbb67 ) << 0x30) \
| (uint64_t( 0xae85 ) << 0x20) \
| (uint64_t( 0x84ca ) << 0x10) \
| (uint64_t( 0xa73b ) ) )
// counter used to determine bits of entropy
// must be less than or equal to secret_hash_type::data_length()
#define GRAPHENE_RNG_SEED_LENGTH (160 / 8)
/**
* every second, the fraction of burned core asset which cycles is
* GRAPHENE_CORE_ASSET_CYCLE_RATE / (1 << GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS)
*/
#define GRAPHENE_CORE_ASSET_CYCLE_RATE 17
#define GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS 32
#define GRAPHENE_DEFAULT_WITNESS_PAY_PER_BLOCK (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t( 10) )
#define GRAPHENE_DEFAULT_WITNESS_PAY_VESTING_SECONDS (60*60*24)
#define GRAPHENE_DEFAULT_WORKER_BUDGET_PER_DAY (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t(500) * 1000 )
#define GRAPHENE_DEFAULT_MINIMUM_FEEDS 7
#define GRAPHENE_MAX_INTEREST_APR uint16_t( 10000 )
#define GRAPHENE_CURRENT_DB_VERSION "PPY2.5"
#define GRAPHENE_DEFAULT_MIN_SON_COUNT (5)
#define GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT 4
#define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3
#define GRAPHENE_CURRENT_DB_VERSION "PPY2.4"
#define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT)
/**
* Reserved Account IDs with special meaning
*/
///@{
/// Represents the current committee members, two-week review period
#define GRAPHENE_COMMITTEE_ACCOUNT (graphene::chain::account_id_type(0))
/// Represents the current witnesses
#define GRAPHENE_WITNESS_ACCOUNT (graphene::chain::account_id_type(1))
/// Represents the current committee members
#define GRAPHENE_RELAXED_COMMITTEE_ACCOUNT (graphene::chain::account_id_type(2))
/// Represents the canonical account with NO authority (nobody can access funds in null account)
#define GRAPHENE_NULL_ACCOUNT (graphene::chain::account_id_type(3))
/// Represents the canonical account with WILDCARD authority (anybody can access funds in temp account)
#define GRAPHENE_TEMP_ACCOUNT (graphene::chain::account_id_type(4))
/// Represents the canonical account for specifying you will vote directly (as opposed to a proxy)
#define GRAPHENE_PROXY_TO_SELF_ACCOUNT (graphene::chain::account_id_type(5))
///
#define GRAPHENE_RAKE_FEE_ACCOUNT_ID (graphene::chain::account_id_type(6))
/// Sentinel value used in the scheduler.
#define GRAPHENE_NULL_WITNESS (graphene::chain::witness_id_type(0))
///@}
#define GRAPHENE_FBA_STEALTH_DESIGNATED_ASSET (asset_id_type(743))
#define GRAPHENE_DEFAULT_RAKE_FEE_PERCENTAGE (3*GRAPHENE_1_PERCENT)
/**
* Betting-related constants.
*
* We store bet multipliers as fixed-precision uint32_t. These values are
* the maximum power-of-ten bet we can have on a "symmetric" market:
* (decimal) 1.0001 - 10001
* (fractional) 1:10000 - 10000:1
*/
///@{
/// betting odds (multipliers) are stored as fixed-precision, divide by this to get the actual multiplier
#define GRAPHENE_BETTING_ODDS_PRECISION 10000
/// the smallest bet multiplier we will accept
#define GRAPHENE_BETTING_MIN_MULTIPLIER 10001
/// the largest bet multiplier we will accept
#define GRAPHENE_BETTING_MAX_MULTIPLIER 100010000
///@}
#define GRAPHENE_DEFAULT_MIN_BET_MULTIPLIER 10100
#define GRAPHENE_DEFAULT_MAX_BET_MULTIPLIER 10000000
#define GRAPHENE_DEFAULT_PERMITTED_BETTING_ODDS_INCREMENTS { { 20000, 100}, /* <= 2: 0.01 */ \
{ 30000, 200}, /* <= 3: 0.02 */ \
{ 40000, 500}, /* <= 4: 0.05 */ \
{ 60000, 1000}, /* <= 6: 0.10 */ \
{ 100000, 2000}, /* <= 10: 0.20 */ \
{ 200000, 5000}, /* <= 20: 0.50 */ \
{ 300000, 10000}, /* <= 30: 1.00 */ \
{ 500000, 20000}, /* <= 50: 2.00 */ \
{ 1000000, 50000}, /* <= 100: 5.00 */ \
{ 10000000, 100000} } /* <= 1000: 10.00 */
#define GRAPHENE_DEFAULT_BETTING_PERCENT_FEE (2 * GRAPHENE_1_PERCENT)
#define GRAPHENE_DEFAULT_LIVE_BETTING_DELAY_TIME 5 // seconds
#define GRAPHENE_MAX_NESTED_OBJECTS (200)
#define TOURNAMENT_MIN_ROUND_DELAY 0
#define TOURNAMENT_MAX_ROUND_DELAY 600
#define TOURNAMENT_MIN_TIME_PER_COMMIT_MOVE 0
#define TOURNAMENT_MAN_TIME_PER_COMMIT_MOVE 600
#define TOURNAMENT_MIN_TIME_PER_REVEAL_MOVE 0
#define TOURNAMENT_MAX_TIME_PER_REVEAL_MOVE 600
#define TOURNAMENT_DEFAULT_RAKE_FEE_PERCENTAGE (3*GRAPHENE_1_PERCENT)
#define TOURNAMENT_MINIMAL_RAKE_FEE_PERCENTAGE (1*GRAPHENE_1_PERCENT)
#define TOURNAMENT_MAXIMAL_RAKE_FEE_PERCENTAGE (20*GRAPHENE_1_PERCENT)
#define TOURNAMENT_MAXIMAL_REGISTRATION_DEADLINE (60*60*24*30) // seconds, 30 days
#define TOURNAMENT_MAX_NUMBER_OF_WINS 100
#define TOURNAMENT_MAX_PLAYERS_NUMBER 256
#define TOURNAMENT_MAX_WHITELIST_LENGTH 1000
#define TOURNAMENT_MAX_START_TIME_IN_FUTURE (60*60*24*7*4) // 1 month
#define TOURNAMENT_MAX_START_DELAY (60*60*24*7) // 1 week
#define SON_VESTING_AMOUNT (50*GRAPHENE_BLOCKCHAIN_PRECISION) // 50 PPY
#define SON_VESTING_PERIOD (60*60*24*2) // 2 days
#define SON_DEREGISTER_TIME (60*60*12) // 12 Hours in seconds
#define SON_HEARTBEAT_FREQUENCY (60*3) // 3 minutes in seconds
#define SON_DOWN_TIME (60*3*2) // 2 Heartbeats in seconds
#define SON_BITCOIN_MIN_TX_CONFIRMATIONS (1)
#define SON_PAY_TIME (60*60*24) // 1 day
#define SON_PAY_MAX (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t(200))
#define SWEEPS_DEFAULT_DISTRIBUTION_PERCENTAGE (2*GRAPHENE_1_PERCENT)
#define SWEEPS_DEFAULT_DISTRIBUTION_ASSET (graphene::chain::asset_id_type(0))
#define SWEEPS_VESTING_BALANCE_MULTIPLIER 100000000
#define SWEEPS_ACCUMULATOR_ACCOUNT (graphene::chain::account_id_type(0))
#define GPOS_PERIOD (60*60*24*30*6) // 6 months
#define GPOS_SUBPERIOD (60*60*24*30) // 1 month
#define GPOS_VESTING_LOCKIN_PERIOD (60*60*24*30) // 1 month
#define RBAC_MIN_PERMISSION_NAME_LENGTH 3
#define RBAC_MAX_PERMISSION_NAME_LENGTH 10
#define RBAC_MAX_PERMISSIONS_PER_ACCOUNT 5 // 5 per account
#define RBAC_MAX_ACCOUNT_AUTHORITY_LIFETIME 180*24*60*60 // 6 months
#define RBAC_MAX_AUTHS_PER_PERMISSION 15 // 15 ops linked per permission
#define NFT_TOKEN_MIN_LENGTH 3
#define NFT_TOKEN_MAX_LENGTH 15
#define NFT_URI_MAX_LENGTH GRAPHENE_MAX_URL_LENGTH
#define ACCOUNT_ROLES_MAX_PER_ACCOUNT 20 // Max 20 roles can be created by a resource owner
#define ACCOUNT_ROLES_MAX_LIFETIME 365*24*60*60 // 1 Year

View file

@ -1,13 +1,14 @@
#pragma once
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/protocol/custom_account_authority.hpp>
#include <graphene/protocol/custom_account_authority.hpp>
namespace graphene
{
namespace chain
{
class create_custom_account_authority_evaluator : public evaluator<create_custom_account_authority_evaluator>
class create_custom_account_authority_evaluator : public fee_handling_evaluator<create_custom_account_authority_evaluator>
{
public:
typedef custom_account_authority_create_operation operation_type;
@ -16,7 +17,7 @@ public:
object_id_type do_apply(const custom_account_authority_create_operation &o);
};
class update_custom_account_authority_evaluator : public evaluator<update_custom_account_authority_evaluator>
class update_custom_account_authority_evaluator : public fee_handling_evaluator<update_custom_account_authority_evaluator>
{
public:
typedef custom_account_authority_update_operation operation_type;
@ -25,7 +26,7 @@ public:
object_id_type do_apply(const custom_account_authority_update_operation &o);
};
class delete_custom_account_authority_evaluator : public evaluator<delete_custom_account_authority_evaluator>
class delete_custom_account_authority_evaluator : public fee_handling_evaluator<delete_custom_account_authority_evaluator>
{
public:
typedef custom_account_authority_delete_operation operation_type;
@ -35,4 +36,5 @@ public:
};
} // namespace chain
} // namespace graphene
} // namespace graphene

View file

@ -1,5 +1,6 @@
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/types.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp>
@ -23,7 +24,6 @@ namespace graphene { namespace chain {
time_point_sec valid_to;
};
struct by_id;
struct by_permission_and_op;
struct by_expiration;
using custom_account_authority_multi_index_type = multi_index_container<
@ -51,5 +51,8 @@ namespace graphene { namespace chain {
} } // graphene::chain
MAP_OBJECT_ID_TO_TYPE(graphene::chain::custom_account_authority_object)
FC_REFLECT_DERIVED( graphene::chain::custom_account_authority_object, (graphene::db::object),
(permission_id)(operation_type)(valid_from)(valid_to) )
(permission_id)(operation_type)(valid_from)(valid_to) )

View file

@ -22,13 +22,13 @@
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/database.hpp>
namespace graphene { namespace chain {
class custom_evaluator : public evaluator<custom_evaluator>
class custom_evaluator : public fee_handling_evaluator<custom_evaluator>
{
public:
typedef custom_operation operation_type;

View file

@ -1,13 +1,15 @@
#pragma once
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/protocol/custom_permission.hpp>
#include <graphene/protocol/custom_permission.hpp>
namespace graphene
{
namespace chain
{
class create_custom_permission_evaluator : public evaluator<create_custom_permission_evaluator>
class create_custom_permission_evaluator : public fee_handling_evaluator<create_custom_permission_evaluator>
{
public:
typedef custom_permission_create_operation operation_type;
@ -16,7 +18,7 @@ public:
object_id_type do_apply(const custom_permission_create_operation &o);
};
class update_custom_permission_evaluator : public evaluator<update_custom_permission_evaluator>
class update_custom_permission_evaluator : public fee_handling_evaluator<update_custom_permission_evaluator>
{
public:
typedef custom_permission_update_operation operation_type;
@ -25,7 +27,7 @@ public:
object_id_type do_apply(const custom_permission_update_operation &o);
};
class delete_custom_permission_evaluator : public evaluator<delete_custom_permission_evaluator>
class delete_custom_permission_evaluator : public fee_handling_evaluator<delete_custom_permission_evaluator>
{
public:
typedef custom_permission_delete_operation operation_type;
@ -35,4 +37,5 @@ public:
};
} // namespace chain
} // namespace graphene
} // namespace graphene

View file

@ -1,5 +1,9 @@
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/types.hpp>
#include <graphene/protocol/authority.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp>
@ -25,7 +29,6 @@ namespace graphene { namespace chain {
authority auth;
};
struct by_id;
struct by_account_and_permission;
using custom_permission_multi_index_type = multi_index_container<
custom_permission_object,
@ -45,5 +48,8 @@ namespace graphene { namespace chain {
} } // graphene::chain
MAP_OBJECT_ID_TO_TYPE(graphene::chain::custom_permission_object)
FC_REFLECT_DERIVED( graphene::chain::custom_permission_object, (graphene::db::object),
(account)(permission_name)(auth) )
(account)(permission_name)(auth) )

View file

@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/global_property_object.hpp>
#include <graphene/chain/node_property_object.hpp>
#include <graphene/chain/account_object.hpp>
@ -30,18 +31,20 @@
#include <graphene/chain/block_database.hpp>
#include <graphene/chain/genesis_state.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/betting_market_object.hpp>
#include <graphene/db/object_database.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/simple_index.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <graphene/protocol/protocol.hpp>
#include <graphene/protocol/sidechain_defs.hpp>
#include <fc/signals.hpp>
#include <fc/crypto/hash_ctr_rng.hpp>
#include <graphene/chain/protocol/protocol.hpp>
#include <graphene/chain/sidechain_defs.hpp>
#include <fc/log/logger.hpp>
#include <map>
@ -51,6 +54,15 @@ namespace graphene { namespace chain {
using graphene::db::object;
class op_evaluator;
class transaction_evaluation_state;
class proposal_object;
class operation_history_object;
class chain_property_object;
class witness_schedule_object;
class witness_object;
class force_settlement_object;
class limit_order_object;
class call_order_object;
class account_role_object;
struct budget_record;
@ -63,7 +75,7 @@ namespace graphene { namespace chain {
public:
//////////////////// db_management.cpp ////////////////////
database();
database(bool allow_testing_edits = false);
~database();
enum validation_steps
@ -334,11 +346,50 @@ namespace graphene { namespace chain {
void initialize_indexes();
void init_genesis(const genesis_state_type& genesis_state = genesis_state_type());
/**
* @brief Register a new third party evaluator to the evaluator chain for its operation type
* @tparam EvaluatorType An evaluator type which will be used to evaluate its declared operation type
* @return Returns a handle for the newly added evaluator which can be used to delete it later.
*
* This method registers a new third party evaluator type with the database. The evaluator specifies an
* operation type which it should be used to evaluate. A third party evaluator is an evaluator which belongs
* to code which is not part of official blockchain consensus. Consensus evaluators can only be added by the
* blockchain database itself. The evaluator will be instantiated each time an operaton of the appropriate
* type is processed and used to evaluate the operation.
*
* This method may be called more than once with multiple evaluator types for a given operation type. When
* multiple evaluator types are registered for a given operation type, they will all execute in the order of
* registration. Values returned by third party evaluators will be ignored.
*
* IMPORTANT: Third party evaluators must observe certain rules of etiquette:
* - No exceptions. Exceptions indicate the operation is invalid, and only consensus code can declare an
* operation invalid. Third party evaluators should not throw exceptions.
* - No yielding. Evaluators run as part of the core consensus pathway, and must not yield, to preserve the
* guarantees of consistency of the database.
* - Fast execution. Evaluators must be quick. If heavy processing is necessary, defer it until after the
* core consensus pathway has finished execution.
*/
template<typename EvaluatorType>
void register_evaluator()
op_evaluator::evaluator_handle register_third_party_evaluator()
{
_operation_evaluators[
operation::tag<typename EvaluatorType::operation_type>::value].reset( new op_evaluator_impl<EvaluatorType>() );
return register_evaluator<EvaluatorType, true>(_third_party_operation_evaluators);
}
/**
* @brief Delete a third party evaluator
* @param handle The evaluator handle for the evaluator to delete, as returned by @ref register_evaluator
*
* Third party evaluators, or evaluators registered by non-consensus code for a given operation type, can be
* deleted so that they no longer execute when operations of the relevant type are processed.
*
* If it may be desired to delete an evaluator, retain the evaluator handle obtained when the evaluator was
* initially registered and when it is necessary to delete the evaluator, pass the handle to this function.
*
* The evaluator will have been deleted by the time this function returns.
*/
void delete_third_party_evaluator(op_evaluator::evaluator_handle&& handle)
{
delete_evaluator(_third_party_operation_evaluators, std::move(handle));
}
//////////////////// db_balance.cpp ////////////////////
@ -403,6 +454,12 @@ namespace graphene { namespace chain {
void debug_dump();
void apply_debug_updates();
void debug_update( const fc::variant_object& update );
template<typename Action>
auto bypass_safety_checks(Action&& action) {
FC_ASSERT(_allow_safety_check_bypass, "Safety check bypass disallowed.");
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
return action();
}
//////////////////// db_market.cpp ////////////////////
@ -499,7 +556,7 @@ namespace graphene { namespace chain {
*/
/// Enable or disable tracking of votes of standby witnesses and committee members
inline void enable_standby_votes_tracking(bool enable) { _track_standby_votes = enable; }
protected:
protected:
//Mark pop_undo() as protected -- we do not want outside calling pop_undo(); it should call pop_block() instead
void pop_undo() { object_database::pop_undo(); }
void notify_applied_block( const signed_block& block );
@ -508,14 +565,49 @@ namespace graphene { namespace chain {
private:
optional<undo_database::session> _pending_tx_session;
vector< unique_ptr<op_evaluator> > _operation_evaluators;
vector< unique_ptr<op_evaluator> > _third_party_operation_evaluators;
vector< unique_ptr<op_evaluator> > _consensus_operation_evaluators;
template<typename EvaluatorType, bool DiscardExceptions>
op_evaluator::evaluator_handle register_evaluator(vector<unique_ptr<op_evaluator>>& registry) {
auto op_tag = operation::tag<typename EvaluatorType::operation_type>::value;
FC_ASSERT(registry.size() > (size_t)op_tag,
"Cannot register evaluator for operation type ${T}: operation type is too large.",
("T", op_tag));
auto& eval_ptr = registry[op_tag];
if (eval_ptr == nullptr) {
eval_ptr = std::make_unique<op_evaluator_impl<EvaluatorType, DiscardExceptions>>();
return {eval_ptr.get(), op_tag};
} else {
auto new_evaluator = std::make_unique<op_evaluator_impl<EvaluatorType, DiscardExceptions>>();
return eval_ptr->append_evaluator(std::move(new_evaluator));
}
}
template<typename EvaluatorType>
op_evaluator::evaluator_handle register_consensus_evaluator() {
return register_evaluator<EvaluatorType, false>(_consensus_operation_evaluators);
}
void delete_evaluator(vector<unique_ptr<op_evaluator>>& registry, op_evaluator::evaluator_handle&& handle)
{
if ((uint64_t)handle.get_operation_type() < registry.size()) {
auto& eval_ptr = registry[handle.get_operation_type()];
if (eval_ptr.get() == handle.pointer)
eval_ptr = eval_ptr->take_next();
else
eval_ptr->delete_evaluator(std::move(handle));
}
}
void delete_consensus_evaluator(op_evaluator::evaluator_handle&& handle)
{
delete_evaluator(_consensus_operation_evaluators, std::move(handle));
}
template<class Index>
vector<std::reference_wrapper<const typename Index::object_type>> sort_votable_objects(size_t count)const;
//////////////////// db_block.cpp ////////////////////
public:
public:
// these were formerly private, but they have a fairly well-defined API, so let's make them public
void apply_block( const signed_block& next_block, uint32_t skip = skip_nothing );
processed_transaction apply_transaction( const signed_transaction& trx, uint32_t skip = skip_nothing );
@ -649,6 +741,13 @@ namespace graphene { namespace chain {
const chain_property_object* _p_chain_property_obj = nullptr;
const witness_schedule_object* _p_witness_schedule_obj = nullptr;
///@}
/// Whether or not to allow safety check bypassing (for unit testing only)
bool _allow_safety_check_bypass;
/// Safety check policy for object space 1
database_lock_safety_check* _check_policy_1 = nullptr;
/// Safety check policy for object space 2
database_lock_safety_check* _check_policy_2 = nullptr;
};
namespace detail

View file

@ -24,19 +24,22 @@
#pragma once
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/transaction_evaluation_state.hpp>
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/protocol/operations.hpp>
namespace graphene { namespace chain {
class database;
struct signed_transaction;
class generic_evaluator;
class consensus_evaluator;
class transaction_evaluation_state;
class account_object;
class account_statistics_object;
class asset_object;
class asset_dynamic_data_object;
class generic_evaluator
class consensus_evaluator
{
public:
virtual ~generic_evaluator(){}
virtual ~consensus_evaluator(){}
virtual int get_type()const = 0;
virtual operation_result start_evaluate(transaction_evaluation_state& eval_state, const operation& op, bool apply);
@ -119,24 +122,88 @@ namespace graphene { namespace chain {
class op_evaluator
{
protected:
unique_ptr<op_evaluator> next_evaluator;
public:
class evaluator_handle {
// Move-only semantics, and only friends can construct
evaluator_handle(const op_evaluator* pointer, operation::tag_type type)
: pointer(pointer), operation_type(type) {}
evaluator_handle(const evaluator_handle&) = delete;
evaluator_handle& operator=(const evaluator_handle&) = delete;
friend class database;
friend class op_evaluator;
template<typename, bool>
friend class op_evaluator_impl;
// Pointer to the handled evaluator
const op_evaluator* pointer;
// Tag of the handled evaluator
operation::tag_type operation_type;
public:
evaluator_handle(evaluator_handle&&) = default;
evaluator_handle& operator=(evaluator_handle&&) = default;
operation::tag_type get_operation_type() const { return operation_type; }
};
virtual ~op_evaluator(){}
virtual evaluator_handle append_evaluator(unique_ptr<op_evaluator> next_evaluator) = 0;
std::unique_ptr<op_evaluator> take_next() { return std::move(next_evaluator); }
virtual void delete_evaluator(evaluator_handle&& handle) {
FC_ASSERT(handle.pointer != this, "Cannot delete first element of evaluator chain!");
if (next_evaluator.get() == handle.pointer)
// Next evaluator in chain is the one to delete. Move its next pointer into ours, and unique_ptr will delete the one that's going away.
next_evaluator = next_evaluator->take_next();
else if (next_evaluator != nullptr)
next_evaluator->delete_evaluator(std::move(handle));
else
elog("ERROR: Attempted to delete evaluator, but did not find referenced evaluator in the chain");
}
virtual operation_result evaluate(transaction_evaluation_state& eval_state, const operation& op, bool apply) = 0;
};
template<typename T>
template<typename T, bool DiscardExceptions>
class op_evaluator_impl : public op_evaluator
{
public:
virtual evaluator_handle append_evaluator(unique_ptr<op_evaluator> next_evaluator) override {
if (this->next_evaluator == nullptr) {
this->next_evaluator = std::move(next_evaluator);
return evaluator_handle(this->next_evaluator.get(), operation::tag<typename T::operation_type>::value);
} else {
return this->next_evaluator->append_evaluator(std::move(next_evaluator));
}
}
virtual operation_result evaluate(transaction_evaluation_state& eval_state, const operation& op, bool apply = true) override
{
T eval;
return eval.start_evaluate(eval_state, op, apply);
operation_result result;
try {
T eval;
result = eval.start_evaluate(eval_state, op, apply);
} catch (fc::exception_ptr e) {
if (DiscardExceptions)
elog("ERROR: Third party evaluator threw an exception. Discarding.", ("exception", e));
else
throw;
} catch (...) {
if (DiscardExceptions)
elog("ERROR: Third party evaluator threw an unknown exception type. Discarding.");
else
throw;
}
if (this->next_evaluator != nullptr)
this->next_evaluator->evaluate(eval_state, op, apply);
return result;
}
};
template<typename DerivedEvaluator>
class evaluator : public generic_evaluator
class fee_handling_evaluator : public consensus_evaluator
{
public:
virtual int get_type()const override { return operation::tag<typename DerivedEvaluator::operation_type>::value; }
@ -174,4 +241,32 @@ namespace graphene { namespace chain {
return result;
}
};
template<typename DerivedEvaluator>
class third_party_evaluator {
protected:
transaction_evaluation_state* trx_state = nullptr;
database& db() {
FC_ASSERT(trx_state != nullptr, "Cannot get database: evaluator not initialized");
return trx_state->db();
}
public:
operation_result start_evaluate(transaction_evaluation_state& eval_state, const operation& op, bool apply) {
trx_state = &eval_state;
using Operation = typename DerivedEvaluator::operation_type;
Operation specific_operation = op.get<Operation>();
DerivedEvaluator& specific_evaluator = static_cast<DerivedEvaluator&>(*this);
operation_result result;
result = specific_evaluator.do_evaluate(specific_operation);
if (apply)
result = specific_evaluator.do_apply(specific_operation);
return result;
}
};
} }

View file

@ -23,13 +23,15 @@
*/
#pragma once
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/event_object.hpp>
#include <graphene/protocol/operations.hpp>
namespace graphene { namespace chain {
class event_create_evaluator : public evaluator<event_create_evaluator>
class event_create_evaluator : public fee_handling_evaluator<event_create_evaluator>
{
public:
typedef event_create_operation operation_type;
@ -40,7 +42,7 @@ namespace graphene { namespace chain {
event_group_id_type event_group_id;
};
class event_update_evaluator : public evaluator<event_update_evaluator>
class event_update_evaluator : public fee_handling_evaluator<event_update_evaluator>
{
public:
typedef event_update_operation operation_type;
@ -51,7 +53,7 @@ namespace graphene { namespace chain {
event_group_id_type event_group_id;
};
class event_update_status_evaluator : public evaluator<event_update_status_evaluator>
class event_update_status_evaluator : public fee_handling_evaluator<event_update_status_evaluator>
{
public:
typedef event_update_status_operation operation_type;

View file

@ -23,7 +23,7 @@
*/
#pragma once
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/database.hpp>
@ -31,7 +31,7 @@ namespace graphene { namespace chain {
class event_group_object;
class event_group_create_evaluator : public evaluator<event_group_create_evaluator>
class event_group_create_evaluator : public fee_handling_evaluator<event_group_create_evaluator>
{
public:
typedef event_group_create_operation operation_type;
@ -43,7 +43,7 @@ namespace graphene { namespace chain {
sport_id_type sport_id;
};
class event_group_update_evaluator : public evaluator<event_group_update_evaluator>
class event_group_update_evaluator : public fee_handling_evaluator<event_group_update_evaluator>
{
public:
typedef event_group_update_operation operation_type;
@ -55,7 +55,7 @@ namespace graphene { namespace chain {
sport_id_type sport_id;
};
class event_group_delete_evaluator : public evaluator<event_group_delete_evaluator>
class event_group_delete_evaluator : public fee_handling_evaluator<event_group_delete_evaluator>
{
public:
typedef event_group_delete_operation operation_type;

View file

@ -23,9 +23,11 @@
*/
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/types.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp>
#include <boost/multi_index/composite_key.hpp>
namespace graphene { namespace chain {
@ -58,4 +60,6 @@ typedef multi_index_container<
typedef generic_index<event_group_object, event_group_object_multi_index_type> event_group_object_index;
} } // graphene::chain
MAP_OBJECT_ID_TO_TYPE(graphene::chain::event_group_object)
FC_REFLECT_DERIVED( graphene::chain::event_group_object, (graphene::db::object), (name)(sport_id) )

View file

@ -23,14 +23,17 @@
*/
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/types.hpp>
#include <graphene/protocol/event.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp>
#include <graphene/chain/protocol/event.hpp>
#include <sstream>
#include <boost/multi_index/composite_key.hpp>
#include <sstream>
namespace graphene { namespace chain {
class event_object;
} }
@ -158,6 +161,9 @@ typedef generic_index<event_object, event_object_multi_index_type> event_object_
return s;
}
} } // graphene::chain
FC_REFLECT(graphene::chain::event_object, (name)(season)(start_time)(event_group_id)(at_least_one_betting_market_group_settled)(scores))
MAP_OBJECT_ID_TO_TYPE(graphene::chain::event_object)
FC_REFLECT_DERIVED(graphene::chain::event_object, (graphene::db::object),
(name)(season)(start_time)(event_group_id)(at_least_one_betting_market_group_settled)(scores))

View file

@ -25,7 +25,10 @@
#include <boost/exception/diagnostic_information.hpp>
#include <fc/exception/exception.hpp>
#include <graphene/chain/protocol/protocol.hpp>
#include <graphene/protocol/exceptions.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/chain/types.hpp>
#define GRAPHENE_ASSERT( expr, exc_type, FORMAT, ... ) \
FC_MULTILINE_MACRO_BEGIN \
@ -33,15 +36,26 @@
FC_THROW_EXCEPTION( exc_type, FORMAT, __VA_ARGS__ ); \
FC_MULTILINE_MACRO_END
#define GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( op_name ) \
FC_DECLARE_DERIVED_EXCEPTION( \
op_name ## _validate_exception, \
graphene::chain::operation_validate_exception, \
3040000 + 100 * operation::tag< op_name ## _operation >::value \
) \
FC_DECLARE_DERIVED_EXCEPTION( \
op_name ## _evaluate_exception, \
graphene::chain::operation_evaluate_exception, \
3050000 + 100 * operation::tag< op_name ## _operation >::value \
)
#define GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( op_name ) \
FC_IMPLEMENT_DERIVED_EXCEPTION( \
op_name ## _validate_exception, \
graphene::chain::operation_validate_exception, \
3040000 + 100 * operation::tag< op_name ## _operation >::value, \
#op_name "_operation validation exception" \
) \
FC_DECLARE_DERIVED_EXCEPTION( \
FC_IMPLEMENT_DERIVED_EXCEPTION( \
op_name ## _evaluate_exception, \
graphene::chain::operation_evaluate_exception, \
3050000 + 100 * operation::tag< op_name ## _operation >::value, \
@ -50,6 +64,14 @@
#define GRAPHENE_DECLARE_OP_VALIDATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \
FC_DECLARE_DERIVED_EXCEPTION( \
op_name ## _ ## exc_name, \
graphene::chain::op_name ## _validate_exception, \
3040000 + 100 * operation::tag< op_name ## _operation >::value \
+ seqnum \
)
#define GRAPHENE_IMPLEMENT_OP_VALIDATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \
FC_IMPLEMENT_DERIVED_EXCEPTION( \
op_name ## _ ## exc_name, \
graphene::chain::op_name ## _validate_exception, \
3040000 + 100 * operation::tag< op_name ## _operation >::value \
@ -59,6 +81,14 @@
#define GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \
FC_DECLARE_DERIVED_EXCEPTION( \
op_name ## _ ## exc_name, \
graphene::chain::op_name ## _evaluate_exception, \
3050000 + 100 * operation::tag< op_name ## _operation >::value \
+ seqnum \
)
#define GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \
FC_IMPLEMENT_DERIVED_EXCEPTION( \
op_name ## _ ## exc_name, \
graphene::chain::op_name ## _evaluate_exception, \
3050000 + 100 * operation::tag< op_name ## _operation >::value \
@ -91,30 +121,21 @@
namespace graphene { namespace chain {
FC_DECLARE_EXCEPTION( chain_exception, 3000000, "blockchain exception" )
FC_DECLARE_DERIVED_EXCEPTION( database_query_exception, graphene::chain::chain_exception, 3010000, "database query exception" )
FC_DECLARE_DERIVED_EXCEPTION( block_validate_exception, graphene::chain::chain_exception, 3020000, "block validation exception" )
FC_DECLARE_DERIVED_EXCEPTION( transaction_exception, graphene::chain::chain_exception, 3030000, "transaction validation exception" )
FC_DECLARE_DERIVED_EXCEPTION( operation_validate_exception, graphene::chain::chain_exception, 3040000, "operation validation exception" )
FC_DECLARE_DERIVED_EXCEPTION( operation_evaluate_exception, graphene::chain::chain_exception, 3050000, "operation evaluation exception" )
FC_DECLARE_DERIVED_EXCEPTION( utility_exception, graphene::chain::chain_exception, 3060000, "utility method exception" )
FC_DECLARE_DERIVED_EXCEPTION( undo_database_exception, graphene::chain::chain_exception, 3070000, "undo database exception" )
FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, graphene::chain::chain_exception, 3080000, "unlinkable block" )
FC_DECLARE_DERIVED_EXCEPTION( black_swan_exception, graphene::chain::chain_exception, 3090000, "black swan" )
FC_DECLARE_DERIVED_EXCEPTION( plugin_exception, graphene::chain::chain_exception, 3100000, "plugin exception" )
FC_DECLARE_EXCEPTION( chain_exception, 3000000 )
FC_DECLARE_DERIVED_EXCEPTION( database_query_exception, chain_exception, 3010000 )
FC_DECLARE_DERIVED_EXCEPTION( block_validate_exception, chain_exception, 3020000 )
FC_DECLARE_DERIVED_EXCEPTION( transaction_exception, chain_exception, 3030000 )
FC_DECLARE_DERIVED_EXCEPTION( operation_validate_exception, chain_exception, 3040000 )
FC_DECLARE_DERIVED_EXCEPTION( operation_evaluate_exception, chain_exception, 3050000 )
FC_DECLARE_DERIVED_EXCEPTION( utility_exception, chain_exception, 3060000 )
FC_DECLARE_DERIVED_EXCEPTION( undo_database_exception, chain_exception, 3070000 )
FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, chain_exception, 3080000 )
FC_DECLARE_DERIVED_EXCEPTION( black_swan_exception, chain_exception, 3090000 )
FC_DECLARE_DERIVED_EXCEPTION( plugin_exception, chain_exception, 3100000 )
FC_DECLARE_DERIVED_EXCEPTION( tx_missing_active_auth, graphene::chain::transaction_exception, 3030001, "missing required active authority" )
FC_DECLARE_DERIVED_EXCEPTION( tx_missing_owner_auth, graphene::chain::transaction_exception, 3030002, "missing required owner authority" )
FC_DECLARE_DERIVED_EXCEPTION( tx_missing_other_auth, graphene::chain::transaction_exception, 3030003, "missing required other authority" )
FC_DECLARE_DERIVED_EXCEPTION( tx_irrelevant_sig, graphene::chain::transaction_exception, 3030004, "irrelevant signature included" )
FC_DECLARE_DERIVED_EXCEPTION( tx_duplicate_sig, graphene::chain::transaction_exception, 3030005, "duplicate signature included" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_approval, graphene::chain::transaction_exception, 3030006, "committee account cannot directly approve transaction" )
FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, graphene::chain::transaction_exception, 3030007, "insufficient fee" )
FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, chain_exception, 37006 )
FC_DECLARE_DERIVED_EXCEPTION( invalid_pts_address, graphene::chain::utility_exception, 3060001, "invalid pts address" )
FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, graphene::chain::chain_exception, 37006, "insufficient feeds" )
FC_DECLARE_DERIVED_EXCEPTION( pop_empty_chain, graphene::chain::undo_database_exception, 3070001, "there are no blocks to pop" )
FC_DECLARE_DERIVED_EXCEPTION( pop_empty_chain, undo_database_exception, 3070001 )
GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( transfer );
GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( from_account_not_whitelisted, transfer, 1, "owner mismatch" )
@ -185,93 +206,11 @@ namespace graphene { namespace chain {
GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( blind_transfer );
GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( unknown_commitment, blind_transfer, 1, "Attempting to claim an unknown prior commitment" );
/*
FC_DECLARE_DERIVED_EXCEPTION( addition_overflow, graphene::chain::chain_exception, 30002, "addition overflow" )
FC_DECLARE_DERIVED_EXCEPTION( subtraction_overflow, graphene::chain::chain_exception, 30003, "subtraction overflow" )
FC_DECLARE_DERIVED_EXCEPTION( asset_type_mismatch, graphene::chain::chain_exception, 30004, "asset/price mismatch" )
FC_DECLARE_DERIVED_EXCEPTION( unsupported_chain_operation, graphene::chain::chain_exception, 30005, "unsupported chain operation" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_transaction, graphene::chain::chain_exception, 30006, "unknown transaction" )
FC_DECLARE_DERIVED_EXCEPTION( duplicate_transaction, graphene::chain::chain_exception, 30007, "duplicate transaction" )
FC_DECLARE_DERIVED_EXCEPTION( zero_amount, graphene::chain::chain_exception, 30008, "zero amount" )
FC_DECLARE_DERIVED_EXCEPTION( zero_price, graphene::chain::chain_exception, 30009, "zero price" )
FC_DECLARE_DERIVED_EXCEPTION( asset_divide_by_self, graphene::chain::chain_exception, 30010, "asset divide by self" )
FC_DECLARE_DERIVED_EXCEPTION( asset_divide_by_zero, graphene::chain::chain_exception, 30011, "asset divide by zero" )
FC_DECLARE_DERIVED_EXCEPTION( new_database_version, graphene::chain::chain_exception, 30012, "new database version" )
FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block, graphene::chain::chain_exception, 30013, "unlinkable block" )
FC_DECLARE_DERIVED_EXCEPTION( price_out_of_range, graphene::chain::chain_exception, 30014, "price out of range" )
FC_DECLARE_DERIVED_EXCEPTION( block_numbers_not_sequential, graphene::chain::chain_exception, 30015, "block numbers not sequential" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_previous_block_id, graphene::chain::chain_exception, 30016, "invalid previous block" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_block_time, graphene::chain::chain_exception, 30017, "invalid block time" )
FC_DECLARE_DERIVED_EXCEPTION( time_in_past, graphene::chain::chain_exception, 30018, "time is in the past" )
FC_DECLARE_DERIVED_EXCEPTION( time_in_future, graphene::chain::chain_exception, 30019, "time is in the future" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_block_digest, graphene::chain::chain_exception, 30020, "invalid block digest" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_member_signee, graphene::chain::chain_exception, 30021, "invalid committee_member signee" )
FC_DECLARE_DERIVED_EXCEPTION( failed_checkpoint_verification, graphene::chain::chain_exception, 30022, "failed checkpoint verification" )
FC_DECLARE_DERIVED_EXCEPTION( wrong_chain_id, graphene::chain::chain_exception, 30023, "wrong chain id" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_block, graphene::chain::chain_exception, 30024, "unknown block" )
FC_DECLARE_DERIVED_EXCEPTION( block_older_than_undo_history, graphene::chain::chain_exception, 30025, "block is older than our undo history allows us to process" )
FC_DECLARE_EXCEPTION( evaluation_error, 31000, "Evaluation Error" )
FC_DECLARE_DERIVED_EXCEPTION( negative_deposit, graphene::chain::evaluation_error, 31001, "negative deposit" )
FC_DECLARE_DERIVED_EXCEPTION( not_a_committee_member, graphene::chain::evaluation_error, 31002, "not a committee_member" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_balance_record, graphene::chain::evaluation_error, 31003, "unknown balance record" )
FC_DECLARE_DERIVED_EXCEPTION( insufficient_funds, graphene::chain::evaluation_error, 31004, "insufficient funds" )
FC_DECLARE_DERIVED_EXCEPTION( missing_signature, graphene::chain::evaluation_error, 31005, "missing signature" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_claim_password, graphene::chain::evaluation_error, 31006, "invalid claim password" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_withdraw_condition, graphene::chain::evaluation_error, 31007, "invalid withdraw condition" )
FC_DECLARE_DERIVED_EXCEPTION( negative_withdraw, graphene::chain::evaluation_error, 31008, "negative withdraw" )
FC_DECLARE_DERIVED_EXCEPTION( not_an_active_committee_member, graphene::chain::evaluation_error, 31009, "not an active committee_member" )
FC_DECLARE_DERIVED_EXCEPTION( expired_transaction, graphene::chain::evaluation_error, 31010, "expired transaction" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_transaction_expiration, graphene::chain::evaluation_error, 31011, "invalid transaction expiration" )
FC_DECLARE_DERIVED_EXCEPTION( oversized_transaction, graphene::chain::evaluation_error, 31012, "transaction exceeded the maximum transaction size" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_account_name, graphene::chain::evaluation_error, 32001, "invalid account name" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_account_id, graphene::chain::evaluation_error, 32002, "unknown account id" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_account_name, graphene::chain::evaluation_error, 32003, "unknown account name" )
FC_DECLARE_DERIVED_EXCEPTION( missing_parent_account_signature, graphene::chain::evaluation_error, 32004, "missing parent account signature" )
FC_DECLARE_DERIVED_EXCEPTION( parent_account_retracted, graphene::chain::evaluation_error, 32005, "parent account retracted" )
FC_DECLARE_DERIVED_EXCEPTION( account_expired, graphene::chain::evaluation_error, 32006, "account expired" )
FC_DECLARE_DERIVED_EXCEPTION( account_already_registered, graphene::chain::evaluation_error, 32007, "account already registered" )
FC_DECLARE_DERIVED_EXCEPTION( account_key_in_use, graphene::chain::evaluation_error, 32008, "account key already in use" )
FC_DECLARE_DERIVED_EXCEPTION( account_retracted, graphene::chain::evaluation_error, 32009, "account retracted" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_parent_account_name, graphene::chain::evaluation_error, 32010, "unknown parent account name" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_committee_member_slate, graphene::chain::evaluation_error, 32011, "unknown committee_member slate" )
FC_DECLARE_DERIVED_EXCEPTION( too_may_committee_members_in_slate, graphene::chain::evaluation_error, 32012, "too many committee_members in slate" )
FC_DECLARE_DERIVED_EXCEPTION( pay_balance_remaining, graphene::chain::evaluation_error, 32013, "pay balance remaining" )
FC_DECLARE_DERIVED_EXCEPTION( not_a_committee_member_signature, graphene::chain::evaluation_error, 33002, "not committee_members signature" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_precision, graphene::chain::evaluation_error, 35001, "invalid precision" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_symbol, graphene::chain::evaluation_error, 35002, "invalid asset symbol" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_asset_id, graphene::chain::evaluation_error, 35003, "unknown asset id" )
FC_DECLARE_DERIVED_EXCEPTION( asset_symbol_in_use, graphene::chain::evaluation_error, 35004, "asset symbol in use" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_amount, graphene::chain::evaluation_error, 35005, "invalid asset amount" )
FC_DECLARE_DERIVED_EXCEPTION( negative_issue, graphene::chain::evaluation_error, 35006, "negative issue" )
FC_DECLARE_DERIVED_EXCEPTION( over_issue, graphene::chain::evaluation_error, 35007, "over issue" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_asset_symbol, graphene::chain::evaluation_error, 35008, "unknown asset symbol" )
FC_DECLARE_DERIVED_EXCEPTION( asset_id_in_use, graphene::chain::evaluation_error, 35009, "asset id in use" )
FC_DECLARE_DERIVED_EXCEPTION( not_user_issued, graphene::chain::evaluation_error, 35010, "not user issued" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_name, graphene::chain::evaluation_error, 35011, "invalid asset name" )
FC_DECLARE_DERIVED_EXCEPTION( committee_member_vote_limit, graphene::chain::evaluation_error, 36001, "committee_member_vote_limit" )
FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, graphene::chain::evaluation_error, 36002, "insufficient fee" )
FC_DECLARE_DERIVED_EXCEPTION( negative_fee, graphene::chain::evaluation_error, 36003, "negative fee" )
FC_DECLARE_DERIVED_EXCEPTION( missing_deposit, graphene::chain::evaluation_error, 36004, "missing deposit" )
FC_DECLARE_DERIVED_EXCEPTION( insufficient_relay_fee, graphene::chain::evaluation_error, 36005, "insufficient relay fee" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_market, graphene::chain::evaluation_error, 37001, "invalid market" )
FC_DECLARE_DERIVED_EXCEPTION( unknown_market_order, graphene::chain::evaluation_error, 37002, "unknown market order" )
FC_DECLARE_DERIVED_EXCEPTION( shorting_base_shares, graphene::chain::evaluation_error, 37003, "shorting base shares" )
FC_DECLARE_DERIVED_EXCEPTION( insufficient_collateral, graphene::chain::evaluation_error, 37004, "insufficient collateral" )
FC_DECLARE_DERIVED_EXCEPTION( insufficient_depth, graphene::chain::evaluation_error, 37005, "insufficient depth" )
FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, graphene::chain::evaluation_error, 37006, "insufficient feeds" )
FC_DECLARE_DERIVED_EXCEPTION( invalid_feed_price, graphene::chain::evaluation_error, 37007, "invalid feed price" )
FC_DECLARE_DERIVED_EXCEPTION( price_multiplication_overflow, graphene::chain::evaluation_error, 38001, "price multiplication overflow" )
FC_DECLARE_DERIVED_EXCEPTION( price_multiplication_underflow, graphene::chain::evaluation_error, 38002, "price multiplication underflow" )
FC_DECLARE_DERIVED_EXCEPTION( price_multiplication_undefined, graphene::chain::evaluation_error, 38003, "price multiplication undefined product 0*inf" )
*/
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( transfer_from_blind_operation )
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_claim_fees_operation )
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( bid_collateral_operation )
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_claim_pool_operation )
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_update_issuer_operation )
#define GRAPHENE_RECODE_EXC( cause_type, effect_type ) \
catch( const cause_type& e ) \

View file

@ -23,7 +23,7 @@
*/
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/types.hpp>
namespace graphene { namespace chain {

View file

@ -23,7 +23,7 @@
*/
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/types.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp>
@ -49,6 +49,8 @@ class fba_accumulator_object : public graphene::db::abstract_object< fba_accumul
} } // graphene::chain
MAP_OBJECT_ID_TO_TYPE(graphene::chain::fba_accumulator_object)
FC_REFLECT_DERIVED( graphene::chain::fba_accumulator_object, (graphene::db::object),
(accumulated_fba_fees)(designated_asset) )

View file

@ -22,7 +22,9 @@
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/block.hpp>
#include <graphene/protocol/block.hpp>
#include <graphene/chain/types.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>

View file

@ -23,12 +23,17 @@
*/
#pragma once
#include <graphene/chain/match_object.hpp>
#include <graphene/chain/rock_paper_scissors.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <graphene/protocol/tournament.hpp>
#include <graphene/db/flat_index.hpp>
#include <graphene/db/generic_index.hpp>
#include <fc/crypto/hex.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <sstream>
namespace graphene { namespace chain {
@ -159,6 +164,8 @@ namespace graphene { namespace chain {
} }
MAP_OBJECT_ID_TO_TYPE(graphene::chain::game_object)
FC_REFLECT_ENUM(graphene::chain::game_state,
(game_in_progress)
(expecting_commit_moves)
@ -166,6 +173,6 @@ FC_REFLECT_ENUM(graphene::chain::game_state,
(game_complete))
//FC_REFLECT_TYPENAME(graphene::chain::game_object) // manually serialized
FC_REFLECT(graphene::chain::game_object, (players))
FC_REFLECT_DERIVED(graphene::chain::game_object, (graphene::db::object), (players))

View file

@ -23,9 +23,9 @@
*/
#pragma once
#include <graphene/chain/protocol/address.hpp>
#include <graphene/chain/protocol/chain_parameters.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/address.hpp>
#include <graphene/protocol/chain_parameters.hpp>
#include <graphene/chain/types.hpp>
#include <graphene/chain/immutable_chain_parameters.hpp>
#include <fc/crypto/sha256.hpp>

View file

@ -30,3 +30,4 @@ namespace graphene { namespace chain {
fc::variant_object get_config();
} } // graphene::chain

View file

@ -23,7 +23,8 @@
*/
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/types.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp>
@ -49,4 +50,6 @@ typedef generic_index<global_betting_statistics_object, global_betting_statistic
} } // graphene::chain
MAP_OBJECT_ID_TO_TYPE(graphene::chain::global_betting_statistics_object)
FC_REFLECT_DERIVED( graphene::chain::global_betting_statistics_object, (graphene::db::object), (number_of_active_events)(total_amount_staked) )

View file

@ -24,10 +24,12 @@
#pragma once
#include <fc/uint128.hpp>
#include <graphene/chain/protocol/chain_parameters.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/son_info.hpp>
#include <graphene/protocol/chain_parameters.hpp>
#include <graphene/protocol/son_info.hpp>
#include <graphene/chain/types.hpp>
#include <graphene/chain/hardfork.hpp>
#include <graphene/db/object.hpp>
namespace graphene { namespace chain {
@ -89,8 +91,6 @@ namespace graphene { namespace chain {
* every time a block is found it decreases by
* RECENTLY_MISSED_COUNT_DECREMENT. It is
* never less than 0.
*
* If the recently_missed_count hits 2*UNDO_HISTORY then no new blocks may be pushed.
*/
uint32_t recently_missed_count = 0;
@ -130,6 +130,9 @@ namespace graphene { namespace chain {
};
}}
MAP_OBJECT_ID_TO_TYPE(graphene::chain::dynamic_global_property_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::global_property_object)
FC_REFLECT_DERIVED( graphene::chain::dynamic_global_property_object, (graphene::db::object),
(head_block_number)
(head_block_id)

View file

@ -24,7 +24,7 @@
#pragma once
#include <graphene/chain/config.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/types.hpp>
namespace graphene { namespace chain {

View file

@ -24,9 +24,9 @@
#pragma once
#include <fc/container/flat.hpp>
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/protocol/transaction.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/protocol/transaction.hpp>
#include <graphene/protocol/types.hpp>
namespace graphene { namespace chain {

View file

@ -23,11 +23,17 @@
*/
#pragma once
#include <fc/exception/exception.hpp>
#include <graphene/chain/exceptions.hpp>
#define GRAPHENE_DECLARE_INTERNAL_EXCEPTION( exc_name, seqnum, msg ) \
FC_DECLARE_DERIVED_EXCEPTION( \
internal_ ## exc_name, \
graphene::chain::internal_exception, \
3990000 + seqnum \
)
#define GRAPHENE_IMPLEMENT_INTERNAL_EXCEPTION( exc_name, seqnum, msg ) \
FC_IMPLEMENT_DERIVED_EXCEPTION( \
internal_ ## exc_name, \
graphene::chain::internal_exception, \
3990000 + seqnum, \
@ -36,7 +42,7 @@
namespace graphene { namespace chain {
FC_DECLARE_DERIVED_EXCEPTION( internal_exception, graphene::chain::chain_exception, 3990000, "internal exception" )
FC_DECLARE_DERIVED_EXCEPTION( internal_exception, graphene::chain::chain_exception, 3990000 )
GRAPHENE_DECLARE_INTERNAL_EXCEPTION( verify_auth_max_auth_exceeded, 1, "Exceeds max authority fan-out" )
GRAPHENE_DECLARE_INTERNAL_EXCEPTION( verify_auth_account_not_found, 2, "Auth account not found" )

View file

@ -22,13 +22,13 @@
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/database.hpp>
namespace graphene { namespace chain {
class ticket_purchase_evaluator : public evaluator<ticket_purchase_evaluator>
class ticket_purchase_evaluator : public fee_handling_evaluator<ticket_purchase_evaluator>
{
public:
typedef ticket_purchase_operation operation_type;
@ -40,7 +40,7 @@ namespace graphene { namespace chain {
const asset_dynamic_data_object* asset_dynamic_data;
};
class lottery_reward_evaluator : public evaluator<lottery_reward_evaluator>
class lottery_reward_evaluator : public fee_handling_evaluator<lottery_reward_evaluator>
{
public:
typedef lottery_reward_operation operation_type;
@ -52,7 +52,7 @@ namespace graphene { namespace chain {
const asset_dynamic_data_object* asset_dynamic_data;
};
class lottery_end_evaluator : public evaluator<lottery_end_evaluator>
class lottery_end_evaluator : public fee_handling_evaluator<lottery_end_evaluator>
{
public:
typedef lottery_end_operation operation_type;
@ -64,7 +64,7 @@ namespace graphene { namespace chain {
const asset_dynamic_data_object* asset_dynamic_data;
};
class sweeps_vesting_claim_evaluator : public evaluator<sweeps_vesting_claim_evaluator>
class sweeps_vesting_claim_evaluator : public fee_handling_evaluator<sweeps_vesting_claim_evaluator>
{
public:
typedef sweeps_vesting_claim_operation operation_type;

View file

@ -23,7 +23,7 @@
*/
#pragma once
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/types.hpp>
namespace graphene { namespace chain {
@ -31,11 +31,9 @@ namespace graphene { namespace chain {
class asset_object;
class asset_bitasset_data_object;
class call_order_object;
struct call_order_update_operation;
struct limit_order_cancel_operation;
struct limit_order_create_operation;
class limit_order_object;
class limit_order_create_evaluator : public evaluator<limit_order_create_evaluator>
class limit_order_create_evaluator : public fee_handling_evaluator<limit_order_create_evaluator>
{
public:
typedef limit_order_create_operation operation_type;
@ -57,7 +55,7 @@ namespace graphene { namespace chain {
const asset_object* _receive_asset = nullptr;
};
class limit_order_cancel_evaluator : public evaluator<limit_order_cancel_evaluator>
class limit_order_cancel_evaluator : public fee_handling_evaluator<limit_order_cancel_evaluator>
{
public:
typedef limit_order_cancel_operation operation_type;
@ -68,7 +66,7 @@ namespace graphene { namespace chain {
const limit_order_object* _order;
};
class call_order_update_evaluator : public evaluator<call_order_update_evaluator>
class call_order_update_evaluator : public fee_handling_evaluator<call_order_update_evaluator>
{
public:
typedef call_order_update_operation operation_type;

View file

@ -23,10 +23,10 @@
*/
#pragma once
#include <graphene/chain/protocol/asset.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/db/generic_index.hpp>
#include <graphene/db/object.hpp>
#include <graphene/protocol/asset.hpp>
#include <graphene/chain/types.hpp>
#include <boost/multi_index/composite_key.hpp>
@ -65,7 +65,6 @@ class limit_order_object : public abstract_object<limit_order_object>
asset amount_to_receive()const { return amount_for_sale() * sell_price; }
};
struct by_id;
struct by_price;
struct by_expiration;
struct by_account;
@ -205,6 +204,10 @@ typedef generic_index<force_settlement_object, force_settlement_object_multi_ind
} } // graphene::chain
MAP_OBJECT_ID_TO_TYPE(graphene::chain::limit_order_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::call_order_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::force_settlement_object)
FC_REFLECT_DERIVED( graphene::chain::limit_order_object,
(graphene::db::object),
(expiration)(seller)(for_sale)(sell_price)(deferred_fee)

View file

@ -1,10 +1,17 @@
#pragma once
#include <graphene/chain/protocol/tournament.hpp>
#include <graphene/chain/rock_paper_scissors.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <graphene/chain/game_object.hpp>
#include <graphene/protocol/tournament.hpp>
#include <graphene/db/flat_index.hpp>
#include <graphene/db/generic_index.hpp>
#include <fc/crypto/hex.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <sstream>
namespace graphene { namespace chain {
@ -157,11 +164,13 @@ namespace graphene { namespace chain {
} }
MAP_OBJECT_ID_TO_TYPE(graphene::chain::match_object)
FC_REFLECT_ENUM(graphene::chain::match_state,
(waiting_on_previous_matches)
(match_in_progress)
(match_complete))
//FC_REFLECT_TYPENAME(graphene::chain::match_object) // manually serialized
FC_REFLECT(graphene::chain::match_object, (players))
FC_REFLECT_DERIVED(graphene::chain::match_object, (graphene::db::object), (players))

View file

@ -2,12 +2,13 @@
#include <graphene/chain/database.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/protocol/types.hpp>
namespace graphene { namespace chain {
class nft_metadata_create_evaluator : public evaluator<nft_metadata_create_evaluator>
class nft_metadata_create_evaluator : public fee_handling_evaluator<nft_metadata_create_evaluator>
{
public:
typedef nft_metadata_create_operation operation_type;
@ -15,7 +16,7 @@ namespace graphene { namespace chain {
object_id_type do_apply( const nft_metadata_create_operation& o );
};
class nft_metadata_update_evaluator : public evaluator<nft_metadata_update_evaluator>
class nft_metadata_update_evaluator : public fee_handling_evaluator<nft_metadata_update_evaluator>
{
public:
typedef nft_metadata_update_operation operation_type;
@ -23,7 +24,7 @@ namespace graphene { namespace chain {
void_result do_apply( const nft_metadata_update_operation& o );
};
class nft_mint_evaluator : public evaluator<nft_mint_evaluator>
class nft_mint_evaluator : public fee_handling_evaluator<nft_mint_evaluator>
{
public:
typedef nft_mint_operation operation_type;
@ -31,7 +32,7 @@ namespace graphene { namespace chain {
object_id_type do_apply( const nft_mint_operation& o );
};
class nft_safe_transfer_from_evaluator : public evaluator<nft_safe_transfer_from_evaluator>
class nft_safe_transfer_from_evaluator : public fee_handling_evaluator<nft_safe_transfer_from_evaluator>
{
public:
typedef nft_safe_transfer_from_operation operation_type;
@ -39,7 +40,7 @@ namespace graphene { namespace chain {
object_id_type do_apply( const nft_safe_transfer_from_operation& o );
};
class nft_approve_evaluator : public evaluator<nft_approve_evaluator>
class nft_approve_evaluator : public fee_handling_evaluator<nft_approve_evaluator>
{
public:
typedef nft_approve_operation operation_type;
@ -47,7 +48,7 @@ namespace graphene { namespace chain {
object_id_type do_apply( const nft_approve_operation& o );
};
class nft_set_approval_for_all_evaluator : public evaluator<nft_set_approval_for_all_evaluator>
class nft_set_approval_for_all_evaluator : public fee_handling_evaluator<nft_set_approval_for_all_evaluator>
{
public:
typedef nft_set_approval_for_all_operation operation_type;

View file

@ -1,14 +1,16 @@
#pragma once
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/protocol/operations.hpp>
namespace graphene
{
namespace chain
{
class nft_lottery_token_purchase_evaluator : public evaluator<nft_lottery_token_purchase_evaluator>
class nft_lottery_token_purchase_evaluator : public fee_handling_evaluator<nft_lottery_token_purchase_evaluator>
{
public:
typedef nft_lottery_token_purchase_operation operation_type;
@ -17,7 +19,7 @@ namespace graphene
object_id_type do_apply(const nft_lottery_token_purchase_operation &o);
};
class nft_lottery_reward_evaluator : public evaluator<nft_lottery_reward_evaluator>
class nft_lottery_reward_evaluator : public fee_handling_evaluator<nft_lottery_reward_evaluator>
{
public:
typedef nft_lottery_reward_operation operation_type;
@ -26,7 +28,7 @@ namespace graphene
void_result do_apply(const nft_lottery_reward_operation &o);
};
class nft_lottery_end_evaluator : public evaluator<nft_lottery_end_evaluator>
class nft_lottery_end_evaluator : public fee_handling_evaluator<nft_lottery_end_evaluator>
{
public:
typedef nft_lottery_end_operation operation_type;

View file

@ -1,5 +1,7 @@
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/types.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp>
@ -33,7 +35,7 @@ namespace graphene { namespace chain {
{
public:
static const uint8_t space_id = protocol_ids;
static const uint8_t type_id = nft_metadata_type;
static const uint8_t type_id = nft_metadata_object_type;
account_id_type owner;
std::string name;
@ -177,6 +179,10 @@ namespace graphene { namespace chain {
} } // graphene::chain
MAP_OBJECT_ID_TO_TYPE(graphene::chain::nft_lottery_balance_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::nft_metadata_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::nft_object)
FC_REFLECT_DERIVED( graphene::chain::nft_lottery_balance_object, (graphene::db::object),
(total_progressive_jackpot)
(jackpot)

View file

@ -1,13 +1,14 @@
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/protocol/operations.hpp>
namespace graphene
{
namespace chain
{
class offer_evaluator : public evaluator<offer_evaluator>
class offer_evaluator : public fee_handling_evaluator<offer_evaluator>
{
public:
typedef offer_operation operation_type;
@ -16,7 +17,7 @@ namespace graphene
object_id_type do_apply(const offer_operation &o);
};
class bid_evaluator : public evaluator<bid_evaluator>
class bid_evaluator : public fee_handling_evaluator<bid_evaluator>
{
public:
typedef bid_operation operation_type;
@ -25,7 +26,7 @@ namespace graphene
void_result do_apply(const bid_operation &o);
};
class cancel_offer_evaluator : public evaluator<cancel_offer_evaluator>
class cancel_offer_evaluator : public fee_handling_evaluator<cancel_offer_evaluator>
{
public:
typedef cancel_offer_operation operation_type;
@ -34,7 +35,7 @@ namespace graphene
void_result do_apply(const cancel_offer_operation &o);
};
class finalize_offer_evaluator : public evaluator<finalize_offer_evaluator>
class finalize_offer_evaluator : public fee_handling_evaluator<finalize_offer_evaluator>
{
public:
typedef finalize_offer_operation operation_type;

View file

@ -1,5 +1,9 @@
#pragma once
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/types.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/db/generic_index.hpp>
namespace graphene
@ -56,7 +60,8 @@ namespace graphene
class offer_item_index : public secondary_index
{
public:
virtual void object_inserted(const object &obj) override;
virtual void object_loaded(const object &obj) override;
virtual void object_created(const object &obj) override;
virtual void object_removed(const object &obj) override;
virtual void about_to_modify(const object &before) override{};
virtual void object_modified(const object &after) override;
@ -99,6 +104,9 @@ namespace graphene
} // namespace chain
} // namespace graphene
MAP_OBJECT_ID_TO_TYPE(graphene::chain::offer_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::offer_history_object)
FC_REFLECT_DERIVED(graphene::chain::offer_object, (graphene::db::object),
(issuer)(item_ids)(bidder)(bid_price)(minimum_price)(
maximum_price)(buying_item)(offer_expiration_date))

Some files were not shown because too many files have changed in this diff Show more