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

Add pretty-printing of SCPEnvelope #637

Merged
merged 8 commits into from
Apr 5, 2020

Conversation

AndrejMitrovic
Copy link
Contributor

I'll wait to see the report from codecov to see if every line has been covered.

Still some things left to do:

  • In some places the hash is still displayed as hexadecimal in full, we could use the HashFmt for this.
  • Deserialization of ConsensusData in this case is handled gracefully. But in the future when we start using hashes, we can just provide another lookup function and print out <tx not found> when we're missing a tx that's being nominated.

Fixes #635

@AndrejMitrovic AndrejMitrovic added the type-enhancement An improvement of existing functionalities label Mar 6, 2020
@codecov
Copy link

codecov bot commented Mar 9, 2020

Codecov Report

Merging #637 into v0.x.x will increase coverage by 0.06%.
The diff coverage is 91.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           v0.x.x     #637      +/-   ##
==========================================
+ Coverage   91.31%   91.37%   +0.06%     
==========================================
  Files          62       63       +1     
  Lines        4927     5101     +174     
==========================================
+ Hits         4499     4661     +162     
- Misses        428      440      +12     
Flag Coverage Δ
#integration 50.81% <0.00%> (-3.11%) ⬇️
#unittests 90.20% <91.47%> (+0.10%) ⬆️
Impacted Files Coverage Δ
source/agora/common/Config.d 90.84% <ø> (ø)
source/agora/consensus/protocol/Nominator.d 91.39% <ø> (ø)
source/agora/utils/PrettyPrinter.d 90.17% <90.62%> (-0.07%) ⬇️
source/agora/utils/SCPPrettyPrinter.d 91.66% <91.66%> (ø)
source/agora/test/Base.d 89.59% <0.00%> (+0.45%) ⬆️
source/agora/common/Serializer.d 96.34% <0.00%> (+0.45%) ⬆️
source/agora/network/NetworkManager.d 80.12% <0.00%> (+0.62%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c45867...d6511db. Read the comment docs.

@AndrejMitrovic
Copy link
Contributor Author

Oh great, I love linker errors.

@Geod24
Copy link
Collaborator

Geod24 commented Mar 9, 2020

Oh great, I love linker errors.

Move all your function-scope imports to global scope.

@AndrejMitrovic
Copy link
Contributor Author

Move all your function-scope imports to global scope.

Thanks that works. But I thought this was just an issue with RDMD, not dub..

@AndrejMitrovic
Copy link
Contributor Author

Ah no it did not work. :>

Ok I will look into this..

@Geod24
Copy link
Collaborator

Geod24 commented Mar 9, 2020

Thanks that works. But I thought this was just an issue with RDMD, not dub..

It's actually an issue with DMD, and we use some of the dependency tracking magic in some places (also we use rdmd in tests/runner.d)

@AndrejMitrovic
Copy link
Contributor Author

The linking issue is for the client configuration. But the client shouldn't be importing into PrettyPrinter, so I don't quite get why this is causing linker issues.

@AndrejMitrovic
Copy link
Contributor Author

Ok I figured it out. Had to add "source/agora/utils/PrettyPrinter.d", to the excluded source files.

@AndrejMitrovic AndrejMitrovic changed the title [wip] Add pretty-printing of SCPEnvelope Add pretty-printing of SCPEnvelope Mar 10, 2020
@Geod24
Copy link
Collaborator

Geod24 commented Mar 12, 2020

Looks like something in the integration test suite depends from the pretty printer tho

@AndrejMitrovic
Copy link
Contributor Author

I've split the SCP pretty-printing into another module, and added several commits introducing ConsensusData and Enrollment pretty-printing support.

Copy link
Collaborator

@Geod24 Geod24 left a comment

Choose a reason for hiding this comment

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

Very nice, a few comments

@@ -54,6 +54,8 @@
"source/agora/common/Config.d",
"source/agora/network/*",
"source/agora/node/*",
"source/agora/utils/PrettyPrinter.d",
"source/agora/utils/SCPPrettyPrinter.d",

This comment was marked as resolved.

import scpd.Cpp;
import scpd.types.Stellar_SCP;
import scpd.types.Stellar_types : StellarHash = Hash;
alias StellarValue = Value;

This comment was marked as resolved.


if (qset !is null)
{
auto qconf = toQuorumConfig(*qset.ptr);

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One was using alias this (shared_ptr) and the other explicit dereference. I'll simplify it.

GCOQ...LRIJ(62,500,000), GCOQ...LRIJ(62,500,000)], enrolls: [{ utxo: 0x0000...e26f, seed: 0x4a5e...a33b, cycles: 1008, sig: 0x0000...be78 }, { utxo: 0x0000...e26f, seed: 0x4a5e...a33b, cycles: 1008, sig: 0x0000...be78 }] } }, prep: <null>, prepPrime: <null>, nc: 100, nH: 200 } }, sig: 0x0af7...b5ab }`;

// with quorum mapping
static immutable PrepareRes2 = `{ statement: { node: GBUV...KOEK, slotIndex: 0, pledge: SCP_PREPARE { qset: { hash: 0xfee13ea2fd956028d31b93cbf0a47ea97c6c9868b7e911b797667113ed12bf0d, quorum: QuorumConfig(2, [GBFDLGQQDDE2CAYVELVPXUXR572ZT5EOTMGJQBPTIHSLPEOEZYQQCEWN, GBYK4I37MZKLL4A2QS7VJCTDIIJK7UXWQWKXKTQ5WZGT2FPCGIVIQCY5], []) }, ballot: { counter: 42, value: { tx_set: [Type : Payment, Inputs (1): 0x0000...0000[0]:0x0000...0000
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we abbreviate SCP_PREPARE.qset.hash ? Also QuorumConfig entries ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good ideas.

@AndrejMitrovic
Copy link
Contributor Author

Update:

  • Renamed SCP_EXTERNALIZE to Externalize, etc.
  • Added formatting for: StellarHash (32 byte hash)
  • Added pretty-printing for QuorumConfig

@AndrejMitrovic
Copy link
Contributor Author

I'll force push again to reorder the commits.

@AndrejMitrovic AndrejMitrovic force-pushed the pretty-scp branch 3 times, most recently from 4c17602 to 4f433a3 Compare April 2, 2020 01:10
@AndrejMitrovic
Copy link
Contributor Author

Fixed linking issues. I had to re-add PrettyPrinter to exclude files again.

@AndrejMitrovic
Copy link
Contributor Author

Hmm. I think I should consider changing all the *Fmt structs in SCPPrettyPrinter to store a pointer rather than a value as a field, because we want to avoid passing C++ types by value.

@Geod24 what do you think?

@Geod24
Copy link
Collaborator

Geod24 commented Apr 2, 2020

That was my original approach, however it didn't work. The details of why escape me ATM. Might be something to do with @safe. But yeah, we definitely want this.

@AndrejMitrovic
Copy link
Contributor Author

Oops. I pinged someone. :x

@AndrejMitrovic
Copy link
Contributor Author

source/agora/common/Config.d(26,8): Error: module node is in file 'dyaml/node.d' which cannot be read

hmm..

@AndrejMitrovic
Copy link
Contributor Author

Update: removed copying.

There's still the weird compilation failure on circle-ci.

@AndrejMitrovic
Copy link
Contributor Author

I know how to fix it, I'll move QuorumConfig out of the Config module.

@AndrejMitrovic
Copy link
Contributor Author

Updated.

It's disallowing passing rvalues.
To allow passing rvalues.
We need the ability to pass rvalues.
It will be used by PrettyPrinter,
and we don't want to import the Config
module just to be able to pretty-print
the quorum data structure.
It includes pretty-printing for all the possible
pledge types (prepare / commit / externalize / nominate),
and also handles deserialization failures gracefully.

It is in a separate module to avoid linking issues
with the integration tests, which import into the
PrettyPrinter module and should not import into SCP.

Fixes bosagora#635
Copy link
Collaborator

@Geod24 Geod24 left a comment

Choose a reason for hiding this comment

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

Amazing, thanks!

@Geod24 Geod24 merged commit 8b2ea0e into bosagora:v0.x.x Apr 5, 2020
@AndrejMitrovic AndrejMitrovic deleted the pretty-scp branch April 6, 2020 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement An improvement of existing functionalities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add prettify stringification for SCPEnvelope
2 participants