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

Feature privacy #10267

Merged
merged 194 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
194 commits
Select commit Hold shift + click to select a range
a0b6ad9
extend block_header_state
huangminghuang Feb 26, 2021
c4a4490
Changes for PR comments
huangminghuang Mar 1, 2021
9902181
Merge pull request #10096 from EOSIO/huangminghuang/bhs-extension
brianjohnson5972 Mar 1, 2021
97d3925
Changed to use the version from chain_snapshot_header
huangminghuang Mar 1, 2021
37cfa92
add global_property_object extension
huangminghuang Mar 2, 2021
f2fc7b5
EPE-672: Added unit test framework
rusty-block-one Mar 5, 2021
5fd0176
EPE-672: unittest
rusty-block-one Mar 5, 2021
9cbb2bf
add/remove participants
huangminghuang Mar 4, 2021
ef52336
EPE-672: Feedback changes
rusty-block-one Mar 5, 2021
afd5601
Merge branch 'huangminghuang/security-group-change' into hook-registr…
victorj8 Mar 8, 2021
de8be5d
Merge pull request #10112 from EOSIO/unittest
brianjohnson5972 Mar 8, 2021
cf36ebf
EPE-721: Add connection management
rusty-block-one Mar 4, 2021
992ef2b
EPE-672: add security group
rusty-block-one Mar 8, 2021
efeef44
implements security group intrinsics
huangminghuang Mar 8, 2021
ddb6310
add snapshot recovery test
huangminghuang Mar 8, 2021
68a3f79
add contract/action callback field to global properties
victorj8 Mar 8, 2021
51f6d91
wip
rusty-block-one Mar 8, 2021
ded04b8
add default constructor for snapshot_global_property_object::extensio…
huangminghuang Mar 8, 2021
23a5024
EPE-672: Review feedback
rusty-block-one Mar 9, 2021
075caf0
Merge branch 'security-group' into EPE-721
rusty-block-one Mar 9, 2021
ca764ad
another workaround for libstdc++ bug
huangminghuang Mar 9, 2021
5568071
certificate generation scripts for tests added
Mar 9, 2021
d52a711
fix protocol feature digest
huangminghuang Mar 9, 2021
d19ac12
Merge branch 'huangminghuang/security-group-intrinsics' into hook-reg…
victorj8 Mar 9, 2021
92348a5
add some constructors for extension_v1 required by libstdc++
victorj8 Mar 9, 2021
299f2bd
wip
rusty-block-one Mar 9, 2021
0ae40c8
Merge pull request #10118 from EOSIO/privacy-tests-cert-setup
brianjohnson5972 Mar 9, 2021
b367d71
EPE-672: Review feedback
rusty-block-one Mar 9, 2021
32c17d3
change recover from state commit
huangminghuang Mar 9, 2021
b8c20a4
wip
rusty-block-one Mar 9, 2021
b3a9627
fix a reflection problem with global_property_object
victorj8 Mar 9, 2021
d089a31
update commit for resume from state test
victorj8 Mar 9, 2021
8f70735
Merge pull request #10115 from EOSIO/security-group
rusty-block-one Mar 9, 2021
66b8e46
wip
rusty-block-one Mar 9, 2021
5e979dd
Merge branch 'feature-privacy' into EPE-721
rusty-block-one Mar 9, 2021
78c5a6b
tls options added to net_plugin
Mar 10, 2021
1ecfaaf
renamed command line options
Mar 10, 2021
7974437
EPE-672: Add security group to net_plugin
rusty-block-one Mar 10, 2021
bca9344
comments updates after net_plugin options rename
Mar 10, 2021
1fb0f20
Merge pull request #10121 from EOSIO/net-plugin-tls
brianjohnson5972 Mar 10, 2021
135391c
address PR comments & add contract test
huangminghuang Mar 10, 2021
bb2c620
Merge pull request #10116 from EOSIO/huangminghuang/security-group-in…
brianjohnson5972 Mar 11, 2021
18884d6
PR Feedback changes
rusty-block-one Mar 11, 2021
66e43ad
delete extension_v1 struct from snapshot_global_property_object
victorj8 Mar 11, 2021
c9aca34
PR Feedback for net_plugin security group message handling
rusty-block-one Mar 11, 2021
d1bc614
Fix security_group_manager unit test
rusty-block-one Mar 11, 2021
23da2a8
Changed --help to display and exit and changed range of files names t…
brianjohnson5972 Mar 11, 2021
32648b0
changing certificate generation script naming
Mar 12, 2021
430bc65
PR Feedback for net_plugin security group message handling
rusty-block-one Mar 12, 2021
ae8921a
PR Feedback for net_plugin security group message handling
rusty-block-one Mar 12, 2021
37ae91d
Merge pull request #10122 from EOSIO/EPE-721
rusty-block-one Mar 12, 2021
37ca095
Merge branch 'develop' into feature-privacy
huangminghuang Mar 12, 2021
7ebb035
Merge branch 'develop' into transaction-sponsorship
Mar 12, 2021
bfdde96
Added a flag to configure the cluster for security groups.
brianjohnson5972 Mar 12, 2021
0029b50
added ec option to test certificates generation
Mar 14, 2021
b879e11
Changed eosio-launcher to treat bios as -1 for spec*-num parameters.
brianjohnson5972 Mar 15, 2021
36d1f9c
Added providing node mapping to topo parameter to select the exact co…
brianjohnson5972 Mar 16, 2021
d48ea78
Merge remote-tracking branch 'origin/transaction-sponsorship' into hu…
huangminghuang Mar 16, 2021
fa9581c
update ship protocol for global property changes
huangminghuang Mar 16, 2021
d76726c
update resume from state commit
huangminghuang Mar 16, 2021
f08d963
changes in the middle of implementation
Mar 16, 2021
91d2cf5
Fixed code for unreported nodes in custom shaped topology.
brianjohnson5972 Mar 16, 2021
13ee62a
Added the privacy_startup_network test script.
brianjohnson5972 Mar 16, 2021
ae13158
partial TLS implementation of net plugin
Mar 17, 2021
c80ef87
address PR comments
huangminghuang Mar 17, 2021
4e64869
Fixed number ordering of producers and relay nodes and topology confi…
brianjohnson5972 Mar 17, 2021
feee04b
Only currently working for 1 producer, will investigate and fix later.
brianjohnson5972 Mar 17, 2021
9c0ae25
Added passing pnodes to launch.
brianjohnson5972 Mar 17, 2021
5178148
Merge pull request #10142 from EOSIO/huangminghuang/ship-gpo
brianjohnson5972 Mar 17, 2021
f2bdbf4
Peer review comment fixes.
brianjohnson5972 Mar 17, 2021
c571480
Missed changing parameter name in last fix.
brianjohnson5972 Mar 18, 2021
76ff2f2
Merge remote-tracking branch 'origin/feature-privacy' into bdj__priva…
brianjohnson5972 Mar 18, 2021
7bd4fc3
Fixed path to generated certificates.
brianjohnson5972 Mar 18, 2021
8e495b2
Changed to use with idiom for opening files and removed python 2 stri…
brianjohnson5972 Mar 18, 2021
82a7256
security groups implementation added to net plugin
Mar 18, 2021
045f6dc
Merge pull request #10153 from EOSIO/bdj__privacy-integration-test_EP…
brianjohnson5972 Mar 18, 2021
1a1e6dd
Fixed file number for bios.
brianjohnson5972 Mar 18, 2021
cd45058
Merge pull request #10159 from EOSIO/bdj__privacy-integration-test-fi…
brianjohnson5972 Mar 18, 2021
e853a86
Moved useful protocol feature methods into Node.py.
brianjohnson5972 Mar 18, 2021
26b4c86
Activating the SECURITY_GROUP protocol feature.
brianjohnson5972 Mar 18, 2021
a1a63b2
bfs added to command line parameters
Mar 19, 2021
c7f63b1
Merge branch 'feature-privacy' into tls-net-plugin-impl
Mar 19, 2021
01b56ef
change of commandline parameter in tests
Mar 19, 2021
fccc758
optimization & bugfixes in net_plugin
Mar 19, 2021
d56ba12
bugfixes + refactoring of net plugin
Mar 23, 2021
b4cd62e
bugfixes to net_plugin tls and tests
Mar 25, 2021
e7f2276
Minor changes to add accounts and load contract to exercise security …
brianjohnson5972 Mar 29, 2021
7187129
Change configSecurityGroup to automatically NOT use the bios bootfile…
brianjohnson5972 Mar 29, 2021
32f4e47
Merge remote-tracking branch 'origin/feature-privacy' into bdj__priva…
brianjohnson5972 Mar 29, 2021
90348f4
Added improved error handling.
brianjohnson5972 Mar 29, 2021
86b65ed
Fixing PR comment, and cleaning up uses of global that should be nonl…
brianjohnson5972 Mar 29, 2021
b5071cc
Could not use nonlocal in this case.
brianjohnson5972 Mar 29, 2021
c74a148
Trying to prevent error on CentOS.
brianjohnson5972 Mar 29, 2021
3ab6049
Merge pull request #10205 from EOSIO/bdj__privacy-integration-test-bo…
brianjohnson5972 Mar 30, 2021
75e4823
Moved useful protocol feature methods into Node.py.
brianjohnson5972 Mar 18, 2021
8c6389e
Activating the SECURITY_GROUP protocol feature.
brianjohnson5972 Mar 18, 2021
69d4232
Minor changes to add accounts and load contract to exercise security …
brianjohnson5972 Mar 29, 2021
17e2cbe
Change configSecurityGroup to automatically NOT use the bios bootfile…
brianjohnson5972 Mar 29, 2021
fa1e796
Added improved error handling.
brianjohnson5972 Mar 29, 2021
9c976cc
Fixing PR comment, and cleaning up uses of global that should be nonl…
brianjohnson5972 Mar 29, 2021
8c78f31
Could not use nonlocal in this case.
brianjohnson5972 Mar 29, 2021
05e7f79
Trying to prevent error on CentOS.
brianjohnson5972 Mar 29, 2021
31829e1
added openssl to EC2 docker images
Mar 30, 2021
43926e4
PR concerns addressed and centos fix
Mar 31, 2021
da55179
Merge pull request #10145 from EOSIO/tls-net-plugin-impl
brianjohnson5972 Mar 31, 2021
90f7301
logs fix + certain systems tests fix
Apr 7, 2021
6138d87
corrected behavior of tls for some corner cases
Apr 8, 2021
e010290
tls connection bugfix
Apr 8, 2021
196b6f7
Node.py test bugfix
Apr 8, 2021
e090180
bugfixes to privacy feature
Apr 8, 2021
8977c50
PR review concerns addressed + bugfixes
Apr 9, 2021
2bf22ef
PR review concerns addressed
Apr 9, 2021
f191f96
Merge pull request #10229 from EOSIO/tls-fix
dimas1185 Apr 9, 2021
40af6c5
Extra diagnostics for CentOS failure.
brianjohnson5972 Mar 30, 2021
8c05ad5
Fixed use of non-shared containers in multi-index container.
brianjohnson5972 Apr 8, 2021
0181fa3
Fixed setting participating_ correctly for invalid participant names.
brianjohnson5972 Apr 8, 2021
5f7cd70
More global_property_object changes.
brianjohnson5972 Apr 9, 2021
c879f90
Integration test script fixes.
brianjohnson5972 Apr 9, 2021
6ea1411
Added simpler scenario for security group testing.
brianjohnson5972 Apr 9, 2021
caf3eb4
Added wasm and abi for simple test usage.
brianjohnson5972 Apr 9, 2021
be01172
Fixed incorrect use of nonlocal.
brianjohnson5972 Apr 12, 2021
8fb7c8d
Cleanup of debug log statement.
brianjohnson5972 Apr 12, 2021
8764643
Made simple test to verify security group functionality.
brianjohnson5972 Apr 12, 2021
8a34e9d
Fixed apply_block functionality for bringing pending security group i…
brianjohnson5972 Apr 12, 2021
99abc09
Additional verification for test.
brianjohnson5972 Apr 12, 2021
0f77739
Made setters for proposed_security_group_participants and transaction…
brianjohnson5972 Apr 13, 2021
85ac2aa
Moved common methods to Cluster and more cleanup.
brianjohnson5972 Apr 13, 2021
c825ceb
Fixing resume from state.
brianjohnson5972 Apr 13, 2021
ba88c84
Cleanup.
brianjohnson5972 Apr 13, 2021
83d46ab
Changed prodCount for single producers to ensure that LIB trails enou…
brianjohnson5972 Apr 13, 2021
bb668ec
Moved parseProducers from Cluster to Node and made member function an…
brianjohnson5972 Apr 14, 2021
21ca57e
Added more senarios to test.
brianjohnson5972 Apr 14, 2021
e8a4e30
Cleaned up unused parameter.
brianjohnson5972 Apr 15, 2021
23f8510
Added method for identifying the node for the provided producer.
brianjohnson5972 Apr 15, 2021
5e82833
Merge pull request #10245 from EOSIO/bdj__privacy-apply-block-fix_EPE…
brianjohnson5972 Apr 16, 2021
27433a9
Improvement for activating features and allowing more control for blo…
brianjohnson5972 Apr 16, 2021
b9d27b8
Added scenarios of adding and removing participants and covers scenar…
brianjohnson5972 Apr 16, 2021
e2182ce
Adding more non-producing nodes for the test.
brianjohnson5972 Apr 16, 2021
fafcfaa
Making logic more straightforward.
brianjohnson5972 Apr 16, 2021
ca8a056
Merge pull request #10253 from EOSIO/bdj__privacy-simple-test-improve…
brianjohnson5972 Apr 16, 2021
853c53b
Peer Review comment changes.
brianjohnson5972 Apr 16, 2021
185975b
Missed committing change.
brianjohnson5972 Apr 16, 2021
c55a0a6
Cleanup
brianjohnson5972 Apr 16, 2021
518bb8d
Fixed reversed logic for createAction.
brianjohnson5972 Apr 17, 2021
f2f963d
tls integration tests added
Apr 17, 2021
7c2ebcb
tests fix
Apr 17, 2021
3c0a244
Fixing more errors.
brianjohnson5972 Apr 17, 2021
3029fe0
Fix another error.
brianjohnson5972 Apr 17, 2021
353314e
Reduced the number of API nodes
brianjohnson5972 Apr 19, 2021
472a394
Merge pull request #10258 from EOSIO/bdj__missed-comments-for-gh-10253
brianjohnson5972 Apr 19, 2021
6747cf4
Merge branch 'feature-privacy' into tls-tests
dimas1185 Apr 19, 2021
146b9e3
Update tester.cpp
shahabi8 Apr 19, 2021
402f557
Update security_group_tests.cpp
shahabi8 Apr 19, 2021
be6c565
Update tester.hpp
shahabi8 Apr 19, 2021
b8f74c5
Update security_group_tests.cpp
shahabi8 Apr 19, 2021
08b9caa
Merge pull request #10259 from EOSIO/tls-tests
dimas1185 Apr 20, 2021
b1fc7b6
Merge pull request #10269 from EOSIO/epe_913_fix_to_test_participants…
brianjohnson5972 Apr 20, 2021
4b1076b
Added retrieving the participant name from the command line for a Node.
brianjohnson5972 Apr 20, 2021
457a22c
Improved logging for Security Group changes.
brianjohnson5972 Apr 20, 2021
abf570c
Added SecurityGroup helper python class.
brianjohnson5972 Apr 20, 2021
9e74dea
Initial conversion to using SecurityGroup.
brianjohnson5972 Apr 20, 2021
523bf9e
Moved more code into SecurityGroup.
brianjohnson5972 Apr 21, 2021
3d50eef
Merge remote-tracking branch 'origin/feature-privacy' into bdj__priva…
brianjohnson5972 Apr 21, 2021
ac8ebb0
Added block delay to ensure repeating a duplicate remove transactin d…
brianjohnson5972 Apr 21, 2021
22cb780
Pulled activation of SECURITY_GROUP feature into SecurityGroup and PR…
brianjohnson5972 Apr 21, 2021
6225f30
More cleanup.
brianjohnson5972 Apr 22, 2021
7f3ca45
Merge pull request #10282 from EOSIO/bdj__privacy-security-group-scri…
brianjohnson5972 Apr 22, 2021
d617d9c
Update security_group_tests.cpp
shahabi8 Apr 22, 2021
1ec27f1
Update security_group_tests.cpp
shahabi8 Apr 22, 2021
31312a7
Update security_group_tests.cpp
shahabi8 Apr 22, 2021
40adba0
Finished Test Case #1.
brianjohnson5972 Apr 23, 2021
d85c4e9
Fixed the comment test descriptions.
brianjohnson5972 Apr 23, 2021
9b42334
Merge pull request #10285 from EOSIO/epe_913_fix_to_test_participants…
brianjohnson5972 Apr 23, 2021
d0139d1
Merge remote-tracking branch 'origin/develop' into bdj__merge-develop…
brianjohnson5972 Apr 23, 2021
37bc68a
Merge pull request #10292 from EOSIO/bdj__merge-develop_2021-04-23
brianjohnson5972 Apr 23, 2021
236cceb
Added comment to better explain what relay and API nodes are.
brianjohnson5972 Apr 23, 2021
b4c6961
Fixing handling for unstarted nodes.
brianjohnson5972 Apr 23, 2021
cc4d02f
Fixed returning value.
brianjohnson5972 Apr 23, 2021
465616c
Merge pull request #10288 from EOSIO/bdj__privacy-test-case-1_EPE-832
brianjohnson5972 Apr 23, 2021
aff0b79
Buildkite failure debug statement.
brianjohnson5972 Apr 26, 2021
a99c899
Fixing issue with duplicate transactions getting rejected.
brianjohnson5972 Apr 26, 2021
c7941be
Fixed waitForNextBlock to work for BlockType.lib and also reusing wai…
brianjohnson5972 Apr 27, 2021
bf048e2
Changed the test to have a minimum of 4 nodes and fixed duplicate pub…
brianjohnson5972 Apr 27, 2021
1f8bdb5
Removing transaction_hook.
brianjohnson5972 Apr 28, 2021
228a4c9
Fixed typo.
brianjohnson5972 Apr 28, 2021
180082d
Added mutex in security_group_manager to protect it instead of using …
brianjohnson5972 Apr 28, 2021
01d2ba6
Reverted changes for adding mutex for security_group_manager and spli…
brianjohnson5972 Apr 29, 2021
4e98375
Peer review cleanup.
brianjohnson5972 Apr 29, 2021
861832d
Reverting change for testing.
brianjohnson5972 Apr 29, 2021
8cd1d19
Removed transaction_hook from abieos.
brianjohnson5972 Apr 30, 2021
73ea43f
Made method name clearer and clean-up.
brianjohnson5972 Apr 30, 2021
4258bdf
Corrected error handling for TLS configuration parameters.
brianjohnson5972 Apr 30, 2021
dd3a99b
More PR comment fixes.
brianjohnson5972 Apr 30, 2021
7fc3c1c
Merge remote-tracking branch 'origin/develop' into feature-privacy
brianjohnson5972 Apr 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cicd/platforms/pinned/amazon_linux-2-pinned.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ENV VERSION 1
# install dependencies.
RUN yum update -y && \
yum install -y which git sudo procps-ng util-linux autoconf automake \
libtool make bzip2 bzip2-devel openssl-devel gmp-devel libstdc++ libcurl-devel \
libtool make bzip2 bzip2-devel openssl openssl-devel gmp-devel libstdc++ libcurl-devel \
libusbx-devel python3 python3-devel python-devel libedit-devel doxygen \
graphviz patch gcc gcc-c++ vim-common jq && \
yum clean all && rm -rf /var/cache/yum
Expand Down
2 changes: 1 addition & 1 deletion .cicd/platforms/pinned/centos-7.7-pinned.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN yum update -y && \
yum --enablerepo=extras install -y centos-release-scl && \
yum --enablerepo=extras install -y devtoolset-8 && \
yum --enablerepo=extras install -y which git autoconf automake libtool make bzip2 doxygen \
graphviz bzip2-devel openssl-devel gmp-devel ocaml \
graphviz bzip2-devel openssl openssl-devel gmp-devel ocaml \
python python-devel rh-python36 file libusbx-devel \
libcurl-devel patch vim-common jq glibc-locale-source glibc-langpack-en && \
yum clean all && rm -rf /var/cache/yum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ENV VERSION 1
# install dependencies.
RUN yum update -y && \
yum install -y which git sudo procps-ng util-linux autoconf automake \
libtool make bzip2 bzip2-devel openssl-devel gmp-devel libstdc++ libcurl-devel \
libtool make bzip2 bzip2-devel openssl openssl-devel gmp-devel libstdc++ libcurl-devel \
libusbx-devel python3 python3-devel python-devel libedit-devel doxygen \
graphviz clang patch llvm-devel llvm-static vim-common jq && \
yum clean all && rm -rf /var/cache/yum
Expand Down
2 changes: 1 addition & 1 deletion .cicd/platforms/unpinned/centos-7.7-unpinned.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN yum update -y && \
yum --enablerepo=extras install -y centos-release-scl && \
yum --enablerepo=extras install -y devtoolset-8 && \
yum --enablerepo=extras install -y which git autoconf automake libtool make bzip2 doxygen \
graphviz bzip2-devel openssl-devel gmp-devel ocaml \
graphviz bzip2-devel openssl openssl-devel gmp-devel ocaml \
python python-devel rh-python36 file libusbx-devel \
libcurl-devel patch vim-common jq llvm-toolset-7.0-llvm-devel llvm-toolset-7.0-llvm-static \
glibc-locale-source glibc-langpack-en && \
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ var/lib/node_*
*.iws
.DS_Store

