Skip to content

Commit

Permalink
feat: MAD Precompile fuzzing (#858)
Browse files Browse the repository at this point in the history
* feat: MAD Precompile fuzzing

* fix: int underflow in the precompile for asset ids

* lint: fix toml indent spacing
  • Loading branch information
shekohex authored Dec 27, 2024
1 parent b1b0084 commit 5dc9766
Show file tree
Hide file tree
Showing 9 changed files with 749 additions and 74 deletions.
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ members = [
"precompiles/verify-schnorr-signatures",
"precompiles/verify-bls381-signature",
"precompiles/multi-asset-delegation",
"precompiles/multi-asset-delegation/fuzzer",
"precompiles/services",
"precompiles/tangle-lst",
"precompiles/assets",
Expand Down Expand Up @@ -271,17 +272,17 @@ fc-api = { git = "https://github.com/paritytech/frontier.git", branch = "stable2

# Frontier Primitive
fp-account = { git = "https://github.com/paritytech/frontier.git", branch = "stable2407", default-features = false, features = [
"serde",
"serde",
] }
fp-consensus = { git = "https://github.com/paritytech/frontier.git", branch = "stable2407", default-features = false }
fp-dynamic-fee = { git = "https://github.com/paritytech/frontier.git", branch = "stable2407", default-features = false }
fp-ethereum = { git = "https://github.com/paritytech/frontier.git", branch = "stable2407", default-features = false }
fp-evm = { git = "https://github.com/paritytech/frontier.git", branch = "stable2407", default-features = false, features = [
"serde",
"serde",
] }
fp-rpc = { git = "https://github.com/paritytech/frontier.git", branch = "stable2407", default-features = false }
fp-self-contained = { git = "https://github.com/paritytech/frontier.git", branch = "stable2407", default-features = false, features = [
"serde",
"serde",
] }
fp-storage = { git = "https://github.com/paritytech/frontier.git", branch = "stable2407", default-features = false }

Expand Down
186 changes: 132 additions & 54 deletions precompiles/multi-asset-delegation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ edition = "2021"
description = "A Precompile to make pallet-multi-asset-delegation calls encoding accessible to pallet-evm"

[dependencies]


precompile-utils = { workspace = true }

# Substrate
Expand All @@ -26,6 +24,46 @@ pallet-evm = { workspace = true, features = ["forbid-evm-reentrancy"] }

tangle-primitives = { workspace = true }

derive_more = { workspace = true, features = ["full"], optional = true }
hex-literal = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
sha3 = { workspace = true, optional = true }
ethereum = { workspace = true, features = ["with-codec"], optional = true }
ethers = { version = "2.0", optional = true }
hex = { workspace = true, optional = true }
num_enum = { workspace = true, optional = true }
libsecp256k1 = { workspace = true, optional = true }
serde_json = { workspace = true, optional = true }
smallvec = { workspace = true, optional = true }
sp-keystore = { workspace = true, optional = true }
pallet-assets = { workspace = true, features = ["std"], optional = true }
pallet-timestamp = { workspace = true, features = ["std"], optional = true }
scale-info = { workspace = true, features = ["derive", "std"], optional = true }
sp-io = { workspace = true, features = ["std"], optional = true }
fp-account = { workspace = true, optional = true }
fp-consensus = { workspace = true, optional = true }
fp-dynamic-fee = { workspace = true, optional = true }
fp-ethereum = { workspace = true, optional = true }
fp-rpc = { workspace = true, optional = true }
fp-self-contained = { workspace = true, optional = true }
fp-storage = { workspace = true, optional = true }
pallet-base-fee = { workspace = true, optional = true }
pallet-dynamic-fee = { workspace = true, optional = true }
pallet-ethereum = { workspace = true, optional = true }
pallet-evm-chain-id = { workspace = true, optional = true }
pallet-evm-precompile-blake2 = { workspace = true, optional = true }
pallet-evm-precompile-bn128 = { workspace = true, optional = true }
pallet-evm-precompile-curve25519 = { workspace = true, optional = true }
pallet-evm-precompile-ed25519 = { workspace = true, optional = true }
pallet-evm-precompile-modexp = { workspace = true, optional = true }
pallet-evm-precompile-sha3fips = { workspace = true, optional = true }
pallet-evm-precompile-simple = { workspace = true, optional = true }
pallet-session = { workspace = true, optional = true }
pallet-staking = { workspace = true, optional = true }
sp-staking = { workspace = true, optional = true }
frame-election-provider-support = { workspace = true, optional = true }
ethabi = { workspace = true, optional = true }

[dev-dependencies]
derive_more = { workspace = true, features = ["full"] }
hex-literal = { workspace = true }
Expand Down Expand Up @@ -83,56 +121,96 @@ ethabi = { workspace = true }

[features]
default = ["std"]
fuzzing = [
"derive_more",
"hex-literal",
"serde",
"sha3",
"ethereum",
"ethers",
"hex",
"num_enum",
"libsecp256k1",
"serde_json",
"smallvec",
"sp-keystore",
"pallet-assets",
"pallet-timestamp",
"scale-info",
"sp-io",
"fp-account",
"fp-consensus",
"fp-dynamic-fee",
"fp-ethereum",
"fp-rpc",
"fp-self-contained",
"fp-storage",
"pallet-base-fee",
"pallet-dynamic-fee",
"pallet-ethereum",
"pallet-evm-chain-id",
"pallet-evm-precompile-blake2",
"pallet-evm-precompile-bn128",
"pallet-evm-precompile-curve25519",
"pallet-evm-precompile-ed25519",
"pallet-evm-precompile-modexp",
"pallet-evm-precompile-sha3fips",
"pallet-evm-precompile-simple",
"pallet-session",
"pallet-staking",
"sp-staking",
"frame-election-provider-support",
"ethabi",
]
std = [
"fp-evm/std",
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"pallet-evm/std",
"pallet-multi-asset-delegation/std",
"parity-scale-codec/std",
"precompile-utils/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
"tangle-primitives/std",
"pallet-assets/std",
"hex/std",
"scale-info/std",
"sp-runtime/std",
"frame-support/std",
"frame-system/std",
"sp-core/std",
"sp-std/std",
"sp-io/std",
"tangle-primitives/std",
"pallet-balances/std",
"pallet-timestamp/std",
"fp-account/std",
"fp-consensus/std",
"fp-dynamic-fee/std",
"fp-ethereum/std",
"fp-evm/std",
"fp-rpc/std",
"fp-self-contained/std",
"fp-storage/std",
"pallet-base-fee/std",
"pallet-dynamic-fee/std",
"pallet-ethereum/std",
"pallet-evm/std",
"pallet-evm-chain-id/std",

"pallet-evm-precompile-modexp/std",
"pallet-evm-precompile-sha3fips/std",
"pallet-evm-precompile-simple/std",
"pallet-evm-precompile-blake2/std",
"pallet-evm-precompile-bn128/std",
"pallet-evm-precompile-curve25519/std",
"pallet-evm-precompile-ed25519/std",
"precompile-utils/std",
"serde/std",
"pallet-session/std",
"pallet-staking/std",
"sp-staking/std",
"frame-election-provider-support/std",
]
"fp-evm/std",
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"pallet-evm/std",
"pallet-multi-asset-delegation/std",
"parity-scale-codec/std",
"precompile-utils/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
"tangle-primitives/std",
"pallet-assets/std",
"hex/std",
"scale-info/std",
"sp-runtime/std",
"frame-support/std",
"frame-system/std",
"sp-core/std",
"sp-std/std",
"sp-io/std",
"tangle-primitives/std",
"pallet-balances/std",
"pallet-timestamp/std",
"fp-account/std",
"fp-consensus/std",
"fp-dynamic-fee/std",
"fp-ethereum/std",
"fp-evm/std",
"fp-rpc/std",
"fp-self-contained/std",
"fp-storage/std",
"pallet-base-fee/std",
"pallet-dynamic-fee/std",
"pallet-ethereum/std",
"pallet-evm/std",
"pallet-evm-chain-id/std",
"pallet-evm-precompile-modexp/std",
"pallet-evm-precompile-sha3fips/std",
"pallet-evm-precompile-simple/std",
"pallet-evm-precompile-blake2/std",
"pallet-evm-precompile-bn128/std",
"pallet-evm-precompile-curve25519/std",
"pallet-evm-precompile-ed25519/std",
"precompile-utils/std",
"serde/std",
"pallet-session/std",
"pallet-staking/std",
"sp-staking/std",
"frame-election-provider-support/std",
]
38 changes: 38 additions & 0 deletions precompiles/multi-asset-delegation/fuzzer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "pallet-evm-precompile-multi-asset-delegation-fuzzer"
version = "2.0.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "Fuzzer for pallet-multi-asset-delegation precompile"
publish = false

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
honggfuzz = { workspace = true }


pallet-multi-asset-delegation = { workspace = true, features = ["fuzzing"], default-features = true }
pallet-evm-precompile-multi-asset-delegation = { features = ["fuzzing"], workspace = true, default-features = true }

frame-system = { workspace = true, default-features = true }
frame-support = { workspace = true, default-features = true }

fp-evm = { workspace = true }
precompile-utils = { workspace = true, features = ["std", "testing"] }
pallet-evm = { workspace = true, features = ["forbid-evm-reentrancy"] }

sp-runtime = { workspace = true, default-features = true }
sp-io = { workspace = true, default-features = true }
sp-tracing = { workspace = true, default-features = true }

rand = { features = ["small_rng"], workspace = true, default-features = true }
log = { workspace = true, default-features = true }

[[bin]]
name = "mad-precompile-fuzzer"
path = "call.rs"
Loading

0 comments on commit 5dc9766

Please sign in to comment.