Compare commits

..

286 commits

Author SHA1 Message Date
Bobinson K B
d3d967a2d7 Merge branch 'hotfix/bookie2024' into 'master'
Bookie 2024

See merge request PBSA/peerplays!259
2023-12-18 06:17:23 +00:00
serkixenos
178756bd34 Bookie 2024 2023-12-18 06:17:22 +00:00
Bobinson K B
1f70857d64 Merge branch 'beatrice' into 'master'
Mainnet release

See merge request PBSA/peerplays!251
2023-10-06 10:50:31 +00:00
Vlad Dobromyslov
97e85a849d Merge branch 'develop' into 'beatrice'
Set HARDFORK_SON_FOR_ETHEREUM_TIME to 24 of October

See merge request PBSA/peerplays!250
2023-10-04 16:51:45 +00:00
Vlad Dobromyslov
dc4cdd6e4b Set HARDFORK_SON_FOR_ETHEREUM_TIME to 24 of October 2023-10-04 16:51:45 +00:00
Vlad Dobromyslov
1472066af6 Merge branch 'develop' into 'beatrice'
Fixes for 1.5.25-beta

See merge request PBSA/peerplays!249
2023-10-03 16:24:00 +00:00
Vlad Dobromyslov
a641b8e93f Fixes for 1.5.25-beta 2023-10-03 16:23:59 +00:00
Vlad Dobromyslov
aa099f960f Merge branch 'develop' into 'beatrice'
Fixes for 1.5.24-beta

See merge request PBSA/peerplays!246
2023-08-23 14:31:39 +00:00
Vlad Dobromyslov
f0654e5ffd Fixes for 1.5.24-beta 2023-08-23 14:31:38 +00:00
Vlad Dobromyslov
9fe351300b Merge branch 'develop' into 'beatrice'
Set test-e2e as manual

See merge request PBSA/peerplays!242
2023-07-17 12:49:53 +00:00
Vlad Dobromyslov
5fd79c3e78 Set test-e2e as manual 2023-07-17 12:49:53 +00:00
Vlad Dobromyslov
b56818b8ae Merge branch 'develop' into 'beatrice'
Change DB_VERSION to PPY2.5

See merge request PBSA/peerplays!240
2023-07-13 16:44:03 +00:00
Vlad Dobromyslov
bc0fbeb707 Change DB_VERSION to PPY2.5 2023-07-13 16:44:03 +00:00
Vlad Dobromyslov
accd334a86 Merge branch 'develop' into 'beatrice'
NEW HARDFORK TIME FOR SON ETH

See merge request PBSA/peerplays!238
2023-07-07 12:10:44 +00:00
Vlad Dobromyslov
84a66c6722 NEW HARDFORK TIME FOR SON ETH 2023-07-07 12:10:44 +00:00
Vlad Dobromyslov
abd446d80b Merge branch 'develop' into 'beatrice'
Fix balance discrepancies in 1.5.23-beta

See merge request PBSA/peerplays!235
2023-07-06 05:31:28 +00:00
Vlad Dobromyslov
93fb57c080 Fix balance discrepancies in 1.5.23-beta 2023-07-06 05:31:28 +00:00
Bobinson K B
a8845ffde9 Merge branch 'develop' into 'beatrice'
Fix issue with balance discrepancies in 1.5.23-beta

See merge request PBSA/peerplays!232
2023-06-20 07:37:24 +00:00
Vlad Dobromyslov
435c1f8e96 Fix issue with balance discrepancies in 1.5.23-beta 2023-06-20 07:37:24 +00:00
Bobinson K B
1123ff6f93 Merge branch 'develop' into 'beatrice'
Fixes for public testnet

See merge request PBSA/peerplays!230
2023-06-09 08:10:26 +00:00
Vlad Dobromyslov
c34415b403 Fixes for public testnet 2023-06-09 08:10:26 +00:00
Christopher Sanborn
daca2813ef Merge branch 'testnet-set-hf-dates' into 'beatrice'
Set Hard Fork dates for testnet and mainnet
2023-05-25 13:25:09 -04:00
Christopher Sanborn
0b37a48b02 Set Hard Fork dates for testnet and main net. 2023-05-25 13:23:05 -04:00
Bobinson K B
e3b10cf1ec Merge branch 'testnet-builds' into 'beatrice'
Updated build rules for mainnet and testnet

See merge request PBSA/peerplays!223
2023-05-17 16:25:03 +00:00
Rily Dunlap
f5c6a6310b Updated build rules for mainnet and testnet 2023-05-17 14:50:10 +00:00
Bobinson K B
75ee6fbed3 Merge branch 'develop' into 'beatrice'
New set of functionality

See merge request PBSA/peerplays!220
2023-05-16 11:46:25 +00:00
Vlad Dobromyslov
7516126d01 New set of functionality 2023-05-16 11:46:25 +00:00
Vlad Dobromyslov
f32a51d03b Merge branch 'develop' into 'beatrice'
Alpha release 06.03.2023

See merge request PBSA/peerplays!215
2023-03-06 16:57:45 +00:00
Vlad Dobromyslov
c421453621 Merge branch 'bug/513-num_son_merge' into 'develop'
num_son no overwriting

See merge request PBSA/peerplays!213
2023-03-06 15:50:17 +00:00
Milo M
54ff842db1 num_son no overwriting 2023-03-06 15:50:17 +00:00
Vlad Dobromyslov
16ba10ffab Merge branch 'feature/SON-connection-pool' into 'develop'
SON connection pool

See merge request PBSA/peerplays!181
2023-03-01 06:01:52 +00:00
timur
79974280c0 SON connection pool 2023-03-01 06:01:52 +00:00
Vlad Dobromyslov
5867a8ae27 Merge branch 'bug/501-connection-pool' into 'develop'
#501 - concurrent_unordered_set for connection

See merge request PBSA/peerplays!212
2023-02-27 13:34:41 +00:00
serkixenos
741534c47f Merge branch 'bug/509-hive-withdrawal' into 'develop'
#509 - fix hive withdrawal processing

See merge request PBSA/peerplays!211
2023-02-24 09:37:55 +00:00
serkixenos
f3227fb33d Merge branch 'bug/421-fix-double' into 'develop'
automated test for nft_lottery

See merge request PBSA/peerplays!208
2023-02-24 09:36:10 +00:00
Milo M
bfb961c7be automated test for nft_lottery 2023-02-24 09:36:10 +00:00
serkixenos
5e08b793c5 Merge branch 'bug/495-hive-wallet-update' into 'develop'
#495 hive wallet update

See merge request PBSA/peerplays!210
2023-02-24 09:31:51 +00:00
Vlad Dobromyslov
7af3d037b5 #495 hive wallet update 2023-02-24 09:31:51 +00:00
Vlad Dobromyslov
2788281062 #501 - concurrent_unordered_set for connection 2023-02-23 17:55:49 +02:00
serkixenos
4e2850f826 Fix libbitcoin build in docker and related README instructions 2023-02-17 05:45:33 +01:00
Vlad Dobromyslov
f477af6771 #509 - fix hive withdrawal processing 2023-02-16 12:45:03 +02:00
serkixenos
80d168e5b6 Merge branch 'bug/421-fix-double' into 'develop'
#421 fix double in consensus of nft_lottery_token_purchase

See merge request PBSA/peerplays!205
2023-02-10 14:50:23 +00:00
Milos Milosevic
e44ed0cfe5 #421 fix double in consensus of nft_lottery_token_purchase 2023-02-10 14:50:23 +00:00
serkixenos
142cf5b903 Merge branch 'develop' into 'beatrice'
Merge develop to beatrice 2023-02

See merge request PBSA/peerplays!206
2023-02-10 13:56:17 +00:00
serkixenos
ebc1529c48 Merge branch 'bug/492-eth-withdrawal' into 'develop'
#492 - fix withdrawal encoders for big numbers

See merge request PBSA/peerplays!207
2023-02-10 13:54:53 +00:00
Vlad Dobromyslov
19e0911d64 #492 - fix withdrawal encoders for big numbers 2023-02-10 13:34:53 +02:00
serkixenos
70cd09495e Merge branch 'feature/libbitcoin-son-final' into 'develop'
Bitcoin SON based on libbitcoin

See merge request PBSA/peerplays!164
2023-02-06 22:48:40 +00:00
Davor Hirunda
e9c7021e16 Bitcoin SON based on libbitcoin 2023-02-06 22:48:40 +00:00
serkixenos
9c9aaa03d3 Merge branch 'bug/506-zero-fees' into 'develop'
#506 - fix load fees from genesis file

See merge request PBSA/peerplays!203
2023-02-06 20:57:51 +00:00
serkixenos
038fa37cc6 Merge branch 'bug/507/bitcoin_regression_detected_on_develop_branch' into 'develop'
Fix the issue for wrong number of signers

See merge request PBSA/peerplays!204
2023-02-06 20:48:11 +00:00
hirunda
73b2ba635b Fix the issue for wrong number of signers 2023-02-06 21:09:28 +01:00
Vlad Dobromyslov
936f13d2a1 #506 - fix load fees from genesis file 2023-02-06 08:14:05 +02:00
Vlad Dobromyslov
fc1cdf2629 Fix build errors active_sidechain_types 2023-02-01 20:54:44 +02:00
serkixenos
71f0806b25 Merge branch 'invalid_son_number_reflection' into 'develop'
Fix replay blockchain

See merge request PBSA/peerplays!202
2023-02-01 17:13:03 +00:00
Vlad Dobromyslov
da3a858aa6 Fix replay blockchain 2023-02-01 17:13:02 +00:00
serkixenos
1883f97be2 Merge branch 'bug/500-primary-wallet-transaction' into 'develop'
#500 - fix son_wallet_update_operation

See merge request PBSA/peerplays!201
2023-02-01 12:35:58 +00:00
serkixenos
559769db2b Merge branch 'feature/473-erc20-support' into 'develop'
#473 erc20-support

See merge request PBSA/peerplays!198
2023-01-31 10:48:45 +00:00
Vlad Dobromyslov
0b64f0cfcc #473 erc20-support 2023-01-31 10:48:45 +00:00
serkixenos
96d737fbc2 Merge branch 'master' into beatrice 2023-01-31 11:45:36 +01:00
Vlad Dobromyslov
d89e5e1f23 #500 - fix son_wallet_update_operation 2023-01-30 19:27:27 +02:00
Bobinson K B
6f472d3d3b Merge branch 'develop' into 'beatrice'
Merge develop to beatrice 2022-12

See merge request PBSA/peerplays!193
2023-01-03 07:33:40 +00:00
serkixenos
cb60cbe5d1 Merge branch 'hotfix/extend_get_block_api' into 'develop'
Streamline get_block API from database and cli wallet

See merge request PBSA/peerplays!197
2022-12-28 07:45:45 +00:00
serkixenos
576c54a260 Merge branch 'bug/499-eth-son_wallet_deposit_process_operation' into 'develop'
#499 - son_wallet_deposit_process_operation approve fix

See merge request PBSA/peerplays!196
2022-12-28 07:45:18 +00:00
serkixenos
2f5e12b28e Merge branch 'bug/496-process_primary_wallet' into 'develop'
#496 process primary wallet

See merge request PBSA/peerplays!195
2022-12-28 07:44:29 +00:00
Vlad Dobromyslov
68fbd6f40b #496 process primary wallet 2022-12-28 07:44:29 +00:00
serkixenos
674b38910d Streamline get_block API from database and cli wallet 2022-12-28 08:23:29 +01:00
Vlad Dobromyslov
d264398a6f #499 - son_wallet_deposit_process_operation approve fix 2022-12-23 15:37:15 +02:00
serkixenos
c1d5691ce2 Merge branch 'feature/nft_get_metadata_by_owner' into 'develop'
Add or revive a few NFT-listing APIs

See merge request PBSA/peerplays!194
2022-12-21 17:45:42 +00:00
timur
ca69a692cc Add or revive a few NFT-listing APIs 2022-12-21 17:45:42 +00:00
serkixenos
bd041bc13f Merge branch 'bug/489-error-message-gas-prediction' into 'develop'
#489 - Fix error message

See merge request PBSA/peerplays!190
2022-12-21 17:24:55 +00:00
serkixenos
6037e89df0 Merge branch 'hive-fix-son-account-owner-authority' into 'develop'
Update Hive's son-account owner authority on primary wallet update

See merge request PBSA/peerplays!192
2022-12-16 04:32:04 +00:00
serkixenos
bb7c534b10 Update Hive's son-account owner authority on primary wallet update 2022-12-16 04:27:31 +01:00
serkixenos
1be6636bbf Merge branch 'bug/api-doc-generation-hotfix-2' into 'develop'
Fix Ubuntu 18 build

See merge request PBSA/peerplays!185
2022-12-16 00:34:34 +00:00
timur
578edc56d8 Fix Ubuntu 18 build 2022-12-16 00:34:33 +00:00
Vlad Dobromyslov
d387e324fe #489 - Fix error message 2022-12-14 15:52:28 +02:00
serkixenos
1bf5c82101 Merge branch 'bug/484-multiple-eth-withdrawals' into 'develop'
#484 multiple eth withdrawals

See merge request PBSA/peerplays!189
2022-12-08 14:03:14 +00:00
Vlad Dobromyslov
4883dfe38d #484 multiple eth withdrawals 2022-12-08 14:03:14 +00:00
serkixenos
249276b009 Merge branch 'feature/479-one-bunch-transaction' into 'develop'
#479 one bunch transaction

See merge request PBSA/peerplays!188
2022-12-08 14:02:53 +00:00
Vlad Dobromyslov
ab1e08a756 #479 one bunch transaction 2022-12-08 14:02:53 +00:00
serkixenos
440e4fbb43 Merge branch 'bug/482-burn-eth-from-son-account' into 'develop'
#482 burn eth from son account

See merge request PBSA/peerplays!186
2022-12-06 12:17:09 +00:00
Vlad Dobromyslov
42b3890a7c #482 burn eth from son account 2022-12-06 12:17:09 +00:00
serkixenos
5dff0830fb Merge branch 'feature/479-one-bunch-transaction' into 'develop'
#479 - Send one transaction for all owners

See merge request PBSA/peerplays!183
2022-12-01 01:53:39 +00:00
Vlad Dobromyslov
c3eab0a80b #479 - Send one transaction for all owners 2022-12-01 01:53:39 +00:00
serkixenos
12c0c66f4b Merge branch 'feature/478-estimate-transaction-fee' into 'develop'
#478 - fix information warning

See merge request PBSA/peerplays!184
2022-12-01 01:53:01 +00:00
Vlad Dobromyslov
b7113c4ff3 #478 - fix information warning 2022-11-28 09:35:00 +02:00
serkixenos
d76b752c8c Merge branch 'develop' into 'beatrice'
Merge develop to beatrice 2022-11

See merge request PBSA/peerplays!180
2022-11-24 17:48:46 +00:00
serkixenos
804376b149 Merge branch 'beatrice' into develop 2022-11-23 17:35:57 +01:00
serkixenos
1b340345f3 Merge branch 'feature/478-estimate-transaction-fee' into 'develop'
#478 estimate transaction fee

See merge request PBSA/peerplays!179
2022-11-22 20:44:07 +00:00
Vlad Dobromyslov
022fdeb40a #478 estimate transaction fee 2022-11-22 20:44:07 +00:00
serkixenos
f6d22466fd Merge branch 'bug/462/investigate_trx_which_caused_mainnet_halt' into 'develop'
Fix for undo crash

See merge request PBSA/peerplays!172
2022-11-15 22:34:05 +00:00
Davor Hirunda
811d68ef4d Fix for undo crash 2022-11-15 22:34:05 +00:00
serkixenos
a6da2a6413 Merge branch 'bug/433-choosing-active-sons' into 'develop'
#433 Down active sons are not substituted

See merge request PBSA/peerplays!177
2022-11-15 22:33:04 +00:00
Milos Milosevic
8853a76752 #433 Down active sons are not substituted 2022-11-15 22:33:04 +00:00
serkixenos
f209ab8ee6 Merge branch 'bug/481-ethereum-listener' into 'develop'
#481 ethereum listener

See merge request PBSA/peerplays!178
2022-11-14 13:42:24 +00:00
Vlad Dobromyslov
9620e3c211 #481 ethereum listener 2022-11-14 13:42:23 +00:00
serkixenos
3ebcd29e10 Merge branch 'bug/476-fix-v-signing-value' into 'develop'
#476 - fix calculating v value from chain id

See merge request PBSA/peerplays!174
2022-11-10 11:35:14 +00:00
serkixenos
d5b2b7aeda Merge branch 'bug/470-get-network_id' into 'develop'
#470 Don't use admin_nodeInfo when get network_id

See merge request PBSA/peerplays!173
2022-11-10 11:35:07 +00:00
Vlad Dobromyslov
759dac5d41 #476 - fix calculating v value from chain id 2022-11-07 12:16:59 +02:00
Bobinson K B
058937a3ee Merge branch 'hotfix/sidechain-address' into 'master'
Hotfix: Fix sidechain address editing

See merge request PBSA/peerplays!171
2022-11-04 11:38:30 +00:00
serkixenos
da73e31038 Hotfix: Fix sidechain address editing 2022-11-04 11:38:30 +00:00
Vlad Dobromyslov
a30325660d #470 Don't use admin_nodeInfo when get network_id 2022-11-04 07:51:22 +02:00
serkixenos
d5d6390030 Merge branch 'bug/461-system_error-exception' into 'develop'
#461 - handle exception when execute POST request

See merge request PBSA/peerplays!165
2022-10-30 02:30:59 +00:00
serkixenos
400c3cfb89 Merge branch 'bug/467-prev-set-active-sons' into 'develop'
#467 - fix create_primary_wallet_transaction signers

See merge request PBSA/peerplays!169
2022-10-30 02:30:22 +00:00
Vlad Dobromyslov
aa90f715fd #467 - fix create_primary_wallet_transaction signers 2022-10-30 02:30:21 +00:00
Davor Hirunda
c3b2a598b4 Fix for undo crash 2022-10-30 03:26:53 +01:00
serkixenos
06bc65cc79 #450 Add documentation for undocumented methods 2022-10-30 03:21:18 +01:00
serkixenos
8e8142235a Merge branch 'bug/issue-463' into 'develop'
#463 Fix unused variable son_count_histogram_buffer in Release mode

See merge request PBSA/peerplays!166
2022-10-19 17:37:23 +00:00
Milos Milosevic
194fa6abfa #463 Fix unused variable son_count_histogram_buffer in Release mode 2022-10-19 17:37:23 +00:00
Vlad Dobromyslov
283fbd28f7 #461 - handle exception when execute POST request 2022-10-18 10:19:03 +03:00
serkixenos
71c113c190 Merge branch 'issue-436-cli_tests' into 'develop'
Updated CLI Tests [Issue 436]

See merge request PBSA/peerplays!159
2022-10-11 00:13:04 +00:00
Meheboob Khan
846366139f Updated CLI Tests [Issue 436] 2022-10-11 00:13:04 +00:00
serkixenos
0856e898bb Merge branch 'update-cli-wallet-docs' into 'develop'
Update cli wallet docs

See merge request PBSA/peerplays!162
2022-10-03 17:34:01 +00:00
serkixenos
4db9f3a15b Update cli wallet docs 2022-10-03 17:34:01 +00:00
serkixenos
1b1df25023 Merge branch 'bug/fix-api-doc-generation-for-map' into 'develop'
Fix API docs generation for map<> and flat_map<>

See merge request PBSA/peerplays!161
2022-10-03 17:31:59 +00:00
serkixenos
f9314a4c0c Merge branch 'bug/457-multithread-son-processing' into 'develop'
bug/457-multithread-son-processing

See merge request PBSA/peerplays!160
2022-10-03 17:04:56 +00:00
Vlad Dobromyslov
d4c015d400 bug/457-multithread-son-processing 2022-10-03 17:04:56 +00:00
timur
e6474f5f2a Fix API docs generation for map<> and flat_map<> 2022-10-01 19:11:54 -03:00
serkixenos
f2f4b57ced Merge branch 'bug/455-sidechain-enabled' into 'develop'
bug/455-sidechain-enabled

See merge request PBSA/peerplays!157
2022-09-27 13:58:07 +00:00
Vlad Dobromyslov
2c95ac0b9d bug/455-sidechain-enabled 2022-09-27 13:58:07 +00:00
serkixenos
9831579bfe Merge branch 'feature/update-debug-node' into 'develop'
Update debug_witness plugin

See merge request PBSA/peerplays!153
2022-09-27 12:25:33 +00:00
timur
2d6dec5943 Update debug_witness plugin 2022-09-27 12:25:33 +00:00
serkixenos
46f4770071 Merge branch 'bug/451-update-son-list-on-maintenance' into 'develop'
bug/451-update-son-list-on-maintenance

See merge request PBSA/peerplays!154
2022-09-27 10:41:35 +00:00
Vlad Dobromyslov
2accee53e2 bug/451-update-son-list-on-maintenance 2022-09-27 10:41:35 +00:00
serkixenos
54a11e7662 Merge branch 'issue-389' into 'develop'
Added functionality to check if the device size is less than 50 MB [Issue 389]

See merge request PBSA/peerplays!151
2022-09-26 20:14:32 +00:00
Meheboob Khan
c1f93f58ee Added functionality to check if the device size is less than 50 MB [Issue 389] 2022-09-26 20:14:31 +00:00
serkixenos
2fd6f60112 Merge branch 'feature/son-for-ethereum' into 'develop'
SON for Ethereum

See merge request PBSA/peerplays!133
2022-09-19 19:23:39 +00:00
serkixenos
5f97eb7662 SON for Ethereum 2022-09-19 19:23:39 +00:00
serkixenos
b4e8b76a30 Merge branch 'bug/fix-wallet-api-doc-generation' into 'develop'
Bug/fix wallet api doc generation

See merge request PBSA/peerplays!152
2022-09-16 02:42:31 +00:00
timur
a9267544de Bug/fix wallet api doc generation 2022-09-16 02:42:31 +00:00
serkixenos
e287d8a845 Merge branch 'issue-430' into 'develop'
Improved get_active_sons and get_son_network_status API/CLI [issue 430]

See merge request PBSA/peerplays!150
2022-09-14 18:03:40 +00:00
Meheboob Khan
0f64947f4a Improved get_active_sons and get_son_network_status API/CLI [issue 430] 2022-09-14 18:03:40 +00:00
serkixenos
b895b52b7b Cherrypick important fixes/cosmetics from feature/son-for-ethereum 2022-09-08 17:13:18 +02:00
serkixenos
9c5aab826d Merge branch 'feature/update-delayed-node' into 'develop'
Update delayed node feature

See merge request PBSA/peerplays!145
2022-09-07 13:57:17 +00:00
serkixenos
6a38fb2382 Update delayed node feature 2022-09-07 13:57:17 +00:00
serkixenos
0a9a324277 Merge branch 'port_net_library' into 'develop'
Port net library

See merge request PBSA/peerplays!147
2022-09-07 13:57:00 +00:00
Meheboob Khan
5c416e3a5b Port net library 2022-09-07 13:57:00 +00:00
serkixenos
9268c31ac4 Code formatting 2022-08-25 17:41:44 +02:00
serkixenos
c4f6f522a4 Merge branch 'bug/fix-unit-tests-develop' into 'develop'
Fix unit test failing on develop branch, #418

See merge request PBSA/peerplays!143
2022-08-25 11:14:17 +00:00
serkixenos
f127495c0e Fix unit test failing on develop branch, #418 2022-08-25 12:21:22 +02:00
serkixenos
9b2c60f76c Merge branch 'feature/son-for-hive-voting' into 'develop'
SON for Hive voting

See merge request PBSA/peerplays!81
2022-07-26 23:17:42 +00:00
serkixenos
22fc780a91 SON for Hive voting 2022-07-26 23:17:42 +00:00
serkixenos
005478e3ef Merge branch 'feature/new-rpc-ws-clients' into 'develop'
Boost Beast based RPC client

See merge request PBSA/peerplays!139
2022-07-26 13:47:16 +00:00
serkixenos
5bfd685684 Boost Beast based RPC client 2022-07-26 13:47:16 +00:00
serkixenos
662139ca22 Fix invalid result of nft_get_total_supply (#399) 2022-07-21 20:51:53 +02:00
serkixenos
6844b74e29 Merge branch 'bug/400-verify_sig' into 'develop'
#400 - fix verify_sig function.

See merge request PBSA/peerplays!138
2022-07-15 17:59:25 +00:00
Vlad Dobromyslov
99ed37e834 #400 - fix verify_sig function. 2022-07-15 17:59:25 +00:00
serkixenos
629a6672fd Merge branch 'feature/357-secp256k1-lib' into 'develop'
#357 secp256k1 lib from libbitcoin

See merge request PBSA/peerplays!118
2022-07-07 00:53:24 +00:00
Vlad Dobromyslov
3b5e928094 #357 secp256k1 lib from libbitcoin 2022-07-07 00:53:23 +00:00
serkixenos
09579fbab1 Fix SON cli tests 2022-07-06 01:07:39 +02:00
serkixenos
ff462234af Merge branch 'bug/394/clean_exit__from_all_threads_on_ctrl_c' into 'develop'
Clean exit from CTRL + C

See merge request PBSA/peerplays!134
2022-07-05 11:48:01 +00:00
Davor Hirunda
873dfd788b Clean exit from CTRL + C 2022-07-05 11:48:01 +00:00
serkixenos
b186a2f0ed Merge branch 'bug/fix-son-count-voting' into 'develop'
#387 Allow changing number of SONs by voting, similar to witnesses

See merge request PBSA/peerplays!129
2022-06-27 12:39:35 +00:00
serkixenos
1a196bfcc2 #387 Allow changing number of SONs by voting, similar to witnesses 2022-06-27 12:39:34 +00:00
Bobinson K B
611a63076b Merge branch 'beatrice' into 'master'
Merge beatrice to master 2022-06

See merge request PBSA/peerplays!131
2022-06-27 07:36:08 +00:00
serkixenos
d234c3a8f8 Set HARDFORK_SON3_TIME to 2022-07-16T00:00:00 2022-06-24 14:39:51 +02:00
serkixenos
bc7b0e7788 Set HARDFORK_SON3_TIME to 2022-07-16T00:00:00 2022-06-24 14:38:38 +02:00
serkixenos
d650e197a9 Add port to sync node endpoints 2022-06-20 14:10:08 +02:00
serkixenos
a7f5e1f603 Add port to sync node endpoints 2022-06-20 14:07:17 +02:00
serkixenos
0a38927b0e Allow querying witness_node version by API 2022-06-17 19:08:59 +02:00
serkixenos
9012e86bd1 Add more mainnet seed nodes 2022-06-17 19:08:47 +02:00
serkixenos
eb2894c3d3 Allow querying witness_node version by API 2022-06-17 19:03:27 +02:00
serkixenos
11834c7f53 Add more mainnet seed nodes 2022-06-17 00:10:21 +02:00
serkixenos
1ae9470dab Code formatting 2022-06-16 04:10:29 +02:00
serkixenos
e575334e30 Merge branch 'bug/issue388' into 'develop'
bug fix 388: add ZMQ_RCVTIMEO, graceful thread shutdown

See merge request PBSA/peerplays!128
2022-06-16 01:16:36 +00:00
serkixenos
1788038224 Add hardcoded seed nodes to the config file 2022-06-16 02:06:11 +02:00
serkixenos
8ce0db6ec3 Add hardcoded seed nodes to the config file 2022-06-16 02:04:58 +02:00
serkixenos
02d898d4dc Silence SON logs when not needed 2022-06-15 06:35:13 +02:00
serkixenos
bcdb355f48 Fix P2P port/endpoint error message 2022-06-15 06:31:38 +02:00
serkixenos
d78e0d0e48 Silence SON logs when not needed 2022-06-15 06:30:33 +02:00
hirunda
4d112936d2 Replace fc::random with std random generator 2022-06-15 05:43:00 +02:00
Vlad Dobromyslov
c102bef768 #345 double-free-or-corruption 2022-06-15 05:41:24 +02:00
serkixenos
092a46ae61 Remove unscheduled hardfork CORE 210 2022-06-15 05:41:17 +02:00
serkixenos
f03cc7ee90 Sidechain API, SONs listener log 2022-06-15 05:28:17 +02:00
serkixenos
3294480e20 Update GitLab CI file, more manual build options 2022-06-15 05:13:10 +02:00
Vlad Dobromyslov
7fd12ccce8 #386 - check valid() for optional<operation_history_object> 2022-06-15 05:09:21 +02:00
Davor Hirunda
03e37896d5 Cancel the thread for sync blocks 2022-06-15 05:09:15 +02:00
Davor Hirunda
bc7d03cb22 Fix for scheduler wrong state 2022-06-15 05:09:06 +02:00
serkixenos
b3e426999d Remove unused libreadline-dev library 2022-06-15 05:08:02 +02:00
serkixenos
ab32415d0c Update GitLab CI file, more manual build options 2022-06-15 05:07:56 +02:00
serkixenos
3152d47eea Update GitLab CI file, more manual build options 2022-06-15 05:07:46 +02:00
serkixenos
8f32e4cdb5 Update README instructions for starting docker containers 2022-06-15 05:05:19 +02:00
serkixenos
b4501167ee Update README instructions for docker build 2022-06-15 05:04:59 +02:00
serkixenos
d13551a277 Remove fc based RNG 2022-06-15 05:04:37 +02:00
Pavel Baykov
9dd0747e5d bug fix 388: add ZMQ_RCVTIMEO, graceful thread shutdown 2022-06-13 17:03:20 -03:00
serkixenos
29189b3897 Merge branch 'bug/386-assert-operation_history_object' into 'develop'
#386 - check valid() for optional<operation_history_object>

See merge request PBSA/peerplays!126
2022-06-10 12:18:54 +00:00
Vlad Dobromyslov
2a373a70f7 #386 - check valid() for optional<operation_history_object> 2022-06-09 21:41:19 +03:00
serkixenos
b05c36b4fe Merge branch 'bug/384/ungraceful_shutdown_on_CTRL+C' into 'develop'
Cancel the thread for sync blocks

See merge request PBSA/peerplays!124
2022-06-08 22:02:40 +00:00
Davor Hirunda
e2d9741af8 Cancel the thread for sync blocks 2022-06-08 22:02:40 +00:00
serkixenos
1846b1709e Merge branch 'feature/enable_sync_with_main_net' into 'develop'
Fix for scheduler wrong state

See merge request PBSA/peerplays!122
2022-06-02 16:18:16 +00:00
Davor Hirunda
2c02591e24 Fix for scheduler wrong state 2022-06-02 16:18:15 +00:00
serkixenos
aa2dea6ddf Remove unused libreadline-dev library 2022-05-25 16:48:38 +02:00
serkixenos
9af213190a Merge branch 'feature/88/disconnect_witness_without_hardfork_info' into 'develop'
Disconnect witness which doesn't provide last hardfork time

See merge request PBSA/peerplays!119
2022-05-24 22:16:10 +00:00
hirunda
0b04faec83 Disconnect witness which doesn't provide last hardfork time 2022-05-24 23:29:57 +02:00
serkixenos
a7b4d1cef5 Merge branch 'feature/gitlabcicd_update' into 'develop'
Update GitLab CI file, more manual build options

See merge request PBSA/peerplays!117
2022-05-22 23:14:42 +00:00
serkixenos
0fd22a9945 Update GitLab CI file, more manual build options 2022-05-20 17:48:30 +02:00
serkixenos
3980512543 Merge branch 'develop' of https://gitlab.com/PBSA/peerplays into develop 2022-05-17 00:52:35 +02:00
serkixenos
fc324559eb Merge branch 'issue/367/disconnecting_non_compatible_witness_nodes_happens_too_late' into 'develop'
Resolving the bug with disconnecting non compatible witness

See merge request PBSA/peerplays!113
2022-05-16 22:49:03 +00:00
serkixenos
f16aa73b3e Fix function name typos, disconnet -> disconnect 2022-05-17 00:32:00 +02:00
serkixenos
ca5dc441a7 Update GitLab CI file, more manual build options 2022-05-16 23:04:30 +02:00
serkixenos
2e55b1818a Update README instructions for starting docker containers 2022-05-16 20:43:24 +02:00
serkixenos
a2702cd1f4 Update README instructions for docker build 2022-05-16 20:43:17 +02:00
serkixenos
564af2e19e Merge branch 'bug/349/error_in_fc_crypto_rand_test' into 'develop'
Replace fc::random with std random generator

See merge request PBSA/peerplays!110
2022-05-16 16:06:23 +00:00
serkixenos
5b4a4d18d8 Remove fc based RNG 2022-05-16 18:03:14 +02:00
serkixenos
23cdcec381 Update README instructions for starting docker containers 2022-05-13 03:26:30 +02:00
serkixenos
82a84a06da Update README instructions for docker build 2022-05-12 13:54:52 +02:00
hirunda
8562a4c655 Resolving the bug with disconnecting non compatible witness 2022-05-11 22:34:02 +02:00
serkixenos
852565dcb1 Merge branch 'beatrice' into develop 2022-05-11 22:27:00 +02:00
serkixenos
d461c718ef Set HARDFORK_SON3_TIME to 2022-05-31T00:00:00 2022-05-11 22:22:46 +02:00
serkixenos
2903fc6446 Fix README build instructions 2022-05-11 22:21:18 +02:00
Pavel Baykov
95c5280be2 fix asserts 2022-05-11 22:13:27 +02:00
serkixenos
ffbe0cd592 Merge branch 'bug/issue366' into 'develop'
fix asserts

See merge request PBSA/peerplays!112
2022-05-11 19:28:08 +00:00
Pavel Baykov
27c77ba74b fix asserts 2022-05-11 03:48:25 -03:00
serkixenos
cb3302160b Fix P2P port/endpoint error message 2022-05-09 16:07:07 +02:00
serkixenos
c79c8987dc Ubuntu 18.04 build support 2022-05-07 02:01:00 +02:00
serkixenos
e0d7a6314a Ubuntu 18.04 build support 2022-05-07 01:54:00 +02:00
hirunda
223d2a528d Replace fc::random with std random generator 2022-05-06 13:08:34 +02:00
serkixenos
62f8983c5e Merge branch 'bug/issue360' into 'develop'
fix bug 360, use zmq_setsockopt

See merge request PBSA/peerplays!109
2022-05-06 01:08:14 +00:00
Pavel Baykov
c973131ed2 fix bug 360, use zmq_setsockopt 2022-05-05 11:10:01 -03:00
serkixenos
0c01935ff4 Merge branch 'ubuntu18.04' into 'develop'
libzmq v4.3.4, cppzmq v4.8.1, cmake v3.23 for Docker Ubuntu 18.04

See merge request PBSA/peerplays!105
2022-05-04 16:46:49 +00:00
Pavel Baykov
520505b667 libzmq v4.3.4, cppzmq v4.8.1, cmake v3.23 for Docker Ubuntu 18.04 2022-05-04 16:46:48 +00:00
serkixenos
000aeaa721 Merge branch 'Manual-Build-In-Pipeline-Job-For-Testnet-CMAKE' into 'develop'
Manual build in pipeline job for testnet cmake

See merge request PBSA/peerplays!71
2022-04-26 19:12:52 +00:00
Rily Dunlap
c1048e1509 Manual build in pipeline job for testnet cmake 2022-04-26 19:12:52 +00:00
serkixenos
3664ee67ca Merge branch 'feature/88/enhance_witness_logging_and_rejecting_non_updated_witness' into 'develop'
Disconnect from non updated witness

See merge request PBSA/peerplays!96
2022-04-26 19:04:30 +00:00
Davor Hirunda
bd6f265409 Disconnect from non updated witness 2022-04-26 19:04:30 +00:00
serkixenos
0f0cf62b20 Merge branch 'bug/345-double-free-or-corruption' into 'develop'
#345 double-free-or-corruption

See merge request PBSA/peerplays!101
2022-04-26 13:09:43 +00:00
Vlad Dobromyslov
13c782ccd6 #345 double-free-or-corruption 2022-04-26 13:09:41 +00:00
serkixenos
659a3c9185 Merge branch '352-missing-after-cmake-in-dependencies-installation-qol' into 'develop'
Resolve "Missing \ after cmake in dependencies installation - QOL"

See merge request PBSA/peerplays!104
2022-04-25 11:29:22 +00:00
Rily Dunlap
b0c7a527fa Resolve "Missing \ after cmake in dependencies installation - QOL" 2022-04-25 11:29:22 +00:00
serkixenos
157e6c2fd8 Docker file for Ubuntu 18.04 2022-04-20 23:24:06 +02:00
Bobinson K B
6a59d9efba Merge branch 'beatrice' into 'master'
Merge beatrice to master 2022-04

See merge request PBSA/peerplays!84
2022-04-14 13:18:26 +00:00
Bobinson K B
93b60efba5 Merge branch 'develop' into 'beatrice'
Merge develop to beatrice 2022-04

See merge request PBSA/peerplays!80
2022-04-14 08:38:43 +00:00
serkixenos
6eccec2ba4 Set SON3 hardfork date to 2022-04-30T00:00:00 2022-04-13 10:42:59 -04:00
serkixenos
d7c654500e Merge branch 'bug/336-exception-parse-json' into 'develop'
#336 exception parse json

See merge request PBSA/peerplays!95
2022-04-06 23:23:48 +00:00
Vlad Dobromyslov
d49017ff21 #336 exception parse json 2022-04-06 23:23:47 +00:00
serkixenos
6ee37d0916 Set HARDFORK_SON3_TIME to 2022-04-24T00:00:00 2022-04-05 18:34:27 -04:00
serkixenos
44b2d21d78 Merge branch 'feature/sidechain-api' into 'develop'
Sidechain API, SONs listener log

See merge request PBSA/peerplays!94
2022-04-05 12:47:32 +00:00
serkixenos
03836d3770 Sidechain API, SONs listener log 2022-04-04 23:28:31 -04:00
serkixenos
4809619892 Merge branch 'feature/337-lock-importmulti-unlock' into 'develop'
#337 lock/unlock importmulti

See merge request PBSA/peerplays!93
2022-04-01 12:20:59 +00:00
Vlad Dobromyslov
ad0b5afb79 #337 lock/unlock importmulti 2022-04-01 12:20:59 +00:00
serkixenos
0e5d599fdd Improved error checks and messages for BTC transfer fees 2022-03-23 17:46:44 -04:00
serkixenos
d39f838eb8 Merge branch 'bug/324/refactor_Bitcoin_block_parsing_v0.21_v0.22' into 'develop'
Support parsing addresses for bitcoin v21 and v22

See merge request PBSA/peerplays!90
2022-03-23 17:37:32 +00:00
Davor Hirunda
d07c343be6 Support parsing addresses for bitcoin v21 and v22 2022-03-23 17:37:32 +00:00
serkixenos
c0bbcca0cf Update clang format config to clang-format 10 2022-03-23 13:32:03 -04:00
serkixenos
4ef0163bf2 Add missing cli wallet command parameter descriptions 2022-03-23 09:24:45 -04:00
serkixenos
65ba17adb0 HARDFORK_SON3_TIME to 2022-04-01T00:00:00, limit wallet rescan from 2022-01-01 2022-03-23 09:03:44 -04:00
serkixenos
ddd0d2fd16 Merge branch 'feature/314-sidechain_withdrawal_transaction' into 'develop'
issue 327 fixed, add block_num

See merge request PBSA/peerplays!89
2022-03-23 12:12:36 +00:00
Pavel Baykov
bfa7b13193 issue 327 fixed, add block_num 2022-03-21 13:32:26 -03:00
serkixenos
7f5a92fb1e Remove deposit/withdrawal cli tests 2022-03-21 11:19:05 -04:00
serkixenos
a408ed0dda Merge branch 'feature/325-import-btc-addresses' into 'develop'
#325 Refactor importing BTC addresses into son-wallet

See merge request PBSA/peerplays!88
2022-03-21 14:50:02 +00:00
Vlad Dobromyslov
ee018cf513 #325 Refactor importing BTC addresses into son-wallet 2022-03-21 14:50:02 +00:00
serkixenos
23e40e1004 Update wallet library Doxygen file, for cleaner build output 2022-03-18 19:29:56 -04:00
serkixenos
f4a0b3fb6d Merge branch 'bug/315/remove_hardcoded_chain_parameters' into 'develop'
Fix update son parameters on maintenance

See merge request PBSA/peerplays!85
2022-03-18 22:36:31 +00:00
Davor Hirunda
d1e425e3c9 Fix update son parameters on maintenance 2022-03-18 22:36:31 +00:00
serkixenos
237889f621 Merge branch 'feature/314-sidechain_withdrawal_transaction' into 'develop'
Feature/314 sidechain withdrawal transaction

See merge request PBSA/peerplays!83
2022-03-16 14:50:38 +00:00
Pavel Baykov
a5a8d6c617 sidechain_withdraw_transaction_test 2022-03-11 14:54:44 -04:00
Pavel Baykov
f3666d7468 sidechain_withdrawal_transaction 2022-03-10 10:28:23 -04:00
serkixenos
21e13ac4d4 Merge branch 'bug/149/prevent_misconfiguration_of_blockchain_parameters' into 'develop'
Add constraints in changing global parameters

See merge request PBSA/peerplays!79
2022-03-08 23:23:43 +00:00
Davor Hirunda
7729c09c2e Add constraints in changing global parameters 2022-03-08 23:23:42 +00:00
serkixenos
d347d3d01b Merge branch 'feature/313-son-deposit-manually' into 'develop'
#313 son deposit manually

See merge request PBSA/peerplays!78
2022-03-08 23:21:28 +00:00
Vlad Dobromyslov
f169e7a7ef #313 son deposit manually 2022-03-08 23:21:28 +00:00
serkixenos
0740bceb74 Update fc to last commit 2022-03-04 18:32:40 -04:00
serkixenos
2c411b63d3 Merge branch 'bug/279-randomly-test-fall' into 'develop'
#279 randomly test fall

See merge request PBSA/peerplays!77
2022-03-04 22:02:42 +00:00
Vlad Dobromyslov
ae5237a781 #279 randomly test fall 2022-03-04 22:02:41 +00:00
serkixenos
4efa7e4fb8 Merge branch 'feature/280-remove-fc-reflect-tamplate' into 'develop'
#280 Delete FC_REFLECT_TEMPLATE from votes

See merge request PBSA/peerplays!76
2022-02-28 23:08:12 +00:00
Vlad Dobromyslov
5e81fc0024 #280 Delete FC_REFLECT_TEMPLATE from votes 2022-02-28 23:08:12 +00:00
serkixenos
49c39afbe1 Merge branch 'bug/235-corrupt-chain-file' into 'develop'
#235 Delete small objects for game_object, tournament_object, match_object,...

See merge request PBSA/peerplays!75
2022-02-28 22:56:20 +00:00
serkixenos
8dc8ac0aec #235 Delete small objects for game_object, tournament_object, match_object,... 2022-02-28 22:56:20 +00:00
serkixenos
7d25589499 Merge branch 'bug/289/deprecation_messages_for_auto_unit_test.hpp' into 'develop'
Resolving boost deprecation include

See merge request PBSA/peerplays!74
2022-02-25 18:41:31 +00:00
hirunda
5602790db9 Resolving boost deprecation include 2022-02-24 22:16:10 +01:00
serkixenos
d46c7201bb Fix Boost component list for v1.71 2022-02-22 20:21:54 +00:00
serkixenos
5b8f14dd68 Update README.md 2022-02-21 20:52:32 +00:00
serkixenos
8b732acf17 Update Boost libraries 2022-02-21 15:29:38 -04:00
serkixenos
2981613a9e Merge branch 'bug/282-abort-when-no-argument' into 'develop'
#282 abort when no argument

See merge request PBSA/peerplays!72
2022-02-21 13:57:39 +00:00
Vlad Dobromyslov
93b57f294d #282 abort when no argument 2022-02-21 13:57:38 +00:00
serkixenos
5860002d0a Code formatting 2022-02-16 18:01:29 -04:00
serkixenos
6e2fb6fac5 Merge branch 'Updating-Gitlab-CI-and-ReadMe' into 'develop'
Updating gitlab ci and read me

See merge request PBSA/peerplays!70
2022-02-16 18:28:25 +00:00
Rily Dunlap
f7b3c8935d Updating gitlab ci and read me 2022-02-16 18:28:25 +00:00
serkixenos
65cc4a4df2 Merge branch 'bug/issue111' into 'develop'
zmq::recv_multipart

See merge request PBSA/peerplays!65
2022-02-16 18:25:25 +00:00
Pavel Baykov
6960ccbde9 zmq::recv_multipart 2022-02-16 18:25:25 +00:00
serkixenos
04eb8c33e0 Merge branch 'bug_54_handling_errors_in_cli_wallet' into 'develop'
Handling some of the errors on wrong user inputs

See merge request PBSA/peerplays!69
2022-02-16 18:22:17 +00:00
Davor Hirunda
6d8a158372 Handling some of the errors on wrong user inputs 2022-02-16 18:22:17 +00:00
serkixenos
639e242693 Unknown cli parameters handling in cli_wallet 2022-02-16 13:29:47 -04:00
serkixenos
8be4dd5e3c Code formatting 2022-02-15 10:48:52 -04:00
serkixenos
050c0b27e5 Add short version parameter to cli_wallet 2022-02-15 10:48:32 -04:00
Bobinson K B
9fd18b32c4 Merge branch 'beatrice' into 'master'
Hotfix: Revert change to a son_update_operation

See merge request PBSA/peerplays!50
2021-12-17 13:33:23 +00:00
serkixenos
632eb4a231 Hotfix: Revert change to a son_update_operation 2021-12-17 13:33:23 +00:00
460 changed files with 17369 additions and 12588 deletions

View file

@ -1,6 +1,5 @@
--- ---
Language: Cpp Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -3 AccessModifierOffset: -3
AlignAfterOpenBracket: Align AlignAfterOpenBracket: Align
AlignConsecutiveMacros: false AlignConsecutiveMacros: false
@ -12,7 +11,7 @@ AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: false AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None AllowShortFunctionsOnASingleLine: None
AllowShortLambdasOnASingleLine: None AllowShortLambdasOnASingleLine: None
@ -57,6 +56,7 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 6 ConstructorInitializerIndentWidth: 6
ContinuationIndentWidth: 6 ContinuationIndentWidth: 6
Cpp11BracedListStyle: true Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false DerivePointerAlignment: false
DisableFormat: false DisableFormat: false
ExperimentalAutoDetectBinPacking: false ExperimentalAutoDetectBinPacking: false
@ -69,12 +69,17 @@ IncludeBlocks: Preserve
IncludeCategories: IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2 Priority: 2
SortPriority: 0
- Regex: '^(<|"(gtest|gmock|isl|json)/)' - Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3 Priority: 3
SortPriority: 0
- Regex: '.*' - Regex: '.*'
Priority: 1 Priority: 1
SortPriority: 0
IncludeIsMainRegex: '(Test)?$' IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: false IndentCaseLabels: false
IndentGotoLabels: false
IndentPPDirectives: None IndentPPDirectives: None
IndentWidth: 3 IndentWidth: 3
IndentWrappedFunctionNames: false IndentWrappedFunctionNames: false
@ -110,18 +115,22 @@ SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1 SpacesBeforeTrailingComments: 1
SpacesInAngles: false SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false SpacesInCStyleCastParentheses: false
SpacesInParentheses: false SpacesInParentheses: false
SpacesInSquareBrackets: false SpacesInSquareBrackets: false
Standard: Cpp11 SpaceBeforeSquareBrackets: false
Standard: Latest
StatementMacros: StatementMacros:
- Q_UNUSED - Q_UNUSED
- QT_REQUIRE_VERSION - QT_REQUIRE_VERSION
TabWidth: 3 TabWidth: 3
UseCRLF: false
UseTab: Never UseTab: Never
... ...

4
.gitignore vendored
View file

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

View file

@ -8,8 +8,11 @@ include:
stages: stages:
- build - build
- test - test
- dockerize
- python-test
- deploy
build: build-mainnet:
stage: build stage: build
script: script:
- rm -rf .git/modules/docs .git/modules/libraries/fc ./docs ./libraries/fc - rm -rf .git/modules/docs .git/modules/libraries/fc ./docs ./libraries/fc
@ -19,7 +22,7 @@ build:
- mkdir build - mkdir build
- cd build - cd build
- cmake -DCMAKE_BUILD_TYPE=Release .. - cmake -DCMAKE_BUILD_TYPE=Release ..
- make -j4 - make -j$(nproc)
artifacts: artifacts:
untracked: true untracked: true
paths: paths:
@ -29,28 +32,140 @@ build:
tags: tags:
- builder - builder
dockerize: test-mainnet:
stage: build
variables:
IMAGE: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
before_script:
- docker info
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build -t $IMAGE .
- docker push $IMAGE
tags:
- builder
when: manual
timeout: 3h
test:
stage: test stage: test
dependencies: dependencies:
- build - build-mainnet
script: script:
- ./build/libraries/fc/tests/all_tests
- ./build/tests/betting_test --log_level=message - ./build/tests/betting_test --log_level=message
- ./build/tests/chain_test --log_level=message - ./build/tests/chain_test --log_level=message
- ./build/tests/cli_test --log_level=message - ./build/tests/cli_test --log_level=message
tags: tags:
- builder - builder
dockerize-mainnet:
stage: dockerize
variables:
IMAGE: $CI_REGISTRY_IMAGE/mainnet/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
before_script:
- docker info
- docker builder prune -a -f
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --no-cache -t $IMAGE .
- docker push $IMAGE
after_script:
- docker rmi $IMAGE
tags:
- builder
timeout:
3h
build-testnet:
stage: build
script:
- rm -rf .git/modules/docs .git/modules/libraries/fc ./docs ./libraries/fc
- git submodule sync
- git submodule update --init --recursive
- rm -rf build
- mkdir build
- cd build
- cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_PEERPLAYS_TESTNET=1 ..
- make -j$(nproc)
artifacts:
untracked: true
paths:
- build/libraries/
- build/programs/
- build/tests/
when: manual
tags:
- builder
deploy-testnet:
stage: deploy
dependencies:
- build-testnet
script:
- sudo systemctl stop witness
- rm $WORK_DIR/peerplays/witness_node || true
- cp build/programs/witness_node/witness_node $WORK_DIR/peerplays/
- sudo systemctl restart witness
rules:
- if: $CI_COMMIT_BRANCH == "master"
when: always
environment:
name: devnet
url: $DEVNET_URL
tags:
- devnet
test-testnet:
stage: test
dependencies:
- build-testnet
script:
- ./build/libraries/fc/tests/all_tests
- ./build/tests/betting_test --log_level=message
- ./build/tests/chain_test --log_level=message
- ./build/tests/cli_test --log_level=message
tags:
- builder
when:
manual
timeout:
1h
dockerize-testnet:
stage: dockerize
variables:
IMAGE: $CI_REGISTRY_IMAGE/testnet/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
before_script:
- docker info
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --no-cache -t $IMAGE .
- docker push $IMAGE
after_script:
- docker rmi $IMAGE
tags:
- builder
when:
manual
timeout:
3h
test-e2e:
stage: python-test
variables:
IMAGE: $CI_REGISTRY_IMAGE/mainnet/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
before_script:
- docker info
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- git clone https://gitlab.com/PBSA/tools-libs/peerplays-utils.git
- cd peerplays-utils/peerplays-qa-environment
- git checkout origin/feature/python-e2e-tests-for-CI
- cd e2e-tests/
- python3 -m venv venv
- source venv/bin/activate
- pip3 install -r requirements.txt
- docker-compose down --remove-orphans
- docker ps -a
- docker pull $IMAGE
- docker tag $IMAGE peerplays-base:latest
- docker image ls -a
- docker-compose build
- python3 main.py --start all
- docker ps -a
- python3 -m pytest test_btc_init_state.py test_hive_inital_state.py test_pp_inital_state.py
- python3 main.py --stop
- deactivate
- docker ps -a
after_script:
- docker rmi $(docker images -a | grep -v 'hive-for-peerplays\|ethereum-for-peerplays\|bitcoin-for-peerplays\|ubuntu-for-peerplays' | awk '{print $3}')
tags:
- python-tests
when:
manual

2
.gitmodules vendored
View file

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

View file

@ -8,15 +8,6 @@ set( CLI_CLIENT_EXECUTABLE_NAME graphene_client )
set( GUI_CLIENT_EXECUTABLE_NAME Peerplays ) set( GUI_CLIENT_EXECUTABLE_NAME Peerplays )
set( CUSTOM_URL_SCHEME "gcs" ) set( CUSTOM_URL_SCHEME "gcs" )
set( INSTALLER_APP_ID "68ad7005-8eee-49c9-95ce-9eed97e5b347" ) 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 # http://stackoverflow.com/a/18369825
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
@ -31,6 +22,37 @@ endif()
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules" ) list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules" )
function(get_linux_lsb_release_information)
find_program(LSB_RELEASE_EXEC lsb_release)
if(NOT LSB_RELEASE_EXEC)
message(FATAL_ERROR "Could not detect lsb_release executable, can not gather required information")
endif()
execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --id OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --release OUTPUT_VARIABLE LSB_RELEASE_VERSION_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --codename OUTPUT_VARIABLE LSB_RELEASE_CODENAME_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LSB_RELEASE_ID_SHORT "${LSB_RELEASE_ID_SHORT}" PARENT_SCOPE)
set(LSB_RELEASE_VERSION_SHORT "${LSB_RELEASE_VERSION_SHORT}" PARENT_SCOPE)
set(LSB_RELEASE_CODENAME_SHORT "${LSB_RELEASE_CODENAME_SHORT}" PARENT_SCOPE)
endfunction()
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(cppzmq)
target_link_libraries(cppzmq)
get_linux_lsb_release_information()
message(STATUS "Linux ${LSB_RELEASE_ID_SHORT} ${LSB_RELEASE_VERSION_SHORT} ${LSB_RELEASE_CODENAME_SHORT}")
string(REGEX MATCHALL "([0-9]+)" arg_list ${LSB_RELEASE_VERSION_SHORT})
list( LENGTH arg_list listlen )
if (NOT listlen)
message(FATAL_ERROR "Could not detect Ubuntu version")
endif()
list(GET arg_list 0 output)
message("Ubuntu version is: ${output}")
add_definitions(-DPEERPLAYS_UBUNTU_VERSION=${output})
endif()
# function to help with cUrl # function to help with cUrl
macro(FIND_CURL) macro(FIND_CURL)
if (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB) if (NOT WIN32 AND NOT APPLE AND CURL_STATICLIB)
@ -97,12 +119,7 @@ LIST(APPEND BOOST_COMPONENTS thread
unit_test_framework unit_test_framework
context context
locale) 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 ) IF( WIN32 )
SET(BOOST_ROOT $ENV{BOOST_ROOT}) SET(BOOST_ROOT $ENV{BOOST_ROOT})
@ -156,11 +173,11 @@ else( WIN32 ) # Apple AND Linux
if( APPLE ) if( APPLE )
# Apple Specific Options Here # Apple Specific Options Here
message( STATUS "Configuring Peerplays on OS X" ) message( STATUS "Configuring Peerplays on OS X" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -stdlib=libc++ -Wall" ) set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -stdlib=libc++ -Wall" )
else( APPLE ) else( APPLE )
# Linux Specific Options Here # Linux Specific Options Here
message( STATUS "Configuring Peerplays on Linux" ) message( STATUS "Configuring Peerplays on Linux" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall" ) set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall" )
set( rt_library rt ) set( rt_library rt )
#set( pthread_library pthread) #set( pthread_library pthread)
set(CMAKE_LINKER_FLAGS "-pthread" CACHE STRING "Linker Flags" FORCE) set(CMAKE_LINKER_FLAGS "-pthread" CACHE STRING "Linker Flags" FORCE)

View file

@ -1,5 +1,4 @@
FROM ubuntu:20.04 FROM ubuntu:20.04
MAINTAINER PeerPlays Blockchain Standards Association
#=============================================================================== #===============================================================================
# Ubuntu setup # Ubuntu setup
@ -11,35 +10,33 @@ RUN \
apt-utils \ apt-utils \
autoconf \ autoconf \
bash \ bash \
bison \
build-essential \ build-essential \
ca-certificates \ ca-certificates \
cmake \
dnsutils \ dnsutils \
doxygen \
expect \ expect \
flex \
git \ git \
graphviz \ graphviz \
libboost1.67-all-dev \
libbz2-dev \ libbz2-dev \
libcurl4-openssl-dev \ libcurl4-openssl-dev \
libncurses-dev \ libncurses-dev \
libreadline-dev \
libsnappy-dev \ libsnappy-dev \
libssl-dev \ libssl-dev \
libtool \ libtool \
libzip-dev \ libzip-dev \
libzmq3-dev \
locales \ locales \
lsb-release \
mc \ mc \
nano \ nano \
net-tools \ net-tools \
ntp \ ntp \
openssh-server \ openssh-server \
pkg-config \ pkg-config \
perl \
python3 \ python3 \
python3-jinja2 \ python3-jinja2 \
sudo \ sudo \
systemd-coredump \
wget wget
ENV HOME /home/peerplays ENV HOME /home/peerplays
@ -53,12 +50,127 @@ RUN echo 'peerplays:peerplays' | chpasswd
# SSH # SSH
EXPOSE 22 EXPOSE 22
WORKDIR /home/peerplays/src
#===============================================================================
# Boost setup
#===============================================================================
RUN \
wget https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.gz && \
tar -xzf boost_1_72_0.tar.gz && \
cd boost_1_72_0 && \
./bootstrap.sh && \
./b2 install && \
ldconfig && \
rm -rf /home/peerplays/src/*
#===============================================================================
# cmake setup
#===============================================================================
RUN \
wget https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2-linux-x86_64.sh && \
chmod 755 ./cmake-3.24.2-linux-x86_64.sh && \
./cmake-3.24.2-linux-x86_64.sh --prefix=/usr --skip-license && \
cmake --version && \
rm -rf /home/peerplays/src/*
#===============================================================================
# libzmq setup
#===============================================================================
RUN \
wget https://github.com/zeromq/libzmq/archive/refs/tags/v4.3.4.tar.gz && \
tar -xzvf v4.3.4.tar.gz && \
cd libzmq-4.3.4 && \
mkdir build && \
cd build && \
cmake .. && \
make -j$(nproc) && \
make install && \
ldconfig && \
rm -rf /home/peerplays/src/*
#===============================================================================
# cppzmq setup
#===============================================================================
RUN \
wget https://github.com/zeromq/cppzmq/archive/refs/tags/v4.9.0.tar.gz && \
tar -xzvf v4.9.0.tar.gz && \
cd cppzmq-4.9.0 && \
mkdir build && \
cd build && \
cmake .. && \
make -j$(nproc) && \
make install && \
ldconfig && \
rm -rf /home/peerplays/src/*
#===============================================================================
# gsl setup
#===============================================================================
RUN \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
libpcre3-dev
RUN \
wget https://github.com/imatix/gsl/archive/refs/tags/v4.1.4.tar.gz && \
tar -xzvf v4.1.4.tar.gz && \
cd gsl-4.1.4 && \
make -j$(nproc) && \
make install && \
rm -rf /home/peerplays/src/*
#===============================================================================
# libbitcoin-build setup
# libbitcoin-explorer setup
#===============================================================================
RUN \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
libsodium-dev
RUN \
git clone --branch version3.8.0 --depth 1 https://gitlab.com/PBSA/peerplays-1.0/libbitcoin-explorer.git && \
cd libbitcoin-explorer && \
./install.sh && \
ldconfig && \
rm -rf /home/peerplays/src/*
#===============================================================================
# Doxygen setup
#===============================================================================
RUN \
sudo apt install -y bison flex && \
wget https://github.com/doxygen/doxygen/archive/refs/tags/Release_1_8_17.tar.gz && \
tar -xvf Release_1_8_17.tar.gz && \
cd doxygen-Release_1_8_17 && \
mkdir build && \
cd build && \
cmake .. && \
make -j$(nproc) install && \
ldconfig
#===============================================================================
# Perl setup
#===============================================================================
RUN \
wget https://github.com/Perl/perl5/archive/refs/tags/v5.30.0.tar.gz && \
tar -xvf v5.30.0.tar.gz && \
cd perl5-5.30.0 && \
./Configure -des && \
make -j$(nproc) install && \
ldconfig
#=============================================================================== #===============================================================================
# Peerplays setup # Peerplays setup
#=============================================================================== #===============================================================================
WORKDIR /home/peerplays/
## Clone Peerplays ## Clone Peerplays
#RUN \ #RUN \
# git clone https://gitlab.com/PBSA/peerplays.git && \ # git clone https://gitlab.com/PBSA/peerplays.git && \
@ -74,6 +186,8 @@ ADD . peerplays
# Configure Peerplays # Configure Peerplays
RUN \ RUN \
cd peerplays && \ cd peerplays && \
git submodule update --init --recursive && \
git log --oneline -n 5 && \
mkdir build && \ mkdir build && \
cd build && \ cd build && \
cmake -DCMAKE_BUILD_TYPE=Release .. cmake -DCMAKE_BUILD_TYPE=Release ..
@ -87,8 +201,8 @@ WORKDIR /home/peerplays/peerplays-network
# Setup Peerplays runimage # Setup Peerplays runimage
RUN \ RUN \
ln -s /home/peerplays/peerplays/build/programs/cli_wallet/cli_wallet ./ && \ ln -s /home/peerplays/src/peerplays/build/programs/cli_wallet/cli_wallet ./ && \
ln -s /home/peerplays/peerplays/build/programs/witness_node/witness_node ./ ln -s /home/peerplays/src/peerplays/build/programs/witness_node/witness_node ./
RUN ./witness_node --create-genesis-json genesis.json && \ RUN ./witness_node --create-genesis-json genesis.json && \
rm genesis.json rm genesis.json

219
Dockerfile.18.04 Normal file
View file

@ -0,0 +1,219 @@
FROM ubuntu:18.04
#===============================================================================
# Ubuntu setup
#===============================================================================
RUN \
apt-get update -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
apt-utils \
autoconf \
bash \
bison \
build-essential \
ca-certificates \
dnsutils \
expect \
flex \
git \
graphviz \
libbz2-dev \
libcurl4-openssl-dev \
libncurses-dev \
libsnappy-dev \
libssl-dev \
libtool \
libzip-dev \
locales \
lsb-release \
mc \
nano \
net-tools \
ntp \
openssh-server \
pkg-config \
python3 \
python3-jinja2 \
sudo \
systemd-coredump \
wget
ENV HOME /home/peerplays
RUN useradd -rm -d /home/peerplays -s /bin/bash -g root -G sudo -u 1000 peerplays
RUN echo "peerplays ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/peerplays
RUN chmod 440 /etc/sudoers.d/peerplays
RUN service ssh start
RUN echo 'peerplays:peerplays' | chpasswd
# SSH
EXPOSE 22
WORKDIR /home/peerplays/src
#===============================================================================
# Boost setup
#===============================================================================
RUN \
wget https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.gz && \
tar -xzf boost_1_72_0.tar.gz && \
cd boost_1_72_0 && \
./bootstrap.sh && \
./b2 install && \
ldconfig && \
rm -rf /home/peerplays/src/*
#===============================================================================
# cmake setup
#===============================================================================
RUN \
wget https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2-linux-x86_64.sh && \
chmod 755 ./cmake-3.24.2-linux-x86_64.sh && \
./cmake-3.24.2-linux-x86_64.sh --prefix=/usr --skip-license && \
cmake --version && \
rm -rf /home/peerplays/src/*
#===============================================================================
# libzmq setup
#===============================================================================
RUN \
wget https://github.com/zeromq/libzmq/archive/refs/tags/v4.3.4.tar.gz && \
tar -xzvf v4.3.4.tar.gz && \
cd libzmq-4.3.4 && \
mkdir build && \
cd build && \
cmake .. && \
make -j$(nproc) && \
make install && \
ldconfig && \
rm -rf /home/peerplays/src/*
#===============================================================================
# cppzmq setup
#===============================================================================
RUN \
wget https://github.com/zeromq/cppzmq/archive/refs/tags/v4.9.0.tar.gz && \
tar -xzvf v4.9.0.tar.gz && \
cd cppzmq-4.9.0 && \
mkdir build && \
cd build && \
cmake .. && \
make -j$(nproc) && \
make install && \
ldconfig && \
rm -rf /home/peerplays/src/*
#===============================================================================
# gsl setup
#===============================================================================
RUN \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
libpcre3-dev
RUN \
wget https://github.com/imatix/gsl/archive/refs/tags/v4.1.4.tar.gz && \
tar -xzvf v4.1.4.tar.gz && \
cd gsl-4.1.4 && \
make -j$(nproc) && \
make install && \
rm -rf /home/peerplays/src/*
#===============================================================================
# libbitcoin-build setup
# libbitcoin-explorer setup
#===============================================================================
RUN \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
libsodium-dev
RUN \
git clone --branch version3.8.0 --depth 1 https://gitlab.com/PBSA/peerplays-1.0/libbitcoin-explorer.git && \
cd libbitcoin-explorer && \
./install.sh && \
ldconfig && \
rm -rf /home/peerplays/src/*
#===============================================================================
# Doxygen setup
#===============================================================================
RUN \
sudo apt install -y bison flex && \
wget https://github.com/doxygen/doxygen/archive/refs/tags/Release_1_8_17.tar.gz && \
tar -xvf Release_1_8_17.tar.gz && \
cd doxygen-Release_1_8_17 && \
mkdir build && \
cd build && \
cmake .. && \
make -j$(nproc) install && \
ldconfig
#===============================================================================
# Perl setup
#===============================================================================
RUN \
wget https://github.com/Perl/perl5/archive/refs/tags/v5.30.0.tar.gz && \
tar -xvf v5.30.0.tar.gz && \
cd perl5-5.30.0 && \
./Configure -des && \
make -j$(nproc) install && \
ldconfig
#===============================================================================
# Peerplays setup
#===============================================================================
## Clone Peerplays
#RUN \
# git clone https://gitlab.com/PBSA/peerplays.git && \
# cd peerplays && \
# git checkout develop && \
# git submodule update --init --recursive && \
# git branch --show-current && \
# git log --oneline -n 5
# Add local source
ADD . peerplays
# Configure Peerplays
RUN \
cd peerplays && \
git submodule update --init --recursive && \
git symbolic-ref --short HEAD && \
git log --oneline -n 5 && \
mkdir build && \
cd build && \
cmake -DCMAKE_BUILD_TYPE=Release ..
# Build Peerplays
RUN \
cd peerplays/build && \
make -j$(nproc) cli_wallet witness_node
WORKDIR /home/peerplays/peerplays-network
# Setup Peerplays runimage
RUN \
ln -s /home/peerplays/src/peerplays/build/programs/cli_wallet/cli_wallet ./ && \
ln -s /home/peerplays/src/peerplays/build/programs/witness_node/witness_node ./
RUN ./witness_node --create-genesis-json genesis.json && \
rm genesis.json
RUN chown peerplays:root -R /home/peerplays/peerplays-network
# Peerplays RPC
EXPOSE 8090
# Peerplays P2P:
EXPOSE 9777
# Peerplays
CMD ["./witness_node", "-d", "./witness_node_data_dir"]

149
README.md
View file

@ -6,37 +6,129 @@ This is a quick introduction to get new developers and witnesses up to speed on
# Building and Installation Instructions # Building and Installation Instructions
Officially supported OS is Ubuntu 20.04. Officially supported OS are Ubuntu 20.04 and Ubuntu 18.04.
Following dependencies are needed for a clean install of Ubuntu 20.04: ## Ubuntu 20.04 and 18.04
Following dependencies are needed for a clean install of Ubuntu 20.04 and Ubuntu 18.04:
``` ```
sudo apt-get install \ sudo apt-get install \
apt-utils autoconf bash build-essential ca-certificates cmake dnsutils \ autoconf bash bison build-essential ca-certificates dnsutils expect flex git \
doxygen expect git graphviz libboost1.67-all-dev libbz2-dev libcurl4-openssl-dev \ graphviz libbz2-dev libcurl4-openssl-dev libncurses-dev libpcre3-dev \
libncurses-dev libreadline-dev libsnappy-dev libssl-dev libtool libzip-dev \ libsnappy-dev libsodium-dev libssl-dev libtool libzip-dev locales lsb-release \
libzmq3-dev locales mc nano net-tools ntp openssh-server pkg-config perl \ mc nano net-tools ntp openssh-server pkg-config python3 python3-jinja2 sudo \
python3 python3-jinja2 sudo wget systemd-coredump wget
``` ```
Boost libraries setup:
## Building Peerplays ```
wget https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.gz
tar -xzf boost_1_72_0.tar.gz boost_1_72_0
cd boost_1_72_0
./bootstrap.sh
./b2
sudo ./b2 install
sudo ldconfig
```
cmake setup:
```
wget https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2-linux-x86_64.sh
chmod 755 ./cmake-3.24.2-linux-x86_64.sh
sudo ./cmake-3.24.2-linux-x86_64.sh --prefix=/usr --skip-license
cmake --version
```
libzmq setup:
```
wget https://github.com/zeromq/libzmq/archive/refs/tags/v4.3.4.tar.gz
tar -xzvf v4.3.4.tar.gz
cd libzmq-4.3.4
mkdir build
cd build
cmake ..
make -j$(nproc)
sudo make install
sudo ldconfig
```
cppzmq setup:
```
wget https://github.com/zeromq/cppzmq/archive/refs/tags/v4.9.0.tar.gz
tar -xzvf v4.9.0.tar.gz
cd cppzmq-4.9.0
mkdir build
cd build
cmake ..
make -j$(nproc)
sudo make install
sudo ldconfig
```
gsl setup:
```
wget https://github.com/imatix/gsl/archive/refs/tags/v4.1.4.tar.gz
tar -xzvf v4.1.4.tar.gz
cd gsl-4.1.4
make -j$(nproc)
sudo make install
sudo ldconfig
```
libbitcoin-explorer setup:
```
git clone --branch version3.8.0 --depth 1 https://gitlab.com/PBSA/peerplays-1.0/libbitcoin-explorer.git
cd libbitcoin-explorer
sudo ./install.sh
sudo ldconfig
```
Doxygen setup:
```
wget https://github.com/doxygen/doxygen/archive/refs/tags/Release_1_8_17.tar.gz
tar -xvf Release_1_8_17.tar.gz
cd doxygen-Release_1_8_17
mkdir build
cd build
cmake ..
make -j$(nproc)
sudo make install
sudo ldconfig
```
Perl setup:
```
wget https://github.com/Perl/perl5/archive/refs/tags/v5.30.0.tar.gz
tar -xvf v5.30.0.tar.gz
cd perl5-5.30.0
./Configure -des
make -j$(nproc)
sudo make install
sudo ldconfig
```
Building Peerplays
``` ```
mkdir $HOME/src
cd $HOME/src
git clone https://gitlab.com/PBSA/peerplays.git git clone https://gitlab.com/PBSA/peerplays.git
cd peerplays cd peerplays
git submodule update --init --recursive git submodule update --init --recursive
# If you want to build Mainnet node # If you want to build Mainnet node
cmake -DCMAKE_BUILD_TYPE=Release cmake -DCMAKE_BUILD_TYPE=Release
# If you want to build Testnet node # If you want to build Testnet node
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_PEERPLAYS_TESTNET=1 cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_PEERPLAYS_TESTNET=1
# Update -j flag depending on your current system specs;
# Recommended 4GB of RAM per 1 CPU core
# make -j2 for 8GB RAM
# make -j4 for 16GB RAM
# make -j8 for 32GB RAM
make -j$(nproc) make -j$(nproc)
make install # this can install the executable files under /usr/local sudo make install # this can install the executable files under /usr/local
``` ```
## Docker images ## Docker images
Install docker, and add current user to docker group. Install docker, and add current user to docker group.
@ -54,15 +146,36 @@ sudo usermod -a -G docker $USER
docker pull datasecuritynode/peerplays:latest docker pull datasecuritynode/peerplays:latest
``` ```
### Building docker image manually ### Building docker images manually
``` ```
# Build docker image (from the project root, must be a docker group member) # Checkout the code
docker build -t peerplays . git clone https://gitlab.com/PBSA/peerplays.git
cd peerplays
# Checkout the branch you want
# E.g.
# git checkout beatrice
# git checkout develop
git checkout master
git submodule update --init --recursive
# Execute from the project root, must be a docker group member
# Build docker image, using Ubuntu 20.04 base
docker build --no-cache -f Dockerfile -t peerplays .
# Build docker image, using Ubuntu 18.04 base
docker build --no-cache -f Dockerfile.18.04 -t peerplays-18-04 .
``` ```
### Start docker image ### Start docker image
``` ```
docker start peerplays # Start docker image, using Ubuntu 20.04 base
docker run peerplays:latest
# Start docker image, using Ubuntu 18.04 base
docker run peerplays-18-04:latest
``` ```
Rest of the instructions on starting the chain remains same. Rest of the instructions on starting the chain remains same.

View file

@ -3,3 +3,4 @@
find ./libraries/app -regex ".*[c|h]pp" | xargs clang-format -i find ./libraries/app -regex ".*[c|h]pp" | xargs clang-format -i
find ./libraries/chain/hardfork.d -regex ".*hf" | xargs clang-format -i find ./libraries/chain/hardfork.d -regex ".*hf" | xargs clang-format -i
find ./libraries/plugins/peerplays_sidechain -regex ".*[c|h]pp" | xargs clang-format -i find ./libraries/plugins/peerplays_sidechain -regex ".*[c|h]pp" | xargs clang-format -i
find ./programs/cli_wallet -regex ".*[c|h]pp" | xargs clang-format -i

View file

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

View file

@ -12,11 +12,10 @@ add_library( graphene_app
) )
# need to link graphene_debug_witness because plugins aren't sufficiently isolated #246 # 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 target_link_libraries( graphene_app
PUBLIC graphene_chain graphene_net graphene_utilities PUBLIC 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 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 target_include_directories( graphene_app
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
@ -44,7 +43,7 @@ add_library( graphene_plugin
) )
target_link_libraries( graphene_plugin target_link_libraries( graphene_plugin
PUBLIC graphene_chain graphene_net graphene_utilities ) PUBLIC graphene_net graphene_utilities )
target_include_directories( graphene_plugin target_include_directories( graphene_plugin
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )

View file

@ -29,16 +29,14 @@
#include <graphene/chain/confidential_object.hpp> #include <graphene/chain/confidential_object.hpp>
#include <graphene/chain/database.hpp> #include <graphene/chain/database.hpp>
#include <graphene/chain/get_config.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/market_object.hpp>
#include <graphene/chain/transaction_history_object.hpp> #include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/chain/tournament_object.hpp>
#include <graphene/chain/transaction_object.hpp>
#include <graphene/chain/withdraw_permission_object.hpp> #include <graphene/chain/withdraw_permission_object.hpp>
#include <graphene/chain/worker_object.hpp> #include <graphene/chain/worker_object.hpp>
#include <graphene/utilities/key_conversion.hpp> #include <graphene/utilities/key_conversion.hpp>
#include <fc/crypto/base64.hpp>
#include <fc/crypto/hex.hpp> #include <fc/crypto/hex.hpp>
#include <fc/rpc/api_connection.hpp> #include <fc/rpc/api_connection.hpp>
#include <fc/thread/future.hpp> #include <fc/thread/future.hpp>
@ -47,7 +45,6 @@ template class fc::api<graphene::app::block_api>;
template class fc::api<graphene::app::network_broadcast_api>; template class fc::api<graphene::app::network_broadcast_api>;
template class fc::api<graphene::app::network_node_api>; template class fc::api<graphene::app::network_node_api>;
template class fc::api<graphene::app::history_api>; template class fc::api<graphene::app::history_api>;
template class fc::api<graphene::app::crypto_api>;
template class fc::api<graphene::app::asset_api>; template class fc::api<graphene::app::asset_api>;
template class fc::api<graphene::debug_witness::debug_api>; template class fc::api<graphene::debug_witness::debug_api>;
template class fc::api<graphene::app::login_api>; template class fc::api<graphene::app::login_api>;
@ -92,8 +89,6 @@ void login_api::enable_api(const std::string &api_name) {
_history_api = std::make_shared<history_api>(_app); _history_api = std::make_shared<history_api>(_app);
} else if (api_name == "network_node_api") { } else if (api_name == "network_node_api") {
_network_node_api = std::make_shared<network_node_api>(std::ref(_app)); _network_node_api = std::make_shared<network_node_api>(std::ref(_app));
} else if (api_name == "crypto_api") {
_crypto_api = std::make_shared<crypto_api>();
} else if (api_name == "asset_api") { } else if (api_name == "asset_api") {
_asset_api = std::make_shared<asset_api>(_app); _asset_api = std::make_shared<asset_api>(_app);
} else if (api_name == "debug_api") { } else if (api_name == "debug_api") {
@ -108,6 +103,10 @@ void login_api::enable_api(const std::string &api_name) {
// can only enable this API if the plugin was loaded // can only enable this API if the plugin was loaded
if (_app.get_plugin("affiliate_stats")) if (_app.get_plugin("affiliate_stats"))
_affiliate_stats_api = std::make_shared<graphene::affiliate_stats::affiliate_stats_api>(std::ref(_app)); _affiliate_stats_api = std::make_shared<graphene::affiliate_stats::affiliate_stats_api>(std::ref(_app));
} else if (api_name == "sidechain_api") {
// can only enable this API if the plugin was loaded
if (_app.get_plugin("peerplays_sidechain"))
_sidechain_api = std::make_shared<graphene::peerplays_sidechain::sidechain_api>(std::ref(_app));
} }
return; return;
} }
@ -146,7 +145,7 @@ void network_broadcast_api::on_applied_block(const signed_block &b) {
if (itr != _callbacks.end()) { if (itr != _callbacks.end()) {
auto block_num = b.block_num(); auto block_num = b.block_num();
auto &callback = _callbacks.find(id)->second; auto &callback = _callbacks.find(id)->second;
fc::async([capture_this, id, block_num, trx_num, trx, callback]() { fc::async([capture_this, this, id, block_num, trx_num, trx, callback]() {
callback(fc::variant(transaction_confirmation{id, block_num, trx_num, trx}, callback(fc::variant(transaction_confirmation{id, block_num, trx_num, trx},
GRAPHENE_MAX_NESTED_OBJECTS)); GRAPHENE_MAX_NESTED_OBJECTS));
}); });
@ -166,7 +165,7 @@ void network_broadcast_api::broadcast_transaction(const signed_transaction &trx)
fc::variant network_broadcast_api::broadcast_transaction_synchronous(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); _app.chain_database()->check_transaction_for_duplicated_operations(trx);
fc::promise<fc::variant>::ptr prom(fc::promise<fc::variant>::create()); fc::promise<fc::variant>::ptr prom(new fc::promise<fc::variant>());
broadcast_transaction_with_callback([=](const fc::variant &v) { broadcast_transaction_with_callback([=](const fc::variant &v) {
prom->set_value(v); prom->set_value(v);
}, },
@ -211,8 +210,8 @@ network_node_api::network_node_api(application &a) :
} }
/* /*
* Remove expired transactions from pending_transactions * Remove expired transactions from pending_transactions
*/ */
for (const auto &transaction : _pending_transactions) { for (const auto &transaction : _pending_transactions) {
if (transaction.second.expiration < block.timestamp) { if (transaction.second.expiration < block.timestamp) {
auto transaction_it = _pending_transactions.find(transaction.second.id()); auto transaction_it = _pending_transactions.find(transaction.second.id());
@ -287,11 +286,6 @@ fc::api<history_api> login_api::history() const {
return *_history_api; return *_history_api;
} }
fc::api<crypto_api> login_api::crypto() const {
FC_ASSERT(_crypto_api);
return *_crypto_api;
}
fc::api<asset_api> login_api::asset() const { fc::api<asset_api> login_api::asset() const {
FC_ASSERT(_asset_api); FC_ASSERT(_asset_api);
return *_asset_api; return *_asset_api;
@ -312,6 +306,11 @@ fc::api<graphene::affiliate_stats::affiliate_stats_api> login_api::affiliate_sta
return *_affiliate_stats_api; return *_affiliate_stats_api;
} }
fc::api<graphene::peerplays_sidechain::sidechain_api> login_api::sidechain() const {
FC_ASSERT(_sidechain_api);
return *_sidechain_api;
}
vector<order_history_object> history_api::get_fill_order_history(std::string asset_a, std::string asset_b, uint32_t limit) const { vector<order_history_object> history_api::get_fill_order_history(std::string asset_a, std::string asset_b, uint32_t limit) const {
FC_ASSERT(_app.chain_database()); FC_ASSERT(_app.chain_database());
const auto &db = *_app.chain_database(); const auto &db = *_app.chain_database();
@ -515,55 +514,6 @@ vector<bucket_object> history_api::get_market_history(std::string asset_a, std::
FC_CAPTURE_AND_RETHROW((asset_a)(asset_b)(bucket_seconds)(start)(end)) FC_CAPTURE_AND_RETHROW((asset_a)(asset_b)(bucket_seconds)(start)(end))
} }
crypto_api::crypto_api(){};
commitment_type crypto_api::blind(const blind_factor_type &blind, uint64_t value) {
return fc::ecc::blind(blind, value);
}
blind_factor_type crypto_api::blind_sum(const std::vector<blind_factor_type> &blinds_in, uint32_t non_neg) {
return fc::ecc::blind_sum(blinds_in, non_neg);
}
bool crypto_api::verify_sum(const std::vector<commitment_type> &commits_in, const std::vector<commitment_type> &neg_commits_in, int64_t excess) {
return fc::ecc::verify_sum(commits_in, neg_commits_in, excess);
}
verify_range_result crypto_api::verify_range(const commitment_type &commit, const std::vector<char> &proof) {
verify_range_result result;
result.success = fc::ecc::verify_range(result.min_val, result.max_val, commit, proof);
return result;
}
std::vector<char> crypto_api::range_proof_sign(uint64_t min_value,
const commitment_type &commit,
const blind_factor_type &commit_blind,
const blind_factor_type &nonce,
int8_t base10_exp,
uint8_t min_bits,
uint64_t actual_value) {
return fc::ecc::range_proof_sign(min_value, commit, commit_blind, nonce, base10_exp, min_bits, actual_value);
}
verify_range_proof_rewind_result crypto_api::verify_range_proof_rewind(const blind_factor_type &nonce,
const commitment_type &commit,
const std::vector<char> &proof) {
verify_range_proof_rewind_result result;
result.success = fc::ecc::verify_range_proof_rewind(result.blind_out,
result.value_out,
result.message_out,
nonce,
result.min_val,
result.max_val,
const_cast<commitment_type &>(commit),
proof);
return result;
}
range_proof_info crypto_api::range_get_info(const std::vector<char> &proof) {
return fc::ecc::range_get_info(proof);
}
// asset_api // asset_api
asset_api::asset_api(graphene::app::application &app) : asset_api::asset_api(graphene::app::application &app) :
_app(app), _app(app),

View file

@ -26,10 +26,8 @@
#include <graphene/app/application.hpp> #include <graphene/app/application.hpp>
#include <graphene/app/plugin.hpp> #include <graphene/app/plugin.hpp>
#include <graphene/chain/db_with.hpp> #include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/chain/genesis_state.hpp> #include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <graphene/protocol/types.hpp>
#include <graphene/egenesis/egenesis.hpp> #include <graphene/egenesis/egenesis.hpp>
@ -50,6 +48,7 @@
#include <boost/range/algorithm/reverse.hpp> #include <boost/range/algorithm/reverse.hpp>
#include <boost/signals2.hpp> #include <boost/signals2.hpp>
#include <atomic>
#include <iostream> #include <iostream>
#include <fc/log/file_appender.hpp> #include <fc/log/file_appender.hpp>
@ -109,6 +108,7 @@ public:
fc::optional<fc::temp_file> _lock_file; fc::optional<fc::temp_file> _lock_file;
bool _is_block_producer = false; bool _is_block_producer = false;
bool _force_validate = false; bool _force_validate = false;
std::atomic_bool _running{true};
void reset_p2p_node(const fc::path &data_dir) { void reset_p2p_node(const fc::path &data_dir) {
try { try {
@ -117,67 +117,29 @@ public:
_p2p_network->load_configuration(data_dir / "p2p"); _p2p_network->load_configuration(data_dir / "p2p");
_p2p_network->set_node_delegate(this); _p2p_network->set_node_delegate(this);
vector<string> all_seeds;
if (_options->count("seed-node")) { if (_options->count("seed-node")) {
auto seeds = _options->at("seed-node").as<vector<string>>(); auto seeds = _options->at("seed-node").as<vector<string>>();
for (const string &endpoint_string : seeds) { all_seeds.insert(all_seeds.end(), seeds.begin(), seeds.end());
try {
std::vector<fc::ip::endpoint> endpoints = resolve_string_to_ip_endpoints(endpoint_string);
for (const fc::ip::endpoint &endpoint : endpoints) {
ilog("Adding seed node ${endpoint}", ("endpoint", endpoint));
_p2p_network->add_node(endpoint);
_p2p_network->connect_to_endpoint(endpoint);
}
} catch (const fc::exception &e) {
wlog("caught exception ${e} while adding seed node ${endpoint}",
("e", e.to_detail_string())("endpoint", endpoint_string));
}
}
} }
if (_options->count("seed-nodes")) { if (_options->count("seed-nodes")) {
auto seeds_str = _options->at("seed-nodes").as<string>(); auto seeds_str = _options->at("seed-nodes").as<string>();
auto seeds = fc::json::from_string(seeds_str).as<vector<string>>(2); auto seeds = fc::json::from_string(seeds_str).as<vector<string>>(2);
for (const string &endpoint_string : seeds) { all_seeds.insert(all_seeds.end(), seeds.begin(), seeds.end());
try { }
std::vector<fc::ip::endpoint> endpoints = resolve_string_to_ip_endpoints(endpoint_string);
for (const fc::ip::endpoint &endpoint : endpoints) {
ilog("Adding seed node ${endpoint}", ("endpoint", endpoint));
_p2p_network->add_node(endpoint);
}
} catch (const fc::exception &e) {
wlog("caught exception ${e} while adding seed node ${endpoint}",
("e", e.to_detail_string())("endpoint", endpoint_string));
}
}
} else {
// t.me/peerplays #seednodes
vector<string> seeds = {
#ifdef BUILD_PEERPLAYS_TESTNET
#else for (const string &endpoint_string : all_seeds) {
"51.222.110.110:9777", try {
"95.216.90.243:9777", std::vector<fc::ip::endpoint> endpoints = resolve_string_to_ip_endpoints(endpoint_string);
"96.46.48.98:19777", for (const fc::ip::endpoint &endpoint : endpoints) {
"96.46.48.98:29777", ilog("Adding seed node ${endpoint}", ("endpoint", endpoint));
"96.46.48.98:39777", _p2p_network->add_node(endpoint);
"96.46.48.98:49777",
"96.46.48.98:59777",
"seed.i9networks.net.br:9777",
"witness.serverpit.com:9777"
#endif
};
for (const string &endpoint_string : seeds) {
try {
std::vector<fc::ip::endpoint> endpoints = resolve_string_to_ip_endpoints(endpoint_string);
for (const fc::ip::endpoint &endpoint : endpoints) {
ilog("Adding seed node ${endpoint}", ("endpoint", endpoint));
_p2p_network->add_node(endpoint);
}
} catch (const fc::exception &e) {
wlog("caught exception ${e} while adding seed node ${endpoint}",
("e", e.to_detail_string())("endpoint", endpoint_string));
} }
} catch (const fc::exception &e) {
wlog("caught exception ${e} while adding seed node ${endpoint}",
("e", e.to_detail_string())("endpoint", endpoint_string));
} }
} }
@ -291,10 +253,6 @@ public:
_self(self), _self(self),
_chain_db(std::make_shared<chain::database>()) { _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() { ~application_impl() {
} }
@ -312,10 +270,10 @@ public:
auto initial_state = [this] { auto initial_state = [this] {
ilog("Initializing database..."); ilog("Initializing database...");
if( _options->count("genesis-json") ) if (_options->count("genesis-json")) {
{ std::string genesis_str;
genesis_state_type genesis = fc::json::from_file( _options->at("genesis-json").as<boost::filesystem::path>()).as<genesis_state_type>( 20 ); fc::read_file_contents(_options->at("genesis-json").as<boost::filesystem::path>(), genesis_str);
std::string genesis_str = fc::json::to_string(genesis) + "\n"; genesis_state_type genesis = fc::json::from_string(genesis_str).as<genesis_state_type>(20);
bool modified_genesis = false; bool modified_genesis = false;
if (_options->count("genesis-timestamp")) { 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>(); genesis.initial_timestamp = fc::time_point_sec(fc::time_point::now()) + genesis.initial_parameters.block_interval + _options->at("genesis-timestamp").as<uint32_t>();
@ -365,7 +323,7 @@ public:
if (_options->count("enable-standby-votes-tracking")) { if (_options->count("enable-standby-votes-tracking")) {
_chain_db->enable_standby_votes_tracking(_options->at("enable-standby-votes-tracking").as<bool>()); _chain_db->enable_standby_votes_tracking(_options->at("enable-standby-votes-tracking").as<bool>());
} }
std::string replay_reason = "reason not provided"; std::string replay_reason = "reason not provided";
if (_options->count("replay-blockchain")) if (_options->count("replay-blockchain"))
@ -404,9 +362,9 @@ public:
wild_access.allowed_apis.push_back("database_api"); wild_access.allowed_apis.push_back("database_api");
wild_access.allowed_apis.push_back("network_broadcast_api"); wild_access.allowed_apis.push_back("network_broadcast_api");
wild_access.allowed_apis.push_back("history_api"); wild_access.allowed_apis.push_back("history_api");
wild_access.allowed_apis.push_back("crypto_api");
wild_access.allowed_apis.push_back("bookie_api"); wild_access.allowed_apis.push_back("bookie_api");
wild_access.allowed_apis.push_back("affiliate_stats_api"); wild_access.allowed_apis.push_back("affiliate_stats_api");
wild_access.allowed_apis.push_back("sidechain_api");
_apiaccess.permission_map["*"] = wild_access; _apiaccess.permission_map["*"] = wild_access;
} }
@ -433,8 +391,8 @@ public:
} }
/** /**
* If delegate has the item, the network has no need to fetch it. * If delegate has the item, the network has no need to fetch it.
*/ */
virtual bool has_item(const net::item_id &id) override { virtual bool has_item(const net::item_id &id) override {
try { try {
if (id.item_type == graphene::net::block_message_type) if (id.item_type == graphene::net::block_message_type)
@ -446,15 +404,21 @@ public:
} }
/** /**
* @brief allows the application to validate an item prior to broadcasting to peers. * @brief allows the application to validate an item prior to broadcasting to peers.
* *
* @param sync_mode true if the message was fetched through the sync process, false during normal operation * @param sync_mode true if the message was fetched through the sync process, false during normal operation
* @returns true if this message caused the blockchain to switch forks, false if it did not * @returns true if this message caused the blockchain to switch forks, false if it did not
* *
* @throws exception if error validating the item, otherwise the item is safe to broadcast on. * @throws exception if error validating the item, otherwise the item is safe to broadcast on.
*/ */
virtual bool handle_block(const graphene::net::block_message &blk_msg, bool sync_mode, virtual bool handle_block(const graphene::net::block_message &blk_msg, bool sync_mode,
std::vector<fc::uint160_t> &contained_transaction_message_ids) override { std::vector<fc::uint160_t> &contained_transaction_message_ids) override {
// check point for the threads which may be cancled on application shutdown
if (!_running.load()) {
return true;
}
try { try {
auto latency = fc::time_point::now() - blk_msg.block.timestamp; auto latency = fc::time_point::now() - blk_msg.block.timestamp;
FC_ASSERT((latency.count() / 1000) > -5000, "Rejecting block with timestamp in the future"); FC_ASSERT((latency.count() / 1000) > -5000, "Rejecting block with timestamp in the future");
@ -534,14 +498,14 @@ public:
} }
/** /**
* Assuming all data elements are ordered in some way, this method should * Assuming all data elements are ordered in some way, this method should
* return up to limit ids that occur *after* the last ID in synopsis that * return up to limit ids that occur *after* the last ID in synopsis that
* we recognize. * we recognize.
* *
* On return, remaining_item_count will be set to the number of items * On return, remaining_item_count will be set to the number of items
* in our blockchain after the last item returned in the result, * in our blockchain after the last item returned in the result,
* or 0 if the result contains the last item in the blockchain * or 0 if the result contains the last item in the blockchain
*/ */
virtual std::vector<item_hash_t> get_block_ids(const std::vector<item_hash_t> &blockchain_synopsis, virtual std::vector<item_hash_t> get_block_ids(const std::vector<item_hash_t> &blockchain_synopsis,
uint32_t &remaining_item_count, uint32_t &remaining_item_count,
uint32_t limit) override { uint32_t limit) override {
@ -588,8 +552,8 @@ public:
} }
/** /**
* Given the hash of the requested data, fetch the body. * Given the hash of the requested data, fetch the body.
*/ */
virtual message get_item(const item_id &id) override { virtual message get_item(const item_id &id) override {
try { try {
// ilog("Request for item ${id}", ("id", id)); // ilog("Request for item ${id}", ("id", id));
@ -612,63 +576,63 @@ public:
} }
/** /**
* Returns a synopsis of the blockchain used for syncing. This consists of a list of * Returns a synopsis of the blockchain used for syncing. This consists of a list of
* block hashes at intervals exponentially increasing towards the genesis block. * block hashes at intervals exponentially increasing towards the genesis block.
* When syncing to a peer, the peer uses this data to determine if we're on the same * When syncing to a peer, the peer uses this data to determine if we're on the same
* fork as they are, and if not, what blocks they need to send us to get us on their * fork as they are, and if not, what blocks they need to send us to get us on their
* fork. * fork.
* *
* In the over-simplified case, this is a straighforward synopsis of our current * In the over-simplified case, this is a straighforward synopsis of our current
* preferred blockchain; when we first connect up to a peer, this is what we will be sending. * preferred blockchain; when we first connect up to a peer, this is what we will be sending.
* It looks like this: * It looks like this:
* If the blockchain is empty, it will return the empty list. * If the blockchain is empty, it will return the empty list.
* If the blockchain has one block, it will return a list containing just that block. * If the blockchain has one block, it will return a list containing just that block.
* If it contains more than one block: * If it contains more than one block:
* the first element in the list will be the hash of the highest numbered block that * the first element in the list will be the hash of the highest numbered block that
* we cannot undo * we cannot undo
* the second element will be the hash of an item at the half way point in the undoable * the second element will be the hash of an item at the half way point in the undoable
* segment of the blockchain * segment of the blockchain
* the third will be ~3/4 of the way through the undoable segment of the block chain * the third will be ~3/4 of the way through the undoable segment of the block chain
* the fourth will be at ~7/8... * the fourth will be at ~7/8...
* &c. * &c.
* the last item in the list will be the hash of the most recent block on our preferred chain * the last item in the list will be the hash of the most recent block on our preferred chain
* so if the blockchain had 26 blocks labeled a - z, the synopsis would be: * so if the blockchain had 26 blocks labeled a - z, the synopsis would be:
* a n u x z * a n u x z
* the idea being that by sending a small (<30) number of block ids, we can summarize a huge * the idea being that by sending a small (<30) number of block ids, we can summarize a huge
* blockchain. The block ids are more dense near the end of the chain where because we are * blockchain. The block ids are more dense near the end of the chain where because we are
* more likely to be almost in sync when we first connect, and forks are likely to be short. * more likely to be almost in sync when we first connect, and forks are likely to be short.
* If the peer we're syncing with in our example is on a fork that started at block 'v', * If the peer we're syncing with in our example is on a fork that started at block 'v',
* then they will reply to our synopsis with a list of all blocks starting from block 'u', * then they will reply to our synopsis with a list of all blocks starting from block 'u',
* the last block they know that we had in common. * the last block they know that we had in common.
* *
* In the real code, there are several complications. * In the real code, there are several complications.
* *
* First, as an optimization, we don't usually send a synopsis of the entire blockchain, we * First, as an optimization, we don't usually send a synopsis of the entire blockchain, we
* send a synopsis of only the segment of the blockchain that we have undo data for. If their * send a synopsis of only the segment of the blockchain that we have undo data for. If their
* fork doesn't build off of something in our undo history, we would be unable to switch, so there's * fork doesn't build off of something in our undo history, we would be unable to switch, so there's
* no reason to fetch the blocks. * no reason to fetch the blocks.
* *
* Second, when a peer replies to our initial synopsis and gives us a list of the blocks they think * Second, when a peer replies to our initial synopsis and gives us a list of the blocks they think
* we are missing, they only send a chunk of a few thousand blocks at once. After we get those * we are missing, they only send a chunk of a few thousand blocks at once. After we get those
* block ids, we need to request more blocks by sending another synopsis (we can't just say "send me * block ids, we need to request more blocks by sending another synopsis (we can't just say "send me
* the next 2000 ids" because they may have switched forks themselves and they don't track what * the next 2000 ids" because they may have switched forks themselves and they don't track what
* they've sent us). For faster performance, we want to get a fairly long list of block ids first, * they've sent us). For faster performance, we want to get a fairly long list of block ids first,
* then start downloading the blocks. * then start downloading the blocks.
* The peer doesn't handle these follow-up block id requests any different from the initial request; * The peer doesn't handle these follow-up block id requests any different from the initial request;
* it treats the synopsis we send as our blockchain and bases its response entirely off that. So to * it treats the synopsis we send as our blockchain and bases its response entirely off that. So to
* get the response we want (the next chunk of block ids following the last one they sent us, or, * get the response we want (the next chunk of block ids following the last one they sent us, or,
* failing that, the shortest fork off of the last list of block ids they sent), we need to construct * failing that, the shortest fork off of the last list of block ids they sent), we need to construct
* a synopsis as if our blockchain was made up of: * a synopsis as if our blockchain was made up of:
* 1. the blocks in our block chain up to the fork point (if there is a fork) or the head block (if no fork) * 1. the blocks in our block chain up to the fork point (if there is a fork) or the head block (if no fork)
* 2. the blocks we've already pushed from their fork (if there's a fork) * 2. the blocks we've already pushed from their fork (if there's a fork)
* 3. the block ids they've previously sent us * 3. the block ids they've previously sent us
* Segment 3 is handled in the p2p code, it just tells us the number of blocks it has (in * Segment 3 is handled in the p2p code, it just tells us the number of blocks it has (in
* number_of_blocks_after_reference_point) so we can leave space in the synopsis for them. * number_of_blocks_after_reference_point) so we can leave space in the synopsis for them.
* We're responsible for constructing the synopsis of Segments 1 and 2 from our active blockchain and * We're responsible for constructing the synopsis of Segments 1 and 2 from our active blockchain and
* fork database. The reference_point parameter is the last block from that peer that has been * fork database. The reference_point parameter is the last block from that peer that has been
* successfully pushed to the blockchain, so that tells us whether the peer is on a fork or on * successfully pushed to the blockchain, so that tells us whether the peer is on a fork or on
* the main chain. * the main chain.
*/ */
virtual std::vector<item_hash_t> get_blockchain_synopsis(const item_hash_t &reference_point, virtual std::vector<item_hash_t> get_blockchain_synopsis(const item_hash_t &reference_point,
uint32_t number_of_blocks_after_reference_point) override { uint32_t number_of_blocks_after_reference_point) override {
try { try {
@ -769,26 +733,26 @@ public:
low_block_num += (true_high_block_num - low_block_num + 2) / 2; low_block_num += (true_high_block_num - low_block_num + 2) / 2;
} while (low_block_num <= high_block_num); } while (low_block_num <= high_block_num);
//idump((synopsis)); // idump((synopsis));
return synopsis; return synopsis;
} }
FC_CAPTURE_AND_RETHROW() FC_CAPTURE_AND_RETHROW()
} }
/** /**
* Call this after the call to handle_message succeeds. * Call this after the call to handle_message succeeds.
* *
* @param item_type the type of the item we're synchronizing, will be the same as item passed to the sync_from() call * @param item_type the type of the item we're synchronizing, will be the same as item passed to the sync_from() call
* @param item_count the number of items known to the node that haven't been sent to handle_item() yet. * @param item_count the number of items known to the node that haven't been sent to handle_item() yet.
* After `item_count` more calls to handle_item(), the node will be in sync * After `item_count` more calls to handle_item(), the node will be in sync
*/ */
virtual void sync_status(uint32_t item_type, uint32_t item_count) override { virtual void sync_status(uint32_t item_type, uint32_t item_count) override {
// any status reports to GUI go here // any status reports to GUI go here
} }
/** /**
* Call any time the number of connected peers changes. * Call any time the number of connected peers changes.
*/ */
virtual void connection_count_changed(uint32_t c) override { virtual void connection_count_changed(uint32_t c) override {
// any status reports to GUI go here // any status reports to GUI go here
} }
@ -800,10 +764,14 @@ public:
FC_CAPTURE_AND_RETHROW((block_id)) FC_CAPTURE_AND_RETHROW((block_id))
} }
virtual fc::time_point_sec get_last_known_hardfork_time() override {
return _chain_db->_hardfork_times[_chain_db->_hardfork_times.size() - 1];
}
/** /**
* Returns the time a block was produced (if block_id = 0, returns genesis time). * Returns the time a block was produced (if block_id = 0, returns genesis time).
* If we don't know about the block, returns time_point_sec::min() * If we don't know about the block, returns time_point_sec::min()
*/ */
virtual fc::time_point_sec get_block_time(const item_hash_t &block_id) override { virtual fc::time_point_sec get_block_time(const item_hash_t &block_id) override {
try { try {
auto opt_block = _chain_db->fetch_block_by_id(block_id); auto opt_block = _chain_db->fetch_block_by_id(block_id);
@ -850,11 +818,7 @@ public:
} // namespace detail } // namespace detail
application::application() : 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() { application::~application() {
@ -869,9 +833,24 @@ application::~application() {
void application::set_program_options(boost::program_options::options_description &cli, void application::set_program_options(boost::program_options::options_description &cli,
boost::program_options::options_description &cfg) const { boost::program_options::options_description &cfg) const {
std::vector<string> seed_nodes = {
#ifdef BUILD_PEERPLAYS_TESTNET
#else
"51.222.110.110:9777",
"95.216.90.243:9777",
"ca.peerplays.info:9777",
"de.peerplays.xyz:9777",
"pl.peerplays.org:9777",
"seed.i9networks.net.br:9777",
"witness.serverpit.com:9777"
#endif
};
std::string seed_nodes_str = fc::json::to_string(seed_nodes);
cfg.add_options()("p2p-endpoint", bpo::value<string>()->default_value("0.0.0.0:9777"), "Endpoint for P2P node to listen on"); cfg.add_options()("p2p-endpoint", bpo::value<string>()->default_value("0.0.0.0:9777"), "Endpoint for P2P node to listen on");
cfg.add_options()("seed-node,s", bpo::value<vector<string>>()->composing(), "P2P nodes to connect to on startup (may specify multiple times)"); cfg.add_options()("seed-node,s", bpo::value<vector<string>>()->composing(), "P2P nodes to connect to on startup (may specify multiple times)");
cfg.add_options()("seed-nodes", bpo::value<string>()->composing(), "JSON array of P2P nodes to connect to on startup"); cfg.add_options()("seed-nodes", bpo::value<string>()->composing()->default_value(seed_nodes_str), "JSON array of P2P nodes to connect to on startup");
cfg.add_options()("checkpoint,c", bpo::value<vector<string>>()->composing(), "Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints."); cfg.add_options()("checkpoint,c", bpo::value<vector<string>>()->composing(), "Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints.");
cfg.add_options()("rpc-endpoint", bpo::value<string>()->default_value("127.0.0.1:8090"), "Endpoint for websocket RPC to listen on"); cfg.add_options()("rpc-endpoint", bpo::value<string>()->default_value("127.0.0.1:8090"), "Endpoint for websocket RPC to listen on");
cfg.add_options()("rpc-tls-endpoint", bpo::value<string>()->implicit_value("127.0.0.1:8089"), "Endpoint for TLS websocket RPC to listen on"); cfg.add_options()("rpc-tls-endpoint", bpo::value<string>()->implicit_value("127.0.0.1:8089"), "Endpoint for TLS websocket RPC to listen on");
@ -938,7 +917,8 @@ void application::initialize(const fc::path &data_dir, const boost::program_opti
wanted.insert("accounts_list"); wanted.insert("accounts_list");
wanted.insert("affiliate_stats"); wanted.insert("affiliate_stats");
} }
wanted.insert("witness"); if (!wanted.count("delayed_node") && !wanted.count("debug_witness") && !wanted.count("witness")) // explicitly requested delayed_node or debug_witness functionality suppresses witness functions
wanted.insert("witness");
wanted.insert("bookie"); wanted.insert("bookie");
int es_ah_conflict_counter = 0; int es_ah_conflict_counter = 0;
@ -970,7 +950,7 @@ void application::startup() {
} }
std::shared_ptr<abstract_plugin> application::get_plugin(const string &name) const { std::shared_ptr<abstract_plugin> application::get_plugin(const string &name) const {
return my->_active_plugins[name]; return is_plugin_enabled(name) ? my->_active_plugins[name] : nullptr;
} }
bool application::is_plugin_enabled(const string &name) const { bool application::is_plugin_enabled(const string &name) const {
@ -1017,6 +997,7 @@ void application::shutdown_plugins() {
return; return;
} }
void application::shutdown() { void application::shutdown() {
my->_running.store(false);
if (my->_p2p_network) if (my->_p2p_network)
my->_p2p_network->close(); my->_p2p_network->close();
if (my->_chain_db) if (my->_chain_db)

View file

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

View file

@ -23,14 +23,13 @@
*/ */
#include <graphene/app/database_api.hpp> #include <graphene/app/database_api.hpp>
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/hardfork.hpp>
#include <graphene/chain/tournament_object.hpp>
#include <graphene/chain/get_config.hpp> #include <graphene/chain/get_config.hpp>
#include <graphene/chain/protocol/address.hpp>
#include <graphene/chain/pts_address.hpp>
#include <graphene/chain/tournament_object.hpp>
#include <graphene/protocol/address.hpp> #include <graphene/utilities/git_revision.hpp>
#include <graphene/protocol/pts_address.hpp>
#include <fc/bloom_filter.hpp> #include <fc/bloom_filter.hpp>
@ -38,6 +37,7 @@
#include <fc/rpc/api_connection.hpp> #include <fc/rpc/api_connection.hpp>
#include <fc/uint128.hpp> #include <fc/uint128.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/iterator_range.hpp> #include <boost/range/iterator_range.hpp>
#include <boost/rational.hpp> #include <boost/rational.hpp>
@ -55,30 +55,33 @@ template class fc::api<graphene::app::database_api>;
namespace graphene { namespace app { namespace graphene { namespace app {
template<class T> template <class T>
optional<T> maybe_id( const string& name_or_id ) optional<T> maybe_id(const string &name_or_id) {
{ if (std::isdigit(name_or_id.front())) {
if( std::isdigit( name_or_id.front() ) ) try {
{
try
{
return fc::variant(name_or_id, 1).as<T>(1); return fc::variant(name_or_id, 1).as<T>(1);
} } catch (const fc::exception &) { // not an ID
catch (const fc::exception&)
{ // not an ID
} }
} }
return optional<T>(); return optional<T>();
} }
std::string object_id_to_string(object_id_type id) std::string object_id_to_string(object_id_type id) {
{ std::string object_id = fc::to_string(id.space()) + "." + fc::to_string(id.type()) + "." + fc::to_string(id.instance());
std::string object_id = fc::to_string(id.space())
+ "." + fc::to_string(id.type())
+ "." + fc::to_string(id.instance());
return object_id; return object_id;
} }
signed_block_with_info::signed_block_with_info(){};
signed_block_with_info::signed_block_with_info(const signed_block &block) :
signed_block(block) {
block_id = id();
signing_key = signee();
transaction_ids.reserve(transactions.size());
for (const processed_transaction &tx : transactions)
transaction_ids.push_back(tx.id());
}
class database_api_impl : public std::enable_shared_from_this<database_api_impl> { class database_api_impl : public std::enable_shared_from_this<database_api_impl> {
public: public:
database_api_impl(graphene::chain::database &db); database_api_impl(graphene::chain::database &db);
@ -97,10 +100,12 @@ public:
optional<block_header> get_block_header(uint32_t block_num) const; optional<block_header> get_block_header(uint32_t block_num) const;
map<uint32_t, optional<block_header>> get_block_header_batch(const vector<uint32_t> block_nums) const; map<uint32_t, optional<block_header>> get_block_header_batch(const vector<uint32_t> block_nums) const;
optional<signed_block> get_block(uint32_t block_num) const; optional<signed_block> get_block(uint32_t block_num) const;
optional<signed_block_with_info> get_block2(uint32_t block_num) const;
vector<optional<signed_block>> get_blocks(uint32_t block_num_from, uint32_t block_num_to) const; vector<optional<signed_block>> get_blocks(uint32_t block_num_from, uint32_t block_num_to) const;
processed_transaction get_transaction(uint32_t block_num, uint32_t trx_in_block) const; processed_transaction get_transaction(uint32_t block_num, uint32_t trx_in_block) const;
// Globals // Globals
version_info get_version_info() const;
chain_property_object get_chain_properties() const; chain_property_object get_chain_properties() const;
global_property_object get_global_properties() const; global_property_object get_global_properties() const;
fc::variant_object get_config() const; fc::variant_object get_config() const;
@ -191,6 +196,10 @@ public:
fc::optional<son_object> get_son_by_account(const std::string account_id_or_name) const; fc::optional<son_object> get_son_by_account(const std::string account_id_or_name) const;
map<string, son_id_type> lookup_son_accounts(const string &lower_bound_name, uint32_t limit) const; map<string, son_id_type> lookup_son_accounts(const string &lower_bound_name, uint32_t limit) const;
uint64_t get_son_count() const; uint64_t get_son_count() const;
flat_map<sidechain_type, vector<son_sidechain_info>> get_active_sons();
vector<son_sidechain_info> get_active_sons_by_sidechain(sidechain_type sidechain);
map<sidechain_type, map<son_id_type, string>> get_son_network_status();
map<son_id_type, string> get_son_network_status_by_sidechain(sidechain_type sidechain);
// SON wallets // SON wallets
optional<son_wallet_object> get_active_son_wallet(); optional<son_wallet_object> get_active_son_wallet();
@ -214,17 +223,16 @@ public:
// Votes // Votes
vector<variant> lookup_vote_ids(const vector<vote_id_type> &votes) const; vector<variant> lookup_vote_ids(const vector<vote_id_type> &votes) const;
vector<vote_id_type> get_votes_ids(const string &account_name_or_id) const; vector<vote_id_type> get_votes_ids(const string &account_name_or_id) const;
template<typename IndexType, typename Tag> template <typename IndexType, typename Tag>
vector<variant> get_votes_objects(const vector<vote_id_type> &votes, unsigned int variant_max_depth = 1) const vector<variant> get_votes_objects(const vector<vote_id_type> &votes, unsigned int variant_max_depth = 1) const {
{ static_assert(std::is_base_of<index, IndexType>::value, "Type must be an index type");
static_assert( std::is_base_of<index,IndexType>::value, "Type must be an index type" );
vector<variant> result; vector<variant> result;
const auto &idx = _db.get_index_type<IndexType>().indices().template get<Tag>(); const auto &idx = _db.get_index_type<IndexType>().indices().template get<Tag>();
for (auto id : votes) { for (auto id : votes) {
auto itr = idx.find(id); auto itr = idx.find(id);
if (itr != idx.end()) if (itr != idx.end())
result.emplace_back(variant(*itr,variant_max_depth)); result.emplace_back(variant(*itr, variant_max_depth));
} }
return result; return result;
} }
@ -245,9 +253,6 @@ public:
// Proposed transactions // Proposed transactions
vector<proposal_object> get_proposed_transactions(const std::string account_id_or_name) const; vector<proposal_object> get_proposed_transactions(const std::string account_id_or_name) const;
// Blinded balances
vector<blinded_balance_object> get_blinded_balances(const flat_set<commitment_type> &commitments) const;
// Tournaments // Tournaments
vector<tournament_object> get_tournaments_in_state(tournament_state state, uint32_t limit) const; vector<tournament_object> get_tournaments_in_state(tournament_state state, uint32_t limit) const;
vector<tournament_object> get_tournaments(tournament_id_type stop, unsigned limit, tournament_id_type start); vector<tournament_object> get_tournaments(tournament_id_type stop, unsigned limit, tournament_id_type start);
@ -276,8 +281,9 @@ public:
uint64_t nft_get_total_supply(const nft_metadata_id_type nft_metadata_id) const; uint64_t nft_get_total_supply(const nft_metadata_id_type nft_metadata_id) const;
nft_object nft_token_by_index(const nft_metadata_id_type nft_metadata_id, const uint64_t token_idx) const; nft_object nft_token_by_index(const nft_metadata_id_type nft_metadata_id, const uint64_t token_idx) const;
nft_object nft_token_of_owner_by_index(const nft_metadata_id_type nft_metadata_id, const account_id_type owner, const uint64_t token_idx) const; nft_object nft_token_of_owner_by_index(const nft_metadata_id_type nft_metadata_id, const account_id_type owner, const uint64_t token_idx) const;
vector<nft_object> nft_get_all_tokens() const; vector<nft_object> nft_get_all_tokens(const nft_id_type lower_id, uint32_t limit) const;
vector<nft_object> nft_get_tokens_by_owner(const account_id_type owner) const; vector<nft_object> nft_get_tokens_by_owner(const account_id_type owner, const nft_id_type lower_id, uint32_t limit) const;
vector<nft_metadata_object> nft_get_metadata_by_owner(const account_id_type owner, const nft_metadata_id_type lower_id, uint32_t limit) const;
// Marketplace // Marketplace
vector<offer_object> list_offers(const offer_id_type lower_id, uint32_t limit) const; vector<offer_object> list_offers(const offer_id_type lower_id, uint32_t limit) const;
@ -298,6 +304,7 @@ public:
uint32_t api_limit_get_limit_orders_by_account = 101; uint32_t api_limit_get_limit_orders_by_account = 101;
uint32_t api_limit_get_order_book = 50; uint32_t api_limit_get_order_book = 50;
uint32_t api_limit_all_offers_count = 100; uint32_t api_limit_all_offers_count = 100;
uint32_t api_limit_nft_tokens = 100;
uint32_t api_limit_lookup_accounts = 1000; uint32_t api_limit_lookup_accounts = 1000;
uint32_t api_limit_lookup_witness_accounts = 1000; uint32_t api_limit_lookup_witness_accounts = 1000;
uint32_t api_limit_lookup_committee_member_accounts = 1000; uint32_t api_limit_lookup_committee_member_accounts = 1000;
@ -306,7 +313,7 @@ public:
uint32_t api_limit_get_trade_history = 100; uint32_t api_limit_get_trade_history = 100;
uint32_t api_limit_get_trade_history_by_sequence = 100; uint32_t api_limit_get_trade_history_by_sequence = 100;
//private: // private:
const account_object *get_account_from_string(const std::string &name_or_id, const account_object *get_account_from_string(const std::string &name_or_id,
bool throw_if_not_found = true) const; bool throw_if_not_found = true) const;
const asset_object *get_asset_from_string(const std::string &symbol_or_id, const asset_object *get_asset_from_string(const std::string &symbol_or_id,
@ -430,9 +437,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 { fc::variants database_api_impl::get_objects(const vector<object_id_type> &ids) const {
if (_subscribe_callback) { if (_subscribe_callback) {
for (auto id : ids) { for (auto id : ids) {
if (id.type() == api_operation_history_object_type && id.space() == api_ids) if (id.type() == operation_history_object_type && id.space() == protocol_ids)
continue; continue;
if (id.type() == api_account_transaction_history_object_type && id.space() == api_ids) if (id.type() == impl_account_transaction_history_object_type && id.space() == implementation_ids)
continue; continue;
this->subscribe_to_item(id); this->subscribe_to_item(id);
@ -463,7 +470,7 @@ void database_api::set_subscribe_callback(std::function<void(const variant &)> c
} }
void database_api_impl::set_subscribe_callback(std::function<void(const variant &)> cb, bool notify_remove_create) { void database_api_impl::set_subscribe_callback(std::function<void(const variant &)> cb, bool notify_remove_create) {
//edump((clear_filter)); // edump((clear_filter));
_subscribe_callback = cb; _subscribe_callback = cb;
_notify_remove_create = notify_remove_create; _notify_remove_create = notify_remove_create;
_subscribed_accounts.clear(); _subscribed_accounts.clear();
@ -537,6 +544,17 @@ optional<signed_block> database_api_impl::get_block(uint32_t block_num) const {
return _db.fetch_block_by_number(block_num); return _db.fetch_block_by_number(block_num);
} }
optional<signed_block_with_info> database_api::get_block2(uint32_t block_num) const {
return my->get_block2(block_num);
}
optional<signed_block_with_info> database_api_impl::get_block2(uint32_t block_num) const {
auto result = _db.fetch_block_by_number(block_num);
if (result)
return signed_block_with_info(*result);
return {};
}
vector<optional<signed_block>> database_api::get_blocks(uint32_t block_num_from, uint32_t block_num_to) const { vector<optional<signed_block>> database_api::get_blocks(uint32_t block_num_from, uint32_t block_num_to) const {
return my->get_blocks(block_num_from, block_num_to); return my->get_blocks(block_num_from, block_num_to);
} }
@ -575,6 +593,27 @@ processed_transaction database_api_impl::get_transaction(uint32_t block_num, uin
// // // //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
version_info database_api::get_version_info() const {
return my->get_version_info();
}
version_info database_api_impl::get_version_info() const {
std::string witness_version(graphene::utilities::git_revision_description);
const size_t pos = witness_version.find('/');
if (pos != std::string::npos && witness_version.size() > pos)
witness_version = witness_version.substr(pos + 1);
version_info vi;
vi.version = witness_version;
vi.git_revision = graphene::utilities::git_revision_sha;
vi.built = std::string(__DATE__) + " at " + std::string(__TIME__);
vi.openssl = OPENSSL_VERSION_TEXT;
vi.boost = boost::replace_all_copy(std::string(BOOST_LIB_VERSION), "_", ".");
return vi;
}
chain_property_object database_api::get_chain_properties() const { chain_property_object database_api::get_chain_properties() const {
return my->get_chain_properties(); return my->get_chain_properties();
} }
@ -1838,6 +1877,80 @@ uint64_t database_api_impl::get_son_count() const {
return _db.get_index_type<son_index>().indices().size(); return _db.get_index_type<son_index>().indices().size();
} }
flat_map<sidechain_type, vector<son_sidechain_info>> database_api::get_active_sons() {
return my->get_active_sons();
}
flat_map<sidechain_type, vector<son_sidechain_info>> database_api_impl::get_active_sons() {
return get_global_properties().active_sons;
}
vector<son_sidechain_info> database_api::get_active_sons_by_sidechain(sidechain_type sidechain) {
return my->get_active_sons_by_sidechain(sidechain);
}
vector<son_sidechain_info> database_api_impl::get_active_sons_by_sidechain(sidechain_type sidechain) {
const global_property_object &gpo = get_global_properties();
vector<son_sidechain_info> result;
if (gpo.active_sons.find(sidechain) != gpo.active_sons.end()) {
result = gpo.active_sons.at(sidechain);
}
return result;
}
map<sidechain_type, map<son_id_type, string>> database_api::get_son_network_status() {
return my->get_son_network_status();
}
map<sidechain_type, map<son_id_type, string>> database_api_impl::get_son_network_status() {
map<sidechain_type, map<son_id_type, string>> result;
for (auto active_sidechain_type : active_sidechain_types(_db.head_block_time())) {
result[active_sidechain_type] = get_son_network_status_by_sidechain(active_sidechain_type);
}
return result;
}
map<son_id_type, string> database_api::get_son_network_status_by_sidechain(sidechain_type sidechain) {
return my->get_son_network_status_by_sidechain(sidechain);
}
map<son_id_type, string> database_api_impl::get_son_network_status_by_sidechain(sidechain_type sidechain) {
const global_property_object &gpo = get_global_properties();
map<son_id_type, string> result;
if (gpo.active_sons.find(sidechain) != gpo.active_sons.end()) {
for (const auto si : gpo.active_sons.at(sidechain)) {
const auto son_obj = si.son_id(_db);
const auto sso = son_obj.statistics(_db);
string status;
if (sso.last_active_timestamp.find(sidechain) != sso.last_active_timestamp.end()) {
if (time_point_sec(sso.last_active_timestamp.at(sidechain) + fc::seconds(gpo.parameters.son_heartbeat_frequency())) > _db.head_block_time()) {
status = "OK, regular SON heartbeat";
} else {
if (time_point_sec(sso.last_active_timestamp.at(sidechain) + fc::seconds(gpo.parameters.son_down_time())) > _db.head_block_time()) {
status = "OK, irregular SON heartbeat, but not triggering SON down proposal";
} else {
status = "NOT OK, irregular SON heartbeat, triggering SON down proposal";
}
}
} else {
status = "No heartbeats sent";
}
result[si.son_id] = status;
}
}
return result;
}
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// // // //
// SON Wallets // // SON Wallets //
@ -2073,7 +2186,9 @@ vector<variant> database_api_impl::lookup_vote_ids(const vector<vote_id_type> &v
const auto &committee_idx = _db.get_index_type<committee_member_index>().indices().get<by_vote_id>(); const auto &committee_idx = _db.get_index_type<committee_member_index>().indices().get<by_vote_id>();
const auto &for_worker_idx = _db.get_index_type<worker_index>().indices().get<by_vote_for>(); const auto &for_worker_idx = _db.get_index_type<worker_index>().indices().get<by_vote_for>();
const auto &against_worker_idx = _db.get_index_type<worker_index>().indices().get<by_vote_against>(); const auto &against_worker_idx = _db.get_index_type<worker_index>().indices().get<by_vote_against>();
const auto &son_idx = _db.get_index_type<son_index>().indices().get<by_vote_id>(); const auto &son_bictoin_idx = _db.get_index_type<son_index>().indices().get<by_vote_id_bitcoin>();
const auto &son_hive_idx = _db.get_index_type<son_index>().indices().get<by_vote_id_hive>();
const auto &son_ethereum_idx = _db.get_index_type<son_index>().indices().get<by_vote_id_ethereum>();
vector<variant> result; vector<variant> result;
result.reserve(votes.size()); result.reserve(votes.size());
@ -2082,7 +2197,7 @@ vector<variant> database_api_impl::lookup_vote_ids(const vector<vote_id_type> &v
case vote_id_type::committee: { case vote_id_type::committee: {
auto itr = committee_idx.find(id); auto itr = committee_idx.find(id);
if (itr != committee_idx.end()) if (itr != committee_idx.end())
result.emplace_back(variant(*itr, 1)); result.emplace_back(variant(*itr, 2)); // Depth of committee_member_object is 1, add 1 to be safe
else else
result.emplace_back(variant()); result.emplace_back(variant());
break; break;
@ -2090,7 +2205,7 @@ vector<variant> database_api_impl::lookup_vote_ids(const vector<vote_id_type> &v
case vote_id_type::witness: { case vote_id_type::witness: {
auto itr = witness_idx.find(id); auto itr = witness_idx.find(id);
if (itr != witness_idx.end()) if (itr != witness_idx.end())
result.emplace_back(variant(*itr, 1)); result.emplace_back(variant(*itr, 2)); // Depth of witness_object is 1, add 1 here to be safe
else else
result.emplace_back(variant()); result.emplace_back(variant());
break; break;
@ -2098,26 +2213,45 @@ vector<variant> database_api_impl::lookup_vote_ids(const vector<vote_id_type> &v
case vote_id_type::worker: { case vote_id_type::worker: {
auto itr = for_worker_idx.find(id); auto itr = for_worker_idx.find(id);
if (itr != for_worker_idx.end()) { if (itr != for_worker_idx.end()) {
result.emplace_back(variant(*itr, 1)); result.emplace_back(variant(*itr, 4)); // Depth of worker_object is 3, add 1 here to be safe.
// If we want to extract the balance object inside,
// need to increase this value
} else { } else {
auto itr = against_worker_idx.find(id); auto itr = against_worker_idx.find(id);
if (itr != against_worker_idx.end()) { if (itr != against_worker_idx.end()) {
result.emplace_back(variant(*itr, 1)); result.emplace_back(variant(*itr, 4)); // Depth of worker_object is 3, add 1 here to be safe.
// If we want to extract the balance object inside,
// need to increase this value
} else { } else {
result.emplace_back(variant()); result.emplace_back(variant());
} }
} }
break; break;
} }
case vote_id_type::son: { case vote_id_type::son_bitcoin: {
auto itr = son_idx.find(id); auto itr = son_bictoin_idx.find(id);
if (itr != son_idx.end()) if (itr != son_bictoin_idx.end())
result.emplace_back(variant(*itr, 5));
else
result.emplace_back(variant());
break;
}
case vote_id_type::son_hive: {
auto itr = son_hive_idx.find(id);
if (itr != son_hive_idx.end())
result.emplace_back(variant(*itr, 5));
else
result.emplace_back(variant());
break;
}
case vote_id_type::son_ethereum: {
auto itr = son_ethereum_idx.find(id);
if (itr != son_ethereum_idx.end())
result.emplace_back(variant(*itr, 5)); result.emplace_back(variant(*itr, 5));
else else
result.emplace_back(variant()); result.emplace_back(variant());
break; break;
} }
case vote_id_type::VOTE_TYPE_COUNT: case vote_id_type::VOTE_TYPE_COUNT:
break; // supress unused enum value warnings break; // supress unused enum value warnings
default: default:
@ -2132,8 +2266,7 @@ vector<vote_id_type> database_api_impl::get_votes_ids(const string &account_name
const account_object *account = get_account_from_string(account_name_or_id); const account_object *account = get_account_from_string(account_name_or_id);
//! Iterate throug votes and fill vector //! Iterate throug votes and fill vector
for( const auto& vote : account->options.votes ) for (const auto &vote : account->options.votes) {
{
result.emplace_back(vote); result.emplace_back(vote);
} }
@ -2143,60 +2276,78 @@ vector<vote_id_type> database_api_impl::get_votes_ids(const string &account_name
votes_info database_api_impl::get_votes(const string &account_name_or_id) const { votes_info database_api_impl::get_votes(const string &account_name_or_id) const {
votes_info result; votes_info result;
const auto& votes_ids = get_votes_ids(account_name_or_id); const auto votes_ids = get_votes_ids(account_name_or_id);
const auto& committee_ids = get_votes_objects<committee_member_index, by_vote_id>(votes_ids); const auto committee_ids = get_votes_objects<committee_member_index, by_vote_id>(votes_ids);
const auto& witness_ids = get_votes_objects<witness_index, by_vote_id>(votes_ids); const auto witness_ids = get_votes_objects<witness_index, by_vote_id>(votes_ids);
const auto& for_worker_ids = get_votes_objects<worker_index, by_vote_for>(votes_ids); const auto for_worker_ids = get_votes_objects<worker_index, by_vote_for>(votes_ids);
const auto& against_worker_ids = get_votes_objects<worker_index, by_vote_against>(votes_ids); const auto against_worker_ids = get_votes_objects<worker_index, by_vote_against>(votes_ids);
const auto& son_ids = get_votes_objects<son_index, by_vote_id>(votes_ids, 5); const auto son_ids = [this, &votes_ids]() {
flat_map<sidechain_type, vector<variant>> son_ids;
const auto son_bitcoin_ids = get_votes_objects<son_index, by_vote_id_bitcoin>(votes_ids, 5);
if (!son_bitcoin_ids.empty())
son_ids[sidechain_type::bitcoin] = std::move(son_bitcoin_ids);
const auto son_hive_ids = get_votes_objects<son_index, by_vote_id_hive>(votes_ids, 5);
if (!son_hive_ids.empty())
son_ids[sidechain_type::hive] = std::move(son_hive_ids);
const auto son_ethereum_ids = get_votes_objects<son_index, by_vote_id_ethereum>(votes_ids, 5);
if (!son_ethereum_ids.empty())
son_ids[sidechain_type::ethereum] = std::move(son_ethereum_ids);
return son_ids;
}();
//! Fill votes info //! Fill votes info
if(!committee_ids.empty()) { if (!committee_ids.empty()) {
vector< votes_info_object<committee_member_id_type> > votes_for_committee_members; vector<votes_info_object> votes_for_committee_members;
votes_for_committee_members.reserve(committee_ids.size()); votes_for_committee_members.reserve(committee_ids.size());
for (const auto &committee : committee_ids) { for (const auto &committee : committee_ids) {
const auto &committee_obj = committee.as<committee_member_object>(2); const auto &committee_obj = committee.as<committee_member_object>(2);
votes_for_committee_members.emplace_back(votes_info_object<committee_member_id_type>{committee_obj.vote_id, committee_obj.id.instance()}); votes_for_committee_members.emplace_back(votes_info_object{committee_obj.vote_id, committee_obj.id});
} }
result.votes_for_committee_members = std::move(votes_for_committee_members); result.votes_for_committee_members = std::move(votes_for_committee_members);
} }
if(!witness_ids.empty()) { if (!witness_ids.empty()) {
vector< votes_info_object<witness_id_type> > votes_for_witnesses; vector<votes_info_object> votes_for_witnesses;
votes_for_witnesses.reserve(witness_ids.size()); votes_for_witnesses.reserve(witness_ids.size());
for (const auto &witness : witness_ids) { for (const auto &witness : witness_ids) {
const auto &witness_obj = witness.as<witness_object>(2); const auto &witness_obj = witness.as<witness_object>(2);
votes_for_witnesses.emplace_back(votes_info_object<witness_id_type>{witness_obj.vote_id, witness_obj.id.instance()}); votes_for_witnesses.emplace_back(votes_info_object{witness_obj.vote_id, witness_obj.id});
} }
result.votes_for_witnesses = std::move(votes_for_witnesses); result.votes_for_witnesses = std::move(votes_for_witnesses);
} }
if(!for_worker_ids.empty()) { if (!for_worker_ids.empty()) {
vector< votes_info_object<worker_id_type> > votes_for_workers; vector<votes_info_object> votes_for_workers;
votes_for_workers.reserve(for_worker_ids.size()); votes_for_workers.reserve(for_worker_ids.size());
for (const auto &for_worker : for_worker_ids) { for (const auto &for_worker : for_worker_ids) {
const auto &for_worker_obj = for_worker.as<worker_object>(2); const auto &for_worker_obj = for_worker.as<worker_object>(2);
votes_for_workers.emplace_back(votes_info_object<worker_id_type>{for_worker_obj.vote_for, for_worker_obj.id.instance()}); votes_for_workers.emplace_back(votes_info_object{for_worker_obj.vote_for, for_worker_obj.id});
} }
result.votes_for_workers = std::move(votes_for_workers); result.votes_for_workers = std::move(votes_for_workers);
} }
if(!against_worker_ids.empty()) { if (!against_worker_ids.empty()) {
vector< votes_info_object<worker_id_type> > votes_against_workers; vector<votes_info_object> votes_against_workers;
votes_against_workers.reserve(against_worker_ids.size()); votes_against_workers.reserve(against_worker_ids.size());
for (const auto &against_worker : against_worker_ids) { for (const auto &against_worker : against_worker_ids) {
const auto &against_worker_obj = against_worker.as<worker_object>(2); const auto &against_worker_obj = against_worker.as<worker_object>(2);
votes_against_workers.emplace_back(votes_info_object<worker_id_type>{against_worker_obj.vote_against, against_worker_obj.id.instance()}); votes_against_workers.emplace_back(votes_info_object{against_worker_obj.vote_against, against_worker_obj.id});
} }
result.votes_against_workers = std::move(votes_against_workers); result.votes_against_workers = std::move(votes_against_workers);
} }
if(!son_ids.empty()) { if (!son_ids.empty()) {
vector< votes_info_object<son_id_type> > votes_for_sons; flat_map<sidechain_type, vector<votes_info_object>> votes_for_sons;
votes_for_sons.reserve(son_ids.size()); for (const auto &son_sidechain_ids : son_ids) {
for (const auto &son : son_ids) { const auto &sidechain = son_sidechain_ids.first;
const auto &son_obj = son.as<son_object>(6); const auto &sidechain_ids = son_sidechain_ids.second;
votes_for_sons.emplace_back(votes_info_object<son_id_type>{son_obj.vote_id, son_obj.id.instance()}); votes_for_sons[sidechain].reserve(sidechain_ids.size());
for (const auto &son : sidechain_ids) {
const auto &son_obj = son.as<son_object>(6);
if (son_obj.get_sidechain_vote_id(sidechain).valid()) {
votes_for_sons[sidechain].emplace_back(votes_info_object{*son_obj.get_sidechain_vote_id(sidechain), son_obj.id});
}
}
} }
result.votes_for_sons = std::move(votes_for_sons); result.votes_for_sons = std::move(votes_for_sons);
} }
@ -2208,10 +2359,9 @@ vector<account_object> database_api_impl::get_voters_by_id(const vote_id_type &v
vector<account_object> result; vector<account_object> result;
//! We search all accounts that have voted for this vote_id //! We search all accounts that have voted for this vote_id
const auto& account_index = _db.get_index_type<graphene::chain::account_index>().indices().get<by_id>(); const auto &account_index = _db.get_index_type<graphene::chain::account_index>().indices().get<by_id>();
for( const auto& account: account_index ) for (const auto &account : account_index) {
{ if (account.options.votes.count(vote_id) != 0)
if(account.options.votes.count(vote_id) != 0)
result.emplace_back(account); result.emplace_back(account);
} }
@ -2226,83 +2376,78 @@ voters_info database_api_impl::get_voters(const string &account_name_or_id) cons
std::string owner_account_id; std::string owner_account_id;
//! Check if we have account by name //! Check if we have account by name
const auto& account_object = get_account_by_name(account_name_or_id); const auto &account_object = get_account_by_name(account_name_or_id);
if(account_object) { if (account_object) {
//! It is account //! It is account
owner_account_id = object_id_to_string( account_object->get_id() ); owner_account_id = object_id_to_string(account_object->get_id());
owner_account_found = true; owner_account_found = true;
} } else {
else {
//! Check if we have account id //! Check if we have account id
const auto& account_id = maybe_id<account_id_type>(account_name_or_id); const auto &account_id = maybe_id<account_id_type>(account_name_or_id);
if(account_id) { if (account_id) {
//! It may be account id //! It may be account id
const auto& account_objects = get_accounts({account_name_or_id}); const auto &account_objects = get_accounts({account_name_or_id});
if(!account_objects.empty()){ if (!account_objects.empty()) {
const auto& account_object = account_objects.front(); const auto &account_object = account_objects.front();
if(account_object) { if (account_object) {
//! It is account object //! It is account object
owner_account_id = object_id_to_string( account_object->get_id() ); owner_account_id = object_id_to_string(account_object->get_id());
owner_account_found = true; owner_account_found = true;
} }
} }
} } else {
else {
//! Check if we have committee member id //! Check if we have committee member id
const auto& committee_member_id = maybe_id<committee_member_id_type>(account_name_or_id); const auto &committee_member_id = maybe_id<committee_member_id_type>(account_name_or_id);
if(committee_member_id) { if (committee_member_id) {
//! It may be committee member id //! It may be committee member id
const auto& committee_member_objects = get_committee_members({*committee_member_id}); const auto &committee_member_objects = get_committee_members({*committee_member_id});
if(!committee_member_objects.empty()){ if (!committee_member_objects.empty()) {
const auto& committee_member_object = committee_member_objects.front(); const auto &committee_member_object = committee_member_objects.front();
if(committee_member_object) { if (committee_member_object) {
//! It is committee member object //! It is committee member object
owner_account_id = object_id_to_string( committee_member_object->committee_member_account ); owner_account_id = object_id_to_string(committee_member_object->committee_member_account);
owner_account_found = true; owner_account_found = true;
} }
} }
} } else {
else {
//! Check if we have witness id //! Check if we have witness id
const auto& witness_id = maybe_id<witness_id_type>(account_name_or_id); const auto &witness_id = maybe_id<witness_id_type>(account_name_or_id);
if(witness_id) { if (witness_id) {
//! It may be witness id //! It may be witness id
const auto& witness_objects = get_witnesses({*witness_id}); const auto &witness_objects = get_witnesses({*witness_id});
if(!witness_objects.empty()){ if (!witness_objects.empty()) {
const auto& witness_object = witness_objects.front(); const auto &witness_object = witness_objects.front();
if(witness_object) { if (witness_object) {
//! It is witness object //! It is witness object
owner_account_id = object_id_to_string( witness_object->witness_account ); owner_account_id = object_id_to_string(witness_object->witness_account);
owner_account_found = true; owner_account_found = true;
} }
} }
} } else {
else {
//! Check if we have worker id //! Check if we have worker id
const auto& worker_id = maybe_id<worker_id_type>(account_name_or_id); const auto &worker_id = maybe_id<worker_id_type>(account_name_or_id);
if(worker_id) { if (worker_id) {
//! It may be worker id //! It may be worker id
const auto& worker_objects = get_workers({*worker_id}); const auto &worker_objects = get_workers({*worker_id});
if(!worker_objects.empty()){ if (!worker_objects.empty()) {
const auto& worker_object = worker_objects.front(); const auto &worker_object = worker_objects.front();
if(worker_object) { if (worker_object) {
//! It is worker object //! It is worker object
owner_account_id = object_id_to_string( worker_object->worker_account ); owner_account_id = object_id_to_string(worker_object->worker_account);
owner_account_found = true; owner_account_found = true;
} }
} }
} } else {
else {
//! Check if we have son id //! Check if we have son id
const auto& son_id = maybe_id<son_id_type>(account_name_or_id); const auto &son_id = maybe_id<son_id_type>(account_name_or_id);
if(son_id) { if (son_id) {
//! It may be son id //! It may be son id
const auto& son_objects = get_sons({*son_id}); const auto &son_objects = get_sons({*son_id});
if(!son_objects.empty()){ if (!son_objects.empty()) {
const auto& son_object = son_objects.front(); const auto &son_object = son_objects.front();
if(son_object) { if (son_object) {
//! It is son object //! It is son object
owner_account_id = object_id_to_string( son_object->son_account ); owner_account_id = object_id_to_string(son_object->son_account);
owner_account_found = true; owner_account_found = true;
} }
} }
@ -2314,41 +2459,41 @@ voters_info database_api_impl::get_voters(const string &account_name_or_id) cons
} }
//! We didn't find who it was //! We didn't find who it was
if(!owner_account_found) if (!owner_account_found)
FC_THROW_EXCEPTION(database_query_exception, "Wrong account_name_or_id: ${account_name_or_id}", ("account_name_or_id", account_name_or_id)); FC_THROW_EXCEPTION(database_query_exception, "Wrong account_name_or_id: ${account_name_or_id}", ("account_name_or_id", account_name_or_id));
//! Fill voters_info //! Fill voters_info
const auto& committee_member_object = get_committee_member_by_account(owner_account_id); const auto &committee_member_object = get_committee_member_by_account(owner_account_id);
const auto& witness_object = get_witness_by_account(owner_account_id); const auto &witness_object = get_witness_by_account(owner_account_id);
const auto& worker_objects = get_workers_by_account(owner_account_id); const auto &worker_objects = get_workers_by_account(owner_account_id);
const auto& son_object = get_son_by_account(owner_account_id); const auto &son_object = get_son_by_account(owner_account_id);
//! Info for committee member voters //! Info for committee member voters
if(committee_member_object) { if (committee_member_object) {
const auto& committee_member_voters = get_voters_by_id(committee_member_object->vote_id); const auto &committee_member_voters = get_voters_by_id(committee_member_object->vote_id);
voters_info_object voters_for_committee_member; voters_info_object voters_for_committee_member;
voters_for_committee_member.vote_id = committee_member_object->vote_id; voters_for_committee_member.vote_id = committee_member_object->vote_id;
voters_for_committee_member.voters.reserve(committee_member_voters.size()); voters_for_committee_member.voters.reserve(committee_member_voters.size());
for(const auto& voter: committee_member_voters) { for (const auto &voter : committee_member_voters) {
voters_for_committee_member.voters.emplace_back(voter.get_id()); voters_for_committee_member.voters.emplace_back(voter.get_id());
} }
result.voters_for_committee_member = std::move(voters_for_committee_member); result.voters_for_committee_member = std::move(voters_for_committee_member);
} }
//! Info for witness voters //! Info for witness voters
if(witness_object) { if (witness_object) {
const auto& witness_voters = get_voters_by_id(witness_object->vote_id); const auto &witness_voters = get_voters_by_id(witness_object->vote_id);
voters_info_object voters_for_witness; voters_info_object voters_for_witness;
voters_for_witness.vote_id = witness_object->vote_id; voters_for_witness.vote_id = witness_object->vote_id;
voters_for_witness.voters.reserve(witness_voters.size()); voters_for_witness.voters.reserve(witness_voters.size());
for(const auto& voter: witness_voters) { for (const auto &voter : witness_voters) {
voters_for_witness.voters.emplace_back(voter.get_id()); voters_for_witness.voters.emplace_back(voter.get_id());
} }
result.voters_for_witness = std::move(voters_for_witness); result.voters_for_witness = std::move(voters_for_witness);
} }
//! Info for worker voters //! Info for worker voters
if(!worker_objects.empty()) { if (!worker_objects.empty()) {
vector<voters_info_object> voters_for_workers(worker_objects.size()); vector<voters_info_object> voters_for_workers(worker_objects.size());
vector<voters_info_object> voters_against_workers(worker_objects.size()); vector<voters_info_object> voters_against_workers(worker_objects.size());
for (const auto &worker_object : worker_objects) { for (const auto &worker_object : worker_objects) {
@ -2375,13 +2520,17 @@ voters_info database_api_impl::get_voters(const string &account_name_or_id) cons
} }
//! Info for son voters //! Info for son voters
if(son_object) { if (son_object) {
const auto& son_voters = get_voters_by_id(son_object->vote_id); flat_map<sidechain_type, voters_info_object> voters_for_son;
voters_info_object voters_for_son; for (const auto &vote_id : son_object->sidechain_vote_ids) {
voters_for_son.vote_id = son_object->vote_id; const auto &son_voters = get_voters_by_id(vote_id.second);
voters_for_son.voters.reserve(son_voters.size()); voters_info_object voters_for_sidechain_son;
for(const auto& voter: son_voters) { voters_for_sidechain_son.vote_id = vote_id.second;
voters_for_son.voters.emplace_back(voter.get_id()); voters_for_sidechain_son.voters.reserve(son_voters.size());
for (const auto &voter : son_voters) {
voters_for_sidechain_son.voters.emplace_back(voter.get_id());
}
voters_for_son[vote_id.first] = std::move(voters_for_sidechain_son);
} }
result.voters_for_son = std::move(voters_for_son); result.voters_for_son = std::move(voters_for_son);
} }
@ -2644,29 +2793,6 @@ vector<proposal_object> database_api_impl::get_proposed_transactions(const std::
return result; return result;
} }
//////////////////////////////////////////////////////////////////////
// //
// Blinded balances //
// //
//////////////////////////////////////////////////////////////////////
vector<blinded_balance_object> database_api::get_blinded_balances(const flat_set<commitment_type> &commitments) const {
return my->get_blinded_balances(commitments);
}
vector<blinded_balance_object> database_api_impl::get_blinded_balances(const flat_set<commitment_type> &commitments) const {
vector<blinded_balance_object> result;
result.reserve(commitments.size());
const auto &bal_idx = _db.get_index_type<blinded_balance_index>();
const auto &by_commitment_idx = bal_idx.indices().get<by_commitment>();
for (const auto &c : commitments) {
auto itr = by_commitment_idx.find(c);
if (itr != by_commitment_idx.end())
result.push_back(*itr);
}
return result;
}
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// // // //
// Tournament methods // // Tournament methods //
@ -2781,7 +2907,7 @@ graphene::app::gpos_info database_api::get_gpos_info(const account_id_type accou
} }
graphene::app::gpos_info database_api_impl::get_gpos_info(const account_id_type account) const { graphene::app::gpos_info database_api_impl::get_gpos_info(const account_id_type account) const {
FC_ASSERT(_db.head_block_time() > HARDFORK_GPOS_TIME); //Can be deleted after GPOS hardfork time FC_ASSERT(_db.head_block_time() > HARDFORK_GPOS_TIME); // Can be deleted after GPOS hardfork time
gpos_info result; gpos_info result;
result.vesting_factor = _db.calculate_vesting_factor(account(_db)); result.vesting_factor = _db.calculate_vesting_factor(account(_db));
@ -2805,9 +2931,10 @@ graphene::app::gpos_info database_api_impl::get_gpos_info(const account_id_type
} }
vector<vesting_balance_object> account_vbos; 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); 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, std::for_each(vesting_range.first, vesting_range.second,
[&account_vbos](const vesting_balance_object &balance) { [&account_vbos, now](const vesting_balance_object &balance) {
if (balance.balance.amount > 0 && balance.balance_type == vesting_balance_type::gpos && balance.balance.asset_id == asset_id_type()) if (balance.balance.amount > 0 && balance.balance_type == vesting_balance_type::gpos && balance.balance.asset_id == asset_id_type())
account_vbos.emplace_back(balance); account_vbos.emplace_back(balance);
}); });
@ -2968,8 +3095,8 @@ uint64_t database_api::nft_get_total_supply(const nft_metadata_id_type nft_metad
} }
uint64_t database_api_impl::nft_get_total_supply(const nft_metadata_id_type nft_metadata_id) const { uint64_t database_api_impl::nft_get_total_supply(const nft_metadata_id_type nft_metadata_id) const {
const auto &idx_nft_md = _db.get_index_type<nft_metadata_index>().indices().get<by_id>(); const auto &idx_nft = _db.get_index_type<nft_index>().indices().get<by_metadata>();
return idx_nft_md.size(); return idx_nft.count(nft_metadata_id);
} }
nft_object database_api::nft_token_by_index(const nft_metadata_id_type nft_metadata_id, const uint64_t token_idx) const { nft_object database_api::nft_token_by_index(const nft_metadata_id_type nft_metadata_id, const uint64_t token_idx) const {
@ -3006,30 +3133,61 @@ nft_object database_api_impl::nft_token_of_owner_by_index(const nft_metadata_id_
return {}; return {};
} }
vector<nft_object> database_api::nft_get_all_tokens() const { vector<nft_object> database_api::nft_get_all_tokens(const nft_id_type lower_id, uint32_t limit) const {
return my->nft_get_all_tokens(); return my->nft_get_all_tokens(lower_id, limit);
} }
vector<nft_object> database_api_impl::nft_get_all_tokens() const { vector<nft_object> database_api_impl::nft_get_all_tokens(const nft_id_type lower_id, uint32_t limit) const {
FC_ASSERT(limit <= api_limit_nft_tokens,
"Number of queried nft tokens can not be greater than ${configured_limit}",
("configured_limit", api_limit_nft_tokens));
const auto &idx_nft = _db.get_index_type<nft_index>().indices().get<by_id>(); const auto &idx_nft = _db.get_index_type<nft_index>().indices().get<by_id>();
vector<nft_object> result; vector<nft_object> result;
for (auto itr = idx_nft.begin(); itr != idx_nft.end(); ++itr) { result.reserve(limit);
result.push_back(*itr); auto itr = idx_nft.lower_bound(lower_id);
} while (limit-- && itr != idx_nft.end())
result.emplace_back(*itr++);
return result; return result;
} }
vector<nft_object> database_api::nft_get_tokens_by_owner(const account_id_type owner) const { vector<nft_object> database_api::nft_get_tokens_by_owner(const account_id_type owner, const nft_id_type lower_id, uint32_t limit) const {
return my->nft_get_tokens_by_owner(owner); return my->nft_get_tokens_by_owner(owner, lower_id, limit);
} }
vector<nft_object> database_api_impl::nft_get_tokens_by_owner(const account_id_type owner) const { vector<nft_object> database_api_impl::nft_get_tokens_by_owner(const account_id_type owner, const nft_id_type lower_id, uint32_t limit) const {
FC_ASSERT(limit <= api_limit_nft_tokens,
"Number of queried nft tokens can not be greater than ${configured_limit}",
("configured_limit", api_limit_nft_tokens));
const auto &idx_nft = _db.get_index_type<nft_index>().indices().get<by_owner>(); const auto &idx_nft = _db.get_index_type<nft_index>().indices().get<by_owner>();
auto idx_nft_range = idx_nft.equal_range(owner); auto idx_nft_range = idx_nft.equal_range(owner);
vector<nft_object> result; vector<nft_object> result;
for (auto itr = idx_nft_range.first; itr != idx_nft_range.second; ++itr) { result.reserve(limit);
result.push_back(*itr); auto itr = std::find_if(idx_nft_range.first, idx_nft_range.second, [&lower_id](const nft_object &obj) {
} return !(obj.id.instance() < lower_id.instance);
});
while (limit-- && itr != idx_nft_range.second)
result.emplace_back(*itr++);
return result;
}
vector<nft_metadata_object> database_api::nft_get_metadata_by_owner(const account_id_type owner, const nft_metadata_id_type lower_id, uint32_t limit) const {
return my->nft_get_metadata_by_owner(owner, lower_id, limit);
}
vector<nft_metadata_object> database_api_impl::nft_get_metadata_by_owner(const account_id_type owner, const nft_metadata_id_type lower_id, uint32_t limit) const {
FC_ASSERT(limit <= api_limit_nft_tokens,
"Number of queried nft metadata objects can not be greater than ${configured_limit}",
("configured_limit", api_limit_nft_tokens));
const auto &idx_nft = _db.get_index_type<nft_metadata_index>().indices().get<by_owner>();
auto idx_nft_range = idx_nft.equal_range(owner);
vector<nft_metadata_object> result;
result.reserve(limit);
auto itr = std::find_if(idx_nft_range.first, idx_nft_range.second, [&lower_id](const nft_metadata_object &obj) {
return !(obj.id.instance() < lower_id.instance);
});
while (limit-- && itr != idx_nft_range.second)
result.emplace_back(*itr++);
return result; return result;
} }
@ -3396,9 +3554,9 @@ void database_api_impl::handle_object_changed(bool force_notify, bool full_objec
/// pushing the future back / popping the prior future if it is complete. /// pushing the future back / popping the prior future if it is complete.
/// if a connection hangs then this could get backed up and result in /// if a connection hangs then this could get backed up and result in
/// a failure to exit cleanly. /// a failure to exit cleanly.
//fc::async([capture_this,this,updates,market_broadcast_queue](){ // fc::async([capture_this,this,updates,market_broadcast_queue](){
//if( _subscribe_callback ) // if( _subscribe_callback )
// _subscribe_callback( updates ); // _subscribe_callback( updates );
for (auto id : ids) { for (auto id : ids) {
if (id.is<call_order_object>()) { if (id.is<call_order_object>()) {

View file

@ -25,19 +25,18 @@
#include <graphene/app/database_api.hpp> #include <graphene/app/database_api.hpp>
#include <graphene/protocol/types.hpp> #include <graphene/chain/protocol/confidential.hpp>
#include <graphene/protocol/confidential.hpp> #include <graphene/chain/protocol/types.hpp>
#include <graphene/net/node.hpp>
#include <graphene/accounts_list/accounts_list_plugin.hpp> #include <graphene/accounts_list/accounts_list_plugin.hpp>
#include <graphene/market_history/market_history_plugin.hpp>
#include <graphene/elasticsearch/elasticsearch_plugin.hpp>
#include <graphene/affiliate_stats/affiliate_stats_api.hpp> #include <graphene/affiliate_stats/affiliate_stats_api.hpp>
#include <graphene/bookie/bookie_api.hpp> #include <graphene/bookie/bookie_api.hpp>
#include <graphene/debug_witness/debug_api.hpp> #include <graphene/debug_witness/debug_api.hpp>
#include <graphene/elasticsearch/elasticsearch_plugin.hpp>
#include <graphene/net/node.hpp> #include <graphene/market_history/market_history_plugin.hpp>
#include <graphene/peerplays_sidechain/sidechain_api.hpp>
#include <fc/api.hpp> #include <fc/api.hpp>
#include <fc/crypto/elliptic.hpp> #include <fc/crypto/elliptic.hpp>
@ -86,10 +85,10 @@ struct asset_holders {
}; };
/** /**
* @brief The history_api class implements the RPC API for account history * @brief The history_api class implements the RPC API for account history
* *
* This API contains methods to access account histories * This API contains methods to access account histories
*/ */
class history_api { class history_api {
public: public:
history_api(application &app) : history_api(application &app) :
@ -98,27 +97,27 @@ public:
} }
/** /**
* @brief Get operations relevant to the specificed account * @brief Get operations relevant to the specificed account
* @param account_id_or_name The account ID or name whose history should be queried * @param account_id_or_name The account ID or name whose history should be queried
* @param stop ID of the earliest operation to retrieve * @param stop ID of the earliest operation to retrieve
* @param limit Maximum number of operations to retrieve (must not exceed 100) * @param limit Maximum number of operations to retrieve (must not exceed 100)
* @param start ID of the most recent operation to retrieve * @param start ID of the most recent operation to retrieve
* @return A list of operations performed by account, ordered from most recent to oldest. * @return A list of operations performed by account, ordered from most recent to oldest.
*/ */
vector<operation_history_object> get_account_history(const std::string account_id_or_name, vector<operation_history_object> get_account_history(const std::string account_id_or_name,
operation_history_id_type stop = operation_history_id_type(), operation_history_id_type stop = operation_history_id_type(),
unsigned limit = 100, unsigned limit = 100,
operation_history_id_type start = operation_history_id_type()) const; operation_history_id_type start = operation_history_id_type()) const;
/** /**
* @brief Get only asked operations relevant to the specified account * @brief Get only asked operations relevant to the specified account
* @param account_id_or_name The account ID or name whose history should be queried * @param account_id_or_name The account ID or name whose history should be queried
* @param operation_id The ID of the operation we want to get operations in the account( 0 = transfer , 1 = limit order create, ...) * @param operation_id The ID of the operation we want to get operations in the account( 0 = transfer , 1 = limit order create, ...)
* @param stop ID of the earliest operation to retrieve * @param stop ID of the earliest operation to retrieve
* @param limit Maximum number of operations to retrieve (must not exceed 100) * @param limit Maximum number of operations to retrieve (must not exceed 100)
* @param start ID of the most recent operation to retrieve * @param start ID of the most recent operation to retrieve
* @return A list of operations performed by account, ordered from most recent to oldest. * @return A list of operations performed by account, ordered from most recent to oldest.
*/ */
vector<operation_history_object> get_account_history_operations(const std::string account_id_or_name, vector<operation_history_object> get_account_history_operations(const std::string account_id_or_name,
int operation_id, int operation_id,
operation_history_id_type start = operation_history_id_type(), operation_history_id_type start = operation_history_id_type(),
@ -126,17 +125,17 @@ public:
unsigned limit = 100) const; unsigned limit = 100) const;
/** /**
* @breif Get operations relevant to the specified account referenced * @breif Get operations relevant to the specified account referenced
* by an event numbering specific to the account. The current number of operations * by an event numbering specific to the account. The current number of operations
* for the account can be found in the account statistics (or use 0 for start). * for the account can be found in the account statistics (or use 0 for start).
* @param account_id_or_name The account ID or name whose history should be queried * @param account_id_or_name The account ID or name whose history should be queried
* @param stop Sequence number of earliest operation. 0 is default and will * @param stop Sequence number of earliest operation. 0 is default and will
* query 'limit' number of operations. * query 'limit' number of operations.
* @param limit Maximum number of operations to retrieve (must not exceed 100) * @param limit Maximum number of operations to retrieve (must not exceed 100)
* @param start Sequence number of the most recent operation to retrieve. * @param start Sequence number of the most recent operation to retrieve.
* 0 is default, which will start querying from the most recent operation. * 0 is default, which will start querying from the most recent operation.
* @return A list of operations performed by account, ordered from most recent to oldest. * @return A list of operations performed by account, ordered from most recent to oldest.
*/ */
vector<operation_history_object> get_relative_account_history(const std::string account_id_or_name, vector<operation_history_object> get_relative_account_history(const std::string account_id_or_name,
uint32_t stop = 0, uint32_t stop = 0,
unsigned limit = 100, unsigned limit = 100,
@ -157,8 +156,8 @@ private:
}; };
/** /**
* @brief Block api * @brief Block api
*/ */
class block_api { class block_api {
public: public:
block_api(graphene::chain::database &db); block_api(graphene::chain::database &db);
@ -171,8 +170,8 @@ private:
}; };
/** /**
* @brief The network_broadcast_api class allows broadcasting of transactions. * @brief The network_broadcast_api class allows broadcasting of transactions.
*/ */
class network_broadcast_api : public std::enable_shared_from_this<network_broadcast_api> { class network_broadcast_api : public std::enable_shared_from_this<network_broadcast_api> {
public: public:
network_broadcast_api(application &a); network_broadcast_api(application &a);
@ -187,36 +186,36 @@ public:
typedef std::function<void(variant /*transaction_confirmation*/)> confirmation_callback; typedef std::function<void(variant /*transaction_confirmation*/)> confirmation_callback;
/** /**
* @brief Broadcast a transaction to the network * @brief Broadcast a transaction to the network
* @param trx The transaction to broadcast * @param trx The transaction to broadcast
* *
* The transaction will be checked for validity in the local database prior to broadcasting. If it fails to * The transaction will be checked for validity in the local database prior to broadcasting. If it fails to
* apply locally, an error will be thrown and the transaction will not be broadcast. * apply locally, an error will be thrown and the transaction will not be broadcast.
*/ */
void broadcast_transaction(const signed_transaction &trx); void broadcast_transaction(const signed_transaction &trx);
/** this version of broadcast transaction registers a callback method that will be called when the transaction is /** this version of broadcast transaction registers a callback method that will be called when the transaction is
* included into a block. The callback method includes the transaction id, block number, and transaction number in the * included into a block. The callback method includes the transaction id, block number, and transaction number in the
* block. * block.
*/ */
void broadcast_transaction_with_callback(confirmation_callback cb, const signed_transaction &trx); void broadcast_transaction_with_callback(confirmation_callback cb, const signed_transaction &trx);
/** this version of broadcast transaction registers a callback method that will be called when the transaction is /** this version of broadcast transaction registers a callback method that will be called when the transaction is
* included into a block. The callback method includes the transaction id, block number, and transaction number in the * included into a block. The callback method includes the transaction id, block number, and transaction number in the
* block. * block.
*/ */
fc::variant broadcast_transaction_synchronous(const signed_transaction &trx); fc::variant broadcast_transaction_synchronous(const signed_transaction &trx);
void broadcast_block(const signed_block &block); void broadcast_block(const signed_block &block);
/** /**
* @brief Not reflected, thus not accessible to API clients. * @brief Not reflected, thus not accessible to API clients.
* *
* This function is registered to receive the applied_block * This function is registered to receive the applied_block
* signal from the chain database when a block is received. * signal from the chain database when a block is received.
* It then dispatches callbacks to clients who have requested * It then dispatches callbacks to clients who have requested
* to be notified when a particular txid is included in a block. * to be notified when a particular txid is included in a block.
*/ */
void on_applied_block(const signed_block &b); void on_applied_block(const signed_block &b);
private: private:
@ -226,60 +225,60 @@ private:
}; };
/** /**
* @brief The network_node_api class allows maintenance of p2p connections. * @brief The network_node_api class allows maintenance of p2p connections.
*/ */
class network_node_api { class network_node_api {
public: public:
network_node_api(application &a); network_node_api(application &a);
/** /**
* @brief Return general network information, such as p2p port * @brief Return general network information, such as p2p port
*/ */
fc::variant_object get_info() const; fc::variant_object get_info() const;
/** /**
* @brief add_node Connect to a new peer * @brief add_node Connect to a new peer
* @param ep The IP/Port of the peer to connect to * @param ep The IP/Port of the peer to connect to
*/ */
void add_node(const fc::ip::endpoint &ep); void add_node(const fc::ip::endpoint &ep);
/** /**
* @brief Get status of all current connections to peers * @brief Get status of all current connections to peers
*/ */
std::vector<net::peer_status> get_connected_peers() const; std::vector<net::peer_status> get_connected_peers() const;
/** /**
* @brief Get advanced node parameters, such as desired and max * @brief Get advanced node parameters, such as desired and max
* number of connections * number of connections
*/ */
fc::variant_object get_advanced_node_parameters() const; fc::variant_object get_advanced_node_parameters() const;
/** /**
* @brief Set advanced node parameters, such as desired and max * @brief Set advanced node parameters, such as desired and max
* number of connections * number of connections
* @param params a JSON object containing the name/value pairs for the parameters to set * @param params a JSON object containing the name/value pairs for the parameters to set
*/ */
void set_advanced_node_parameters(const fc::variant_object &params); void set_advanced_node_parameters(const fc::variant_object &params);
/** /**
* @brief Return list of potential peers * @brief Return list of potential peers
*/ */
std::vector<net::potential_peer_record> get_potential_peers() const; std::vector<net::potential_peer_record> get_potential_peers() const;
/** /**
* @brief Return list of pending transactions. * @brief Return list of pending transactions.
*/ */
map<transaction_id_type, signed_transaction> list_pending_transactions() const; map<transaction_id_type, signed_transaction> list_pending_transactions() const;
/** /**
* @brief Subscribes caller for notifications about pending transactions. * @brief Subscribes caller for notifications about pending transactions.
* @param callback a functional object which will be called when new transaction is created. * @param callback a functional object which will be called when new transaction is created.
*/ */
void subscribe_to_pending_transactions(std::function<void(const variant &)> callback); void subscribe_to_pending_transactions(std::function<void(const variant &)> callback);
/** /**
* @brief Unsubscribes caller from notifications about pending transactions. * @brief Unsubscribes caller from notifications about pending transactions.
*/ */
void unsubscribe_from_pending_transactions(); void unsubscribe_from_pending_transactions();
private: private:
@ -290,61 +289,34 @@ private:
std::function<void(const variant &)> _on_pending_transaction; std::function<void(const variant &)> _on_pending_transaction;
}; };
class crypto_api {
public:
crypto_api();
fc::ecc::commitment_type blind(const fc::ecc::blind_factor_type &blind, uint64_t value);
fc::ecc::blind_factor_type blind_sum(const std::vector<blind_factor_type> &blinds_in, uint32_t non_neg);
bool verify_sum(const std::vector<commitment_type> &commits_in, const std::vector<commitment_type> &neg_commits_in, int64_t excess);
verify_range_result verify_range(const fc::ecc::commitment_type &commit, const std::vector<char> &proof);
std::vector<char> range_proof_sign(uint64_t min_value,
const commitment_type &commit,
const blind_factor_type &commit_blind,
const blind_factor_type &nonce,
int8_t base10_exp,
uint8_t min_bits,
uint64_t actual_value);
verify_range_proof_rewind_result verify_range_proof_rewind(const blind_factor_type &nonce,
const fc::ecc::commitment_type &commit,
const std::vector<char> &proof);
range_proof_info range_get_info(const std::vector<char> &proof);
};
/** /**
* @brief * @brief
*/ */
class asset_api { class asset_api {
public: public:
asset_api(graphene::app::application &app); asset_api(graphene::app::application &app);
~asset_api(); ~asset_api();
/** /**
* @brief Get asset holders for a specific asset * @brief Get asset holders for a specific asset
* @param asset The specific asset id or symbol * @param asset The specific asset id or symbol
* @param start The start index * @param start The start index
* @param limit Maximum limit must not exceed 100 * @param limit Maximum limit must not exceed 100
* @return A list of asset holders for the specified asset * @return A list of asset holders for the specified asset
*/ */
vector<account_asset_balance> get_asset_holders(std::string asset, uint32_t start, uint32_t limit) const; vector<account_asset_balance> get_asset_holders(std::string asset, uint32_t start, uint32_t limit) const;
/** /**
* @brief Get asset holders count for a specific asset * @brief Get asset holders count for a specific asset
* @param asset The specific asset id or symbol * @param asset The specific asset id or symbol
* @return Holders count for the specified asset * @return Holders count for the specified asset
*/ */
int get_asset_holders_count(std::string asset) const; int get_asset_holders_count(std::string asset) const;
/** /**
* @brief Get all asset holders * @brief Get all asset holders
* @return A list of all asset holders * @return A list of all asset holders
*/ */
vector<asset_holders> get_all_asset_holders() const; vector<asset_holders> get_all_asset_holders() const;
uint32_t api_limit_get_asset_holders = 100; uint32_t api_limit_get_asset_holders = 100;
@ -360,30 +332,29 @@ extern template class fc::api<graphene::app::block_api>;
extern template class fc::api<graphene::app::network_broadcast_api>; extern template class fc::api<graphene::app::network_broadcast_api>;
extern template class fc::api<graphene::app::network_node_api>; extern template class fc::api<graphene::app::network_node_api>;
extern template class fc::api<graphene::app::history_api>; extern template class fc::api<graphene::app::history_api>;
extern template class fc::api<graphene::app::crypto_api>;
extern template class fc::api<graphene::app::asset_api>; extern template class fc::api<graphene::app::asset_api>;
extern template class fc::api<graphene::debug_witness::debug_api>; extern template class fc::api<graphene::debug_witness::debug_api>;
namespace graphene { namespace app { namespace graphene { namespace app {
/** /**
* @brief The login_api class implements the bottom layer of the RPC API * @brief The login_api class implements the bottom layer of the RPC API
* *
* All other APIs must be requested from this API. * All other APIs must be requested from this API.
*/ */
class login_api { class login_api {
public: public:
login_api(application &a); login_api(application &a);
~login_api(); ~login_api();
/** /**
* @brief Authenticate to the RPC server * @brief Authenticate to the RPC server
* @param user Username to login with * @param user Username to login with
* @param password Password to login with * @param password Password to login with
* @return True if logged in successfully; false otherwise * @return True if logged in successfully; false otherwise
* *
* @note This must be called prior to requesting other APIs. Other APIs may not be accessible until the client * @note This must be called prior to requesting other APIs. Other APIs may not be accessible until the client
* has sucessfully authenticated. * has sucessfully authenticated.
*/ */
bool login(const string &user, const string &password); bool login(const string &user, const string &password);
/// @brief Retrieve the network block API /// @brief Retrieve the network block API
fc::api<block_api> block() const; fc::api<block_api> block() const;
@ -395,8 +366,6 @@ public:
fc::api<history_api> history() const; fc::api<history_api> history() const;
/// @brief Retrieve the network node API /// @brief Retrieve the network node API
fc::api<network_node_api> network_node() const; fc::api<network_node_api> network_node() const;
/// @brief Retrieve the cryptography API
fc::api<crypto_api> crypto() const;
/// @brief Retrieve the asset API /// @brief Retrieve the asset API
fc::api<asset_api> asset() const; fc::api<asset_api> asset() const;
/// @brief Retrieve the debug API (if available) /// @brief Retrieve the debug API (if available)
@ -405,6 +374,8 @@ public:
fc::api<graphene::bookie::bookie_api> bookie() const; fc::api<graphene::bookie::bookie_api> bookie() const;
/// @brief Retrieve the affiliate_stats API (if available) /// @brief Retrieve the affiliate_stats API (if available)
fc::api<graphene::affiliate_stats::affiliate_stats_api> affiliate_stats() const; fc::api<graphene::affiliate_stats::affiliate_stats_api> affiliate_stats() const;
/// @brief Retrieve the sidechain_api API (if available)
fc::api<graphene::peerplays_sidechain::sidechain_api> sidechain() const;
/// @brief Called to enable an API, not reflected. /// @brief Called to enable an API, not reflected.
void enable_api(const string &api_name); void enable_api(const string &api_name);
@ -416,11 +387,11 @@ private:
optional<fc::api<network_broadcast_api>> _network_broadcast_api; optional<fc::api<network_broadcast_api>> _network_broadcast_api;
optional<fc::api<network_node_api>> _network_node_api; optional<fc::api<network_node_api>> _network_node_api;
optional<fc::api<history_api>> _history_api; optional<fc::api<history_api>> _history_api;
optional<fc::api<crypto_api>> _crypto_api;
optional<fc::api<asset_api>> _asset_api; optional<fc::api<asset_api>> _asset_api;
optional<fc::api<graphene::debug_witness::debug_api>> _debug_api; optional<fc::api<graphene::debug_witness::debug_api>> _debug_api;
optional<fc::api<graphene::bookie::bookie_api>> _bookie_api; optional<fc::api<graphene::bookie::bookie_api>> _bookie_api;
optional<fc::api<graphene::affiliate_stats::affiliate_stats_api>> _affiliate_stats_api; optional<fc::api<graphene::affiliate_stats::affiliate_stats_api>> _affiliate_stats_api;
optional<fc::api<graphene::peerplays_sidechain::sidechain_api>> _sidechain_api;
}; };
}} // namespace graphene::app }} // namespace graphene::app
@ -473,15 +444,6 @@ FC_API(graphene::app::network_node_api,
(subscribe_to_pending_transactions) (subscribe_to_pending_transactions)
(unsubscribe_from_pending_transactions)) (unsubscribe_from_pending_transactions))
FC_API(graphene::app::crypto_api,
(blind)
(blind_sum)
(verify_sum)
(verify_range)
(range_proof_sign)
(verify_range_proof_rewind)
(range_get_info))
FC_API(graphene::app::asset_api, FC_API(graphene::app::asset_api,
(get_asset_holders) (get_asset_holders)
(get_asset_holders_count) (get_asset_holders_count)
@ -494,10 +456,10 @@ FC_API(graphene::app::login_api,
(database) (database)
(history) (history)
(network_node) (network_node)
(crypto)
(asset) (asset)
(debug) (debug)
(bookie) (bookie)
(affiliate_stats)) (affiliate_stats)
(sidechain))
// clang-format on // clang-format on

View file

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

View file

@ -25,7 +25,7 @@
#include <graphene/app/full_account.hpp> #include <graphene/app/full_account.hpp>
#include <graphene/protocol/types.hpp> #include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/database.hpp> #include <graphene/chain/database.hpp>
@ -56,8 +56,8 @@
#include <graphene/chain/custom_permission_object.hpp> #include <graphene/chain/custom_permission_object.hpp>
#include <graphene/chain/nft_object.hpp> #include <graphene/chain/nft_object.hpp>
#include <graphene/chain/offer_object.hpp> #include <graphene/chain/offer_object.hpp>
#include <graphene/chain/votes_info.hpp>
#include <graphene/chain/voters_info.hpp> #include <graphene/chain/voters_info.hpp>
#include <graphene/chain/votes_info.hpp>
#include <graphene/market_history/market_history_plugin.hpp> #include <graphene/market_history/market_history_plugin.hpp>
@ -82,6 +82,15 @@ using namespace std;
class database_api_impl; class database_api_impl;
struct signed_block_with_info : public signed_block {
signed_block_with_info();
signed_block_with_info(const signed_block &block);
signed_block_with_info(const signed_block_with_info &block) = default;
block_id_type block_id;
public_key_type signing_key;
vector<transaction_id_type> transaction_ids;
};
struct order { struct order {
double price; double price;
double quote; double quote;
@ -130,6 +139,14 @@ struct gpos_info {
share_type account_vested_balance; share_type account_vested_balance;
}; };
struct version_info {
string version;
string git_revision;
string built;
string openssl;
string boost;
};
/** /**
* @brief The database_api class implements the RPC API for the chain database. * @brief The database_api class implements the RPC API for the chain database.
* *
@ -181,10 +198,10 @@ public:
optional<block_header> get_block_header(uint32_t block_num) const; optional<block_header> get_block_header(uint32_t block_num) const;
/** /**
* @brief Retrieve multiple block header by block numbers * @brief Retrieve multiple block header by block numbers
* @param block_num vector containing heights of the block whose header should be returned * @param block_num vector containing heights of the block whose header should be returned
* @return array of headers of the referenced blocks, or null if no matching block was found * @return array of headers of the referenced blocks, or null if no matching block was found
*/ */
map<uint32_t, optional<block_header>> get_block_header_batch(const vector<uint32_t> block_nums) const; map<uint32_t, optional<block_header>> get_block_header_batch(const vector<uint32_t> block_nums) const;
/** /**
@ -194,6 +211,13 @@ public:
*/ */
optional<signed_block> get_block(uint32_t block_num) const; optional<signed_block> get_block(uint32_t block_num) const;
/**
* @brief Retrieve a full, signed block, with some extra info
* @param block_num Height of the block to be returned
* @return the referenced block, or null if no matching block was found
*/
optional<signed_block_with_info> get_block2(uint32_t block_num) const;
/** /**
* @brief Retrieve a list of signed blocks * @brief Retrieve a list of signed blocks
* @param block_num_from start * @param block_num_from start
@ -218,6 +242,11 @@ public:
// Globals // // Globals //
///////////// /////////////
/**
* @brief Retrieve the @ref version_info associated with the witness node
*/
version_info get_version_info() const;
/** /**
* @brief Retrieve the @ref chain_property_object associated with the chain * @brief Retrieve the @ref chain_property_object associated with the chain
*/ */
@ -250,12 +279,12 @@ public:
vector<vector<account_id_type>> get_key_references(vector<public_key_type> key) const; vector<vector<account_id_type>> get_key_references(vector<public_key_type> key) const;
/** /**
* Determine whether a textual representation of a public key * Determine whether a textual representation of a public key
* (in Base-58 format) is *currently* linked * (in Base-58 format) is *currently* linked
* to any *registered* (i.e. non-stealth) account on the blockchain * to any *registered* (i.e. non-stealth) account on the blockchain
* @param public_key Public key * @param public_key Public key
* @return Whether a public key is known * @return Whether a public key is known
*/ */
bool is_public_key_registered(string public_key) const; bool is_public_key_registered(string public_key) const;
////////////// //////////////
@ -662,6 +691,32 @@ public:
*/ */
uint64_t get_son_count() const; uint64_t get_son_count() const;
/**
* @brief Get list of active sons
* @return List of active SONs
*/
flat_map<sidechain_type, vector<son_sidechain_info>> get_active_sons();
/**
* @brief Get list of active sons
* @param sidechain Sidechain type [bitcoin|ethereum|hive]
* @return List of active SONs
*/
vector<son_sidechain_info> get_active_sons_by_sidechain(sidechain_type sidechain);
/**
* @brief Get SON network status
* @return SON network status description for a given sidechain type
*/
map<sidechain_type, map<son_id_type, string>> get_son_network_status();
/**
* @brief Get SON network status
* @param sidechain Sidechain type [bitcoin|ethereum|hive]
* @return SON network status description for a given sidechain type
*/
map<son_id_type, string> get_son_network_status_by_sidechain(sidechain_type sidechain);
///////////////////////// /////////////////////////
// SON Wallets // // SON Wallets //
///////////////////////// /////////////////////////
@ -864,15 +919,6 @@ public:
*/ */
vector<proposal_object> get_proposed_transactions(const std::string account_id_or_name) const; vector<proposal_object> get_proposed_transactions(const std::string account_id_or_name) const;
//////////////////////
// Blinded balances //
//////////////////////
/**
* @return the set of blinded balance objects by commitment ID
*/
vector<blinded_balance_object> get_blinded_balances(const flat_set<commitment_type> &commitments) const;
///////////////// /////////////////
// Tournaments // // Tournaments //
///////////////// /////////////////
@ -997,14 +1043,25 @@ public:
* @brief Returns list of all available NTF's * @brief Returns list of all available NTF's
* @return List of all available NFT's * @return List of all available NFT's
*/ */
vector<nft_object> nft_get_all_tokens() const; vector<nft_object> nft_get_all_tokens(const nft_id_type lower_id, uint32_t limit) const;
/** /**
* @brief Returns NFT's owned by owner * @brief Returns NFT's owned by owner
* @param owner NFT owner * @param owner NFT owner
* @param lower_id ID of the first NFT to return
* @param limit Maximum number of results to return
* @return List of NFT owned by owner * @return List of NFT owned by owner
*/ */
vector<nft_object> nft_get_tokens_by_owner(const account_id_type owner) const; vector<nft_object> nft_get_tokens_by_owner(const account_id_type owner, const nft_id_type lower_id, uint32_t limit) const;
/**
* @brief Returns NFT metadata owned by owner
* @param owner NFT owner
* @param lower_id ID of the first NFT metadata to return
* @param limit Maximum number of results to return
* @return List of NFT owned by owner
*/
vector<nft_metadata_object> nft_get_metadata_by_owner(const account_id_type owner, const nft_metadata_id_type lower_id, uint32_t limit) const;
////////////////// //////////////////
// MARKET PLACE // // MARKET PLACE //
@ -1034,12 +1091,15 @@ extern template class fc::api<graphene::app::database_api>;
// clang-format off // clang-format off
FC_REFLECT_DERIVED(graphene::app::signed_block_with_info, (graphene::chain::signed_block), (block_id)(signing_key)(transaction_ids));
FC_REFLECT(graphene::app::order, (price)(quote)(base)); FC_REFLECT(graphene::app::order, (price)(quote)(base));
FC_REFLECT(graphene::app::order_book, (base)(quote)(bids)(asks)); FC_REFLECT(graphene::app::order_book, (base)(quote)(bids)(asks));
FC_REFLECT(graphene::app::market_ticker, (base)(quote)(latest)(lowest_ask)(highest_bid)(percent_change)(base_volume)(quote_volume)); FC_REFLECT(graphene::app::market_ticker, (base)(quote)(latest)(lowest_ask)(highest_bid)(percent_change)(base_volume)(quote_volume));
FC_REFLECT(graphene::app::market_volume, (base)(quote)(base_volume)(quote_volume)); FC_REFLECT(graphene::app::market_volume, (base)(quote)(base_volume)(quote_volume));
FC_REFLECT(graphene::app::market_trade, (date)(price)(amount)(value)); FC_REFLECT(graphene::app::market_trade, (date)(price)(amount)(value));
FC_REFLECT(graphene::app::gpos_info, (vesting_factor)(award)(total_amount)(current_subperiod)(last_voted_time)(allowed_withdraw_amount)(account_vested_balance)); FC_REFLECT(graphene::app::gpos_info, (vesting_factor)(award)(total_amount)(current_subperiod)(last_voted_time)(allowed_withdraw_amount)(account_vested_balance));
FC_REFLECT(graphene::app::version_info, (version)(git_revision)(built)(openssl)(boost));
FC_API(graphene::app::database_api, FC_API(graphene::app::database_api,
// Objects // Objects
@ -1055,11 +1115,13 @@ FC_API(graphene::app::database_api,
(get_block_header) (get_block_header)
(get_block_header_batch) (get_block_header_batch)
(get_block) (get_block)
(get_block2)
(get_blocks) (get_blocks)
(get_transaction) (get_transaction)
(get_recent_transaction_by_id) (get_recent_transaction_by_id)
// Globals // Globals
(get_version_info)
(get_chain_properties) (get_chain_properties)
(get_global_properties) (get_global_properties)
(get_config) (get_config)
@ -1143,6 +1205,10 @@ FC_API(graphene::app::database_api,
(get_son_by_account) (get_son_by_account)
(lookup_son_accounts) (lookup_son_accounts)
(get_son_count) (get_son_count)
(get_active_sons)
(get_active_sons_by_sidechain)
(get_son_network_status)
(get_son_network_status_by_sidechain)
// SON wallets // SON wallets
(get_active_son_wallet) (get_active_son_wallet)
@ -1183,9 +1249,6 @@ FC_API(graphene::app::database_api,
// Proposed transactions // Proposed transactions
(get_proposed_transactions) (get_proposed_transactions)
// Blinded balances
(get_blinded_balances)
// Tournaments // Tournaments
(get_tournaments_in_state) (get_tournaments_in_state)
(get_tournaments_by_state) (get_tournaments_by_state)
@ -1216,6 +1279,7 @@ FC_API(graphene::app::database_api,
(nft_token_of_owner_by_index) (nft_token_of_owner_by_index)
(nft_get_all_tokens) (nft_get_all_tokens)
(nft_get_tokens_by_owner) (nft_get_tokens_by_owner)
(nft_get_metadata_by_owner)
// Marketplace // Marketplace
(list_offers) (list_offers)

View file

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

View file

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

View file

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

View file

@ -53,7 +53,54 @@ void verify_authority_accounts( const database& db, const authority& a )
} }
} }
void verify_account_votes( const database& db, const account_options& options ) // Overwrites the num_son values from the origin to the destination for those sidechains which are found in the origin.
// Keeps the values of num_son for the sidechains which are found in the destination, but not in the origin.
// Returns false if an error is detected.
bool merge_num_sons( flat_map<sidechain_type, uint16_t>& destination,
const flat_map<sidechain_type, uint16_t>& origin,
fc::optional<time_point_sec> head_block_time = {})
{
const auto active_sidechains = head_block_time.valid() ? active_sidechain_types(*head_block_time) : all_sidechain_types;
bool success = true;
for (const auto &ns : origin)
{
destination[ns.first] = ns.second;
if (active_sidechains.find(ns.first) == active_sidechains.end())
{
success = false;
}
}
return success;
}
flat_map<sidechain_type, uint16_t> count_SON_votes_per_sidechain( const flat_set<vote_id_type>& votes )
{
flat_map<sidechain_type, uint16_t> SON_votes_per_sidechain = account_options::ext::empty_num_son();
for (const auto &vote : votes)
{
switch (vote.type())
{
case vote_id_type::son_bitcoin:
SON_votes_per_sidechain[sidechain_type::bitcoin]++;
break;
case vote_id_type::son_hive:
SON_votes_per_sidechain[sidechain_type::hive]++;
break;
case vote_id_type::son_ethereum:
SON_votes_per_sidechain[sidechain_type::ethereum]++;
break;
default:
break;
}
}
return SON_votes_per_sidechain;
}
void verify_account_votes( const database& db, const account_options& options, fc::optional<account_object> account = {} )
{ {
// ensure account's votes satisfy requirements // ensure account's votes satisfy requirements
// NB only the part of vote checking that requires chain state is here, // NB only the part of vote checking that requires chain state is here,
@ -62,10 +109,47 @@ void verify_account_votes( const database& db, const account_options& options )
const auto& gpo = db.get_global_properties(); const auto& gpo = db.get_global_properties();
const auto& chain_params = gpo.parameters; const auto& chain_params = gpo.parameters;
FC_ASSERT( db.find_object(options.voting_account), "Invalid proxy account specified." );
FC_ASSERT( options.num_witness <= chain_params.maximum_witness_count, FC_ASSERT( options.num_witness <= chain_params.maximum_witness_count,
"Voted for more witnesses than currently allowed (${c})", ("c", chain_params.maximum_witness_count) ); "Voted for more witnesses than currently allowed (${c})", ("c", chain_params.maximum_witness_count) );
FC_ASSERT( options.num_committee <= chain_params.maximum_committee_count, FC_ASSERT( options.num_committee <= chain_params.maximum_committee_count,
"Voted for more committee members than currently allowed (${c})", ("c", chain_params.maximum_committee_count) ); "Voted for more committee members than currently allowed (${c})", ("c", chain_params.maximum_committee_count) );
FC_ASSERT( chain_params.extensions.value.maximum_son_count.valid() , "Invalid maximum son count" );
flat_map<sidechain_type, uint16_t> merged_num_sons = account_options::ext::empty_num_son();
// Merge with existing account if exists
if ( account.valid() && account->options.extensions.value.num_son.valid())
{
merge_num_sons( merged_num_sons, *account->options.extensions.value.num_son, db.head_block_time() );
}
// Apply update operation on top
if ( options.extensions.value.num_son.valid() )
{
merge_num_sons( merged_num_sons, *options.extensions.value.num_son, db.head_block_time() );
}
for(const auto& num_sons : merged_num_sons)
{
FC_ASSERT( num_sons.second <= *chain_params.extensions.value.maximum_son_count,
"Voted for more sons than currently allowed (${c})", ("c", *chain_params.extensions.value.maximum_son_count) );
}
// Count the votes for SONs and confirm that the account did not vote for less SONs than num_son
flat_map<sidechain_type, uint16_t> SON_votes_per_sidechain = count_SON_votes_per_sidechain(options.votes);
for (const auto& number_of_votes : SON_votes_per_sidechain)
{
// Number of votes of account_options are also checked in account_options::do_evaluate,
// but there we are checking the value before merging num_sons, so the values should be checked again
const auto sidechain = number_of_votes.first;
FC_ASSERT( number_of_votes.second >= merged_num_sons[sidechain],
"Voted for less sons than specified in num_son (votes ${v} < num_son ${ns}) for sidechain ${s}",
("v", number_of_votes.second) ("ns", merged_num_sons[sidechain]) ("s", sidechain) );
}
FC_ASSERT( db.find_object(options.voting_account), "Invalid proxy account specified." ); FC_ASSERT( db.find_object(options.voting_account), "Invalid proxy account specified." );
uint32_t max_vote_id = gpo.next_available_vote_id; uint32_t max_vote_id = gpo.next_available_vote_id;
@ -179,6 +263,13 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio
obj.owner = o.owner; obj.owner = o.owner;
obj.active = o.active; obj.active = o.active;
obj.options = o.options; obj.options = o.options;
obj.options.extensions.value.num_son = account_options::ext::empty_num_son();
if ( o.options.extensions.value.num_son.valid() )
{
merge_num_sons( *obj.options.extensions.value.num_son, *o.options.extensions.value.num_son );
}
obj.statistics = d.create<account_statistics_object>([&obj](account_statistics_object& s){ obj.statistics = d.create<account_statistics_object>([&obj](account_statistics_object& s){
s.owner = obj.id; s.owner = obj.id;
s.name = obj.name; s.name = obj.name;
@ -214,7 +305,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 if( dynamic_properties.accounts_registered_this_interval % global_properties.parameters.accounts_per_fee_scale == 0
&& global_properties.parameters.account_fee_scale_bitshifts != 0 ) && global_properties.parameters.account_fee_scale_bitshifts != 0 )
{ {
d.modify(global_properties, [](global_property_object& p) { d.modify(global_properties, [&dynamic_properties](global_property_object& p) {
p.parameters.current_fees->get<account_create_operation>().basic_fee <<= p.parameters.account_fee_scale_bitshifts; p.parameters.current_fees->get<account_create_operation>().basic_fee <<= p.parameters.account_fee_scale_bitshifts;
}); });
} }
@ -278,7 +369,7 @@ void_result account_update_evaluator::do_evaluate( const account_update_operatio
acnt = &o.account(d); acnt = &o.account(d);
if( o.new_options.valid() ) if( o.new_options.valid() )
verify_account_votes( d, *o.new_options ); verify_account_votes( d, *o.new_options, *acnt );
return void_result(); return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) } } FC_CAPTURE_AND_RETHROW( (o) ) }
@ -317,7 +408,31 @@ void_result account_update_evaluator::do_apply( const account_update_operation&
a.active = *o.active; a.active = *o.active;
a.top_n_control_flags = 0; a.top_n_control_flags = 0;
} }
if( o.new_options ) a.options = *o.new_options;
// New num_son structure initialized to 0
flat_map<sidechain_type, uint16_t> new_num_son = account_options::ext::empty_num_son();
// If num_son of existing object is valid, we should merge the existing data
if ( a.options.extensions.value.num_son.valid() )
{
merge_num_sons( new_num_son, *a.options.extensions.value.num_son );
}
// If num_son of the operation are valid, they should merge the existing data
if ( o.new_options )
{
const auto new_options = *o.new_options;
if ( new_options.extensions.value.num_son.valid() )
{
merge_num_sons( new_num_son, *new_options.extensions.value.num_son );
}
a.options = *o.new_options;
}
a.options.extensions.value.num_son = new_num_son;
if( o.extensions.value.owner_special_authority.valid() ) if( o.extensions.value.owner_special_authority.valid() )
{ {
a.owner_special_authority = *(o.extensions.value.owner_special_authority); a.owner_special_authority = *(o.extensions.value.owner_special_authority);

View file

@ -36,10 +36,10 @@ share_type cut_fee(share_type a, uint16_t p)
if( p == GRAPHENE_100_PERCENT ) if( p == GRAPHENE_100_PERCENT )
return a; return a;
fc::uint128_t r = a.value; fc::uint128 r(a.value);
r *= p; r *= p;
r /= GRAPHENE_100_PERCENT; r /= GRAPHENE_100_PERCENT;
return r; return r.to_uint64();
} }
void account_balance_object::adjust_balance(const asset& delta) void account_balance_object::adjust_balance(const asset& delta)
@ -142,12 +142,7 @@ set<address> account_member_index::get_address_members(const account_object& a)c
return result; return result;
} }
void account_member_index::object_loaded(const object& obj) void account_member_index::object_inserted(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 assert( dynamic_cast<const account_object*>(&obj) ); // for debug only
const account_object& a = static_cast<const account_object&>(obj); const account_object& a = static_cast<const account_object&>(obj);
@ -261,10 +256,7 @@ void account_member_index::object_modified(const object& after)
} }
void account_referrer_index::object_loaded( const object& obj ) void account_referrer_index::object_inserted( const object& obj )
{
}
void account_referrer_index::object_created( const object& obj )
{ {
} }
void account_referrer_index::object_removed( const object& obj ) void account_referrer_index::object_removed( const object& obj )
@ -280,12 +272,7 @@ void account_referrer_index::object_modified( const object& after )
const uint8_t balances_by_account_index::bits = 20; const uint8_t balances_by_account_index::bits = 20;
const uint64_t balances_by_account_index::mask = (1ULL << balances_by_account_index::bits) - 1; const uint64_t balances_by_account_index::mask = (1ULL << balances_by_account_index::bits) - 1;
void balances_by_account_index::object_loaded( const object& obj ) void balances_by_account_index::object_inserted( 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 ); const auto& abo = dynamic_cast< const account_balance_object& >( obj );
while( balances.size() < (abo.owner.instance.value >> bits) + 1 ) 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) ); //ilog("Paying ${p} of ${P} for ${s} of ${r}", ("p",payout.to_uint64())("P",to_pay.value)("s",share)("r",remaining) );
remaining -= share; remaining -= share;
} }
FC_ASSERT( payout <= to_pay ); FC_ASSERT( payout.to_uint64() <= to_pay );
if( payout > 0 ) if( payout > 0 )
{ {
if ( accumulator.find(affiliate) == accumulator.end() ) if ( accumulator.find(affiliate) == accumulator.end() )
accumulator[affiliate] = payout; accumulator[affiliate] = payout.to_uint64();
else else
accumulator[affiliate] += payout; accumulator[affiliate] += payout.to_uint64();
to_pay -= payout; to_pay -= payout.to_uint64();
paid += payout; paid += payout.to_uint64();
} }
} }
FC_ASSERT( to_pay == 0 ); 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; fee_is_odd = core_fee_paid.value & 1;
core_fee_paid -= core_fee_paid.value/2; core_fee_paid -= core_fee_paid.value/2;
consensus_evaluator::pay_fee(); generic_evaluator::pay_fee();
} }
object_id_type asset_create_evaluator::do_apply( const asset_create_operation& op ) 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; fee_is_odd = core_fee_paid.value & 1;
core_fee_paid -= core_fee_paid.value/2; core_fee_paid -= core_fee_paid.value/2;
consensus_evaluator::pay_fee(); generic_evaluator::pay_fee();
} }
object_id_type lottery_asset_create_evaluator::do_apply( const lottery_asset_create_operation& op ) object_id_type lottery_asset_create_evaluator::do_apply( const lottery_asset_create_operation& op )

View file

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

View file

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

View file

@ -541,7 +541,7 @@ void betting_market_group_object::dispatch_new_status(database& db, betting_mark
} } // graphene::chain } } // graphene::chain
namespace fc { namespace fc {
// Manually reflect betting_market_group_object to variant to properly reflect "state" // Manually reflect betting_market_group_object to variant to properly reflect "state"
void to_variant(const graphene::chain::betting_market_group_object& betting_market_group_obj, fc::variant& v, uint32_t max_depth) void to_variant(const graphene::chain::betting_market_group_object& betting_market_group_obj, fc::variant& v, uint32_t max_depth)
{ {

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 - 1;
amount_to_match_128 /= backer_multiplier - GRAPHENE_BETTING_ODDS_PRECISION; amount_to_match_128 /= backer_multiplier - GRAPHENE_BETTING_ODDS_PRECISION;
} }
return amount_to_match_128; return amount_to_match_128.to_uint64();
} }
share_type bet_object::get_approximate_matching_amount(bool round_up /* = false */) const share_type bet_object::get_approximate_matching_amount(bool round_up /* = false */) const
@ -466,7 +466,7 @@ void betting_market_object::on_canceled_event(database& db)
} } // graphene::chain } } // graphene::chain
namespace fc { namespace fc {
// Manually reflect betting_market_object to variant to properly reflect "state" // Manually reflect betting_market_object to variant to properly reflect "state"
void to_variant(const graphene::chain::betting_market_object& event_obj, fc::variant& v, uint32_t max_depth) void to_variant(const graphene::chain::betting_market_object& event_obj, fc::variant& v, uint32_t max_depth)
{ {
@ -493,4 +493,3 @@ namespace fc {
const_cast<int*>(event_obj.my->state_machine.current_state())[0] = (int)status; const_cast<int*>(event_obj.my->state_machine.current_state())[0] = (int)status;
} }
} //end namespace fc } //end namespace fc

View file

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

View file

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

View file

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

View file

@ -22,7 +22,7 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include <graphene/chain/exceptions.hpp> #include <graphene/chain/exceptions.hpp>
#include <graphene/protocol/confidential.hpp> #include <graphene/chain/protocol/confidential.hpp>
#include <graphene/chain/confidential_evaluator.hpp> #include <graphene/chain/confidential_evaluator.hpp>
#include <graphene/chain/confidential_object.hpp> #include <graphene/chain/confidential_object.hpp>
#include <graphene/chain/database.hpp> #include <graphene/chain/database.hpp>
@ -33,149 +33,163 @@ namespace graphene { namespace chain {
void_result transfer_to_blind_evaluator::do_evaluate( const transfer_to_blind_operation& o ) void_result transfer_to_blind_evaluator::do_evaluate( const transfer_to_blind_operation& o )
{ try { { try {
const auto& d = db(); const auto& d = db();
if( d.head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME )
{
const auto& atype = o.amount.asset_id(d);
FC_ASSERT( atype.allow_confidential() );
FC_ASSERT( !atype.is_transfer_restricted() );
FC_ASSERT( !(atype.options.flags & white_list) );
const auto& atype = o.amount.asset_id(db()); for( const auto& out : o.outputs )
FC_ASSERT( atype.allow_confidential() ); {
FC_ASSERT( !atype.is_transfer_restricted() ); for( const auto& a : out.owner.account_auths )
FC_ASSERT( !(atype.options.flags & white_list) ); a.first(d); // verify all accounts exist and are valid
}
}
for( const auto& out : o.outputs ) return void_result();
{
for( const auto& a : out.owner.account_auths )
a.first(d); // verify all accounts exist and are valid
}
return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) } } FC_CAPTURE_AND_RETHROW( (o) ) }
void_result transfer_to_blind_evaluator::do_apply( const transfer_to_blind_operation& o ) void_result transfer_to_blind_evaluator::do_apply( const transfer_to_blind_operation& o )
{ try { { try {
db().adjust_balance( o.from, -o.amount ); if( db().head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
db().adjust_balance(o.from, -o.amount);
const auto& add = o.amount.asset_id(db()).dynamic_asset_data_id(db()); // verify fee is a legit asset const auto &add = o.amount.asset_id(db()).dynamic_asset_data_id(db()); // verify fee is a legit asset
db().modify( add, [&]( asset_dynamic_data_object& obj ){ db().modify(add, [&](asset_dynamic_data_object &obj) {
obj.confidential_supply += o.amount.amount; obj.confidential_supply += o.amount.amount;
FC_ASSERT( obj.confidential_supply >= 0 ); FC_ASSERT(obj.confidential_supply >= 0);
}); });
for( const auto& out : o.outputs ) for (const auto &out : o.outputs) {
{ db().create<blinded_balance_object>([&](blinded_balance_object &obj) {
db().create<blinded_balance_object>( [&]( blinded_balance_object& obj ){ obj.asset_id = o.amount.asset_id;
obj.asset_id = o.amount.asset_id; obj.owner = out.owner;
obj.owner = out.owner; obj.commitment = out.commitment;
obj.commitment = out.commitment; });
}); }
} }
return void_result(); return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) } } FC_CAPTURE_AND_RETHROW( (o) ) }
void transfer_to_blind_evaluator::pay_fee() void transfer_to_blind_evaluator::pay_fee()
{ {
if( db().head_block_time() >= HARDFORK_563_TIME ) const auto& d = db();
pay_fba_fee( fba_accumulator_id_transfer_to_blind ); if( d.head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
else if (d.head_block_time() >= HARDFORK_563_TIME)
consensus_evaluator::pay_fee(); pay_fba_fee(fba_accumulator_id_transfer_to_blind);
else
generic_evaluator::pay_fee();
}
} }
void_result transfer_from_blind_evaluator::do_evaluate( const transfer_from_blind_operation& o ) void_result transfer_from_blind_evaluator::do_evaluate( const transfer_from_blind_operation& o )
{ try { { try {
const auto& d = db(); const auto& d = db();
o.fee.asset_id(d); // verify fee is a legit asset if( d.head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
const auto& bbi = d.get_index_type<blinded_balance_index>(); o.fee.asset_id(d); // verify fee is a legit asset
const auto& cidx = bbi.indices().get<by_commitment>(); const auto &bbi = d.get_index_type<blinded_balance_index>();
for( const auto& in : o.inputs ) const auto &cidx = bbi.indices().get<by_commitment>();
{ for (const auto &in : o.inputs) {
auto itr = cidx.find( in.commitment ); auto itr = cidx.find(in.commitment);
FC_ASSERT( itr != cidx.end() ); FC_ASSERT(itr != cidx.end());
FC_ASSERT( itr->asset_id == o.fee.asset_id ); FC_ASSERT(itr->asset_id == o.fee.asset_id);
FC_ASSERT( itr->owner == in.owner ); FC_ASSERT(itr->owner == in.owner);
} }
return void_result(); }
return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) } } FC_CAPTURE_AND_RETHROW( (o) ) }
void_result transfer_from_blind_evaluator::do_apply( const transfer_from_blind_operation& o ) void_result transfer_from_blind_evaluator::do_apply( const transfer_from_blind_operation& o )
{ try { { try {
db().adjust_balance( o.fee_payer(), o.fee ); if( db().head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
db().adjust_balance( o.to, o.amount ); db().adjust_balance(o.fee_payer(), o.fee);
const auto& bbi = db().get_index_type<blinded_balance_index>(); db().adjust_balance(o.to, o.amount);
const auto& cidx = bbi.indices().get<by_commitment>(); const auto &bbi = db().get_index_type<blinded_balance_index>();
for( const auto& in : o.inputs ) const auto &cidx = bbi.indices().get<by_commitment>();
{ for (const auto &in : o.inputs) {
auto itr = cidx.find( in.commitment ); auto itr = cidx.find(in.commitment);
FC_ASSERT( itr != cidx.end() ); FC_ASSERT(itr != cidx.end());
db().remove( *itr ); db().remove(*itr);
} }
const auto& add = o.amount.asset_id(db()).dynamic_asset_data_id(db()); // verify fee is a legit asset const auto &add = o.amount.asset_id(db()).dynamic_asset_data_id(db()); // verify fee is a legit asset
db().modify( add, [&]( asset_dynamic_data_object& obj ){ db().modify(add, [&](asset_dynamic_data_object &obj) {
obj.confidential_supply -= o.amount.amount + o.fee.amount; obj.confidential_supply -= o.amount.amount + o.fee.amount;
FC_ASSERT( obj.confidential_supply >= 0 ); FC_ASSERT(obj.confidential_supply >= 0);
}); });
return void_result(); }
return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) } } FC_CAPTURE_AND_RETHROW( (o) ) }
void transfer_from_blind_evaluator::pay_fee() void transfer_from_blind_evaluator::pay_fee()
{ {
if( db().head_block_time() >= HARDFORK_563_TIME ) const auto& d = db();
pay_fba_fee( fba_accumulator_id_transfer_from_blind ); if( d.head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
else if (d.head_block_time() >= HARDFORK_563_TIME)
consensus_evaluator::pay_fee(); pay_fba_fee(fba_accumulator_id_transfer_from_blind);
else
generic_evaluator::pay_fee();
}
} }
void_result blind_transfer_evaluator::do_evaluate( const blind_transfer_operation& o ) void_result blind_transfer_evaluator::do_evaluate( const blind_transfer_operation& o )
{ try { { try {
const auto& d = db(); const auto& d = db();
o.fee.asset_id(db()); // verify fee is a legit asset if( d.head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
const auto& bbi = db().get_index_type<blinded_balance_index>(); o.fee.asset_id(d); // verify fee is a legit asset
const auto& cidx = bbi.indices().get<by_commitment>(); const auto &bbi = d.get_index_type<blinded_balance_index>();
for( const auto& out : o.outputs ) const auto &cidx = bbi.indices().get<by_commitment>();
{ for (const auto &out : o.outputs) {
for( const auto& a : out.owner.account_auths ) for (const auto &a : out.owner.account_auths)
a.first(d); // verify all accounts exist and are valid a.first(d); // verify all accounts exist and are valid
} }
for( const auto& in : o.inputs ) for (const auto &in : o.inputs) {
{ auto itr = cidx.find(in.commitment);
auto itr = cidx.find( in.commitment ); GRAPHENE_ASSERT(itr != cidx.end(), blind_transfer_unknown_commitment, "", ("commitment", in.commitment));
GRAPHENE_ASSERT( itr != cidx.end(), blind_transfer_unknown_commitment, "", ("commitment",in.commitment) ); FC_ASSERT(itr->asset_id == o.fee.asset_id);
FC_ASSERT( itr->asset_id == o.fee.asset_id ); FC_ASSERT(itr->owner == in.owner);
FC_ASSERT( itr->owner == in.owner ); }
} }
return void_result(); return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) } } FC_CAPTURE_AND_RETHROW( (o) ) }
void_result blind_transfer_evaluator::do_apply( const blind_transfer_operation& o ) void_result blind_transfer_evaluator::do_apply( const blind_transfer_operation& o )
{ try { { try {
db().adjust_balance( o.fee_payer(), o.fee ); // deposit the fee to the temp account if( db().head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
const auto& bbi = db().get_index_type<blinded_balance_index>(); db().adjust_balance(o.fee_payer(), o.fee); // deposit the fee to the temp account
const auto& cidx = bbi.indices().get<by_commitment>(); const auto &bbi = db().get_index_type<blinded_balance_index>();
for( const auto& in : o.inputs ) const auto &cidx = bbi.indices().get<by_commitment>();
{ for (const auto &in : o.inputs) {
auto itr = cidx.find( in.commitment ); auto itr = cidx.find(in.commitment);
GRAPHENE_ASSERT( itr != cidx.end(), blind_transfer_unknown_commitment, "", ("commitment",in.commitment) ); GRAPHENE_ASSERT(itr != cidx.end(), blind_transfer_unknown_commitment, "", ("commitment", in.commitment));
db().remove( *itr ); db().remove(*itr);
} }
for( const auto& out : o.outputs ) for (const auto &out : o.outputs) {
{ db().create<blinded_balance_object>([&](blinded_balance_object &obj) {
db().create<blinded_balance_object>( [&]( blinded_balance_object& obj ){ obj.asset_id = o.fee.asset_id;
obj.asset_id = o.fee.asset_id; obj.owner = out.owner;
obj.owner = out.owner; obj.commitment = out.commitment;
obj.commitment = out.commitment; });
}); }
} const auto &add = o.fee.asset_id(db()).dynamic_asset_data_id(db());
const auto& add = o.fee.asset_id(db()).dynamic_asset_data_id(db()); db().modify(add, [&](asset_dynamic_data_object &obj) {
db().modify( add, [&]( asset_dynamic_data_object& obj ){ obj.confidential_supply -= o.fee.amount;
obj.confidential_supply -= o.fee.amount; FC_ASSERT(obj.confidential_supply >= 0);
FC_ASSERT( obj.confidential_supply >= 0 ); });
}); }
return void_result();
return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) } } FC_CAPTURE_AND_RETHROW( (o) ) }
void blind_transfer_evaluator::pay_fee() void blind_transfer_evaluator::pay_fee()
{ {
if( db().head_block_time() >= HARDFORK_563_TIME ) const auto& d = db();
pay_fba_fee( fba_accumulator_id_blind_transfer ); if( d.head_block_time() < HARDFORK_SON_FOR_ETHEREUM_TIME ) {
else if (d.head_block_time() >= HARDFORK_563_TIME)
consensus_evaluator::pay_fee(); pay_fba_fee(fba_accumulator_id_blind_transfer);
else
generic_evaluator::pay_fee();
}
} }
} } // graphene::chain } } // graphene::chain

View file

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

View file

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

View file

@ -26,23 +26,24 @@
#include <graphene/chain/db_with.hpp> #include <graphene/chain/db_with.hpp>
#include <graphene/chain/hardfork.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/block_summary_object.hpp>
#include <graphene/chain/global_property_object.hpp> #include <graphene/chain/global_property_object.hpp>
#include <graphene/chain/operation_history_object.hpp> #include <graphene/chain/operation_history_object.hpp>
#include <graphene/chain/proposal_object.hpp> #include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/transaction_history_object.hpp> #include <graphene/chain/transaction_object.hpp>
#include <graphene/chain/witness_object.hpp> #include <graphene/chain/witness_object.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/chain/exceptions.hpp> #include <graphene/chain/exceptions.hpp>
#include <graphene/chain/evaluator.hpp> #include <graphene/chain/evaluator.hpp>
#include <graphene/chain/witness_schedule_object.hpp> #include <graphene/chain/witness_schedule_object.hpp>
#include <graphene/db/object_database.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/crypto/digest.hpp>
#include <fc/thread/non_preemptable_scope_check.hpp>
#include <boost/filesystem.hpp>
namespace { namespace {
@ -161,10 +162,13 @@ void database::check_transaction_for_duplicated_operations(const signed_transact
existed_operations_digests.insert( proposed_operations_digests.begin(), proposed_operations_digests.end() ); existed_operations_digests.insert( proposed_operations_digests.begin(), proposed_operations_digests.end() );
}); });
for (auto& pending_transaction: _pending_tx)
{ {
auto proposed_operations_digests = gather_proposed_operations_digests(pending_transaction); const std::lock_guard<std::mutex> pending_tx_lock{_pending_tx_mutex};
existed_operations_digests.insert(proposed_operations_digests.begin(), proposed_operations_digests.end()); for (auto &pending_transaction : _pending_tx)
{
auto proposed_operations_digests = gather_proposed_operations_digests(pending_transaction);
existed_operations_digests.insert(proposed_operations_digests.begin(), proposed_operations_digests.end());
}
} }
auto proposed_operations_digests = gather_proposed_operations_digests(trx); auto proposed_operations_digests = gather_proposed_operations_digests(trx);
@ -186,7 +190,12 @@ bool database::push_block(const signed_block& new_block, uint32_t skip)
bool result; bool result;
detail::with_skip_flags( *this, skip, [&]() detail::with_skip_flags( *this, skip, [&]()
{ {
detail::without_pending_transactions( *this, std::move(_pending_tx), std::vector<processed_transaction> pending_tx = [this] {
const std::lock_guard<std::mutex> pending_tx_lock{_pending_tx_mutex};
return std::move(_pending_tx);
}();
detail::without_pending_transactions( *this, std::move(pending_tx),
[&]() [&]()
{ {
result = _push_block(new_block); result = _push_block(new_block);
@ -197,6 +206,9 @@ bool database::push_block(const signed_block& new_block, uint32_t skip)
bool database::_push_block(const signed_block& new_block) bool database::_push_block(const signed_block& new_block)
{ try { { try {
boost::filesystem::space_info si = boost::filesystem::space(get_data_dir());
FC_ASSERT((si.available) > 104857600, "Rejecting block due to low disk space"); // 104857600 bytes = 100 MB
uint32_t skip = get_node_properties().skip_flags; uint32_t skip = get_node_properties().skip_flags;
const auto now = fc::time_point::now().sec_since_epoch(); const auto now = fc::time_point::now().sec_since_epoch();
@ -381,20 +393,28 @@ processed_transaction database::push_transaction( const signed_transaction& trx,
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. // 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. // 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() ) {
_pending_tx_session = _undo_db.start_undo_session(); const std::lock_guard<std::mutex> pending_tx_session_lock{_pending_tx_session_mutex};
if (!_pending_tx_session.valid()) {
const std::lock_guard<std::mutex> undo_db_lock{_undo_db_mutex};
_pending_tx_session = _undo_db.start_undo_session();
}
}
// Create a temporary undo session as a child of _pending_tx_session. // Create a temporary undo session as a child of _pending_tx_session.
// The temporary session will be discarded by the destructor if // The temporary session will be discarded by the destructor if
// _apply_transaction fails. If we make it to merge(), we // _apply_transaction fails. If we make it to merge(), we
// apply the changes. // apply the changes.
const std::lock_guard<std::mutex> undo_db_lock{_undo_db_mutex};
auto temp_session = _undo_db.start_undo_session(); auto temp_session = _undo_db.start_undo_session();
auto processed_trx = _apply_transaction( trx ); auto processed_trx = _apply_transaction(trx);
_pending_tx.push_back(processed_trx); {
const std::lock_guard<std::mutex> pending_tx_lock{_pending_tx_mutex};
_pending_tx.push_back(processed_trx);
}
// notify_changed_objects(); // notify_changed_objects();
// The transaction applied successfully. Merge its changes into the pending block session. // The transaction applied successfully. Merge its changes into the pending block session.
@ -407,13 +427,13 @@ processed_transaction database::_push_transaction( const signed_transaction& trx
processed_transaction database::validate_transaction( const signed_transaction& trx ) processed_transaction database::validate_transaction( const signed_transaction& trx )
{ {
const std::lock_guard<std::mutex> undo_db_lock{_undo_db_mutex};
auto session = _undo_db.start_undo_session(); auto session = _undo_db.start_undo_session();
return _apply_transaction( trx ); return _apply_transaction( trx );
} }
processed_transaction database::push_proposal(const proposal_object& proposal) processed_transaction database::push_proposal(const proposal_object& proposal)
{ try { { try {
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
transaction_evaluation_state eval_state(this); transaction_evaluation_state eval_state(this);
eval_state._is_proposed_trx = true; eval_state._is_proposed_trx = true;
@ -436,7 +456,12 @@ processed_transaction database::push_proposal(const proposal_object& proposal)
{ {
for( size_t i=old_applied_ops_size,n=_applied_ops.size(); i<n; i++ ) for( size_t i=old_applied_ops_size,n=_applied_ops.size(); i<n; i++ )
{ {
ilog( "removing failed operation from applied_ops: ${op}", ("op", *(_applied_ops[i])) ); if(_applied_ops[i].valid()) {
ilog("removing failed operation from applied_ops: ${op}", ("op", *(_applied_ops[i])));
}
else{
ilog("Can't remove failed operation from applied_ops (operation is not valid), op_id : ${op_id}", ("op_id", i));
}
_applied_ops[i].reset(); _applied_ops[i].reset();
} }
} }
@ -459,7 +484,6 @@ signed_block database::generate_block(
uint32_t skip /* = 0 */ uint32_t skip /* = 0 */
) )
{ try { { try {
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
signed_block result; signed_block result;
detail::with_skip_flags( *this, skip, [&]() detail::with_skip_flags( *this, skip, [&]()
{ {
@ -503,47 +527,52 @@ signed_block database::_generate_block(
// the value of the "when" variable is known, which means we need to // the value of the "when" variable is known, which means we need to
// re-apply pending transactions in this method. // re-apply pending transactions in this method.
// //
_pending_tx_session.reset(); {
_pending_tx_session = _undo_db.start_undo_session(); const std::lock_guard<std::mutex> pending_tx_session_lock{_pending_tx_session_mutex};
_pending_tx_session.reset();
_pending_tx_session = _undo_db.start_undo_session();
}
uint64_t postponed_tx_count = 0; uint64_t postponed_tx_count = 0;
// pop pending state (reset to head block state) // pop pending state (reset to head block state)
for( const processed_transaction& tx : _pending_tx )
{ {
size_t new_total_size = total_block_size + fc::raw::pack_size( tx ); const std::lock_guard<std::mutex> pending_tx_lock{_pending_tx_mutex};
for (const processed_transaction &tx : _pending_tx) {
size_t new_total_size = total_block_size + fc::raw::pack_size(tx);
// postpone transaction if it would make block too big // postpone transaction if it would make block too big
if( new_total_size >= maximum_block_size ) if (new_total_size >= maximum_block_size) {
{ postponed_tx_count++;
postponed_tx_count++; continue;
continue; }
}
try try {
{ auto temp_session = _undo_db.start_undo_session();
auto temp_session = _undo_db.start_undo_session(); processed_transaction ptx = _apply_transaction(tx);
processed_transaction ptx = _apply_transaction( tx ); temp_session.merge();
temp_session.merge();
// We have to recompute pack_size(ptx) because it may be different // We have to recompute pack_size(ptx) because it may be different
// than pack_size(tx) (i.e. if one or more results increased // than pack_size(tx) (i.e. if one or more results increased
// their size) // their size)
total_block_size += fc::raw::pack_size( ptx ); total_block_size += fc::raw::pack_size(ptx);
pending_block.transactions.push_back( ptx ); pending_block.transactions.push_back(ptx);
} } catch (const fc::exception &e) {
catch ( const fc::exception& e ) // Do nothing, transaction will not be re-applied
{ wlog("Transaction was not processed while generating block due to ${e}", ("e", e));
// Do nothing, transaction will not be re-applied wlog("The transaction was ${t}", ("t", tx));
wlog( "Transaction was not processed while generating block due to ${e}", ("e", e) ); }
wlog( "The transaction was ${t}", ("t", tx) );
} }
} }
if( postponed_tx_count > 0 ) if( postponed_tx_count > 0 )
{ {
wlog( "Postponed ${n} transactions due to block size limit", ("n", postponed_tx_count) ); wlog( "Postponed ${n} transactions due to block size limit", ("n", postponed_tx_count) );
} }
_pending_tx_session.reset(); {
const std::lock_guard<std::mutex> pending_tx_session_lock{_pending_tx_session_mutex};
_pending_tx_session.reset();
}
// We have temporarily broken the invariant that // We have temporarily broken the invariant that
// _pending_tx_session is the result of applying _pending_tx, as // _pending_tx_session is the result of applying _pending_tx, as
@ -591,8 +620,11 @@ signed_block database::_generate_block(
*/ */
void database::pop_block() void database::pop_block()
{ try { { try {
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2); {
_pending_tx_session.reset(); const std::lock_guard<std::mutex> pending_tx_session_lock{_pending_tx_session_mutex};
_pending_tx_session.reset();
}
auto head_id = head_block_id(); auto head_id = head_block_id();
optional<signed_block> head_block = fetch_block_by_id( head_id ); optional<signed_block> head_block = fetch_block_by_id( head_id );
GRAPHENE_ASSERT( head_block.valid(), pop_empty_chain, "there are no blocks to pop" ); GRAPHENE_ASSERT( head_block.valid(), pop_empty_chain, "there are no blocks to pop" );
@ -606,7 +638,8 @@ void database::pop_block()
void database::clear_pending() void database::clear_pending()
{ try { { try {
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2); const std::lock_guard<std::mutex> pending_tx_lock{_pending_tx_mutex};
const std::lock_guard<std::mutex> pending_tx_session_lock{_pending_tx_session_mutex};
assert( (_pending_tx.size() == 0) || _pending_tx_session.valid() ); assert( (_pending_tx.size() == 0) || _pending_tx_session.valid() );
_pending_tx.clear(); _pending_tx.clear();
_pending_tx_session.reset(); _pending_tx_session.reset();
@ -625,7 +658,7 @@ uint32_t database::push_applied_operation( const operation& op )
void database::set_applied_operation_result( uint32_t op_id, const operation_result& result ) void database::set_applied_operation_result( uint32_t op_id, const operation_result& result )
{ {
assert( op_id < _applied_ops.size() ); assert( op_id < _applied_ops.size() );
if( _applied_ops[op_id] ) if( _applied_ops[op_id].valid() )
_applied_ops[op_id]->result = result; _applied_ops[op_id]->result = result;
else else
{ {
@ -666,7 +699,6 @@ void database::apply_block( const signed_block& next_block, uint32_t skip )
void database::_apply_block( const signed_block& next_block ) void database::_apply_block( const signed_block& next_block )
{ try { { try {
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
uint32_t next_block_num = next_block.block_num(); uint32_t next_block_num = next_block.block_num();
uint32_t skip = get_node_properties().skip_flags; uint32_t skip = get_node_properties().skip_flags;
_applied_ops.clear(); _applied_ops.clear();
@ -707,8 +739,11 @@ void database::_apply_block( const signed_block& next_block )
if (global_props.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM) { if (global_props.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM) {
update_witness_schedule(next_block); update_witness_schedule(next_block);
if(global_props.active_sons.size() > 0) {
update_son_schedule(next_block); for(const auto& active_sons : global_props.active_sons) {
if(!active_sons.second.empty()) {
update_son_schedule(active_sons.first, next_block);
}
} }
} }
@ -723,7 +758,7 @@ void database::_apply_block( const signed_block& next_block )
check_ending_lotteries(); check_ending_lotteries();
check_ending_nft_lotteries(); check_ending_nft_lotteries();
create_block_summary(next_block); create_block_summary(next_block);
place_delayed_bets(); // must happen after update_global_dynamic_data() updates the time place_delayed_bets(); // must happen after update_global_dynamic_data() updates the time
clear_expired_transactions(); clear_expired_transactions();
@ -741,11 +776,15 @@ void database::_apply_block( const signed_block& next_block )
// TODO: figure out if we could collapse this function into // TODO: figure out if we could collapse this function into
// update_global_dynamic_data() as perhaps these methods only need // update_global_dynamic_data() as perhaps these methods only need
// to be called for header validation? // to be called for header validation?
update_maintenance_flag( maint_needed ); update_maintenance_flag( maint_needed );
if (global_props.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SHUFFLED_ALGORITHM) { if (global_props.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SHUFFLED_ALGORITHM) {
update_witness_schedule(); update_witness_schedule();
if(global_props.active_sons.size() > 0) {
update_son_schedule(); for(const auto& active_sidechain_type : active_sidechain_types(dynamic_global_props.time)) {
if(global_props.active_sons.at(active_sidechain_type).size() > 0) {
update_son_schedule(active_sidechain_type);
}
} }
} }
@ -786,7 +825,6 @@ class undo_size_restorer {
processed_transaction database::_apply_transaction(const signed_transaction& trx) processed_transaction database::_apply_transaction(const signed_transaction& trx)
{ try { { try {
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
uint32_t skip = get_node_properties().skip_flags; uint32_t skip = get_node_properties().skip_flags;
if( true || !(skip&skip_validate) ) /* issue #505 explains why this skip_flag is disabled */ if( true || !(skip&skip_validate) ) /* issue #505 explains why this skip_flag is disabled */
@ -814,7 +852,7 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
return get_account_custom_authorities(id, op); return get_account_custom_authorities(id, op);
}; };
trx.verify_authority( chain_id, get_active, get_owner, get_custom, trx.verify_authority( chain_id, get_active, get_owner, get_custom,
MUST_IGNORE_CUSTOM_OP_REQD_AUTHS(head_block_time()), true,
get_global_properties().parameters.max_authority_depth ); get_global_properties().parameters.max_authority_depth );
} }
@ -827,7 +865,7 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
const auto& tapos_block_summary = block_summary_id_type( trx.ref_block_num )(*this); 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 //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].value() ); FC_ASSERT( trx.ref_block_prefix == tapos_block_summary.block_id._hash[1] );
} }
fc::time_point_sec now = head_block_time(); fc::time_point_sec now = head_block_time();
@ -840,8 +878,8 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
//Insert transaction into unique transactions database. //Insert transaction into unique transactions database.
if( !(skip & skip_transaction_dupe_check) ) if( !(skip & skip_transaction_dupe_check) )
{ {
create<transaction_history_object>([&trx](transaction_history_object& transaction) { create<transaction_object>([&trx_id,&trx](transaction_object& transaction) {
transaction.trx_id = trx.id(); transaction.trx_id = trx_id;
transaction.trx = trx; transaction.trx = trx;
}); });
} }
@ -871,26 +909,15 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
operation_result database::apply_operation(transaction_evaluation_state& eval_state, const operation& op) operation_result database::apply_operation(transaction_evaluation_state& eval_state, const operation& op)
{ try { { try {
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
int i_which = op.which(); int i_which = op.which();
uint64_t u_which = uint64_t( i_which ); uint64_t u_which = uint64_t( i_which );
FC_ASSERT( i_which >= 0, "Negative operation tag in operation ${op}", ("op",op) ); FC_ASSERT( i_which >= 0, "Negative operation tag in operation ${op}", ("op",op) );
FC_ASSERT( u_which < _consensus_operation_evaluators.size(), "No registered evaluator for operation ${op}", ("op",op) ); FC_ASSERT( u_which < _operation_evaluators.size(), "No registered evaluator for operation ${op}", ("op",op) );
unique_ptr<op_evaluator>& eval = _consensus_operation_evaluators[ u_which ]; unique_ptr<op_evaluator>& eval = _operation_evaluators[ u_which ];
FC_ASSERT( eval, "No registered evaluator for operation ${op}", ("op",op) ); FC_ASSERT( eval, "No registered evaluator for operation ${op}", ("op",op) );
auto op_id = push_applied_operation( op ); auto op_id = push_applied_operation( op );
auto result = eval->evaluate( eval_state, op, true ); auto result = eval->evaluate( eval_state, op, true );
set_applied_operation_result( op_id, result ); 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; return result;
} FC_CAPTURE_AND_RETHROW( (op) ) } } FC_CAPTURE_AND_RETHROW( (op) ) }

View file

@ -113,15 +113,13 @@ std::vector<uint32_t> database::get_seeds( asset_id_type for_asset, uint8_t coun
{ {
FC_ASSERT( count_winners <= 64 ); FC_ASSERT( count_winners <= 64 );
std::string salted_string = std::string(_random_number_generator._seed) + std::to_string(for_asset.instance.value); std::string salted_string = std::string(_random_number_generator._seed) + std::to_string(for_asset.instance.value);
auto seeds_hash = fc::sha256::hash(salted_string); uint32_t* seeds = (uint32_t*)(fc::sha256::hash(salted_string)._hash);
uint32_t* seeds = (uint32_t*)(seeds_hash._hash);
std::vector<uint32_t> result; std::vector<uint32_t> result;
result.reserve(64); result.reserve(64);
for( int s = 0; s < 8; ++s ) { for( int s = 0; s < 8; ++s ) {
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* ) fc::sha256::hash( std::to_string( seeds[s] ) + std::to_string( for_asset.instance.value ) )._hash;
uint32_t* sub_seeds = (uint32_t*) sub_seeds_hash._hash;
for( int ss = 0; ss < 8; ++ss ) { for( int ss = 0; ss < 8; ++ss ) {
result.push_back(sub_seeds[ss]); result.push_back(sub_seeds[ss]);
} }
@ -224,18 +222,32 @@ std::set<son_id_type> database::get_sons_to_be_deregistered()
for( auto& son : son_idx ) for( auto& son : son_idx )
{ {
if(son.status == son_status::in_maintenance) bool need_to_be_deregistered = true;
for(const auto& status : son.statuses)
{ {
auto& stats = son.statistics(*this); const auto& sidechain = status.first;
if(status.second != son_status::in_maintenance)
need_to_be_deregistered = false;
// TODO : We need to add a function that returns if we can deregister SON if(need_to_be_deregistered)
// 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
if(head_block_time() - stats.last_down_timestamp >= fc::seconds(get_global_properties().parameters.son_deregister_time()))
{ {
ret.insert(son.id); 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
if(stats.last_active_timestamp.contains(sidechain)) {
if (head_block_time() - stats.last_active_timestamp.at(sidechain) < fc::seconds(get_global_properties().parameters.son_deregister_time())) {
need_to_be_deregistered = false;
}
}
} }
} }
if(need_to_be_deregistered)
{
ret.insert(son.id);
}
} }
return ret; return ret;
} }
@ -292,28 +304,50 @@ bool database::is_son_dereg_valid( son_id_type son_id )
return false; return false;
} }
return (son->status == son_status::in_maintenance && bool status_son_dereg_valid = true;
(head_block_time() - son->statistics(*this).last_down_timestamp >= fc::seconds(get_global_properties().parameters.son_deregister_time()))); for (const auto &active_sidechain_type : active_sidechain_types(head_block_time())) {
if(son->statuses.at(active_sidechain_type) != son_status::in_maintenance)
status_son_dereg_valid = false;
if(status_son_dereg_valid)
{
if(son->statistics(*this).last_active_timestamp.contains(active_sidechain_type)) {
if (head_block_time() - son->statistics(*this).last_active_timestamp.at(active_sidechain_type) < fc::seconds(get_global_properties().parameters.son_deregister_time())) {
status_son_dereg_valid = false;
}
}
}
}
return status_son_dereg_valid;
} }
bool database::is_son_active( son_id_type son_id ) bool database::is_son_active( sidechain_type type, son_id_type son_id )
{ {
const auto& son_idx = get_index_type<son_index>().indices().get< by_id >(); const auto& son_idx = get_index_type<son_index>().indices().get< by_id >();
auto son = son_idx.find( son_id ); auto son = son_idx.find( son_id );
if(son == son_idx.end()) if(son == son_idx.end()) {
{
return false; return false;
} }
const global_property_object& gpo = get_global_properties(); const global_property_object& gpo = get_global_properties();
if(!gpo.active_sons.contains(type)) {
return false;
}
const auto& gpo_as = gpo.active_sons.at(type);
vector<son_id_type> active_son_ids; vector<son_id_type> active_son_ids;
active_son_ids.reserve(gpo.active_sons.size()); active_son_ids.reserve(gpo_as.size());
std::transform(gpo.active_sons.begin(), gpo.active_sons.end(), std::transform(gpo_as.cbegin(), gpo_as.cend(),
std::inserter(active_son_ids, active_son_ids.end()), std::inserter(active_son_ids, active_son_ids.end()),
[](const son_info& swi) { [](const son_sidechain_info& swi) {
return swi.son_id; return swi.son_id;
}); });
if(active_son_ids.empty()) {
return false;
}
auto it_son = std::find(active_son_ids.begin(), active_son_ids.end(), son_id); auto it_son = std::find(active_son_ids.begin(), active_son_ids.end(), son_id);
return (it_son != active_son_ids.end()); return (it_son != active_son_ids.end());
} }
@ -352,23 +386,14 @@ vector<uint64_t> database::get_random_numbers(uint64_t minimum, uint64_t maximum
bool database::is_asset_creation_allowed(const string &symbol) bool database::is_asset_creation_allowed(const string &symbol)
{ {
time_point_sec now = head_block_time();
std::unordered_set<std::string> post_son_hf_symbols = {"ETH", "USDT", "BNB", "ADA", "DOGE", "XRP", "USDC", "DOT", "UNI", "BUSD", "BCH", "LTC", "SOL", "LINK", "MATIC", "THETA",
"WBTC", "XLM", "ICP", "DAI", "VET", "ETC", "TRX", "FIL", "XMR", "EGR", "EOS", "SHIB", "AAVE", "CRO", "ALGO", "AMP", "BTCB",
"BSV", "KLAY", "CAKE", "FTT", "LEO", "XTZ", "TFUEL", "MIOTA", "LUNA", "NEO", "ATOM", "MKR", "FEI", "WBNB", "UST", "AVAX",
"STEEM", "HIVE", "HBD", "SBD", "BTS"};
if (symbol == "BTC") if (symbol == "BTC")
{ {
if (now < HARDFORK_SON_TIME) if (head_block_time() < HARDFORK_SON_TIME)
return false;
}
if (post_son_hf_symbols.find(symbol) != post_son_hf_symbols.end())
{
if (now >= HARDFORK_SON_TIME)
return false; return false;
} }
return true; return true;
} }
} } }
}

View file

@ -40,7 +40,7 @@
#include <graphene/chain/operation_history_object.hpp> #include <graphene/chain/operation_history_object.hpp>
#include <graphene/chain/proposal_object.hpp> #include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/special_authority_object.hpp> #include <graphene/chain/special_authority_object.hpp>
#include <graphene/chain/transaction_history_object.hpp> #include <graphene/chain/transaction_object.hpp>
#include <graphene/chain/vesting_balance_object.hpp> #include <graphene/chain/vesting_balance_object.hpp>
#include <graphene/chain/withdraw_permission_object.hpp> #include <graphene/chain/withdraw_permission_object.hpp>
#include <graphene/chain/witness_object.hpp> #include <graphene/chain/witness_object.hpp>
@ -104,7 +104,7 @@
#include <graphene/chain/sidechain_transaction_evaluator.hpp> #include <graphene/chain/sidechain_transaction_evaluator.hpp>
#include <graphene/chain/random_number_evaluator.hpp> #include <graphene/chain/random_number_evaluator.hpp>
#include <graphene/protocol/fee_schedule.hpp> #include <graphene/chain/protocol/fee_schedule.hpp>
#include <fc/uint128.hpp> #include <fc/uint128.hpp>
#include <fc/crypto/digest.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::space_id;
const uint8_t proposal_object::type_id; const uint8_t proposal_object::type_id;
const uint8_t transaction_history_object::space_id; const uint8_t transaction_object::space_id;
const uint8_t transaction_history_object::type_id; const uint8_t transaction_object::type_id;
const uint8_t vesting_balance_object::space_id; const uint8_t vesting_balance_object::space_id;
const uint8_t vesting_balance_object::type_id; const uint8_t vesting_balance_object::type_id;
@ -214,132 +214,169 @@ const uint8_t random_number_object::type_id;
void database::initialize_evaluators() void database::initialize_evaluators()
{ {
_consensus_operation_evaluators.resize(255); _operation_evaluators.resize(255);
_third_party_operation_evaluators.resize(255); register_evaluator<account_create_evaluator>();
register_consensus_evaluator<account_create_evaluator>(); register_evaluator<account_update_evaluator>();
register_consensus_evaluator<account_update_evaluator>(); register_evaluator<account_upgrade_evaluator>();
register_consensus_evaluator<account_upgrade_evaluator>(); register_evaluator<account_whitelist_evaluator>();
register_consensus_evaluator<account_whitelist_evaluator>(); register_evaluator<committee_member_create_evaluator>();
register_consensus_evaluator<committee_member_create_evaluator>(); register_evaluator<committee_member_update_evaluator>();
register_consensus_evaluator<committee_member_update_evaluator>(); register_evaluator<committee_member_update_global_parameters_evaluator>();
register_consensus_evaluator<committee_member_update_global_parameters_evaluator>(); register_evaluator<custom_evaluator>();
register_consensus_evaluator<custom_evaluator>(); register_evaluator<asset_create_evaluator>();
register_consensus_evaluator<asset_create_evaluator>(); register_evaluator<asset_issue_evaluator>();
register_consensus_evaluator<asset_issue_evaluator>(); register_evaluator<asset_reserve_evaluator>();
register_consensus_evaluator<asset_reserve_evaluator>(); register_evaluator<asset_update_evaluator>();
register_consensus_evaluator<asset_update_evaluator>(); register_evaluator<asset_update_bitasset_evaluator>();
register_consensus_evaluator<asset_update_bitasset_evaluator>(); register_evaluator<asset_update_dividend_evaluator>();
register_consensus_evaluator<asset_update_dividend_evaluator>(); register_evaluator<asset_update_feed_producers_evaluator>();
register_consensus_evaluator<asset_update_feed_producers_evaluator>(); register_evaluator<asset_settle_evaluator>();
register_consensus_evaluator<asset_settle_evaluator>(); register_evaluator<asset_global_settle_evaluator>();
register_consensus_evaluator<asset_global_settle_evaluator>(); register_evaluator<assert_evaluator>();
register_consensus_evaluator<assert_evaluator>(); register_evaluator<limit_order_create_evaluator>();
register_consensus_evaluator<limit_order_create_evaluator>(); register_evaluator<limit_order_cancel_evaluator>();
register_consensus_evaluator<limit_order_cancel_evaluator>(); register_evaluator<call_order_update_evaluator>();
register_consensus_evaluator<call_order_update_evaluator>(); register_evaluator<transfer_evaluator>();
register_consensus_evaluator<transfer_evaluator>(); register_evaluator<override_transfer_evaluator>();
register_consensus_evaluator<override_transfer_evaluator>(); register_evaluator<asset_fund_fee_pool_evaluator>();
register_consensus_evaluator<asset_fund_fee_pool_evaluator>(); register_evaluator<asset_publish_feeds_evaluator>();
register_consensus_evaluator<asset_publish_feeds_evaluator>(); register_evaluator<proposal_create_evaluator>();
register_consensus_evaluator<proposal_create_evaluator>(); register_evaluator<proposal_update_evaluator>();
register_consensus_evaluator<proposal_update_evaluator>(); register_evaluator<proposal_delete_evaluator>();
register_consensus_evaluator<proposal_delete_evaluator>(); register_evaluator<vesting_balance_create_evaluator>();
register_consensus_evaluator<vesting_balance_create_evaluator>(); register_evaluator<vesting_balance_withdraw_evaluator>();
register_consensus_evaluator<vesting_balance_withdraw_evaluator>(); register_evaluator<witness_create_evaluator>();
register_consensus_evaluator<witness_create_evaluator>(); register_evaluator<witness_update_evaluator>();
register_consensus_evaluator<witness_update_evaluator>(); register_evaluator<withdraw_permission_create_evaluator>();
register_consensus_evaluator<withdraw_permission_create_evaluator>(); register_evaluator<withdraw_permission_claim_evaluator>();
register_consensus_evaluator<withdraw_permission_claim_evaluator>(); register_evaluator<withdraw_permission_update_evaluator>();
register_consensus_evaluator<withdraw_permission_update_evaluator>(); register_evaluator<withdraw_permission_delete_evaluator>();
register_consensus_evaluator<withdraw_permission_delete_evaluator>(); register_evaluator<worker_create_evaluator>();
register_consensus_evaluator<worker_create_evaluator>(); register_evaluator<balance_claim_evaluator>();
register_consensus_evaluator<balance_claim_evaluator>(); register_evaluator<transfer_to_blind_evaluator>();
register_consensus_evaluator<transfer_to_blind_evaluator>(); register_evaluator<transfer_from_blind_evaluator>();
register_consensus_evaluator<transfer_from_blind_evaluator>(); register_evaluator<blind_transfer_evaluator>();
register_consensus_evaluator<blind_transfer_evaluator>(); register_evaluator<asset_claim_fees_evaluator>();
register_consensus_evaluator<asset_claim_fees_evaluator>(); register_evaluator<sport_create_evaluator>();
register_consensus_evaluator<sport_create_evaluator>(); register_evaluator<sport_update_evaluator>();
register_consensus_evaluator<sport_update_evaluator>(); register_evaluator<sport_delete_evaluator>();
register_consensus_evaluator<sport_delete_evaluator>(); register_evaluator<event_group_create_evaluator>();
register_consensus_evaluator<event_group_create_evaluator>(); register_evaluator<event_group_update_evaluator>();
register_consensus_evaluator<event_group_update_evaluator>(); register_evaluator<event_group_delete_evaluator>();
register_consensus_evaluator<event_group_delete_evaluator>(); register_evaluator<event_create_evaluator>();
register_consensus_evaluator<event_create_evaluator>(); register_evaluator<event_update_evaluator>();
register_consensus_evaluator<event_update_evaluator>(); register_evaluator<event_update_status_evaluator>();
register_consensus_evaluator<event_update_status_evaluator>(); register_evaluator<betting_market_rules_create_evaluator>();
register_consensus_evaluator<betting_market_rules_create_evaluator>(); register_evaluator<betting_market_rules_update_evaluator>();
register_consensus_evaluator<betting_market_rules_update_evaluator>(); register_evaluator<betting_market_group_create_evaluator>();
register_consensus_evaluator<betting_market_group_create_evaluator>(); register_evaluator<betting_market_group_update_evaluator>();
register_consensus_evaluator<betting_market_group_update_evaluator>(); register_evaluator<betting_market_create_evaluator>();
register_consensus_evaluator<betting_market_create_evaluator>(); register_evaluator<betting_market_update_evaluator>();
register_consensus_evaluator<betting_market_update_evaluator>(); register_evaluator<bet_place_evaluator>();
register_consensus_evaluator<bet_place_evaluator>(); register_evaluator<bet_cancel_evaluator>();
register_consensus_evaluator<bet_cancel_evaluator>(); register_evaluator<betting_market_group_resolve_evaluator>();
register_consensus_evaluator<betting_market_group_resolve_evaluator>(); register_evaluator<betting_market_group_cancel_unmatched_bets_evaluator>();
register_consensus_evaluator<betting_market_group_cancel_unmatched_bets_evaluator>(); register_evaluator<tournament_create_evaluator>();
register_consensus_evaluator<tournament_create_evaluator>(); register_evaluator<tournament_join_evaluator>();
register_consensus_evaluator<tournament_join_evaluator>(); register_evaluator<game_move_evaluator>();
register_consensus_evaluator<game_move_evaluator>(); register_evaluator<tournament_leave_evaluator>();
register_consensus_evaluator<tournament_leave_evaluator>(); register_evaluator<lottery_asset_create_evaluator>();
register_consensus_evaluator<lottery_asset_create_evaluator>(); register_evaluator<ticket_purchase_evaluator>();
register_consensus_evaluator<ticket_purchase_evaluator>(); register_evaluator<lottery_reward_evaluator>();
register_consensus_evaluator<lottery_reward_evaluator>(); register_evaluator<lottery_end_evaluator>();
register_consensus_evaluator<lottery_end_evaluator>(); register_evaluator<sweeps_vesting_claim_evaluator>();
register_consensus_evaluator<sweeps_vesting_claim_evaluator>(); register_evaluator<create_custom_permission_evaluator>();
register_consensus_evaluator<create_custom_permission_evaluator>(); register_evaluator<update_custom_permission_evaluator>();
register_consensus_evaluator<update_custom_permission_evaluator>(); register_evaluator<delete_custom_permission_evaluator>();
register_consensus_evaluator<delete_custom_permission_evaluator>(); register_evaluator<create_custom_account_authority_evaluator>();
register_consensus_evaluator<create_custom_account_authority_evaluator>(); register_evaluator<update_custom_account_authority_evaluator>();
register_consensus_evaluator<update_custom_account_authority_evaluator>(); register_evaluator<delete_custom_account_authority_evaluator>();
register_consensus_evaluator<delete_custom_account_authority_evaluator>(); register_evaluator<offer_evaluator>();
register_consensus_evaluator<offer_evaluator>(); register_evaluator<bid_evaluator>();
register_consensus_evaluator<bid_evaluator>(); register_evaluator<cancel_offer_evaluator>();
register_consensus_evaluator<cancel_offer_evaluator>(); register_evaluator<finalize_offer_evaluator>();
register_consensus_evaluator<finalize_offer_evaluator>(); register_evaluator<nft_metadata_create_evaluator>();
register_consensus_evaluator<nft_metadata_create_evaluator>(); register_evaluator<nft_metadata_update_evaluator>();
register_consensus_evaluator<nft_metadata_update_evaluator>(); register_evaluator<nft_mint_evaluator>();
register_consensus_evaluator<nft_mint_evaluator>(); register_evaluator<nft_safe_transfer_from_evaluator>();
register_consensus_evaluator<nft_safe_transfer_from_evaluator>(); register_evaluator<nft_approve_evaluator>();
register_consensus_evaluator<nft_approve_evaluator>(); register_evaluator<nft_set_approval_for_all_evaluator>();
register_consensus_evaluator<nft_set_approval_for_all_evaluator>(); register_evaluator<account_role_create_evaluator>();
register_consensus_evaluator<account_role_create_evaluator>(); register_evaluator<account_role_update_evaluator>();
register_consensus_evaluator<account_role_update_evaluator>(); register_evaluator<account_role_delete_evaluator>();
register_consensus_evaluator<account_role_delete_evaluator>(); register_evaluator<nft_lottery_token_purchase_evaluator>();
register_consensus_evaluator<nft_lottery_token_purchase_evaluator>(); register_evaluator<nft_lottery_reward_evaluator>();
register_consensus_evaluator<nft_lottery_reward_evaluator>(); register_evaluator<nft_lottery_end_evaluator>();
register_consensus_evaluator<nft_lottery_end_evaluator>(); register_evaluator<create_son_evaluator>();
register_consensus_evaluator<create_son_evaluator>(); register_evaluator<update_son_evaluator>();
register_consensus_evaluator<update_son_evaluator>(); register_evaluator<deregister_son_evaluator>();
register_consensus_evaluator<deregister_son_evaluator>(); register_evaluator<son_heartbeat_evaluator>();
register_consensus_evaluator<son_heartbeat_evaluator>(); register_evaluator<son_report_down_evaluator>();
register_consensus_evaluator<son_report_down_evaluator>(); register_evaluator<son_maintenance_evaluator>();
register_consensus_evaluator<son_maintenance_evaluator>(); register_evaluator<recreate_son_wallet_evaluator>();
register_consensus_evaluator<recreate_son_wallet_evaluator>(); register_evaluator<update_son_wallet_evaluator>();
register_consensus_evaluator<update_son_wallet_evaluator>(); register_evaluator<create_son_wallet_deposit_evaluator>();
register_consensus_evaluator<create_son_wallet_deposit_evaluator>(); register_evaluator<process_son_wallet_deposit_evaluator>();
register_consensus_evaluator<process_son_wallet_deposit_evaluator>(); register_evaluator<create_son_wallet_withdraw_evaluator>();
register_consensus_evaluator<create_son_wallet_withdraw_evaluator>(); register_evaluator<process_son_wallet_withdraw_evaluator>();
register_consensus_evaluator<process_son_wallet_withdraw_evaluator>(); register_evaluator<add_sidechain_address_evaluator>();
register_consensus_evaluator<add_sidechain_address_evaluator>(); register_evaluator<update_sidechain_address_evaluator>();
register_consensus_evaluator<update_sidechain_address_evaluator>(); register_evaluator<delete_sidechain_address_evaluator>();
register_consensus_evaluator<delete_sidechain_address_evaluator>(); register_evaluator<sidechain_transaction_create_evaluator>();
register_consensus_evaluator<sidechain_transaction_create_evaluator>(); register_evaluator<sidechain_transaction_sign_evaluator>();
register_consensus_evaluator<sidechain_transaction_sign_evaluator>(); register_evaluator<sidechain_transaction_send_evaluator>();
register_consensus_evaluator<sidechain_transaction_send_evaluator>(); register_evaluator<sidechain_transaction_settle_evaluator>();
register_consensus_evaluator<sidechain_transaction_settle_evaluator>(); register_evaluator<random_number_store_evaluator>();
register_consensus_evaluator<random_number_store_evaluator>(); }
void database::initialize_hardforks()
{
_hardfork_times.emplace_back(HARDFORK_357_TIME);
_hardfork_times.emplace_back(HARDFORK_359_TIME);
_hardfork_times.emplace_back(HARDFORK_385_TIME);
_hardfork_times.emplace_back(HARDFORK_409_TIME);
_hardfork_times.emplace_back(HARDFORK_413_TIME);
_hardfork_times.emplace_back(HARDFORK_415_TIME);
_hardfork_times.emplace_back(HARDFORK_416_TIME);
_hardfork_times.emplace_back(HARDFORK_419_TIME);
_hardfork_times.emplace_back(HARDFORK_436_TIME);
_hardfork_times.emplace_back(HARDFORK_445_TIME);
_hardfork_times.emplace_back(HARDFORK_453_TIME);
_hardfork_times.emplace_back(HARDFORK_480_TIME);
_hardfork_times.emplace_back(HARDFORK_483_TIME);
_hardfork_times.emplace_back(HARDFORK_516_TIME);
_hardfork_times.emplace_back(HARDFORK_533_TIME);
_hardfork_times.emplace_back(HARDFORK_538_TIME);
_hardfork_times.emplace_back(HARDFORK_555_TIME);
_hardfork_times.emplace_back(HARDFORK_563_TIME);
_hardfork_times.emplace_back(HARDFORK_572_TIME);
_hardfork_times.emplace_back(HARDFORK_599_TIME);
_hardfork_times.emplace_back(HARDFORK_607_TIME);
_hardfork_times.emplace_back(HARDFORK_613_TIME);
_hardfork_times.emplace_back(HARDFORK_615_TIME);
_hardfork_times.emplace_back(HARDFORK_999_TIME);
_hardfork_times.emplace_back(HARDFORK_1000_TIME);
_hardfork_times.emplace_back(HARDFORK_1001_TIME);
_hardfork_times.emplace_back(HARDFORK_5050_1_TIME);
_hardfork_times.emplace_back(HARDFORK_CORE_429_TIME);
_hardfork_times.emplace_back(HARDFORK_GPOS_TIME);
_hardfork_times.emplace_back(HARDFORK_NFT_TIME);
_hardfork_times.emplace_back(HARDFORK_SON_FOR_HIVE_TIME);
_hardfork_times.emplace_back(HARDFORK_SON_TIME);
_hardfork_times.emplace_back(HARDFORK_SON2_TIME);
_hardfork_times.emplace_back(HARDFORK_SON_FOR_ETHEREUM_TIME);
_hardfork_times.emplace_back(HARDFORK_SWEEPS_TIME);
std::sort(_hardfork_times.begin(), _hardfork_times.end());
} }
void database::initialize_indexes() void database::initialize_indexes()
{ {
reset_indexes(); reset_indexes();
_undo_db.set_max_size( GRAPHENE_MIN_UNDO_HISTORY );
_check_policy_1 = allocate_object_space<database_lock_safety_check>(protocol_ids); const std::lock_guard<std::mutex> undo_db_lock{_undo_db_mutex};
_check_policy_2 = allocate_object_space<database_lock_safety_check>(implementation_ids); _undo_db.set_max_size(GRAPHENE_MIN_UNDO_HISTORY);
// 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 //Protocol object indexes
add_index< primary_index<asset_index, 13> >(); // 8192 assets per chunk add_index< primary_index<asset_index, 13> >(); // 8192 assets per chunk
@ -427,8 +464,6 @@ void database::initialize_indexes()
add_index< primary_index<son_stats_index > >(); add_index< primary_index<son_stats_index > >();
add_index< primary_index<random_number_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) void database::init_genesis(const genesis_state_type& genesis_state)
@ -441,8 +476,9 @@ void database::init_genesis(const genesis_state_type& genesis_state)
FC_ASSERT(genesis_state.initial_active_witnesses <= genesis_state.initial_witness_candidates.size(), FC_ASSERT(genesis_state.initial_active_witnesses <= genesis_state.initial_witness_candidates.size(),
"initial_active_witnesses is larger than the number of candidate witnesses."); "initial_active_witnesses is larger than the number of candidate witnesses.");
const std::lock_guard<std::mutex> undo_db_lock{_undo_db_mutex};
_undo_db.disable(); _undo_db.disable();
scoped_database_unlocker unlocker(*_check_policy_1, *_check_policy_2);
struct auth_inhibitor { struct auth_inhibitor {
auth_inhibitor(database& db) : db(db), old_flags(db.node_properties().skip_flags) auth_inhibitor(database& db) : db(db), old_flags(db.node_properties().skip_flags)
{ db.node_properties().skip_flags |= skip_authority_check; } { db.node_properties().skip_flags |= skip_authority_check; }
@ -690,7 +726,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
p.time = genesis_state.initial_timestamp; p.time = genesis_state.initial_timestamp;
p.dynamic_flags = 0; p.dynamic_flags = 0;
p.witness_budget = 0; p.witness_budget = 0;
p.recent_slots_filled = std::numeric_limits<fc::uint128_t>::max(); p.recent_slots_filled = fc::uint128::max_value();
}); });
create<global_betting_statistics_object>([&](global_betting_statistics_object& betting_statistics) { create<global_betting_statistics_object>([&](global_betting_statistics_object& betting_statistics) {
betting_statistics.number_of_active_events = 0; betting_statistics.number_of_active_events = 0;
@ -913,7 +949,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
for( const auto& handout : genesis_state.initial_balances ) for( const auto& handout : genesis_state.initial_balances )
{ {
const auto asset_id = get_asset_id(handout.asset_symbol); const auto asset_id = get_asset_id(handout.asset_symbol);
create<balance_object>([&handout,total_allocation,asset_id](balance_object& b) { create<balance_object>([&handout,&get_asset_id,total_allocation,asset_id](balance_object& b) {
b.balance = asset(handout.amount, asset_id); b.balance = asset(handout.amount, asset_id);
b.owner = handout.owner; b.owner = handout.owner;
}); });
@ -1059,7 +1095,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
_wso.last_scheduling_block = 0; _wso.last_scheduling_block = 0;
_wso.recent_slots_filled = std::numeric_limits<fc::uint128_t>::max(); _wso.recent_slots_filled = fc::uint128::max_value();
// for shuffled // for shuffled
for( const witness_id_type& wid : get_global_properties().active_witnesses ) for( const witness_id_type& wid : get_global_properties().active_witnesses )
@ -1068,8 +1104,9 @@ void database::init_genesis(const genesis_state_type& genesis_state)
FC_ASSERT( _p_witness_schedule_obj->id == witness_schedule_id_type() ); FC_ASSERT( _p_witness_schedule_obj->id == witness_schedule_id_type() );
// Initialize witness schedule // Initialize witness schedule
#ifndef NDEBUG #ifndef NDEBUG
const son_schedule_object& sso = const son_schedule_object& ssobitcoin =
#endif #endif
create<son_schedule_object>([&](son_schedule_object& _sso) create<son_schedule_object>([&](son_schedule_object& _sso)
{ {
@ -1078,24 +1115,64 @@ void database::init_genesis(const genesis_state_type& genesis_state)
witness_scheduler_rng rng(_sso.rng_seed.begin(), GRAPHENE_NEAR_SCHEDULE_CTR_IV); witness_scheduler_rng rng(_sso.rng_seed.begin(), GRAPHENE_NEAR_SCHEDULE_CTR_IV);
auto init_witnesses = get_global_properties().active_witnesses; auto init_bitcoin_sons = get_global_properties().active_sons.at(sidechain_type::bitcoin);
_sso.scheduler = son_scheduler(); _sso.scheduler = son_scheduler();
_sso.scheduler._min_token_count = std::max(int(init_witnesses.size()) / 2, 1); _sso.scheduler._min_token_count = std::max(int(init_bitcoin_sons.size()) / 2, 1);
_sso.last_scheduling_block = 0; _sso.last_scheduling_block = 0;
_sso.recent_slots_filled = std::numeric_limits<fc::uint128_t>::max(); _sso.recent_slots_filled = fc::uint128::max_value();
}); });
assert( sso.id == son_schedule_id_type() ); assert( ssobitcoin.id == son_schedule_id_type(get_son_schedule_id(sidechain_type::bitcoin)) );
#ifndef NDEBUG
const son_schedule_object& ssoethereum =
#endif
create<son_schedule_object>([&](son_schedule_object& _sso)
{
// for scheduled
memset(_sso.rng_seed.begin(), 0, _sso.rng_seed.size());
witness_scheduler_rng rng(_sso.rng_seed.begin(), GRAPHENE_NEAR_SCHEDULE_CTR_IV);
auto init_ethereum_sons = get_global_properties().active_sons.at(sidechain_type::ethereum);
_sso.scheduler = son_scheduler();
_sso.scheduler._min_token_count = std::max(int(init_ethereum_sons.size()) / 2, 1);
_sso.last_scheduling_block = 0;
_sso.recent_slots_filled = fc::uint128::max_value();
});
assert( ssoethereum.id == son_schedule_id_type(get_son_schedule_id(sidechain_type::ethereum)) );
#ifndef NDEBUG
const son_schedule_object& ssohive =
#endif
create<son_schedule_object>([&](son_schedule_object& _sso)
{
// for scheduled
memset(_sso.rng_seed.begin(), 0, _sso.rng_seed.size());
witness_scheduler_rng rng(_sso.rng_seed.begin(), GRAPHENE_NEAR_SCHEDULE_CTR_IV);
auto init_hive_sons = get_global_properties().active_sons.at(sidechain_type::hive);
_sso.scheduler = son_scheduler();
_sso.scheduler._min_token_count = std::max(int(init_hive_sons.size()) / 2, 1);
_sso.last_scheduling_block = 0;
_sso.recent_slots_filled = fc::uint128::max_value();
});
assert( ssohive.id == son_schedule_id_type(get_son_schedule_id(sidechain_type::hive)) );
// Enable fees // Enable fees
modify(get_global_properties(), [&genesis_state](global_property_object& p) { modify(get_global_properties(), [&genesis_state](global_property_object& p) {
p.parameters.current_fees = genesis_state.initial_parameters.current_fees; p.parameters.current_fees = genesis_state.initial_parameters.current_fees;
}); });
// Create FBA counters // Create FBA counters
create<fba_accumulator_object>([&]( fba_accumulator_object& acc ) create<fba_accumulator_object>([&]( fba_accumulator_object& acc )
{ {

File diff suppressed because it is too large Load diff

View file

@ -29,8 +29,7 @@
#include <graphene/chain/special_authority_object.hpp> #include <graphene/chain/special_authority_object.hpp>
#include <graphene/chain/operation_history_object.hpp> #include <graphene/chain/operation_history_object.hpp>
#include <graphene/chain/nft_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> #include <fc/io/fstream.hpp>
@ -40,14 +39,12 @@
namespace graphene { namespace chain { namespace graphene { namespace chain {
database::database(bool allow_testing_edits) : database::database() :
_random_number_generator(fc::ripemd160().data()), _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_indexes();
initialize_evaluators(); initialize_evaluators();
initialize_hardforks();
} }
database::~database() database::~database()

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 ) if( trade_asset.options.market_fee_percent == 0 )
return trade_asset.amount(0); return trade_asset.amount(0);
fc::uint128_t a(trade_amount.amount.value); fc::uint128 a(trade_amount.amount.value);
a *= trade_asset.options.market_fee_percent; a *= trade_asset.options.market_fee_percent;
a /= GRAPHENE_100_PERCENT; a /= GRAPHENE_100_PERCENT;
asset percent_fee = trade_asset.amount(a); asset percent_fee = trade_asset.amount(a.to_uint64());
if( percent_fee.amount > trade_asset.options.max_market_fee ) if( percent_fee.amount > trade_asset.options.max_market_fee )
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 <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/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/withdraw_permission_object.hpp>
#include <graphene/chain/worker_object.hpp> #include <graphene/chain/worker_object.hpp>
#include <graphene/chain/confidential_object.hpp> #include <graphene/chain/confidential_object.hpp>
@ -39,17 +39,14 @@
#include <graphene/chain/proposal_object.hpp> #include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/operation_history_object.hpp> #include <graphene/chain/operation_history_object.hpp>
#include <graphene/chain/vesting_balance_object.hpp> #include <graphene/chain/vesting_balance_object.hpp>
#include <graphene/chain/transaction_history_object.hpp> #include <graphene/chain/transaction_object.hpp>
#include <graphene/chain/impacted.hpp> #include <graphene/chain/impacted.hpp>
#include <graphene/chain/hardfork.hpp> #include <graphene/chain/hardfork.hpp>
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
#include <graphene/chain/account_role_object.hpp> #include <graphene/chain/account_role_object.hpp>
#include <graphene/chain/son_object.hpp> #include <graphene/chain/son_object.hpp>
#include <graphene/chain/sidechain_address_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 fc;
using namespace graphene::chain; using namespace graphene::chain;
@ -206,27 +203,10 @@ struct get_impacted_account_visitor
_impacted.insert( op.issuer ); _impacted.insert( op.issuer );
} }
void operator()( const transfer_to_blind_operation& op ) //! We don't use this operations
{ void operator()( const transfer_to_blind_operation& op ){}
_impacted.insert( op.from ); void operator()( const blind_transfer_operation& op ){}
for( const auto& out : op.outputs ) void operator()( const transfer_from_blind_operation& op ){}
add_authority_accounts( _impacted, out.owner );
}
void operator()( const blind_transfer_operation& op )
{
for( const auto& in : op.inputs )
add_authority_accounts( _impacted, in.owner );
for( const auto& out : op.outputs )
add_authority_accounts( _impacted, out.owner );
}
void operator()( const transfer_from_blind_operation& op )
{
_impacted.insert( op.to );
for( const auto& in : op.inputs )
add_authority_accounts( _impacted, in.owner );
}
void operator()( const asset_settle_cancel_operation& op ) void operator()( const asset_settle_cancel_operation& op )
{ {
@ -453,6 +433,7 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
{ {
case null_object_type: case null_object_type:
case base_object_type: case base_object_type:
case OBJECT_TYPE_COUNT:
return; return;
case account_object_type:{ case account_object_type:{
accounts.insert( obj->id ); accounts.insert( obj->id );
@ -495,7 +476,11 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
transaction_get_impacted_accounts( aobj->proposed_transaction, accounts, transaction_get_impacted_accounts( aobj->proposed_transaction, accounts,
ignore_custom_operation_required_auths); ignore_custom_operation_required_auths);
break; break;
} case reserved0_object_type:{ } 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);
break; break;
} case withdraw_permission_object_type:{ } case withdraw_permission_object_type:{
const auto& aobj = dynamic_cast<const withdraw_permission_object*>(obj); const auto& aobj = dynamic_cast<const withdraw_permission_object*>(obj);
@ -516,85 +501,7 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
} case balance_object_type:{ } case balance_object_type:{
/** these are free from any accounts */ /** these are free from any accounts */
break; break;
} case tournament_object_type:{ } case account_role_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); const auto& aobj = dynamic_cast<const account_role_object*>(obj);
assert( aobj != nullptr ); assert( aobj != nullptr );
accounts.insert( aobj->owner ); accounts.insert( aobj->owner );
@ -605,8 +512,6 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
assert( aobj != nullptr ); assert( aobj != nullptr );
accounts.insert( aobj->son_account ); accounts.insert( aobj->son_account );
break; break;
} case son_proposal_object_type:{
break;
} case son_wallet_object_type:{ } case son_wallet_object_type:{
break; break;
} case son_wallet_deposit_object_type:{ } case son_wallet_deposit_object_type:{
@ -636,9 +541,9 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
break; break;
case impl_reserved0_object_type: case impl_reserved0_object_type:
break; break;
case impl_asset_dynamic_data_object_type: case impl_asset_dynamic_data_type:
break; break;
case impl_asset_bitasset_data_object_type: case impl_asset_bitasset_data_type:
break; break;
case impl_account_balance_object_type:{ case impl_account_balance_object_type:{
const auto& aobj = dynamic_cast<const account_balance_object*>(obj); const auto& aobj = dynamic_cast<const account_balance_object*>(obj);
@ -650,11 +555,11 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
assert( aobj != nullptr ); assert( aobj != nullptr );
accounts.insert( aobj->owner ); accounts.insert( aobj->owner );
break; break;
} case impl_transaction_history_object_type:{ } case impl_transaction_object_type:{
const auto& aobj = dynamic_cast<const transaction_history_object*>(obj); const auto& aobj = dynamic_cast<const transaction_object*>(obj);
FC_ASSERT( aobj != nullptr ); assert( aobj != nullptr );
transaction_get_impacted_accounts( aobj->trx, accounts, transaction_get_impacted_accounts( aobj->trx, accounts,
ignore_custom_operation_required_auths ); ignore_custom_operation_required_auths);
break; break;
} case impl_blinded_balance_object_type:{ } case impl_blinded_balance_object_type:{
const auto& aobj = dynamic_cast<const blinded_balance_object*>(obj); const auto& aobj = dynamic_cast<const blinded_balance_object*>(obj);
@ -664,7 +569,7 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
break; break;
} case impl_block_summary_object_type: } case impl_block_summary_object_type:
break; break;
case impl_reserved1_object_type: case impl_account_transaction_history_object_type:
break; break;
case impl_chain_property_object_type: case impl_chain_property_object_type:
break; break;
@ -678,62 +583,11 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
break; break;
case impl_fba_accumulator_object_type: case impl_fba_accumulator_object_type:
break; 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: case impl_nft_lottery_balance_object_type:
break; break;
default: default:
break; 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 ) } // end get_relevant_accounts( const object* obj, flat_set<account_id_type>& accounts )
@ -754,7 +608,6 @@ void database::notify_changed_objects()
if( _undo_db.enabled() ) if( _undo_db.enabled() )
{ {
const auto& head_undo = _undo_db.head(); const auto& head_undo = _undo_db.head();
auto chain_time = head_block_time();
// New // New
if( !new_objects.empty() ) if( !new_objects.empty() )
@ -766,8 +619,7 @@ void database::notify_changed_objects()
new_ids.push_back(item); new_ids.push_back(item);
auto obj = find_object(item); auto obj = find_object(item);
if(obj != nullptr) if(obj != nullptr)
get_relevant_accounts(obj, new_accounts_impacted, get_relevant_accounts(obj, new_accounts_impacted, true);
MUST_IGNORE_CUSTOM_OP_REQD_AUTHS(chain_time));
} }
GRAPHENE_TRY_NOTIFY( new_objects, new_ids, new_accounts_impacted) GRAPHENE_TRY_NOTIFY( new_objects, new_ids, new_accounts_impacted)
@ -781,8 +633,7 @@ void database::notify_changed_objects()
for( const auto& item : head_undo.old_values ) for( const auto& item : head_undo.old_values )
{ {
changed_ids.push_back(item.first); changed_ids.push_back(item.first);
get_relevant_accounts(item.second.get(), changed_accounts_impacted, get_relevant_accounts(item.second.get(), changed_accounts_impacted, true);
MUST_IGNORE_CUSTOM_OP_REQD_AUTHS(chain_time));
} }
GRAPHENE_TRY_NOTIFY( changed_objects, changed_ids, changed_accounts_impacted) GRAPHENE_TRY_NOTIFY( changed_objects, changed_ids, changed_accounts_impacted)
@ -799,8 +650,7 @@ void database::notify_changed_objects()
removed_ids.emplace_back( item.first ); removed_ids.emplace_back( item.first );
auto obj = item.second.get(); auto obj = item.second.get();
removed.emplace_back( obj ); removed.emplace_back( obj );
get_relevant_accounts(obj, removed_accounts_impacted, get_relevant_accounts(obj, removed_accounts_impacted, true);
MUST_IGNORE_CUSTOM_OP_REQD_AUTHS(chain_time));
} }
GRAPHENE_TRY_NOTIFY( removed_objects, removed_ids, removed, removed_accounts_impacted) GRAPHENE_TRY_NOTIFY( removed_objects, removed_ids, removed, removed_accounts_impacted)

View file

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

View file

@ -22,14 +22,12 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include <graphene/protocol/son_info.hpp>
#include <graphene/chain/database.hpp> #include <graphene/chain/database.hpp>
#include <graphene/chain/global_property_object.hpp> #include <graphene/chain/global_property_object.hpp>
#include <graphene/chain/witness_object.hpp> #include <graphene/chain/witness_object.hpp>
#include <graphene/chain/witness_schedule_object.hpp> #include <graphene/chain/witness_schedule_object.hpp>
#include <graphene/chain/son_object.hpp> #include <graphene/chain/son_object.hpp>
#include <graphene/chain/son_info.hpp>
#include <fc/popcount.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
@ -76,21 +74,32 @@ witness_id_type database::get_scheduled_witness( uint32_t slot_num )const
return wid; return wid;
} }
son_id_type database::get_scheduled_son( uint32_t slot_num )const unsigned_int database::get_son_schedule_id( sidechain_type type )const
{
static const map<sidechain_type, unsigned_int> schedule_map = {
{ sidechain_type::bitcoin, 0 },
{ sidechain_type::ethereum, 1 },
{ sidechain_type::hive, 2 }
};
return schedule_map.at(type);
}
son_id_type database::get_scheduled_son( sidechain_type type, uint32_t slot_num )const
{ {
son_id_type sid; son_id_type sid;
const global_property_object& gpo = get_global_properties(); const global_property_object& gpo = get_global_properties();
if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SHUFFLED_ALGORITHM) if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SHUFFLED_ALGORITHM)
{ {
const dynamic_global_property_object& dpo = get_dynamic_global_properties(); const dynamic_global_property_object& dpo = get_dynamic_global_properties();
const son_schedule_object& sso = son_schedule_id_type()(*this); const son_schedule_object& sso = son_schedule_id_type(get_son_schedule_id(type))(*this);
uint64_t current_aslot = dpo.current_aslot + slot_num; uint64_t current_aslot = dpo.current_aslot + slot_num;
return sso.current_shuffled_sons[ current_aslot % sso.current_shuffled_sons.size() ]; return sso.current_shuffled_sons[ current_aslot % sso.current_shuffled_sons.size() ];
} }
if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM && if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM &&
slot_num != 0 ) slot_num != 0 )
{ {
const son_schedule_object& sso = son_schedule_id_type()(*this); const son_schedule_object& sso = son_schedule_id_type(get_son_schedule_id(type))(*this);
// ask the near scheduler who goes in the given slot // ask the near scheduler who goes in the given slot
bool slot_is_near = sso.scheduler.get_slot(slot_num-1, sid); bool slot_is_near = sso.scheduler.get_slot(slot_num-1, sid);
if(! slot_is_near) if(! slot_is_near)
@ -191,36 +200,39 @@ void database::update_witness_schedule()
} }
} }
void database::update_son_schedule() void database::update_son_schedule(sidechain_type type)
{ {
const son_schedule_object& sso = son_schedule_id_type()(*this);
const global_property_object& gpo = get_global_properties(); const global_property_object& gpo = get_global_properties();
if( head_block_num() % gpo.active_sons.size() == 0 ) const son_schedule_object& sidechain_sso = get(son_schedule_id_type(get_son_schedule_id(type)));
if( gpo.active_sons.at(type).size() != 0 &&
head_block_num() % gpo.active_sons.at(type).size() == 0)
{ {
modify( sso, [&]( son_schedule_object& _sso ) modify( sidechain_sso, [&]( son_schedule_object& _sso )
{ {
_sso.current_shuffled_sons.clear(); _sso.current_shuffled_sons.clear();
_sso.current_shuffled_sons.reserve( gpo.active_sons.size() ); _sso.current_shuffled_sons.reserve( gpo.active_sons.at(type).size() );
for( const son_info& w : gpo.active_sons ) for ( const auto &w : gpo.active_sons.at(type) ) {
_sso.current_shuffled_sons.push_back( w.son_id ); _sso.current_shuffled_sons.push_back(w.son_id);
}
auto now_hi = uint64_t(head_block_time().sec_since_epoch()) << 32; auto now_hi = uint64_t(head_block_time().sec_since_epoch()) << 32;
for( uint32_t i = 0; i < _sso.current_shuffled_sons.size(); ++i )
for (uint32_t i = 0; i < _sso.current_shuffled_sons.size(); ++i)
{ {
/// High performance random generator /// High performance random generator
/// http://xorshift.di.unimi.it/ /// http://xorshift.di.unimi.it/
uint64_t k = now_hi + uint64_t(i)*2685821657736338717ULL; uint64_t k = now_hi + uint64_t(i) * 2685821657736338717ULL;
k ^= (k >> 12); k ^= (k >> 12);
k ^= (k << 25); k ^= (k << 25);
k ^= (k >> 27); k ^= (k >> 27);
k *= 2685821657736338717ULL; k *= 2685821657736338717ULL;
uint32_t jmax = _sso.current_shuffled_sons.size() - i; uint32_t jmax = _sso.current_shuffled_sons.size() - i;
uint32_t j = i + k%jmax; uint32_t j = i + k % jmax;
std::swap( _sso.current_shuffled_sons[i], std::swap(_sso.current_shuffled_sons[i],
_sso.current_shuffled_sons[j] ); _sso.current_shuffled_sons[j]);
} }
}); });
} }
@ -269,7 +281,7 @@ void database::update_witness_schedule(const signed_block& next_block)
modify(wso, [&](witness_schedule_object& _wso) modify(wso, [&](witness_schedule_object& _wso)
{ {
_wso.slots_since_genesis += schedule_slot; _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); _wso.scheduler._min_token_count = std::max(int(gpo.active_witnesses.size()) / 2, 1);
@ -306,13 +318,15 @@ void database::update_witness_schedule(const signed_block& next_block)
idump( ( double(total_time/1000000.0)/calls) ); idump( ( double(total_time/1000000.0)/calls) );
} }
void database::update_son_schedule(const signed_block& next_block) void database::update_son_schedule(sidechain_type type, const signed_block& next_block)
{ {
auto start = fc::time_point::now(); auto start = fc::time_point::now();
const global_property_object& gpo = get_global_properties(); #ifndef NDEBUG
const son_schedule_object& sso = get(son_schedule_id_type()); const son_schedule_object& sso = get(son_schedule_id_type());
uint32_t schedule_needs_filled = gpo.active_sons.size(); #endif
uint32_t schedule_slot = get_slot_at_time(next_block.timestamp); const global_property_object& gpo = get_global_properties();
const uint32_t schedule_needs_filled = gpo.active_sons.at(type).size();
const uint32_t schedule_slot = get_slot_at_time(next_block.timestamp);
// We shouldn't be able to generate _pending_block with timestamp // We shouldn't be able to generate _pending_block with timestamp
// in the past, and incoming blocks from the network with timestamp // in the past, and incoming blocks from the network with timestamp
@ -321,48 +335,49 @@ void database::update_son_schedule(const signed_block& next_block)
assert( schedule_slot > 0 ); assert( schedule_slot > 0 );
son_id_type first_son;
bool slot_is_near = sso.scheduler.get_slot( schedule_slot-1, first_son );
son_id_type son;
const dynamic_global_property_object& dpo = get_dynamic_global_properties(); const dynamic_global_property_object& dpo = get_dynamic_global_properties();
assert( dpo.random.data_size() == witness_scheduler_rng::seed_length ); assert( dpo.random.data_size() == witness_scheduler_rng::seed_length );
assert( witness_scheduler_rng::seed_length == sso.rng_seed.size() ); assert( witness_scheduler_rng::seed_length == sso.rng_seed.size() );
modify(sso, [&](son_schedule_object& _sso) const son_schedule_object& sidechain_sso = get(son_schedule_id_type(get_son_schedule_id(type)));
son_id_type first_son;
bool slot_is_near = sidechain_sso.scheduler.get_slot( schedule_slot-1, first_son );
son_id_type son_id;
modify(sidechain_sso, [&](son_schedule_object& _sso)
{ {
_sso.slots_since_genesis += schedule_slot; _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); _sso.scheduler._min_token_count = std::max(int(gpo.active_sons.at(type).size()) / 2, 1);
if( slot_is_near ) if( slot_is_near )
{ {
uint32_t drain = schedule_slot; uint32_t drain = schedule_slot;
while( drain > 0 ) while( drain > 0 )
{ {
if( _sso.scheduler.size() == 0 ) if( _sso.scheduler.size() == 0 )
break; break;
_sso.scheduler.consume_schedule(); _sso.scheduler.consume_schedule();
--drain; --drain;
} }
} }
else else
{ {
_sso.scheduler.reset_schedule( first_son ); _sso.scheduler.reset_schedule( first_son );
} }
while( !_sso.scheduler.get_slot(schedule_needs_filled, son) ) while( !_sso.scheduler.get_slot(schedule_needs_filled, son_id) )
{ {
if( _sso.scheduler.produce_schedule(rng) & emit_turn ) if( _sso.scheduler.produce_schedule(rng) & emit_turn )
memcpy(_sso.rng_seed.begin(), dpo.random.data(), dpo.random.data_size()); memcpy(_sso.rng_seed.begin(), dpo.random.data(), dpo.random.data_size());
} }
_sso.last_scheduling_block = next_block.block_num(); _sso.last_scheduling_block = next_block.block_num();
_sso.recent_slots_filled = ( _sso.recent_slots_filled = (
(_sso.recent_slots_filled << 1) (_sso.recent_slots_filled << 1)
+ 1) << (schedule_slot - 1); + 1) << (schedule_slot - 1);
}); });
auto end = fc::time_point::now(); auto end = fc::time_point::now();
static uint64_t total_time = 0; static uint64_t total_time = 0;
static uint64_t calls = 0; static uint64_t calls = 0;
@ -393,12 +408,12 @@ uint32_t database::witness_participation_rate()const
if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SHUFFLED_ALGORITHM) if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SHUFFLED_ALGORITHM)
{ {
const dynamic_global_property_object& dpo = get_dynamic_global_properties(); const dynamic_global_property_object& dpo = get_dynamic_global_properties();
return uint64_t(GRAPHENE_100_PERCENT) * fc::popcount(dpo.recent_slots_filled) / 128; return uint64_t(GRAPHENE_100_PERCENT) * dpo.recent_slots_filled.popcount() / 128;
} }
if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM) if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM)
{ {
const witness_schedule_object& wso = get_witness_schedule_object(); const witness_schedule_object& wso = get_witness_schedule_object();
return uint64_t(GRAPHENE_100_PERCENT) * fc::popcount(wso.recent_slots_filled) / 128; return uint64_t(GRAPHENE_100_PERCENT) * wso.recent_slots_filled.popcount() / 128;
} }
return 0; return 0;
} }

View file

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

View file

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

View file

@ -47,7 +47,7 @@ namespace graphene { namespace chain {
}; };
} } } }
FC_REFLECT_ENUM(graphene::chain::event_state, FC_REFLECT_ENUM(graphene::chain::event_state,
(upcoming) (upcoming)
(frozen_upcoming) (frozen_upcoming)
(in_progress) (in_progress)
@ -61,12 +61,12 @@ namespace graphene { namespace chain {
namespace msm = boost::msm; namespace msm = boost::msm;
namespace mpl = boost::mpl; namespace mpl = boost::mpl;
namespace namespace
{ {
// Events -- most events happen when the witnesses publish an event_update operation with a new // Events -- most events happen when the witnesses publish an event_update operation with a new
// status, so if they publish an event with the status set to `frozen`, we'll generate a `frozen_event` // status, so if they publish an event with the status set to `frozen`, we'll generate a `frozen_event`
struct upcoming_event struct upcoming_event
{ {
database& db; database& db;
upcoming_event(database& db) : db(db) {} upcoming_event(database& db) : db(db) {}
@ -76,12 +76,12 @@ namespace graphene { namespace chain {
database& db; database& db;
in_progress_event(database& db) : db(db) {} in_progress_event(database& db) : db(db) {}
}; };
struct frozen_event struct frozen_event
{ {
database& db; database& db;
frozen_event(database& db) : db(db) {} frozen_event(database& db) : db(db) {}
}; };
struct finished_event struct finished_event
{ {
database& db; database& db;
finished_event(database& db) : db(db) {} finished_event(database& db) : db(db) {}
@ -104,7 +104,7 @@ namespace graphene { namespace chain {
betting_market_group_resolved_event(database& db, betting_market_group_id_type resolved_group, bool was_canceled) : db(db), resolved_group(resolved_group), was_canceled(was_canceled) {} betting_market_group_resolved_event(database& db, betting_market_group_id_type resolved_group, bool was_canceled) : db(db), resolved_group(resolved_group), was_canceled(was_canceled) {}
}; };
// event triggered when a betting market group is closed. When we get this, // event triggered when a betting market group is closed. When we get this,
// if all child betting market groups are closed, transition to finished // if all child betting market groups are closed, transition to finished
struct betting_market_group_closed_event struct betting_market_group_closed_event
{ {
@ -127,7 +127,7 @@ namespace graphene { namespace chain {
void on_entry(const upcoming_event& event, event_state_machine_& fsm) { void on_entry(const upcoming_event& event, event_state_machine_& fsm) {
dlog("event ${id} -> upcoming", ("id", fsm.event_obj->id)); dlog("event ${id} -> upcoming", ("id", fsm.event_obj->id));
auto& betting_market_group_index = event.db.get_index_type<betting_market_group_object_index>().indices().get<by_event_id>(); auto& betting_market_group_index = event.db.get_index_type<betting_market_group_object_index>().indices().get<by_event_id>();
for (const betting_market_group_object& betting_market_group : for (const betting_market_group_object& betting_market_group :
boost::make_iterator_range(betting_market_group_index.equal_range(fsm.event_obj->id))) boost::make_iterator_range(betting_market_group_index.equal_range(fsm.event_obj->id)))
try try
{ {
@ -147,7 +147,7 @@ namespace graphene { namespace chain {
void on_entry(const in_progress_event& event, event_state_machine_& fsm) { void on_entry(const in_progress_event& event, event_state_machine_& fsm) {
dlog("event ${id} -> in_progress", ("id", fsm.event_obj->id)); dlog("event ${id} -> in_progress", ("id", fsm.event_obj->id));
auto& betting_market_group_index = event.db.get_index_type<betting_market_group_object_index>().indices().get<by_event_id>(); auto& betting_market_group_index = event.db.get_index_type<betting_market_group_object_index>().indices().get<by_event_id>();
for (const betting_market_group_object& betting_market_group : for (const betting_market_group_object& betting_market_group :
boost::make_iterator_range(betting_market_group_index.equal_range(fsm.event_obj->id))) boost::make_iterator_range(betting_market_group_index.equal_range(fsm.event_obj->id)))
try try
{ {
@ -203,7 +203,7 @@ namespace graphene { namespace chain {
void freeze_betting_market_groups(const frozen_event& event) { void freeze_betting_market_groups(const frozen_event& event) {
auto& betting_market_group_index = event.db.get_index_type<betting_market_group_object_index>().indices().get<by_event_id>(); auto& betting_market_group_index = event.db.get_index_type<betting_market_group_object_index>().indices().get<by_event_id>();
for (const betting_market_group_object& betting_market_group : for (const betting_market_group_object& betting_market_group :
boost::make_iterator_range(betting_market_group_index.equal_range(event_obj->id))) boost::make_iterator_range(betting_market_group_index.equal_range(event_obj->id)))
{ {
try try
@ -222,7 +222,7 @@ namespace graphene { namespace chain {
void close_all_betting_market_groups(const finished_event& event) { void close_all_betting_market_groups(const finished_event& event) {
auto& betting_market_group_index = event.db.get_index_type<betting_market_group_object_index>().indices().get<by_event_id>(); auto& betting_market_group_index = event.db.get_index_type<betting_market_group_object_index>().indices().get<by_event_id>();
for (const betting_market_group_object& betting_market_group : for (const betting_market_group_object& betting_market_group :
boost::make_iterator_range(betting_market_group_index.equal_range(event_obj->id))) boost::make_iterator_range(betting_market_group_index.equal_range(event_obj->id)))
{ {
try try
@ -241,7 +241,7 @@ namespace graphene { namespace chain {
void cancel_all_betting_market_groups(const canceled_event& event) { void cancel_all_betting_market_groups(const canceled_event& event) {
auto& betting_market_group_index = event.db.template get_index_type<betting_market_group_object_index>().indices().template get<by_event_id>(); auto& betting_market_group_index = event.db.template get_index_type<betting_market_group_object_index>().indices().template get<by_event_id>();
for (const betting_market_group_object& betting_market_group : for (const betting_market_group_object& betting_market_group :
boost::make_iterator_range(betting_market_group_index.equal_range(event_obj->id))) boost::make_iterator_range(betting_market_group_index.equal_range(event_obj->id)))
event.db.modify(betting_market_group, [&event](betting_market_group_object& betting_market_group_obj) { event.db.modify(betting_market_group, [&event](betting_market_group_object& betting_market_group_obj) {
betting_market_group_obj.on_canceled_event(event.db, true); betting_market_group_obj.on_canceled_event(event.db, true);
@ -252,15 +252,15 @@ namespace graphene { namespace chain {
bool all_betting_market_groups_are_closed(const betting_market_group_closed_event& event) bool all_betting_market_groups_are_closed(const betting_market_group_closed_event& event)
{ {
auto& betting_market_group_index = event.db.get_index_type<betting_market_group_object_index>().indices().get<by_event_id>(); auto& betting_market_group_index = event.db.get_index_type<betting_market_group_object_index>().indices().get<by_event_id>();
for (const betting_market_group_object& betting_market_group : for (const betting_market_group_object& betting_market_group :
boost::make_iterator_range(betting_market_group_index.equal_range(event_obj->id))) boost::make_iterator_range(betting_market_group_index.equal_range(event_obj->id)))
if (betting_market_group.id != event.closed_group) if (betting_market_group.id != event.closed_group)
{ {
betting_market_group_status status = betting_market_group.get_status(); betting_market_group_status status = betting_market_group.get_status();
if (status != betting_market_group_status::closed && if (status != betting_market_group_status::closed &&
status != betting_market_group_status::graded && status != betting_market_group_status::graded &&
status != betting_market_group_status::re_grading && status != betting_market_group_status::re_grading &&
status != betting_market_group_status::settled && status != betting_market_group_status::settled &&
status != betting_market_group_status::canceled) status != betting_market_group_status::canceled)
return false; return false;
} }
@ -276,7 +276,7 @@ namespace graphene { namespace chain {
if (event_obj->at_least_one_betting_market_group_settled) if (event_obj->at_least_one_betting_market_group_settled)
return false; return false;
auto& betting_market_group_index = event.db.get_index_type<betting_market_group_object_index>().indices().get<by_event_id>(); auto& betting_market_group_index = event.db.get_index_type<betting_market_group_object_index>().indices().get<by_event_id>();
for (const betting_market_group_object& betting_market_group : for (const betting_market_group_object& betting_market_group :
boost::make_iterator_range(betting_market_group_index.equal_range(event_obj->id))) boost::make_iterator_range(betting_market_group_index.equal_range(event_obj->id)))
if (betting_market_group.id != event.resolved_group) if (betting_market_group.id != event.resolved_group)
if (betting_market_group.get_status() != betting_market_group_status::canceled) if (betting_market_group.get_status() != betting_market_group_status::canceled)
@ -290,7 +290,7 @@ namespace graphene { namespace chain {
event_obj->at_least_one_betting_market_group_settled = true; event_obj->at_least_one_betting_market_group_settled = true;
auto& betting_market_group_index = event.db.get_index_type<betting_market_group_object_index>().indices().get<by_event_id>(); auto& betting_market_group_index = event.db.get_index_type<betting_market_group_object_index>().indices().get<by_event_id>();
for (const betting_market_group_object& betting_market_group : for (const betting_market_group_object& betting_market_group :
boost::make_iterator_range(betting_market_group_index.equal_range(event_obj->id))) { boost::make_iterator_range(betting_market_group_index.equal_range(event_obj->id))) {
if (betting_market_group.id != event.resolved_group) { if (betting_market_group.id != event.resolved_group) {
betting_market_group_status status = betting_market_group.get_status(); betting_market_group_status status = betting_market_group.get_status();
@ -344,7 +344,6 @@ namespace graphene { namespace chain {
{ {
FC_THROW_EXCEPTION(graphene::chain::no_transition, "No transition"); FC_THROW_EXCEPTION(graphene::chain::no_transition, "No transition");
} }
template <class Fsm> template <class Fsm>
void no_transition(canceled_event const& e, Fsm&, int state) void no_transition(canceled_event const& e, Fsm&, int state)
{ {
@ -372,7 +371,7 @@ namespace graphene { namespace chain {
{ {
} }
event_object::event_object(const event_object& rhs) : event_object::event_object(const event_object& rhs) :
graphene::db::abstract_object<event_object>(rhs), graphene::db::abstract_object<event_object>(rhs),
name(rhs.name), name(rhs.name),
season(rhs.season), season(rhs.season),
@ -408,7 +407,7 @@ namespace graphene { namespace chain {
} }
namespace { namespace {
bool verify_event_status_constants() bool verify_event_status_constants()
{ {
unsigned error_count = 0; unsigned error_count = 0;
@ -443,19 +442,19 @@ namespace graphene { namespace chain {
dlog("Event status constants are correct"); dlog("Event status constants are correct");
else else
wlog("There were ${count} errors in the event status constants", ("count", error_count)); wlog("There were ${count} errors in the event status constants", ("count", error_count));
return error_count == 0; return error_count == 0;
} }
} // end anonymous namespace } // end anonymous namespace
event_status event_object::get_status() const event_status event_object::get_status() const
{ {
static bool state_constants_are_correct = verify_event_status_constants(); static bool state_constants_are_correct = verify_event_status_constants();
(void)&state_constants_are_correct; (void)&state_constants_are_correct;
event_state state = (event_state)my->state_machine.current_state()[0]; event_state state = (event_state)my->state_machine.current_state()[0];
ddump((state)); ddump((state));
switch (state) switch (state)
{ {
case event_state::upcoming: case event_state::upcoming:
@ -523,8 +522,8 @@ namespace graphene { namespace chain {
my->state_machine.process_event(betting_market_group_closed_event(db, closed_group)); my->state_machine.process_event(betting_market_group_closed_event(db, closed_group));
} }
// These are the only statuses that can be explicitly set by witness operations. The missing // These are the only statuses that can be explicitly set by witness operations. The missing
// status, 'settled', is automatically set when all of the betting market groups have // status, 'settled', is automatically set when all of the betting market groups have
// settled/canceled // settled/canceled
void event_object::dispatch_new_status(database& db, event_status new_status) void event_object::dispatch_new_status(database& db, event_status new_status)
{ {
@ -533,16 +532,16 @@ namespace graphene { namespace chain {
on_upcoming_event(db); on_upcoming_event(db);
break; break;
case event_status::in_progress: // by witnesses when the event starts case event_status::in_progress: // by witnesses when the event starts
on_in_progress_event(db); on_in_progress_event(db);
break; break;
case event_status::frozen: // by witnesses when the event needs to be frozen case event_status::frozen: // by witnesses when the event needs to be frozen
on_frozen_event(db); on_frozen_event(db);
break; break;
case event_status::finished: // by witnesses when the event is complete case event_status::finished: // by witnesses when the event is complete
on_finished_event(db); on_finished_event(db);
break; break;
case event_status::canceled: // by witnesses to cancel the event case event_status::canceled: // by witnesses to cancel the event
on_canceled_event(db); on_canceled_event(db);
break; break;
default: default:
FC_THROW("Status ${new_status} cannot be explicitly set", ("new_status", new_status)); FC_THROW("Status ${new_status} cannot be explicitly set", ("new_status", new_status));
@ -551,7 +550,7 @@ namespace graphene { namespace chain {
} } // graphene::chain } } // graphene::chain
namespace fc { namespace fc {
// Manually reflect event_object to variant to properly reflect "state" // Manually reflect event_object to variant to properly reflect "state"
void to_variant(const graphene::chain::event_object& event_obj, fc::variant& v, uint32_t max_depth) void to_variant(const graphene::chain::event_object& event_obj, fc::variant& v, uint32_t max_depth)
{ {

View file

@ -1,135 +0,0 @@
/*
* 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/fork_database.hpp>
#include <graphene/chain/exceptions.hpp> #include <graphene/chain/exceptions.hpp>
#include <graphene/protocol/fee_schedule.hpp> #include <graphene/chain/protocol/fee_schedule.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
fork_database::fork_database() fork_database::fork_database()

View file

@ -547,7 +547,7 @@ namespace graphene { namespace chain {
} } // graphene::chain } } // graphene::chain
namespace fc { namespace fc {
// Manually reflect game_object to variant to properly reflect "state" // Manually reflect game_object to variant to properly reflect "state"
void to_variant(const graphene::chain::game_object& game_obj, fc::variant& v, uint32_t max_depth) void to_variant(const graphene::chain::game_object& game_obj, fc::variant& v, uint32_t max_depth)
{ {

View file

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

View file

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

View file

@ -1,10 +0,0 @@
// #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("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
// Bugfix: pre-HF 210, custom_operation's required_auths field was ignored.
#define MUST_IGNORE_CUSTOM_OP_REQD_AUTHS(chain_time) (chain_time <= HARDFORK_CORE_210_TIME)
#endif

View file

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

View file

@ -0,0 +1,7 @@
#ifndef HARDFORK_HOTFIX_2024_TIME
#ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_HOTFIX_2024_TIME (fc::time_point_sec::from_iso_string("2023-12-20T00:00:00"))
#else
#define HARDFORK_HOTFIX_2024_TIME (fc::time_point_sec::from_iso_string("2023-12-20T00:00:00"))
#endif
#endif

View file

@ -0,0 +1,7 @@
#ifndef HARDFORK_SIDECHAIN_DELETE_TIME
#ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_SIDECHAIN_DELETE_TIME (fc::time_point_sec::from_iso_string("2022-11-16T02:00:00"))
#else
#define HARDFORK_SIDECHAIN_DELETE_TIME (fc::time_point_sec::from_iso_string("2022-11-16T02:00:00"))
#endif
#endif

View file

@ -0,0 +1,7 @@
#ifndef HARDFORK_SON_FOR_ETHEREUM_TIME
#ifdef BUILD_PEERPLAYS_TESTNET
#define HARDFORK_SON_FOR_ETHEREUM_TIME (fc::time_point_sec::from_iso_string("2023-07-17T12:00:00"))
#else
#define HARDFORK_SON_FOR_ETHEREUM_TIME (fc::time_point_sec::from_iso_string("2023-10-24T12:00:00"))
#endif
#endif

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -23,15 +23,11 @@
*/ */
#pragma once #pragma once
#include <graphene/chain/types.hpp> #include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/protocol/betting_market.hpp>
#include <graphene/protocol/betting_market.hpp>
#include <graphene/db/object.hpp> #include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp> #include <graphene/db/generic_index.hpp>
#include <boost/multi_index/composite_key.hpp> #include <boost/multi_index/composite_key.hpp>
#include <sstream> #include <sstream>
namespace graphene { namespace chain { namespace graphene { namespace chain {
@ -39,7 +35,7 @@ namespace graphene { namespace chain {
class betting_market_group_object; class betting_market_group_object;
} } } }
namespace fc { namespace fc {
void to_variant(const graphene::chain::betting_market_object& betting_market_obj, fc::variant& v, uint32_t max_depth = 1); void to_variant(const graphene::chain::betting_market_object& betting_market_obj, fc::variant& v, uint32_t max_depth = 1);
void from_variant(const fc::variant& v, graphene::chain::betting_market_object& betting_market_obj, uint32_t max_depth = 1); void from_variant(const fc::variant& v, graphene::chain::betting_market_object& betting_market_obj, uint32_t max_depth = 1);
void to_variant(const graphene::chain::betting_market_group_object& betting_market_group_obj, fc::variant& v, uint32_t max_depth = 1); void to_variant(const graphene::chain::betting_market_group_object& betting_market_group_obj, fc::variant& v, uint32_t max_depth = 1);
@ -48,7 +44,7 @@ namespace fc {
namespace graphene { namespace chain { namespace graphene { namespace chain {
FC_DECLARE_EXCEPTION(no_transition, 100000); FC_DECLARE_EXCEPTION(no_transition, 100000, "Invalid state transition");
class database; class database;
struct by_event_id; struct by_event_id;
@ -629,10 +625,9 @@ typedef multi_index_container<
typedef generic_index<betting_market_position_object, betting_market_position_multi_index_type> betting_market_position_index; typedef generic_index<betting_market_position_object, betting_market_position_multi_index_type> betting_market_position_index;
template<typename Stream> template<typename Stream>
inline Stream& operator<<( Stream& s, const betting_market_object& betting_market_obj ) inline Stream& operator<<( Stream& s, const betting_market_object& betting_market_obj )
{ {
// pack all fields exposed in the header in the usual way // pack all fields exposed in the header in the usual way
// instead of calling the derived pack, just serialize the one field in the base class // instead of calling the derived pack, just serialize the one field in the base class
// fc::raw::pack<Stream, const graphene::db::abstract_object<betting_market_object> >(s, betting_market_obj); // fc::raw::pack<Stream, const graphene::db::abstract_object<betting_market_object> >(s, betting_market_obj);
@ -652,7 +647,7 @@ inline Stream& operator<<( Stream& s, const betting_market_object& betting_marke
} }
template<typename Stream> template<typename Stream>
inline Stream& operator>>( Stream& s, betting_market_object& betting_market_obj ) inline Stream& operator>>( Stream& s, betting_market_object& betting_market_obj )
{ {
// unpack all fields exposed in the header in the usual way // unpack all fields exposed in the header in the usual way
//fc::raw::unpack<Stream, graphene::db::abstract_object<betting_market_object> >(s, betting_market_obj); //fc::raw::unpack<Stream, graphene::db::abstract_object<betting_market_object> >(s, betting_market_obj);
fc::raw::unpack(s, betting_market_obj.id); fc::raw::unpack(s, betting_market_obj.id);
@ -666,14 +661,14 @@ inline Stream& operator>>( Stream& s, betting_market_object& betting_market_obj
fc::raw::unpack(s, stringified_stream); fc::raw::unpack(s, stringified_stream);
std::istringstream stream(stringified_stream); std::istringstream stream(stringified_stream);
betting_market_obj.unpack_impl(stream); betting_market_obj.unpack_impl(stream);
return s; return s;
} }
template<typename Stream> template<typename Stream>
inline Stream& operator<<( Stream& s, const betting_market_group_object& betting_market_group_obj ) inline Stream& operator<<( Stream& s, const betting_market_group_object& betting_market_group_obj )
{ {
// pack all fields exposed in the header in the usual way // pack all fields exposed in the header in the usual way
// instead of calling the derived pack, just serialize the one field in the base class // instead of calling the derived pack, just serialize the one field in the base class
// fc::raw::pack<Stream, const graphene::db::abstract_object<betting_market_group_object> >(s, betting_market_group_obj); // fc::raw::pack<Stream, const graphene::db::abstract_object<betting_market_group_object> >(s, betting_market_group_obj);
@ -696,7 +691,7 @@ inline Stream& operator<<( Stream& s, const betting_market_group_object& betting
} }
template<typename Stream> template<typename Stream>
inline Stream& operator>>( Stream& s, betting_market_group_object& betting_market_group_obj ) inline Stream& operator>>( Stream& s, betting_market_group_object& betting_market_group_obj )
{ {
// unpack all fields exposed in the header in the usual way // unpack all fields exposed in the header in the usual way
//fc::raw::unpack<Stream, graphene::db::abstract_object<betting_market_group_object> >(s, betting_market_group_obj); //fc::raw::unpack<Stream, graphene::db::abstract_object<betting_market_group_object> >(s, betting_market_group_obj);
fc::raw::unpack(s, betting_market_group_obj.id); fc::raw::unpack(s, betting_market_group_obj.id);
@ -714,22 +709,113 @@ inline Stream& operator>>( Stream& s, betting_market_group_object& betting_marke
fc::raw::unpack(s, stringified_stream); fc::raw::unpack(s, stringified_stream);
std::istringstream stream(stringified_stream); std::istringstream stream(stringified_stream);
betting_market_group_obj.unpack_impl(stream); betting_market_group_obj.unpack_impl(stream);
return s; return s;
} }
} } // graphene::chain } } // 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_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::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) ) 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) )
namespace fc {
template<>
template<>
inline void if_enum<fc::false_type>::from_variant(const variant &vo, graphene::chain::betting_market_object &v, uint32_t max_depth) {
from_variant(vo, v, max_depth);
}
template<>
template<>
inline void if_enum<fc::false_type>::to_variant(const graphene::chain::betting_market_object &v, variant &vo, uint32_t max_depth) {
to_variant(v, vo, max_depth);
}
namespace raw { namespace detail {
template<>
template<>
inline void if_enum<fc::false_type>::pack(fc::datastream<size_t> &s, const graphene::chain::betting_market_object &v, uint32_t) {
s << v;
}
template<>
template<>
inline void if_enum<fc::false_type>::pack(fc::datastream<char*> &s, const graphene::chain::betting_market_object &v, uint32_t) {
s << v;
}
template<>
template<>
inline void if_enum<fc::false_type>::unpack(fc::datastream<const char*> &s, graphene::chain::betting_market_object &v, uint32_t) {
s >> v;
}
} } // namespace fc::raw::detail
template <>
struct get_typename<graphene::chain::betting_market_object> {
static const char *name() {
return "graphene::chain::betting_market_object";
}
};
template <>
struct reflector<graphene::chain::betting_market_object> {
typedef graphene::chain::betting_market_object type;
typedef fc::true_type is_defined;
typedef fc::false_type is_enum;
};
} // namespace fc
namespace fc {
template<>
template<>
inline void if_enum<fc::false_type>::from_variant(const variant &vo, graphene::chain::betting_market_group_object &v, uint32_t max_depth) {
from_variant(vo, v, max_depth);
}
template<>
template<>
inline void if_enum<fc::false_type>::to_variant(const graphene::chain::betting_market_group_object &v, variant &vo, uint32_t max_depth) {
to_variant(v, vo, max_depth);
}
namespace raw { namespace detail {
template<>
template<>
inline void if_enum<fc::false_type>::pack(fc::datastream<size_t> &s, const graphene::chain::betting_market_group_object &v, uint32_t) {
s << v;
}
template<>
template<>
inline void if_enum<fc::false_type>::pack(fc::datastream<char*> &s, const graphene::chain::betting_market_group_object &v, uint32_t) {
s << v;
}
template<>
template<>
inline void if_enum<fc::false_type>::unpack(fc::datastream<const char*> &s, graphene::chain::betting_market_group_object &v, uint32_t) {
s >> v;
}
} } // namespace fc::raw:detail
template <>
struct get_typename<graphene::chain::betting_market_group_object> {
static const char *name() {
return "graphene::chain::betting_market_group_object";
}
};
template <>
struct reflector<graphene::chain::betting_market_group_object> {
typedef graphene::chain::betting_market_group_object type;
typedef fc::true_type is_defined;
typedef fc::false_type is_enum;
};
} // namespace fc

View file

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

View file

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

View file

@ -22,9 +22,7 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#pragma once #pragma once
#include <graphene/chain/types.hpp> #include <graphene/chain/protocol/types.hpp>
#include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp> #include <graphene/db/generic_index.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
@ -69,8 +67,6 @@ 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, FC_REFLECT(graphene::chain::budget_record,
(time_since_last_budget) (time_since_last_budget)
(from_initial_reserve) (from_initial_reserve)

View file

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

View file

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

View file

@ -24,7 +24,6 @@
#pragma once #pragma once
#include <graphene/chain/immutable_chain_parameters.hpp> #include <graphene/chain/immutable_chain_parameters.hpp>
#include <graphene/chain/types.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
@ -43,8 +42,6 @@ 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), FC_REFLECT_DERIVED( graphene::chain::chain_property_object, (graphene::db::object),
(chain_id) (chain_id)
(immutable_parameters) (immutable_parameters)

View file

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

View file

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

View file

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

View file

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

View file

@ -23,16 +23,242 @@
*/ */
#pragma once #pragma once
#include <graphene/protocol/config.hpp> #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
#define GRAPHENE_MIN_UNDO_HISTORY 10 #define GRAPHENE_MIN_UNDO_HISTORY 10
#define GRAPHENE_MAX_UNDO_HISTORY 10000 #define GRAPHENE_MAX_UNDO_HISTORY 10000
#define GRAPHENE_MAX_NESTED_OBJECTS (200) #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_CURRENT_DB_VERSION "PPY2.5" #define GRAPHENE_BLOCKCHAIN_PRECISION_DIGITS 5
#define GRAPHENE_DEFAULT_MIN_SON_COUNT (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_RECENTLY_MISSED_COUNT_INCREMENT 4 #define GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT 4
#define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3 #define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3
#define GRAPHENE_CURRENT_DB_VERSION "PPY2.5"
#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,14 +1,13 @@
#pragma once #pragma once
#include <graphene/chain/evaluator.hpp> #include <graphene/chain/evaluator.hpp>
#include <graphene/chain/protocol/custom_account_authority.hpp>
#include <graphene/protocol/custom_account_authority.hpp>
namespace graphene namespace graphene
{ {
namespace chain namespace chain
{ {
class create_custom_account_authority_evaluator : public fee_handling_evaluator<create_custom_account_authority_evaluator> class create_custom_account_authority_evaluator : public evaluator<create_custom_account_authority_evaluator>
{ {
public: public:
typedef custom_account_authority_create_operation operation_type; typedef custom_account_authority_create_operation operation_type;
@ -17,7 +16,7 @@ public:
object_id_type do_apply(const custom_account_authority_create_operation &o); object_id_type do_apply(const custom_account_authority_create_operation &o);
}; };
class update_custom_account_authority_evaluator : public fee_handling_evaluator<update_custom_account_authority_evaluator> class update_custom_account_authority_evaluator : public evaluator<update_custom_account_authority_evaluator>
{ {
public: public:
typedef custom_account_authority_update_operation operation_type; typedef custom_account_authority_update_operation operation_type;
@ -26,7 +25,7 @@ public:
object_id_type do_apply(const custom_account_authority_update_operation &o); object_id_type do_apply(const custom_account_authority_update_operation &o);
}; };
class delete_custom_account_authority_evaluator : public fee_handling_evaluator<delete_custom_account_authority_evaluator> class delete_custom_account_authority_evaluator : public evaluator<delete_custom_account_authority_evaluator>
{ {
public: public:
typedef custom_account_authority_delete_operation operation_type; typedef custom_account_authority_delete_operation operation_type;
@ -36,5 +35,4 @@ public:
}; };
} // namespace chain } // namespace chain
} // namespace graphene } // namespace graphene

View file

@ -1,6 +1,5 @@
#pragma once #pragma once
#include <graphene/chain/types.hpp> #include <graphene/chain/protocol/types.hpp>
#include <graphene/db/object.hpp> #include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp> #include <graphene/db/generic_index.hpp>
@ -24,6 +23,7 @@ namespace graphene { namespace chain {
time_point_sec valid_to; time_point_sec valid_to;
}; };
struct by_id;
struct by_permission_and_op; struct by_permission_and_op;
struct by_expiration; struct by_expiration;
using custom_account_authority_multi_index_type = multi_index_container< using custom_account_authority_multi_index_type = multi_index_container<
@ -51,8 +51,5 @@ namespace graphene { namespace chain {
} } // graphene::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), 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. * THE SOFTWARE.
*/ */
#pragma once #pragma once
#include <graphene/protocol/operations.hpp> #include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/evaluator.hpp> #include <graphene/chain/evaluator.hpp>
#include <graphene/chain/database.hpp> #include <graphene/chain/database.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
class custom_evaluator : public fee_handling_evaluator<custom_evaluator> class custom_evaluator : public evaluator<custom_evaluator>
{ {
public: public:
typedef custom_operation operation_type; typedef custom_operation operation_type;

View file

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

View file

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

View file

@ -22,7 +22,6 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#pragma once #pragma once
#include <graphene/chain/global_property_object.hpp> #include <graphene/chain/global_property_object.hpp>
#include <graphene/chain/node_property_object.hpp> #include <graphene/chain/node_property_object.hpp>
#include <graphene/chain/account_object.hpp> #include <graphene/chain/account_object.hpp>
@ -31,20 +30,18 @@
#include <graphene/chain/block_database.hpp> #include <graphene/chain/block_database.hpp>
#include <graphene/chain/genesis_state.hpp> #include <graphene/chain/genesis_state.hpp>
#include <graphene/chain/evaluator.hpp> #include <graphene/chain/evaluator.hpp>
#include <graphene/chain/betting_market_object.hpp>
#include <graphene/db/object_database.hpp> #include <graphene/db/object_database.hpp>
#include <graphene/db/object.hpp> #include <graphene/db/object.hpp>
#include <graphene/db/simple_index.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/signals.hpp>
#include <fc/crypto/hash_ctr_rng.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 <fc/log/logger.hpp>
#include <map> #include <map>
@ -54,15 +51,6 @@ namespace graphene { namespace chain {
using graphene::db::object; using graphene::db::object;
class op_evaluator; class op_evaluator;
class transaction_evaluation_state; 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; struct budget_record;
@ -75,9 +63,11 @@ namespace graphene { namespace chain {
public: public:
//////////////////// db_management.cpp //////////////////// //////////////////// db_management.cpp ////////////////////
database(bool allow_testing_edits = false); database();
~database(); ~database();
std::vector<fc::time_point_sec> _hardfork_times;
enum validation_steps enum validation_steps
{ {
skip_nothing = 0, skip_nothing = 0,
@ -255,7 +245,16 @@ namespace graphene { namespace chain {
witness_id_type get_scheduled_witness(uint32_t slot_num)const; witness_id_type get_scheduled_witness(uint32_t slot_num)const;
/** /**
* @brief Get the son scheduled for block production in a slot. * @brief Get son schedule id for the given sidechain_type.
*
* type sidechain_type we getting schedule.
*
* returns Id of the schedule object.
*/
unsigned_int get_son_schedule_id(sidechain_type type)const;
/**
* @brief Get the bitcoin or hive son scheduled for block production in a slot.
* *
* slot_num always corresponds to a time in the future. * slot_num always corresponds to a time in the future.
* *
@ -268,7 +267,7 @@ namespace graphene { namespace chain {
* *
* Passing slot_num == 0 returns GRAPHENE_NULL_WITNESS * Passing slot_num == 0 returns GRAPHENE_NULL_WITNESS
*/ */
son_id_type get_scheduled_son(uint32_t slot_num)const; son_id_type get_scheduled_son(sidechain_type type, uint32_t slot_num)const;
/** /**
* Get the time at which the given slot occurs. * Get the time at which the given slot occurs.
@ -293,8 +292,8 @@ namespace graphene { namespace chain {
vector<witness_id_type> get_near_witness_schedule()const; vector<witness_id_type> get_near_witness_schedule()const;
void update_witness_schedule(); void update_witness_schedule();
void update_witness_schedule(const signed_block& next_block); void update_witness_schedule(const signed_block& next_block);
void update_son_schedule(); void update_son_schedule(sidechain_type type);
void update_son_schedule(const signed_block& next_block); void update_son_schedule(sidechain_type type, const signed_block& next_block);
void check_lottery_end_by_participants( asset_id_type asset_id ); void check_lottery_end_by_participants( asset_id_type asset_id );
void check_ending_lotteries(); void check_ending_lotteries();
@ -323,7 +322,7 @@ namespace graphene { namespace chain {
fc::optional<operation> create_son_deregister_proposal( son_id_type son_id, account_id_type paying_son ); fc::optional<operation> create_son_deregister_proposal( son_id_type son_id, account_id_type paying_son );
signed_transaction create_signed_transaction( const fc::ecc::private_key& signing_private_key, const operation& op ); signed_transaction create_signed_transaction( const fc::ecc::private_key& signing_private_key, const operation& op );
bool is_son_dereg_valid( son_id_type son_id ); bool is_son_dereg_valid( son_id_type son_id );
bool is_son_active( son_id_type son_id ); bool is_son_active( sidechain_type type, son_id_type son_id );
bool is_asset_creation_allowed(const string& symbol); bool is_asset_creation_allowed(const string& symbol);
time_point_sec head_block_time()const; time_point_sec head_block_time()const;
@ -344,52 +343,15 @@ namespace graphene { namespace chain {
void initialize_evaluators(); void initialize_evaluators();
/// Reset the object graph in-memory /// Reset the object graph in-memory
void initialize_indexes(); void initialize_indexes();
void initialize_hardforks();
void init_genesis(const genesis_state_type& genesis_state = genesis_state_type()); 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> template<typename EvaluatorType>
op_evaluator::evaluator_handle register_third_party_evaluator() void register_evaluator()
{ {
return register_evaluator<EvaluatorType, true>(_third_party_operation_evaluators); _operation_evaluators[
} operation::tag<typename EvaluatorType::operation_type>::value].reset( new op_evaluator_impl<EvaluatorType>() );
/**
* @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 //////////////////// //////////////////// db_balance.cpp ////////////////////
@ -454,12 +416,6 @@ namespace graphene { namespace chain {
void debug_dump(); void debug_dump();
void apply_debug_updates(); void apply_debug_updates();
void debug_update( const fc::variant_object& update ); 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 //////////////////// //////////////////// db_market.cpp ////////////////////
@ -556,7 +512,7 @@ namespace graphene { namespace chain {
*/ */
/// Enable or disable tracking of votes of standby witnesses and committee members /// Enable or disable tracking of votes of standby witnesses and committee members
inline void enable_standby_votes_tracking(bool enable) { _track_standby_votes = enable; } 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 //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 pop_undo() { object_database::pop_undo(); }
void notify_applied_block( const signed_block& block ); void notify_applied_block( const signed_block& block );
@ -564,50 +520,19 @@ namespace graphene { namespace chain {
void notify_changed_objects(); void notify_changed_objects();
private: private:
std::mutex _pending_tx_session_mutex;
optional<undo_database::session> _pending_tx_session; optional<undo_database::session> _pending_tx_session;
vector< unique_ptr<op_evaluator> > _third_party_operation_evaluators; vector< unique_ptr<op_evaluator> > _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> template<class Index>
vector<std::reference_wrapper<const typename Index::object_type>> sort_votable_objects(size_t count)const; vector<std::reference_wrapper<const typename Index::object_type>> sort_votable_objects(size_t count)const;
template<class Index>
vector<std::reference_wrapper<const typename Index::object_type>> sort_votable_objects(sidechain_type sidechain, size_t count)const;
//////////////////// db_block.cpp //////////////////// //////////////////// db_block.cpp ////////////////////
public: public:
// these were formerly private, but they have a fairly well-defined API, so let's make them 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 ); 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 ); processed_transaction apply_transaction( const signed_transaction& trx, uint32_t skip = skip_nothing );
@ -654,19 +579,22 @@ namespace graphene { namespace chain {
void initialize_budget_record( fc::time_point_sec now, budget_record& rec )const; void initialize_budget_record( fc::time_point_sec now, budget_record& rec )const;
void process_budget(); void process_budget();
void pay_workers( share_type& budget ); void pay_workers( share_type& budget );
void pay_sons(); void pay_sons_before_hf_ethereum();
void pay_sons_after_hf_ethereum();
void perform_son_tasks(); void perform_son_tasks();
void perform_chain_maintenance(const signed_block& next_block, const global_property_object& global_props); void perform_chain_maintenance(const signed_block& next_block, const global_property_object& global_props);
void update_active_witnesses(); void update_active_witnesses();
void update_active_committee_members(); void update_active_committee_members();
void update_son_metrics( const vector<son_info>& curr_active_sons ); void update_son_metrics( const flat_map<sidechain_type, vector<son_sidechain_info> >& curr_active_sons );
void update_active_sons(); void update_active_sons();
void remove_son_proposal( const proposal_object& proposal ); void remove_son_proposal( const proposal_object& proposal );
void remove_inactive_son_down_proposals( const vector<son_id_type>& son_ids_to_remove ); void remove_inactive_son_down_proposals( const vector<son_id_type>& son_ids_to_remove );
void remove_inactive_son_proposals( const vector<son_id_type>& son_ids_to_remove ); void remove_inactive_son_proposals( const vector<son_id_type>& son_ids_to_remove );
void update_son_statuses( const vector<son_info>& cur_active_sons, const vector<son_info>& new_active_sons ); void update_son_statuses( const flat_map<sidechain_type, vector<son_sidechain_info> >& curr_active_sons,
void update_son_wallet( const vector<son_info>& new_active_sons ); const flat_map<sidechain_type, vector<son_sidechain_info> >& new_active_sons );
void update_son_wallet( const flat_map<sidechain_type, vector<son_sidechain_info> >& new_active_sons );
void update_worker_votes(); void update_worker_votes();
void hotfix_2024();
public: public:
double calculate_vesting_factor(const account_object& stake_account); double calculate_vesting_factor(const account_object& stake_account);
@ -677,6 +605,7 @@ namespace graphene { namespace chain {
///@} ///@}
///@} ///@}
std::mutex _pending_tx_mutex;
vector< processed_transaction > _pending_tx; vector< processed_transaction > _pending_tx;
fork_database _fork_db; fork_database _fork_db;
@ -704,11 +633,17 @@ namespace graphene { namespace chain {
uint16_t _current_op_in_trx = 0; uint16_t _current_op_in_trx = 0;
uint32_t _current_virtual_op = 0; uint32_t _current_virtual_op = 0;
vector<uint64_t> _vote_tally_buffer; vector<uint64_t> _vote_tally_buffer;
vector<uint64_t> _witness_count_histogram_buffer; vector<uint64_t> _witness_count_histogram_buffer;
vector<uint64_t> _committee_count_histogram_buffer; vector<uint64_t> _committee_count_histogram_buffer;
vector<uint64_t> _son_count_histogram_buffer; flat_map<sidechain_type, vector<uint64_t> > _son_count_histogram_buffer = []{
uint64_t _total_voting_stake; flat_map<sidechain_type, vector<uint64_t> > son_count_histogram_buffer;
for(const auto& active_sidechain_type : all_sidechain_types){
son_count_histogram_buffer[active_sidechain_type] = vector<uint64_t>{};
}
return son_count_histogram_buffer;
}();
uint64_t _total_voting_stake;
flat_map<uint32_t,block_id_type> _checkpoints; flat_map<uint32_t,block_id_type> _checkpoints;
@ -741,13 +676,6 @@ namespace graphene { namespace chain {
const chain_property_object* _p_chain_property_obj = nullptr; const chain_property_object* _p_chain_property_obj = nullptr;
const witness_schedule_object* _p_witness_schedule_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 namespace detail

View file

@ -24,22 +24,19 @@
#pragma once #pragma once
#include <graphene/chain/exceptions.hpp> #include <graphene/chain/exceptions.hpp>
#include <graphene/chain/transaction_evaluation_state.hpp> #include <graphene/chain/transaction_evaluation_state.hpp>
#include <graphene/protocol/operations.hpp> #include <graphene/chain/protocol/operations.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
class database; class database;
class consensus_evaluator; struct signed_transaction;
class generic_evaluator;
class transaction_evaluation_state; class transaction_evaluation_state;
class account_object;
class account_statistics_object;
class asset_object;
class asset_dynamic_data_object;
class consensus_evaluator class generic_evaluator
{ {
public: public:
virtual ~consensus_evaluator(){} virtual ~generic_evaluator(){}
virtual int get_type()const = 0; virtual int get_type()const = 0;
virtual operation_result start_evaluate(transaction_evaluation_state& eval_state, const operation& op, bool apply); virtual operation_result start_evaluate(transaction_evaluation_state& eval_state, const operation& op, bool apply);
@ -122,88 +119,24 @@ namespace graphene { namespace chain {
class op_evaluator class op_evaluator
{ {
protected:
unique_ptr<op_evaluator> next_evaluator;
public: 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 ~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; virtual operation_result evaluate(transaction_evaluation_state& eval_state, const operation& op, bool apply) = 0;
}; };
template<typename T, bool DiscardExceptions> template<typename T>
class op_evaluator_impl : public op_evaluator class op_evaluator_impl : public op_evaluator
{ {
public: 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 virtual operation_result evaluate(transaction_evaluation_state& eval_state, const operation& op, bool apply = true) override
{ {
operation_result result; T eval;
try { return eval.start_evaluate(eval_state, op, apply);
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> template<typename DerivedEvaluator>
class fee_handling_evaluator : public consensus_evaluator class evaluator : public generic_evaluator
{ {
public: public:
virtual int get_type()const override { return operation::tag<typename DerivedEvaluator::operation_type>::value; } virtual int get_type()const override { return operation::tag<typename DerivedEvaluator::operation_type>::value; }
@ -241,32 +174,4 @@ namespace graphene { namespace chain {
return result; 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,15 +23,13 @@
*/ */
#pragma once #pragma once
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/evaluator.hpp> #include <graphene/chain/evaluator.hpp>
#include <graphene/chain/database.hpp> #include <graphene/chain/database.hpp>
#include <graphene/chain/event_object.hpp>
#include <graphene/protocol/operations.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
class event_create_evaluator : public fee_handling_evaluator<event_create_evaluator> class event_create_evaluator : public evaluator<event_create_evaluator>
{ {
public: public:
typedef event_create_operation operation_type; typedef event_create_operation operation_type;
@ -42,7 +40,7 @@ namespace graphene { namespace chain {
event_group_id_type event_group_id; event_group_id_type event_group_id;
}; };
class event_update_evaluator : public fee_handling_evaluator<event_update_evaluator> class event_update_evaluator : public evaluator<event_update_evaluator>
{ {
public: public:
typedef event_update_operation operation_type; typedef event_update_operation operation_type;
@ -53,7 +51,7 @@ namespace graphene { namespace chain {
event_group_id_type event_group_id; event_group_id_type event_group_id;
}; };
class event_update_status_evaluator : public fee_handling_evaluator<event_update_status_evaluator> class event_update_status_evaluator : public evaluator<event_update_status_evaluator>
{ {
public: public:
typedef event_update_status_operation operation_type; typedef event_update_status_operation operation_type;

View file

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

View file

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

View file

@ -23,22 +23,19 @@
*/ */
#pragma once #pragma once
#include <graphene/chain/types.hpp> #include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/event.hpp>
#include <graphene/db/object.hpp> #include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp> #include <graphene/db/generic_index.hpp>
#include <graphene/chain/protocol/event.hpp>
#include <sstream>
#include <boost/multi_index/composite_key.hpp> #include <boost/multi_index/composite_key.hpp>
#include <sstream>
namespace graphene { namespace chain { namespace graphene { namespace chain {
class event_object; class event_object;
} } } }
namespace fc { namespace fc {
void to_variant(const graphene::chain::event_object& event_obj, fc::variant& v, uint32_t max_depth = 1); void to_variant(const graphene::chain::event_object& event_obj, fc::variant& v, uint32_t max_depth = 1);
void from_variant(const fc::variant& v, graphene::chain::event_object& event_obj, uint32_t max_depth = 1); void from_variant(const fc::variant& v, graphene::chain::event_object& event_obj, uint32_t max_depth = 1);
} //end namespace fc } //end namespace fc
@ -59,7 +56,7 @@ class event_object : public graphene::db::abstract_object< event_object >
event_object& operator=(const event_object& rhs); event_object& operator=(const event_object& rhs);
internationalized_string_type name; internationalized_string_type name;
internationalized_string_type season; internationalized_string_type season;
optional<time_point_sec> start_time; optional<time_point_sec> start_time;
@ -117,7 +114,7 @@ typedef generic_index<event_object, event_object_multi_index_type> event_object_
template<typename Stream> template<typename Stream>
inline Stream& operator<<( Stream& s, const event_object& event_obj ) inline Stream& operator<<( Stream& s, const event_object& event_obj )
{ {
fc_elog(fc::logger::get("event"), "In event_obj to_raw"); fc_elog(fc::logger::get("event"), "In event_obj to_raw");
// pack all fields exposed in the header in the usual way // pack all fields exposed in the header in the usual way
// instead of calling the derived pack, just serialize the one field in the base class // instead of calling the derived pack, just serialize the one field in the base class
@ -140,7 +137,7 @@ typedef generic_index<event_object, event_object_multi_index_type> event_object_
} }
template<typename Stream> template<typename Stream>
inline Stream& operator>>( Stream& s, event_object& event_obj ) inline Stream& operator>>( Stream& s, event_object& event_obj )
{ {
fc_elog(fc::logger::get("event"), "In event_obj from_raw"); fc_elog(fc::logger::get("event"), "In event_obj from_raw");
// unpack all fields exposed in the header in the usual way // unpack all fields exposed in the header in the usual way
//fc::raw::unpack<Stream, graphene::db::abstract_object<event_object> >(s, event_obj); //fc::raw::unpack<Stream, graphene::db::abstract_object<event_object> >(s, event_obj);
@ -157,13 +154,57 @@ typedef generic_index<event_object, event_object_multi_index_type> event_object_
fc::raw::unpack(s, stringified_stream); fc::raw::unpack(s, stringified_stream);
std::istringstream stream(stringified_stream); std::istringstream stream(stringified_stream);
event_obj.unpack_impl(stream); event_obj.unpack_impl(stream);
return s; return s;
} }
} } // graphene::chain } } // graphene::chain
MAP_OBJECT_ID_TO_TYPE(graphene::chain::event_object) namespace fc {
FC_REFLECT_DERIVED(graphene::chain::event_object, (graphene::db::object), template<>
(name)(season)(start_time)(event_group_id)(at_least_one_betting_market_group_settled)(scores)) template<>
inline void if_enum<fc::false_type>::from_variant(const variant &vo, graphene::chain::event_object &v, uint32_t max_depth) {
from_variant(vo, v, max_depth);
}
template<>
template<>
inline void if_enum<fc::false_type>::to_variant(const graphene::chain::event_object &v, variant &vo, uint32_t max_depth) {
to_variant(v, vo, max_depth);
}
namespace raw { namespace detail {
template<>
template<>
inline void if_enum<fc::false_type>::pack(fc::datastream<size_t> &s, const graphene::chain::event_object &v, uint32_t) {
s << v;
}
template<>
template<>
inline void if_enum<fc::false_type>::pack(fc::datastream<char*> &s, const graphene::chain::event_object &v, uint32_t) {
s << v;
}
template<>
template<>
inline void if_enum<fc::false_type>::unpack(fc::datastream<const char*> &s, graphene::chain::event_object &v, uint32_t) {
s >> v;
}
} } // namespace fc::raw::detail
template <>
struct get_typename<graphene::chain::event_object> {
static const char *name() {
return "graphene::chain::event_object";
}
};
template <>
struct reflector<graphene::chain::event_object> {
typedef graphene::chain::event_object type;
typedef fc::true_type is_defined;
typedef fc::false_type is_enum;
};
} // namespace fc

View file

@ -25,10 +25,7 @@
#include <boost/exception/diagnostic_information.hpp> #include <boost/exception/diagnostic_information.hpp>
#include <fc/exception/exception.hpp> #include <fc/exception/exception.hpp>
#include <graphene/protocol/exceptions.hpp> #include <graphene/chain/protocol/protocol.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/chain/types.hpp>
#define GRAPHENE_ASSERT( expr, exc_type, FORMAT, ... ) \ #define GRAPHENE_ASSERT( expr, exc_type, FORMAT, ... ) \
FC_MULTILINE_MACRO_BEGIN \ FC_MULTILINE_MACRO_BEGIN \
@ -36,26 +33,15 @@
FC_THROW_EXCEPTION( exc_type, FORMAT, __VA_ARGS__ ); \ FC_THROW_EXCEPTION( exc_type, FORMAT, __VA_ARGS__ ); \
FC_MULTILINE_MACRO_END FC_MULTILINE_MACRO_END
#define GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( op_name ) \ #define GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( op_name ) \
FC_DECLARE_DERIVED_EXCEPTION( \ 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, \ op_name ## _validate_exception, \
graphene::chain::operation_validate_exception, \ graphene::chain::operation_validate_exception, \
3040000 + 100 * operation::tag< op_name ## _operation >::value, \ 3040000 + 100 * operation::tag< op_name ## _operation >::value, \
#op_name "_operation validation exception" \ #op_name "_operation validation exception" \
) \ ) \
FC_IMPLEMENT_DERIVED_EXCEPTION( \ FC_DECLARE_DERIVED_EXCEPTION( \
op_name ## _evaluate_exception, \ op_name ## _evaluate_exception, \
graphene::chain::operation_evaluate_exception, \ graphene::chain::operation_evaluate_exception, \
3050000 + 100 * operation::tag< op_name ## _operation >::value, \ 3050000 + 100 * operation::tag< op_name ## _operation >::value, \
@ -64,14 +50,6 @@
#define GRAPHENE_DECLARE_OP_VALIDATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \ #define GRAPHENE_DECLARE_OP_VALIDATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \
FC_DECLARE_DERIVED_EXCEPTION( \ 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, \ op_name ## _ ## exc_name, \
graphene::chain::op_name ## _validate_exception, \ graphene::chain::op_name ## _validate_exception, \
3040000 + 100 * operation::tag< op_name ## _operation >::value \ 3040000 + 100 * operation::tag< op_name ## _operation >::value \
@ -81,14 +59,6 @@
#define GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \ #define GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \
FC_DECLARE_DERIVED_EXCEPTION( \ 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, \ op_name ## _ ## exc_name, \
graphene::chain::op_name ## _evaluate_exception, \ graphene::chain::op_name ## _evaluate_exception, \
3050000 + 100 * operation::tag< op_name ## _operation >::value \ 3050000 + 100 * operation::tag< op_name ## _operation >::value \
@ -121,21 +91,30 @@
namespace graphene { namespace chain { namespace graphene { namespace chain {
FC_DECLARE_EXCEPTION( chain_exception, 3000000 ) FC_DECLARE_EXCEPTION( chain_exception, 3000000, "blockchain exception" )
FC_DECLARE_DERIVED_EXCEPTION( database_query_exception, chain_exception, 3010000 ) FC_DECLARE_DERIVED_EXCEPTION( database_query_exception, graphene::chain::chain_exception, 3010000, "database query exception" )
FC_DECLARE_DERIVED_EXCEPTION( block_validate_exception, chain_exception, 3020000 ) FC_DECLARE_DERIVED_EXCEPTION( block_validate_exception, graphene::chain::chain_exception, 3020000, "block validation exception" )
FC_DECLARE_DERIVED_EXCEPTION( transaction_exception, chain_exception, 3030000 ) FC_DECLARE_DERIVED_EXCEPTION( transaction_exception, graphene::chain::chain_exception, 3030000, "transaction validation exception" )
FC_DECLARE_DERIVED_EXCEPTION( operation_validate_exception, chain_exception, 3040000 ) FC_DECLARE_DERIVED_EXCEPTION( operation_validate_exception, graphene::chain::chain_exception, 3040000, "operation validation exception" )
FC_DECLARE_DERIVED_EXCEPTION( operation_evaluate_exception, chain_exception, 3050000 ) FC_DECLARE_DERIVED_EXCEPTION( operation_evaluate_exception, graphene::chain::chain_exception, 3050000, "operation evaluation exception" )
FC_DECLARE_DERIVED_EXCEPTION( utility_exception, chain_exception, 3060000 ) FC_DECLARE_DERIVED_EXCEPTION( utility_exception, graphene::chain::chain_exception, 3060000, "utility method exception" )
FC_DECLARE_DERIVED_EXCEPTION( undo_database_exception, chain_exception, 3070000 ) FC_DECLARE_DERIVED_EXCEPTION( undo_database_exception, graphene::chain::chain_exception, 3070000, "undo database exception" )
FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, chain_exception, 3080000 ) FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, graphene::chain::chain_exception, 3080000, "unlinkable block" )
FC_DECLARE_DERIVED_EXCEPTION( black_swan_exception, chain_exception, 3090000 ) FC_DECLARE_DERIVED_EXCEPTION( black_swan_exception, graphene::chain::chain_exception, 3090000, "black swan" )
FC_DECLARE_DERIVED_EXCEPTION( plugin_exception, chain_exception, 3100000 ) FC_DECLARE_DERIVED_EXCEPTION( plugin_exception, graphene::chain::chain_exception, 3100000, "plugin exception" )
FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, chain_exception, 37006 ) 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( pop_empty_chain, undo_database_exception, 3070001 ) 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" )
GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( transfer ); GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( transfer );
GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( from_account_not_whitelisted, transfer, 1, "owner mismatch" ) GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( from_account_not_whitelisted, transfer, 1, "owner mismatch" )
@ -206,11 +185,93 @@ namespace graphene { namespace chain {
GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( blind_transfer ); GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( blind_transfer );
GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( unknown_commitment, blind_transfer, 1, "Attempting to claim an unknown prior commitment" ); GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( unknown_commitment, blind_transfer, 1, "Attempting to claim an unknown prior commitment" );
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( transfer_from_blind_operation ) /*
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_claim_fees_operation ) FC_DECLARE_DERIVED_EXCEPTION( addition_overflow, graphene::chain::chain_exception, 30002, "addition overflow" )
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( bid_collateral_operation ) FC_DECLARE_DERIVED_EXCEPTION( subtraction_overflow, graphene::chain::chain_exception, 30003, "subtraction overflow" )
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_claim_pool_operation ) FC_DECLARE_DERIVED_EXCEPTION( asset_type_mismatch, graphene::chain::chain_exception, 30004, "asset/price mismatch" )
//GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_update_issuer_operation ) 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" )
*/
#define GRAPHENE_RECODE_EXC( cause_type, effect_type ) \ #define GRAPHENE_RECODE_EXC( cause_type, effect_type ) \
catch( const cause_type& e ) \ catch( const cause_type& e ) \

View file

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

View file

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

View file

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

View file

@ -24,23 +24,16 @@
#pragma once #pragma once
#include <graphene/chain/rock_paper_scissors.hpp> #include <graphene/chain/rock_paper_scissors.hpp>
#include <graphene/db/object.hpp>
#include <graphene/protocol/tournament.hpp>
#include <graphene/db/flat_index.hpp>
#include <graphene/db/generic_index.hpp> #include <graphene/db/generic_index.hpp>
#include <fc/crypto/hex.hpp> #include <fc/crypto/hex.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <sstream> #include <sstream>
namespace graphene { namespace chain { namespace graphene { namespace chain {
class game_object; class game_object;
} } } }
namespace fc { namespace fc {
void to_variant(const graphene::chain::game_object& game_obj, fc::variant& v, uint32_t max_depth = 1); void to_variant(const graphene::chain::game_object& game_obj, fc::variant& v, uint32_t max_depth = 1);
void from_variant(const fc::variant& v, graphene::chain::game_object& game_obj, uint32_t max_depth = 1); void from_variant(const fc::variant& v, graphene::chain::game_object& game_obj, uint32_t max_depth = 1);
} //end namespace fc } //end namespace fc
@ -87,7 +80,7 @@ namespace graphene { namespace chain {
void on_move(database& db, const game_move_operation& op); void on_move(database& db, const game_move_operation& op);
void on_timeout(database& db); void on_timeout(database& db);
void start_game(database& db, const std::vector<account_id_type>& players); void start_game(database& db, const std::vector<account_id_type>& players);
// serialization functions: // serialization functions:
// for serializing to raw, go through a temporary sstream object to avoid // for serializing to raw, go through a temporary sstream object to avoid
// having to implement serialization in the header file // having to implement serialization in the header file
@ -121,7 +114,7 @@ namespace graphene { namespace chain {
template<typename Stream> template<typename Stream>
inline Stream& operator<<( Stream& s, const game_object& game_obj ) inline Stream& operator<<( Stream& s, const game_object& game_obj )
{ {
// pack all fields exposed in the header in the usual way // pack all fields exposed in the header in the usual way
// instead of calling the derived pack, just serialize the one field in the base class // instead of calling the derived pack, just serialize the one field in the base class
// fc::raw::pack<Stream, const graphene::db::abstract_object<game_object> >(s, game_obj); // fc::raw::pack<Stream, const graphene::db::abstract_object<game_object> >(s, game_obj);
@ -143,7 +136,7 @@ namespace graphene { namespace chain {
template<typename Stream> template<typename Stream>
inline Stream& operator>>( Stream& s, game_object& game_obj ) inline Stream& operator>>( Stream& s, game_object& game_obj )
{ {
// unpack all fields exposed in the header in the usual way // unpack all fields exposed in the header in the usual way
//fc::raw::unpack<Stream, graphene::db::abstract_object<game_object> >(s, game_obj); //fc::raw::unpack<Stream, graphene::db::abstract_object<game_object> >(s, game_obj);
fc::raw::unpack(s, game_obj.id); fc::raw::unpack(s, game_obj.id);
@ -158,21 +151,63 @@ namespace graphene { namespace chain {
fc::raw::unpack(s, stringified_stream); fc::raw::unpack(s, stringified_stream);
std::istringstream stream(stringified_stream); std::istringstream stream(stringified_stream);
game_obj.unpack_impl(stream); game_obj.unpack_impl(stream);
return s; return s;
} }
} } } }
MAP_OBJECT_ID_TO_TYPE(graphene::chain::game_object)
FC_REFLECT_ENUM(graphene::chain::game_state, FC_REFLECT_ENUM(graphene::chain::game_state,
(game_in_progress) (game_in_progress)
(expecting_commit_moves) (expecting_commit_moves)
(expecting_reveal_moves) (expecting_reveal_moves)
(game_complete)) (game_complete))
//FC_REFLECT_TYPENAME(graphene::chain::game_object) // manually serialized namespace fc {
FC_REFLECT_DERIVED(graphene::chain::game_object, (graphene::db::object), (players))
template<>
template<>
inline void if_enum<fc::false_type>::from_variant(const variant &vo, graphene::chain::game_object &v, uint32_t max_depth) {
from_variant(vo, v, max_depth);
}
template<>
template<>
inline void if_enum<fc::false_type>::to_variant(const graphene::chain::game_object &v, variant &vo, uint32_t max_depth) {
to_variant(v, vo, max_depth);
}
namespace raw { namespace detail {
template<>
template<>
inline void if_enum<fc::false_type>::pack(fc::datastream<size_t> &s, const graphene::chain::game_object &v, uint32_t) {
s << v;
}
template<>
template<>
inline void if_enum<fc::false_type>::pack(fc::datastream<char*> &s, const graphene::chain::game_object &v, uint32_t) {
s << v;
}
template<>
template<>
inline void if_enum<fc::false_type>::unpack(fc::datastream<const char*> &s, graphene::chain::game_object &v, uint32_t) {
s >> v;
}
} } // namespace fc::raw::detail
template <>
struct get_typename<graphene::chain::game_object> {
static const char *name() {
return "graphene::chain::game_object";
}
};
template <>
struct reflector<graphene::chain::game_object> {
typedef graphene::chain::game_object type;
typedef fc::true_type is_defined;
typedef fc::false_type is_enum;
};
} // namespace fc

View file

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

View file

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

View file

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

View file

@ -24,12 +24,10 @@
#pragma once #pragma once
#include <fc/uint128.hpp> #include <fc/uint128.hpp>
#include <graphene/protocol/chain_parameters.hpp> #include <graphene/chain/protocol/chain_parameters.hpp>
#include <graphene/protocol/son_info.hpp> #include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/types.hpp> #include <graphene/chain/son_sidechain_info.hpp>
#include <graphene/chain/hardfork.hpp>
#include <graphene/db/object.hpp> #include <graphene/db/object.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
@ -51,10 +49,18 @@ namespace graphene { namespace chain {
chain_parameters parameters; chain_parameters parameters;
optional<chain_parameters> pending_parameters; optional<chain_parameters> pending_parameters;
uint32_t next_available_vote_id = 0; uint32_t next_available_vote_id = 0;
vector<committee_member_id_type> active_committee_members; // updated once per maintenance interval vector<committee_member_id_type> active_committee_members; // updated once per maintenance interval
flat_set<witness_id_type> active_witnesses; // updated once per maintenance interval flat_set<witness_id_type> active_witnesses; // updated once per maintenance interval
vector<son_info> active_sons; // updated once per maintenance interval flat_map<sidechain_type, vector<son_sidechain_info> > active_sons = []() // updated once per maintenance interval
{
flat_map<sidechain_type, vector<son_sidechain_info> > active_sons;
for(const auto& active_sidechain_type : all_sidechain_types)
{
active_sons[active_sidechain_type] = vector<son_sidechain_info>();
}
return active_sons;
}();
// n.b. witness scheduling is done by witness_schedule object // n.b. witness scheduling is done by witness_schedule object
}; };
@ -91,6 +97,8 @@ namespace graphene { namespace chain {
* every time a block is found it decreases by * every time a block is found it decreases by
* RECENTLY_MISSED_COUNT_DECREMENT. It is * RECENTLY_MISSED_COUNT_DECREMENT. It is
* never less than 0. * 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; uint32_t recently_missed_count = 0;
@ -130,10 +138,8 @@ 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), FC_REFLECT_DERIVED( graphene::chain::dynamic_global_property_object, (graphene::db::object),
(random)
(head_block_number) (head_block_number)
(head_block_id) (head_block_id)
(time) (time)

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