!*.swagger.*
!*.swagger.*
1 change: 1 addition & 0 deletions libraries/chain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ set(CHAIN_WEBASSEMBLY_SOURCES
webassembly/softfloat.cpp
webassembly/system.cpp
webassembly/transaction.cpp
webassembly/security_group.cpp
)

## SORT .cpp by most likely to change / break compile
Expand Down
4 changes: 4 additions & 0 deletions libraries/chain/block_header_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ namespace eosio { namespace chain {
result.producer_to_last_implied_irb[proauth.producer_name] = dpos_proposed_irreversible_blocknum;
}

result.security_group = get_security_group_info();

return result;
}

Expand Down Expand Up @@ -314,6 +316,8 @@ namespace eosio { namespace chain {

result.activated_protocol_features = std::move( new_activated_protocol_features );

result.set_security_group_info(std::move(security_group));

return result;
}

Expand Down
2 changes: 2 additions & 0 deletions libraries/chain/combined_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ namespace eosio { namespace chain {
header.validate();
});

snapshot->chain_snapshot_version = header.version;

db.create<kv_db_config_object>([](auto&) {});
check_backing_store_setting(true);

Expand Down
107 changes: 107 additions & 0 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ struct controller_impl {
set_activation_handler<builtin_protocol_feature_t::kv_database>();
set_activation_handler<builtin_protocol_feature_t::configurable_wasm_limits>();
set_activation_handler<builtin_protocol_feature_t::blockchain_parameters>();
set_activation_handler<builtin_protocol_feature_t::security_group>();

self.irreversible_block.connect([this](const block_state_ptr& bsp) {
wasmif.current_lib(bsp->block_num);
Expand Down Expand Up @@ -1432,6 +1433,29 @@ struct controller_impl {
});
}

if (gpo.proposed_security_group_block_num) {
if (gpo.proposed_security_group_block_num <= pbhs.dpos_irreversible_blocknum) {

// Promote proposed security group to pending.
if( !replay_head_time ) {
ilog( "promoting proposed security group (set in block ${proposed_num}) to pending; current block: ${n} lib: ${lib} participants: ${participants} ",
("proposed_num", gpo.proposed_security_group_block_num)("n", pbhs.block_num)
("lib", pbhs.dpos_irreversible_blocknum)
("participants", gpo.proposed_security_group_participants ) );
}

++bb._pending_block_header_state.security_group.version;
bb._pending_block_header_state.security_group.participants = {
gpo.proposed_security_group_participants.begin(),
gpo.proposed_security_group_participants.end()};

db.modify(gpo, [&](auto& gp) {
gp.proposed_security_group_block_num = 0;
gp.proposed_security_group_participants.clear();
});
}
}

try {
transaction_metadata_ptr onbtrx =
transaction_metadata::create_no_recover_keys( std::make_shared<packed_transaction>( get_on_block_transaction(), true ),
Expand Down Expand Up @@ -1736,6 +1760,9 @@ struct controller_impl {
if( !use_bsp_cached ) {
bsp->set_trxs_metas( std::move( ab._trx_metas ), !skip_auth_checks );
}

auto& pbsh = ab._pending_block_header_state;
bsp->set_security_group_info(std::move(pbsh.security_group));
// create completed_block with the existing block_state as we just verified it is the same as assembled_block
pending->_block_stage = completed_block{ bsp };

Expand Down Expand Up @@ -2232,6 +2259,37 @@ struct controller_impl {
return deep_mind_logger;
}

int64_t propose_security_group(std::function<void(flat_set<account_name>&)> && modify_participants) {
const auto& gpo = self.get_global_properties();
auto cur_block_num = head->block_num + 1;

if (!self.is_builtin_activated(builtin_protocol_feature_t::security_group)) {
return -1;
}

flat_set<account_name> proposed_participants = gpo.proposed_security_group_block_num == 0
? self.active_security_group().participants
: flat_set<account_name>{gpo.proposed_security_group_participants.begin(),
gpo.proposed_security_group_participants.end()};

auto orig_participants_size = proposed_participants.size();

modify_participants(proposed_participants);

if (orig_participants_size == proposed_participants.size()) {
// no changes in the participants
return -1;
}

db.modify(gpo, [&proposed_participants, cur_block_num](auto& gp) {
gp.proposed_security_group_block_num = cur_block_num;
gp.set_proposed_security_group_participants(proposed_participants.begin(),
proposed_participants.end());
});

return 0;
}

}; /// controller_impl

const resource_limits_manager& controller::get_resource_limits_manager()const
Expand Down Expand Up @@ -2817,6 +2875,44 @@ int64_t controller::set_proposed_producers( vector<producer_authority> producers
return version;
}

const security_group_info_t& controller::active_security_group() const {
if( !(my->pending) )
return my->head->get_security_group_info();

return std::visit(
overloaded{
[](const building_block& bb) -> const security_group_info_t& { return bb._pending_block_header_state.security_group; },
[](const assembled_block& ab) -> const security_group_info_t& { return ab._pending_block_header_state.security_group; },
[](const completed_block& cb) -> const security_group_info_t& { return cb._block_state->get_security_group_info(); }},
my->pending->_block_stage);
}

flat_set<account_name> controller::proposed_security_group_participants() const {
return {get_global_properties().proposed_security_group_participants.begin(),
get_global_properties().proposed_security_group_participants.end()};
}

int64_t controller::add_security_group_participants(const flat_set<account_name>& participants) {
return participants.size() == 0 ? -1 : my->propose_security_group([&participants](auto& pending_participants) {
pending_participants.insert(participants.begin(), participants.end());
});
}

int64_t controller::remove_security_group_participants(const flat_set<account_name>& participants) {
return participants.size() == 0 ? -1 : my->propose_security_group([&participants](auto& pending_participants) {
flat_set<account_name>::sequence_type tmp;
tmp.reserve(pending_participants.size());
std::set_difference(pending_participants.begin(), pending_participants.end(), participants.begin(),
participants.end(), std::back_inserter(tmp));
pending_participants.adopt_sequence(std::move(tmp));
});
}

bool controller::in_active_security_group(const flat_set<account_name>& participants) const {
const auto& active = active_security_group().participants;
return std::includes(active.begin(), active.end(), participants.begin(), participants.end());
}

const producer_authority_schedule& controller::active_producers()const {
if( !(my->pending) )
return my->head->active_schedule;
Expand Down Expand Up @@ -3324,6 +3420,17 @@ void controller_impl::on_activation<builtin_protocol_feature_t::blockchain_param
} );
}


template<>
void controller_impl::on_activation<builtin_protocol_feature_t::security_group>() {
db.modify( db.get<protocol_state_object>(), [&]( auto& ps ) {
add_intrinsic_to_whitelist( ps.whitelisted_intrinsics, "add_security_group_participants" );
add_intrinsic_to_whitelist( ps.whitelisted_intrinsics, "remove_security_group_participants" );
add_intrinsic_to_whitelist( ps.whitelisted_intrinsics, "in_active_security_group" );
add_intrinsic_to_whitelist( ps.whitelisted_intrinsics, "get_active_security_group" );
} );
}

/// End of protocol feature activation handlers

} } /// eosio::chain
16 changes: 13 additions & 3 deletions libraries/chain/fork_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <boost/multi_index/composite_key.hpp>
#include <fc/io/fstream.hpp>
#include <fstream>
#include <eosio/chain/versioned_unpack_stream.hpp>

