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
feat: improve config debug-ability #4456
base: main
Are you sure you want to change the base?
Conversation
@@ -88,7 +88,7 @@ mod model { | |||
)] | |||
#[display(fmt = "({header})")] | |||
#[allow(missing_docs)] | |||
pub(crate) struct BlockPayload { | |||
pub struct BlockPayload { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain yourself here? This shouldn't be public
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This warning appears when I run cargo check -p iroha_swarm
(this is about TransactionPayload
, but the cause is the same):
warning: type `transaction::model::TransactionPayload` is more private than the item `transaction::SignedTransaction::signatures`
--> data_model/src/transaction.rs:297:5
|
297 | pub fn signatures(&self) -> &SignaturesOf<TransactionPayload> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method `transaction::SignedTransaction::signatures` is reachable at visibility `pub`
|
note: but type `transaction::model::TransactionPayload` is only usable at visibility `pub(crate)`
--> data_model/src/transaction.rs:101:5
|
101 | pub(crate) struct TransactionPayload {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(private_interfaces)]` on by default
However, it doesn't appear if I check iroha
, or iroha_core
, or iroha_client
(targetly). I guess that is because they all by the end of the day use iroha_data_model
with transparent_api
enabled, while iroha_swarm
uses it without any features.
I guess the temporary solution would be, first of all, to create an issue like "Fix all transparent_api
usage across workspace" (you also mentioned _transparent_api
here: #4382 (comment)), but in scope of this PR either:
- Return
pub(crate)
and silent the warning, temporarily - Enable
transparent_api
foriroha_swarm
, temporarily
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we don't want to leak private types here:
pub fn signatures(&self) -> &SignaturesOf<TransactionPayload> {
we can consider changing the function to:
pub fn signatures(&self) -> &SignaturesOf<SignedTransaction> {
I guess the temporary solution would be, first of all, to create an issue like "Fix all transparent_api usage across workspace" (you also mentioned _transparent_api here: #4382 (comment)), but in scope of this PR either:
there isn't much to fix. We just need to remove transparent_api
from test_network
because it's leaking into our integration tests and then client appears to have access to internals when in fact it doesn't. But that's too big of an effort so we have to live with it for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to change it to SignedTransaction
(and SignedBlock
), but I need to transmute the type then. What is the proper way to do so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we don't want to leak private types here:
pub fn signatures(&self) -> &SignaturesOf {
we can consider changing the function to:
pub fn signatures(&self) -> &SignaturesOf {
I don't think it's a good idea, as SignedTransaction
is not scale-compatible with TransactionPayload
(SignedTransactionV1
= TransactionPayload
+ SignaturesOf<TransactionPayload>
). I guess we can make another versioned structure for transaction signatures (as a newtype around SignaturesOf<TransactionPayload>
)? Or we can expose the TransactionPayload
itself..
@@ -98,7 +98,7 @@ mod model { | |||
Serialize, | |||
IntoSchema, | |||
)] | |||
pub(crate) struct TransactionPayload { | |||
pub struct TransactionPayload { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same as here
@DCNick3, I would appreciate if you can take a look at the procmacro I wrote here, in config/base/derive. |
6b96f4d
to
5af02bf
Compare
A bit concerned with the inclusion of source code location in the error trace (the |
I am concerned too. There are also complete backtraces attached, which are displayed in dev environment. Anyway, we can disable |
9b613a6
to
1aa3bf6
Compare
address hyperledger#4456 (comment) Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Co-authored-by: ⭐️NINIKA⭐️ <DCNick3@users.noreply.github.com> Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
rust-lang/rust#44752 (comment) Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
address hyperledger#4456 (comment) Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
1513d92
to
400e968
Compare
Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
Description
This PR contains a major improvement of the work done in #4239. This is a big step towards better debug-ability of Iroha configuration system due to better errors. And yet, there are still many things to improve further!
Key points:
ConfigReader
API, which handles configuration sources in a dynamic manner rather than relying onserde
completely, thus giving high flexibility in how to handle different cases. It is also built targeting Iroha domain specifically and doesn't have any extra stuff. Much less boilerplate.error_stack
crate, which gives higher control over errors reporting thaneyre
does.--trace-config
works! Useslog
&stderrlog
crates for it. Seems to be not a heavy solution for this. It is completely separate fromtracing
stack.Further enhancements
There are still many things that might be improved.
error_stack
:format!
ConfigReader
, use better naming and abstractions, perhaps.ConfigReader
. There is lots of naive code and extra allocations.error_stack
. Sometimes it would be really cool to just "forward" underlying context without changing it, but currently it's howerror_stack
is designed. So, we have sometimes stacks like "Failed to load config -> Failed to load config -> failed to read file system -> ..."slim
compile feature for Iroha, which will remove--trace-config
support alongside withlog
&stderrlog
dependencies, and morePRIVATE_KEY_ALGORITHM
+PRIVATE_KEY_PAYLOAD
, and removing cratchyenv_custom
API fromConfigReader
Linked isues
Closes #3470, #4299, #4300
Gallery
Note: I've changed some bits after making these screenshots.
Some terminal screenshots
TODO
iroha_config_base
iroha_client_cli
compilation failurefails_with_no_trusted...
incli/src/lib.rs