Skip to content

Resolve "Remove use of consensus controller in API, route requests via massa node." - [merged] #615

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

Closed
massa-bot opened this issue Nov 10, 2021 · 48 comments

Comments

@massa-bot
Copy link

In GitLab by @AureliaDolo

Merges 127-remove-use-of-consensus-controller-in-api-route-requests-via-massa-node-2 -> master

Closes #127

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

  • ff46335 - Api events are sent to node

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

  • eeccfe1 - command sender methods are now more opaque

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

I still have tests to fix, but hopefully the channel magick is ok.

I messed up a little bit the use of command senders is mostly reverting some parts of the first one. If there are some tips to make it clean, I would be happy to give it a try.

@gterzian can you give me some feedback on event_tx usage ? Thanks

@massa-bot
Copy link
Author

In GitLab by @gterzian

Commented on api/src/filters.rs line 811

Is the clone necessary here?

@massa-bot
Copy link
Author

In GitLab by @gterzian

Commented on api/src/filters.rs line 1026

Same question on clone

@massa-bot
Copy link
Author

In GitLab by @gterzian

Commented on massa-node/src/main.rs line 72

nit: I would say it would be clearer to assign the first response to a variable, and then send it on the response sender.

@massa-bot
Copy link
Author

In GitLab by @gterzian

Oui super! Juste quelque petit commentaire....

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

Commented on api/src/filters.rs line 811

No, it isn't. Removed it.

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

Commented on api/src/filters.rs line 1026

Here it is necessary because it is also borrowed later when retrieving next slots for staker.

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

Commented on massa-node/src/main.rs line 72

From what I understood on another occasion according to @damip it is better for performances to avoid intermediate variables.

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

Commented on api/src/filters.rs line 811

changed this line in version 3 of the diff

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @damip

Commented on massa-node/src/main.rs line 72

Modern compilers should optimize it away, but I've heard from many programmers (C++ admittedly) that when readability is not hampered too much (i.e not too much nesting), it is a good practice to avoid intermediate variables.
However here you may need one more indentation level to clarify:

response_sender_tx.send(
    consensus_command_sender
        .get_active_block(hash)
        .await
        .expect("could not retrieve block")
).expect("could not send block");

note that all error messages should be lowercase without a capital letter at the start and no punctuation at the end: rust-lang/rust#437

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

  • f042bdf - Removed useless Serialize impl.

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

  • e200c7c - Fixed get graph interval test.

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

  • 069c54a - Fixed test current parents.

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

  • 04e352a - Fixed get block interval test.

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 1 commit

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

Commented on api/src/tests/filter_tests.rs line 1079

I'm not sure at all with this pattern but it fixed the value moved here, in previous iteration of loop I was getting.

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

added 2 commits

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

requested review from @gterzian

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

marked this merge request as ready

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

marked this merge request as draft

@massa-bot
Copy link
Author

In GitLab by @damip

added 1 commit

Compare with previous version

@massa-bot
Copy link
Author

In GitLab by @damip

Commented on api/src/tests/filter_tests.rs line 1079

the cloned_xxx before an async move is completely acceptable :)

@massa-bot
Copy link
Author

In GitLab by @damip

@gterzian can you do a last check of this MR ? so that @Adolo can correct the remaining details, then I will merge it and this should mark the end of milestone 0.1 🎉

@massa-bot
Copy link
Author

In GitLab by @damip

Commented on api/src/filters.rs line 1026

the functions retrieve_graph_export and similar should take a reference to event_tx, and not a moved version of it. This will eliminate the need for clone() here

@massa-bot
Copy link
Author

In GitLab by @gterzian

Commented on massa-node/src/main.rs line 72

Even if it were slower to add a variable, how do you know if this would actually matter(be in the "hot path")? It might be a kind of premature optimization at this stage?

On the other hand readability does matter at this stage, so it's up to you to decide what you prefer. I'm fine with the current code, although I would probably write it with the extra variables and I don't think it matters much.

@massa-bot
Copy link
Author

In GitLab by @gterzian

Ok very good.

The last things to do:

  1. Look into the fall in test coverage, and see if the previous level can be maintained.
  2. Squash all commits into one, since they all represent the same "work".

Regarding 2, I suggest you first try this on a copy of this branch, since I assume you haven't done this before.

It goes like this:

  1. git rebase -i HEAD~19
  2. in the interactive shell, pick the first commit, then s(quash) all the others like in the screenshot below

Screen_Shot_2021-02-10_at_1.19.41_PM

  1. do a "esc" followed by a wq to exit the shell.
  2. Comment away, by adding a # in front, the descriptions of the squashed commits. See the screenshot below.

Screen_Shot_2021-02-10_at_1.21.59_PM

  1. Do the same at 3, and then git push --force back to this PR.

@massa-bot
Copy link
Author

In GitLab by @gterzian

approved this merge request

@massa-bot
Copy link
Author

In GitLab by @gterzian

Tiens pour le squash tu peux le faire automatiquement: https://docs.gitlab.com/ee/user/project/merge_requests/squash_and_merge.html

@massa-bot
Copy link
Author

In GitLab by @damip

@gterzian pour info, je coche toujours "squash commits" quand je merge une merge request vers master, du coup ne vous tracassez pas avec ça, mieux vaut garder les commits jusqu'au dernier moment

@massa-bot
Copy link
Author

In GitLab by @damip

Commented on massa-node/src/main.rs line 72

I guess it boils down to personal preference in this simple case, because to me both options are just as readable.

@massa-bot
Copy link
Author

In GitLab by @gterzian

Commented on api/src/filters.rs line 1026

Ok we can either file an issue to change retrieve_graph_export, or do it in this PR(this should ideally be in a separate commit actually).

Follow-up issue for things like that are quite nice, especially when we are open-source since this would be a great "good first issue" for beginners.

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

Du coup, c'est bien toi qui va squasher pour de vrai ?

@massa-bot
Copy link
Author

In GitLab by @AureliaDolo

Commented on api/src/filters.rs line 1026

I wrote a follow up issue #133.

@massa-bot
Copy link
Author

In GitLab by @damip

approved this merge request

@massa-bot
Copy link
Author

In GitLab by @damip

Commented on api/src/filters.rs line 1026

ok

@massa-bot
Copy link
Author

In GitLab by @damip

marked this merge request as ready

@massa-bot
Copy link
Author

In GitLab by @damip

mentioned in commit 7062504

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

No branches or pull requests

1 participant