namespace eosio { namespace chain {
using boost::multi_index_container;
Expand All @@ -17,7 +18,7 @@ namespace eosio { namespace chain {
const uint32_t fork_database::magic_number = 0x30510FDB;

const uint32_t fork_database::min_supported_version = 1;
const uint32_t fork_database::max_supported_version = 1;
const uint32_t fork_database::max_supported_version = 2;

// work around block_state::is_valid being private
inline bool block_state_is_valid( const block_state& bs ) {
Expand Down Expand Up @@ -122,14 +123,23 @@ namespace eosio { namespace chain {
("max", max_supported_version)
);

// The unpack_strm here is used only to unpack `block_header_state` and `block_state`. However, those two
// classes are written to unpack based on the snapshot version; therefore, we orient it to the snapshot version.

const bool has_block_header_state_extension = version > min_supported_version;
versioned_unpack_stream unpack_strm(
ds, has_block_header_state_extension
? block_header_state::minimum_snapshot_version_with_state_extension
: block_header_state::minimum_snapshot_version_with_state_extension - 1);

block_header_state bhs;
fc::raw::unpack( ds, bhs );
fc::raw::unpack( unpack_strm, bhs );
reset( bhs );

unsigned_int size; fc::raw::unpack( ds, size );
for( uint32_t i = 0, n = size.value; i < n; ++i ) {
block_state s;
fc::raw::unpack( ds, s );
fc::raw::unpack( unpack_strm, s );
// do not populate transaction_metadatas, they will be created as needed in apply_block with appropriate key recovery
s.header_exts = s.block->validate_and_extract_header_extensions();
my->add( std::make_shared<block_state>( move( s ) ), false, true, validator );
Expand Down
Loading