Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve #1506: Break protocol off into its own library #1737

Merged
merged 16 commits into from
May 7, 2019

Conversation

nathanielhourt
Copy link
Contributor

@nathanielhourt nathanielhourt commented Apr 26, 2019

This pull moves the chain/protocol folder into its own library, formalizing the separation between the protocol and the implementation. #1506

Notable architectural changes:

  • Remove xyz_object types from object_id<> template and replace with a mapping of object_id<> to xyz_object type which is defined in the header that defines xyz_object
  • Move object_id_type and object_id<> from db library to protocol, make db depend on protocol rather than vice versa

@pmconrad pmconrad mentioned this pull request Apr 27, 2019
@pmconrad
Copy link
Contributor

Docker build fails with

[ 60%] Building CXX object libraries/chain/CMakeFiles/graphene_chain.dir/db_notify.cpp.o
In file included from /bitshares-core/libraries/chain/db_notify.cpp:7:0:
/bitshares-core/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp:43:41: error: ‘protocol_ids’ was not declared in this scope
static const uint8_t space_id = protocol_ids;
^
/bitshares-core/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp:43:41: note: suggested alternative:
In file included from /bitshares-core/libraries/protocol/include/graphene/protocol/authority.hpp:25:0,
from /bitshares-core/libraries/chain/db_notify.cpp:3:
/bitshares-core/libraries/protocol/include/graphene/protocol/types.hpp:121:5: note: ‘protocol_ids’
protocol_ids = 1,
^

@pmconrad
Copy link
Contributor

pmconrad commented Apr 27, 2019

The travis build works. Both docker and travis are on Ubuntu-16.04 with gcc-5.4.x and boost-1.58.0.
Most notable difference is that travis builds with type Debug whereas docker builds with type Release.
I can reproduce the build failure locally with type RelWithDebInfo (my standard), on openSUSE with gcc-7.4 and boost-1.69. Trying Debug build now. Debug build fails just the same. I wonder why travis works.

@nathanielhourt
Copy link
Contributor Author

OK, requested changes applied, and I think the build should be fixed.

nathanielhourt and others added 10 commits May 1, 2019 16:04
Allows the more concise expression `object_downcast_t<xyz>` instead of
the old `typename object_downcast<xyz>::type`
The ID types, object_id and object_id_type, were defined in the db
library, and the protocol library depends on db to get these types.
Technically, the ID types are defined by the protocol and used by the
database, and not vice versa. Therefore these types should be in the
protocol library, and db should depend on protocol to get them.

This commit makes it so.
@nathanielhourt
Copy link
Contributor Author

....aaaand Travis timed out....

pmconrad
pmconrad previously approved these changes May 4, 2019
@abitmore abitmore self-requested a review May 4, 2019 09:40
Copy link
Member

@abitmore abitmore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good. Thanks a lot!

libraries/chain/evaluator.cpp Outdated Show resolved Hide resolved
libraries/chain/include/graphene/chain/config.hpp Outdated Show resolved Hide resolved
libraries/chain/include/graphene/chain/types.hpp Outdated Show resolved Hide resolved
libraries/chain/include/graphene/chain/types.hpp Outdated Show resolved Hide resolved

#define GRAPHENE_MAX_SIG_CHECK_DEPTH 2

#define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this doesn't belong to protocol.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It determines fork validity... I think it would be interesting to a third party implementation. Otherwise they would have to replicate this number in their own project, or risk their implementations following a fork that the reference implementation won't follow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line between protocol and implementation is somewhat blurred. We have lots of consensus logic in the implementation, and all of it determines block validity.

I lean a bit towards @abitmore in this case. The threshold is only helpful for the local node, in that it defines any fork that goes back beyond LIB to be invalid. But an independent observer given two forks cannot decide which one is "real". Therefore the value is irrelevant wrt the protocol.

libraries/protocol/include/graphene/protocol/config.hpp Outdated Show resolved Hide resolved
libraries/protocol/include/graphene/protocol/types.hpp Outdated Show resolved Hide resolved
libraries/wallet/wallet.cpp Outdated Show resolved Hide resolved
Copy link
Member

@abitmore abitmore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

Define macros to fully de-boilerplate ID type definitions.

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

The first is to avoid a naming collision on transaction_id_type, and the
other two are to maintain consistency with the naming of the other
types.
@nathanielhourt
Copy link
Contributor Author

OK, I've made some macros that eliminate all the boilerplate around the ID types, enums, and typename reflection. How does that look?

@abitmore
Copy link
Member

abitmore commented May 4, 2019

Looks good to me.
Restarted Travis.
Noticed some warnings when running tests, e.g.

1435270ms th_a reflect_util.hpp:51 clean_name ] don't know how to clean name: graphene::protocol::override_transfer_operation

@nathanielhourt
Copy link
Contributor Author

Huh, never seen that before... Easy fix, though. :)

@abitmore
Copy link
Member

abitmore commented May 5, 2019

cli_tests fails.

@nathanielhourt
Copy link
Contributor Author

I have no idea how that happened... Oops!

@pmconrad
Copy link
Contributor

pmconrad commented May 5, 2019

Docker build timed out. Restarted. :-/

@nathanielhourt
Copy link
Contributor Author

Did it time out again? At least travis finally passed.

.gitignore Outdated Show resolved Hide resolved
Copy link
Member

@abitmore abitmore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Don't know why Docker Cloud failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants