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

Authenticator Fuzzer #14869

Merged
merged 9 commits into from
Oct 11, 2024
Merged

Authenticator Fuzzer #14869

merged 9 commits into from
Oct 11, 2024

Conversation

zi0Black
Copy link
Contributor

@zi0Black zi0Black commented Oct 4, 2024

Description

An early stage fuzzer for Authenticators. This PR exists only to push it on OSS-Fuzz, while working on the other strategies and refactoring the code.
Brought back coverage report generation in fuzz.sh.

New:

  • aptosvm_authenticators.rs
  • ./fuzz.sh coverage
  • Arbitrary implementations for custom types

How Has This Been Tested?

Local build and runs.

Key Areas to Review

N/A

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Move Compiler
  • Other (specify)

Checklist

  • I have read and followed the CONTRIBUTING doc
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I identified and added all stakeholders and component owners affected by this change as reviewers
  • I tested both happy and unhappy path of the functionality
  • I have made corresponding changes to the documentation

Copy link

trunk-io bot commented Oct 4, 2024

⏱️ 3h 27m total CI duration on this PR
Slowest 15 Jobs Cumulative Duration Recent Runs
execution-performance / single-node-performance 25m 🟩
dispatch_event 16m 🟩
dispatch_event 16m 🟩
dispatch_event 15m 🟩
dispatch_event 15m 🟩
rust-cargo-deny 13m 🟩🟩🟩🟩🟩 (+2 more)
check-dynamic-deps 11m 🟩🟩🟩🟩🟩 (+2 more)
rust-move-tests 10m 🟩
rust-move-tests 10m 🟩
rust-move-tests 10m 🟩
rust-move-tests 10m 🟩
rust-move-tests 10m 🟩
rust-move-tests 10m 🟩
execution-performance / test-target-determinator 6m 🟩
rust-move-tests 6m

🚨 2 jobs on the last run were significantly faster/slower than expected

Job Duration vs 7d avg Delta
execution-performance / single-node-performance 25m 16m +56%
execution-performance / test-target-determinator 6m 4m +45%

settingsfeedbackdocs ⋅ learn more about trunk.io

@zi0Black zi0Black marked this pull request as ready for review October 4, 2024 09:57
testsuite/fuzzer/fuzz.sh Outdated Show resolved Hide resolved
Co-authored-by: Gerardo Di Giacomo <gerardo@aptoslabs.com>
@@ -38,6 +38,15 @@ impl Clone for Ed25519PrivateKey {
#[derive(DeserializeKey, Clone, SerializeKey)]
pub struct Ed25519PublicKey(pub(crate) ed25519_dalek::PublicKey);

#[cfg(any(test, feature = "fuzzing"))]
Copy link
Contributor

@alinush alinush Oct 8, 2024

Choose a reason for hiding this comment

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

So this just picks uniform random bytes, right?

If so, this will not be a valid PK.

The Q is: do you want it to be?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I should either move to a custom implementation of arbitrary or get rid of it. It comes in handy for starting a really dumb fuzzer without having to recreate too many types.

@@ -18,6 +18,15 @@ use std::{cmp::Ordering, fmt};
#[derive(DeserializeKey, Clone, SerializeKey)]
pub struct Ed25519Signature(pub(crate) ed25519_dalek::Signature);

#[cfg(any(test, feature = "fuzzing"))]
impl<'a> arbitrary::Arbitrary<'a> for Ed25519Signature {
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same point here as for the PK.

It's even trickier here because a "valid" signature is defined w.r.t. to a PK and a message, so you cannot even sample it randomly without having those.

FuzzerTransactionAuthenticator::Keyless {
sender: _,
style,
any_keyless_public_key,
Copy link
Contributor

Choose a reason for hiding this comment

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

How is this sampled? Via the Arbitrary trait?

How do you plan on sampling keyless public keys and signatures that are at least partially-valid (e.g., the EphemeralCertificate in the KeylessSignature verifies under the KeylessPublicKey?)

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess you will modify them appropriately inside your match style cases, as needed for that fuzzing strategy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I can override within the match what I want done in a specific way.

echo " add adds a new fuzz target"
echo " build builds fuzz targets"
echo " build-oss-fuzz builds fuzz targets for oss-fuzz"
echo " coverage generates coverage for a fuzz target"
Copy link
Contributor

Choose a reason for hiding this comment

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

clean-coverage missing?

)
.set_not_parallel();

let sender_acc = if true {
Copy link
Contributor

Choose a reason for hiding this comment

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

is the if statement needed?

@zi0Black zi0Black enabled auto-merge (squash) October 10, 2024 15:07

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

✅ Forge suite realistic_env_max_load success on cbe5413246f81ab0053e2df37ba8d46a1676892b

two traffics test: inner traffic : committed: 13750.65 txn/s, latency: 2890.99 ms, (p50: 2700 ms, p70: 3000, p90: 3000 ms, p99: 3600 ms), latency samples: 5228340
two traffics test : committed: 100.08 txn/s, latency: 2386.44 ms, (p50: 2400 ms, p70: 2500, p90: 2700 ms, p99: 3000 ms), latency samples: 1840
Latency breakdown for phase 0: ["QsBatchToPos: max: 0.246, avg: 0.219", "QsPosToProposal: max: 0.326, avg: 0.271", "ConsensusProposalToOrdered: max: 0.320, avg: 0.299", "ConsensusOrderedToCommit: max: 0.494, avg: 0.469", "ConsensusProposalToCommit: max: 0.794, avg: 0.768"]
Max non-epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.72s no progress at version 2511504 (avg 0.21s) [limit 15].
Max epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 8.39s no progress at version 2511502 (avg 8.39s) [limit 15].
Test Ok

Copy link
Contributor

✅ Forge suite framework_upgrade success on beff51858b445401e49d5be352feadcf05652cc0 ==> cbe5413246f81ab0053e2df37ba8d46a1676892b

Compatibility test results for beff51858b445401e49d5be352feadcf05652cc0 ==> cbe5413246f81ab0053e2df37ba8d46a1676892b (PR)
Upgrade the nodes to version: cbe5413246f81ab0053e2df37ba8d46a1676892b
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1250.81 txn/s, submitted: 1253.57 txn/s, failed submission: 2.76 txn/s, expired: 2.76 txn/s, latency: 2560.89 ms, (p50: 2100 ms, p70: 2600, p90: 4500 ms, p99: 6000 ms), latency samples: 108780
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1220.16 txn/s, submitted: 1222.60 txn/s, failed submission: 2.43 txn/s, expired: 2.43 txn/s, latency: 2664.59 ms, (p50: 2100 ms, p70: 2900, p90: 4500 ms, p99: 7200 ms), latency samples: 100220
5. check swarm health
Compatibility test for beff51858b445401e49d5be352feadcf05652cc0 ==> cbe5413246f81ab0053e2df37ba8d46a1676892b passed
Upgrade the remaining nodes to version: cbe5413246f81ab0053e2df37ba8d46a1676892b
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1290.05 txn/s, submitted: 1292.42 txn/s, failed submission: 2.37 txn/s, expired: 2.37 txn/s, latency: 2629.05 ms, (p50: 2400 ms, p70: 2700, p90: 4500 ms, p99: 6000 ms), latency samples: 108940
Test Ok

Copy link
Contributor

✅ Forge suite compat success on beff51858b445401e49d5be352feadcf05652cc0 ==> cbe5413246f81ab0053e2df37ba8d46a1676892b

Compatibility test results for beff51858b445401e49d5be352feadcf05652cc0 ==> cbe5413246f81ab0053e2df37ba8d46a1676892b (PR)
1. Check liveness of validators at old version: beff51858b445401e49d5be352feadcf05652cc0
compatibility::simple-validator-upgrade::liveness-check : committed: 11820.14 txn/s, latency: 2872.69 ms, (p50: 1900 ms, p70: 2100, p90: 3100 ms, p99: 27200 ms), latency samples: 452340
2. Upgrading first Validator to new version: cbe5413246f81ab0053e2df37ba8d46a1676892b
compatibility::simple-validator-upgrade::single-validator-upgrading : committed: 5834.23 txn/s, latency: 4917.77 ms, (p50: 5500 ms, p70: 5800, p90: 6300 ms, p99: 6400 ms), latency samples: 112540
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 5433.92 txn/s, latency: 5979.05 ms, (p50: 6400 ms, p70: 6600, p90: 6900 ms, p99: 8000 ms), latency samples: 179440
3. Upgrading rest of first batch to new version: cbe5413246f81ab0053e2df37ba8d46a1676892b
compatibility::simple-validator-upgrade::half-validator-upgrading : committed: 7462.08 txn/s, latency: 3875.64 ms, (p50: 4300 ms, p70: 4500, p90: 4700 ms, p99: 4700 ms), latency samples: 143380
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 6670.52 txn/s, latency: 4824.35 ms, (p50: 4800 ms, p70: 4900, p90: 7000 ms, p99: 7200 ms), latency samples: 233840
4. upgrading second batch to new version: cbe5413246f81ab0053e2df37ba8d46a1676892b
compatibility::simple-validator-upgrade::rest-validator-upgrading : committed: 10639.43 txn/s, latency: 2559.91 ms, (p50: 2800 ms, p70: 3000, p90: 3100 ms, p99: 3200 ms), latency samples: 187580
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 9522.98 txn/s, latency: 3256.88 ms, (p50: 2900 ms, p70: 3000, p90: 5900 ms, p99: 7500 ms), latency samples: 326560
5. check swarm health
Compatibility test for beff51858b445401e49d5be352feadcf05652cc0 ==> cbe5413246f81ab0053e2df37ba8d46a1676892b passed
Test Ok

@zi0Black zi0Black merged commit a6ad9d3 into main Oct 11, 2024
49 checks passed
@zi0Black zi0Black deleted the authenticator-hell-of-types-fuzz branch October 11, 2024 14:23
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.

3 participants