-
Notifications
You must be signed in to change notification settings - Fork 337
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
uses SipHasher24 for gossip ping tokens #3974
Conversation
db41ecb
to
6528cb4
Compare
@ryoqun the frozen-abi tests are failing here. I tried manually doing impl<const N:usize> solana_frozen_abi::abi_example::AbiExample for Ping<N> {
// ...
} as well but that didn't work either. Do you mind taking a look? Thank you, |
e835aa4
to
7110838
Compare
@ryoqun surprisingly this is also making the Tried a few things, but none worked. I have for now removed failing frozen-abi tests to unblock this. $ RUST_BACKTRACE=1 cargo test --features frozen-abi --lib -- TimedTracedEvent_frozen_abi --nocapture
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.36s
Running unittests src/lib.rs (/home/acer/solana/target/debug/deps/solana_core-78548d94c0ee7b01)
running 1 test
thread 'banking_trace::TimedTracedEvent_frozen_abi::test_abi_digest' panicked at /home/acer/solana/sdk/frozen-abi/src/abi_example.rs:279:13:
derive or implement AbiExample/AbiEnumVisitor for solana_packet::Packet |
cb687c5
to
5cce98d
Compare
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.
generally looks good. have you tested this against v2 to make sure there are not backwards compatibility issues?
type Ping = ping_pong::Ping<REPAIR_PING_TOKEN_SIZE>; | ||
type PingCache = ping_pong::PingCache<REPAIR_PING_TOKEN_SIZE>; |
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.
is there any reason why REPAIR_PING_TOKEN_SIZE
may differ from GOSSIP_PING_TOKEN_SIZE
? And would it make sense to just turn it into one variable called PING_TOKEN_SIZE
and make it public in gossip/src/protocol.rs
?
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.
It is a legacy thing. I have commented in the ping_pong.rs file that the new code should only use [u8; 8]
. Old code was unnecessarily generic to allow different protocols specify different ping tokens.
I guess that could have been useful to distinguish types but with the new siphasher it no longer is applicable.
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.
debug_assert!(N >= std::mem::size_of::<u64>());
is this the only safeguard if someone accidentally defines N < 8? is it worth making sure someone can't define N < 8 for non debug builds?
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.
Yes, I have commented this out where struct Ping
is defined.
is it worth making sure someone can't define N < 8 for non debug builds?
how?
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.
could we just change that line to:
const_assert!(N >= std::mem::size_of::<u64>());
This would fail at compile time and wouldn't add runtime overhead.
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 that before, but const_assert
wouldn't work because N
is const generic parameter, and apparently static_assertions cannot handle it.
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.
ahh ok not ideal but ya not sure exactly how this could be enforced at compile time. and runtime check probably doesn't make sense. happy to stick with how you've documented the requirements for N
5cce98d
to
ee77f6b
Compare
yes, I have a node running on mainnet with this code and it looks fine. |
ee77f6b
to
2b22556
Compare
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.
lgtm!
@behzadnouri oh, it's interesting... I'll take a look at the frozen abi failure later. |
Thanks @ryoqun , |
Problem
More efficient ping tokens in gossip ping/pong protocol.
Summary of Changes
The commit uses
SipHasher24
for gossip ping tokens where keys are refreshed every 1 minute.