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

P2P signing on direct send #4466

Merged

Conversation

iulianpascalau
Copy link
Contributor

Description of the reasoning behind the pull request (what feature was missing / how the problem was manifesting itself / what was the motive behind the refactoring)

  • the direct send messages are not signed. This is not a security concern since the libp2p lib checks the keys anyway at handshake time. To ensure behavioral consistency, we will add signature to the direct send messages, anyway.

Proposed Changes

  • added direct send message signing to ensure behavior consistency in the p2p network messenger
  • added exception in consensus interceptor to not allow messages without signature

Testing procedure

  • standard testing procedure
  • half network run

… the p2p network messenger

- added exception in consensus interceptor to not allow messages without signature
@iulianpascalau iulianpascalau marked this pull request as draft September 15, 2022 07:28
@codecov-commenter
Copy link

codecov-commenter commented Sep 15, 2022

Codecov Report

Base: 73.87% // Head: 73.94% // Increases project coverage by +0.07% 🎉

Coverage data is based on head (3a50d66) compared to base (6558459).
Patch coverage: 91.48% of modified lines in pull request are covered.

Additional details and impacted files
@@                         Coverage Diff                          @@
##           feat/optimise-consensus-sigcheck    #4466      +/-   ##
====================================================================
+ Coverage                             73.87%   73.94%   +0.07%     
====================================================================
  Files                                   693      680      -13     
  Lines                                 88459    87154    -1305     
====================================================================
- Hits                                  65349    64450     -899     
+ Misses                                18182    17887     -295     
+ Partials                               4928     4817     -111     
Impacted Files Coverage Δ
p2p/libp2p/directSender.go 88.67% <89.74%> (-0.21%) ⬇️
consensus/spos/worker.go 82.08% <100.00%> (+0.09%) ⬆️
p2p/libp2p/mockMessenger.go 72.72% <100.00%> (+4.30%) ⬆️
p2p/libp2p/netMessenger.go 80.02% <100.00%> (ø)
trie/factory/trieCreator.go 51.80% <0.00%> (-27.15%) ⬇️
process/smartContract/backwardsCompatibility.go 0.00% <0.00%> (-20.00%) ⬇️
process/smartContract/builtInFunctions/factory.go 75.00% <0.00%> (-10.97%) ⬇️
state/peerAccountsDB.go 91.46% <0.00%> (-8.54%) ⬇️
...cess/block/preprocess/validatorInfoPreProcessor.go 53.24% <0.00%> (-8.30%) ⬇️
trie/snapshotTrieStorageManager.go 63.88% <0.00%> (-5.93%) ⬇️
... and 137 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines +263 to +267
buff, err := mes.Marshal()
if err != nil {
return nil, err
}

Copy link
Contributor

Choose a reason for hiding this comment

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

in libp2p there is the SignPrefix that's being added, should we think about it here, while we construct the message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Comment on lines 70 to 71
func TestNewDirectSender(t *testing.T) {
t.Run("nil context", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

t.Parallel() for main test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in all tests

Copy link
Contributor

@sstanculeanu sstanculeanu left a comment

Choose a reason for hiding this comment

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

no other comments

…irect-send

# Conflicts:
#	p2p/libp2p/export_test.go
#	p2p/libp2p/netMessenger.go
#	p2p/libp2p/netMessenger_test.go
ssd04
ssd04 previously approved these changes Sep 15, 2022
@@ -27,6 +27,8 @@ var _ p2p.DirectSender = (*directSender)(nil)

const timeSeenMessages = time.Second * 120
const maxMutexes = 10000
const signPrefix = "en-directsend:"
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe use the same prefix as in libp2p so that we can treat broadcast and direct send messages similarly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, reused pubsub.SignPrefix

sstanculeanu
sstanculeanu previously approved these changes Sep 15, 2022
AdoAdoAdo
AdoAdoAdo previously approved these changes Sep 15, 2022
ssd04
ssd04 previously approved these changes Sep 15, 2022
@AdoAdoAdo AdoAdoAdo merged commit e479b28 into feat/optimise-consensus-sigcheck Sep 19, 2022
@AdoAdoAdo AdoAdoAdo deleted the p2p-signing-on-direct-send branch September 19, 2022 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants