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

fix/Notary request tracking #2459

Merged
merged 4 commits into from
Jul 28, 2023

Conversation

carpawell
Copy link
Member

Closes #2315

@carpawell carpawell self-assigned this Jul 25, 2023
@codecov
Copy link

codecov bot commented Jul 25, 2023

Codecov Report

Merging #2459 (e361c3b) into master (12e8b08) will increase coverage by 0.03%.
The diff coverage is 87.50%.

❗ Current head e361c3b differs from pull request most recent head 4fd9775. Consider uploading reports for the commit 4fd9775 to get more accurate results

@@            Coverage Diff             @@
##           master    #2459      +/-   ##
==========================================
+ Coverage   29.44%   29.47%   +0.03%     
==========================================
  Files         399      399              
  Lines       30410    30432      +22     
==========================================
+ Hits         8954     8971      +17     
- Misses      20713    20717       +4     
- Partials      743      744       +1     
Files Changed Coverage Δ
pkg/morph/event/listener.go 0.00% <0.00%> (ø)
pkg/morph/event/parsers.go 0.00% <ø> (ø)
pkg/morph/event/utils.go 0.00% <ø> (ø)
pkg/morph/event/notary_preparator.go 77.89% <93.33%> (+1.56%) ⬆️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

Does it really close #2315? How about someone (an IR node) sending an epoch update prematurely?

@carpawell
Copy link
Member Author

@roman-khimov, TBH, yesterday I figured out that it was not a problem at all. Yes, we parse every notary request and are ready to sign each of them but not every method has a handler and a parser for it: e.g. our beloved NewEpoch event is listened as a simple notification cause netmap processor has a parser and a handler for it. It is ready to update its internal state and be sure that everyone thinks that a NewEpoch has happened cause it believes the contract. But if another IR sends notary requests it won't be handled cause IR does not have NewEpoch notary parser and notary handler for it.

But why have I added the last commit then? I still think that morph refactor is somewhere near and we will drop (simplify) Listener. Also, I think notary events are missing contract side checks (the netmap contract will not allow ticking epoch if there are less than 5 IR requested a new epoch; but IR would tick epoch if there are a hander for it and a corresponding notary request has been parsed) so I think it should be a notary preparator (preparator now) who must skip unnecessary requests not a missing handler.

Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM.

pkg/morph/event/notary_preparator.go Show resolved Hide resolved
Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

We've discussed and came to the solution that transctions cache isn't needed and can be removed. The only purpose of this cache is to filter out notary requests that were sent by the alphabet node itself. Instead of this we can add a check for notary request: the second signer of fallback transaction shouldn't be the committee member.

Disadvantage of this approach is that we have to always keep the list of committee members up-to-date. It can be reached with RPC-based cache (but then a lot of getcommittee RPC requests are expected) or with cache that is subscribed to the committee updates (we need to add some code to our cache than).

@roman-khimov, what do you think?

@roman-khimov
Copy link
Member

Do you mean alreadyHandledTXs?

sent by the alphabet node itself
the second signer of fallback transaction shouldn't be the committee member

So is it a node key that is a problem of is it a whole committee that is a problem? What if SN uses the same key as some IR node?

Hi, neo-project/neo#2763, anyway.

@AnnaShaleva
Copy link
Member

Do you mean alreadyHandledTXs?

Yes.

What if SN uses the same key as some IR node?

But is it possible? I thought that SN and IR are always different antities with different accounts. If not, then the described way isn't workable.

@roman-khimov
Copy link
Member

Nothing technically prevents SN from using the same key as IR.

Public structs that implement public interfaces with constructors that
return interfaces instead of structs; and all of that is in a one package
only. Not a part of best practices.

Signed-off-by: Pavel Karpy <[email protected]>
Missing attribute type does not allow to hash the entire TX.

Signed-off-by: Pavel Karpy <[email protected]>
Allows skipping any checks if notary request has been received the second
time (every request always returns back).

Signed-off-by: Pavel Karpy <[email protected]>
Notary requests can be sent by anybody who has GAS and knows how an Alphabet
node parses them. Add predefined allowed events on notary request parsing
level.

Closes nspcc-dev#2315.

Signed-off-by: Pavel Karpy <[email protected]>
@carpawell carpawell force-pushed the fix/notary-request-tracking branch from 414934f to 4fd9775 Compare July 28, 2023 08:30
@roman-khimov roman-khimov merged commit 14ad097 into nspcc-dev:master Jul 28, 2023
7 of 8 checks passed
@carpawell carpawell deleted the fix/notary-request-tracking branch July 28, 2023 15:06
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.

Notary request tracking is incorrect
3 participants