Skip to content

Commit d78460b

Browse files
MitchTurnerxgreenx
andauthored
Add fork resilience for Leader Lock (#3210)
## Linked Issues/PRs Implements #3209 ## Description <!-- List of detailed changes --> ## Checklist - [ ] Breaking changes are clearly marked as such in the PR description and changelog - [ ] New behavior is reflected in tests - [ ] [The specification](https://github.com/FuelLabs/fuel-specs/) matches the implemented behavior (link update PR if changes are needed) ### Before requesting review - [ ] I have reviewed the code myself - [ ] I have created follow-up issues caused by this PR and linked them here ### After merging, notify other teams [Add or remove entries as needed] - [ ] [Rust SDK](https://github.com/FuelLabs/fuels-rs/) - [ ] [Sway compiler](https://github.com/FuelLabs/sway/) - [ ] [Platform documentation](https://github.com/FuelLabs/devrel-requests/issues/new?assignees=&labels=new+request&projects=&template=NEW-REQUEST.yml&title=%5BRequest%5D%3A+) (for out-of-organization contributors, the person merging the PR will do this) - [ ] Someone else? --------- Co-authored-by: Green Baneling <XgreenX9999@gmail.com>
1 parent ceeeed4 commit d78460b

45 files changed

Lines changed: 2349 additions & 506 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/audit.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ ignore = [
44
"RUSTSEC-2025-0009", # https://github.com/FuelLabs/fuel-core/issues/2814
55
"RUSTSEC-2025-0118", # handled in master
66
"RUSTSEC-2026-0006", # handled in master
7-
]
7+
"RUSTSEC-2026-0020", # wasmtime advisory, pending upgrade
8+
"RUSTSEC-2026-0021", # wasmtime advisory, pending upgrade
9+
]

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ jobs:
236236
run: cargo test -p fuel-core-tests --features aws-kms -- kms
237237

238238
leader-lock-integration-tests:
239-
name: Leader Lock Integration Tests (w/Redis)
239+
name: Leader Lock Tests (w/Redis)
240240
needs:
241241
- lint-toml-files
242242
- prevent-openssl
@@ -266,6 +266,7 @@ jobs:
266266
env | sort | grep -Ei 'REDIS|LEADER|LOCK|FUEL' || true
267267
(timeout 90s redis-cli MONITOR | stdbuf -oL grep -E 'SELECT|SET|PEXPIRE|DEL|leader|lock' || true) &
268268
cargo test --package fuel-core-tests --test integration_tests leader_lock --features leader_lock -- --test-threads=1 --nocapture
269+
cargo test --package fuel-core --lib service::adapters::consensus_module::poa::tests:: --features leader_lock -- --test-threads=1 --nocapture
269270
270271
verifications-complete:
271272
needs:

Cargo.toml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ version = "0.47.1"
5959

6060
# Common dependencies
6161
anyhow = "1.0"
62-
async-graphql = { version = "=7.0.15", features = [
63-
"graphiql",
64-
"tracing",
65-
], default-features = false }
62+
async-graphql = { version = "=7.0.15", features = ["graphiql", "tracing"], default-features = false }
6663
async-graphql-value = { version = "=7.0.15" }
6764
async-trait = "0.1"
6865

@@ -78,12 +75,7 @@ cynic = { version = "3.1.0", features = ["http-reqwest"] }
7875
derive_more = { version = "0.99" }
7976
ed25519 = { version = "2.2.3", default-features = false }
8077
ed25519-dalek = { version = "2.1.1", default-features = false }
81-
educe = { version = "0.6", default-features = false, features = [
82-
"Eq",
83-
"PartialEq",
84-
"Hash",
85-
"Debug",
86-
] }
78+
educe = { version = "0.6", default-features = false, features = ["Eq", "PartialEq", "Hash", "Debug"] }
8779
enum-iterator = "1.2"
8880
enum_dispatch = "0.3.13"
8981
# Workspace members
@@ -143,10 +135,7 @@ proptest = "1.1"
143135
rand = "0.8"
144136
rayon = "1.10.0"
145137
# enable cookie store to support L7 sticky sessions
146-
reqwest = { version = "0.12.0", default-features = false, features = [
147-
"rustls-tls",
148-
"cookies",
149-
] }
138+
reqwest = { version = "0.12.0", default-features = false, features = ["rustls-tls", "cookies"] }
150139
serde = "1.0"
151140
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
152141
serde_with = { version = "3.4", default-features = false }

benches/Cargo.toml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,24 @@ fault-proving = [
2121
anyhow = { workspace = true }
2222
async-trait = { workspace = true }
2323
clap = { workspace = true, features = ["derive"] }
24-
criterion = { version = "0.5", features = [
25-
"html_reports",
26-
"async",
27-
"async_tokio",
28-
] }
24+
criterion = { version = "0.5", features = ["html_reports", "async", "async_tokio"] }
2925
ctrlc = "3.2.3"
3026
ed25519-dalek = { workspace = true, features = ["rand_core"] }
3127
enum-iterator = { workspace = true }
3228
ethnum = "1.3"
33-
fuel-core = { path = "../crates/fuel-core", default-features = false, features = [
34-
"rocksdb-production",
35-
] }
29+
fuel-core = { path = "../crates/fuel-core", default-features = false, features = ["rocksdb-production"] }
3630
fuel-core-chain-config = { workspace = true }
3731
fuel-core-database = { path = "./../crates/database" }
3832
fuel-core-services = { path = "./../crates/services" }
3933
fuel-core-storage = { path = "./../crates/storage" }
40-
fuel-core-sync = { path = "./../crates/services/sync", features = [
41-
"benchmarking",
42-
] }
34+
fuel-core-sync = { path = "./../crates/services/sync", features = ["benchmarking"] }
4335
fuel-core-trace = { path = "./../crates/trace" }
4436
fuel-core-types = { path = "./../crates/types", features = ["test-helpers"] }
4537
futures = { workspace = true }
4638
hex = "0.4.3"
4739
itertools = { workspace = true }
4840
num_enum = { workspace = true }
49-
p256 = { version = "0.13", default-features = false, features = [
50-
"digest",
51-
"ecdsa",
52-
] }
41+
p256 = { version = "0.13", default-features = false, features = ["digest", "ecdsa"] }
5342
postcard = { workspace = true }
5443
primitive-types = { workspace = true, default-features = false }
5544
quanta = "0.12"

bin/e2e-test-client/Cargo.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,7 @@ toml = { version = "0.5" }
3535

3636
[dev-dependencies]
3737
assert_cmd = "2.0"
38-
fuel-core = { workspace = true, features = [
39-
"rocksdb",
40-
"wasm-executor",
41-
"p2p",
42-
"test-helpers",
43-
] }
38+
fuel-core = { workspace = true, features = ["rocksdb", "wasm-executor", "p2p", "test-helpers"] }
4439
fuel-core-trace = { path = "../../crates/trace" }
4540
insta = { workspace = true }
4641
tempfile = { workspace = true }

bin/fuel-core/Cargo.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ fault-proving = [
4646

4747
[dependencies]
4848
anyhow = { workspace = true }
49-
aws-config = { workspace = true, features = [
50-
"behavior-version-latest",
51-
], optional = true }
49+
aws-config = { workspace = true, features = ["behavior-version-latest"], optional = true }
5250
aws-sdk-kms = { workspace = true, optional = true }
5351
clap = { workspace = true, features = ["derive", "env", "string"] }
5452
const_format = { version = "0.2", optional = true }
@@ -69,11 +67,7 @@ serde_json = { workspace = true }
6967
tikv-jemallocator = { workspace = true }
7068
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
7169
tracing = { workspace = true }
72-
tracing-subscriber = { workspace = true, features = [
73-
"ansi",
74-
"env-filter",
75-
"json",
76-
] }
70+
tracing-subscriber = { workspace = true, features = ["ansi", "env-filter", "json"] }
7771
url = { workspace = true, optional = true }
7872

7973
[dev-dependencies]

bin/fuel-core/src/cli/run/consensus.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ impl PoATriggerArgs {
3535
retry_delay,
3636
max_retry_delay_offset,
3737
max_attempts,
38+
stream_max_len,
3839
} = self.leader_lock.clone();
3940
if enabled {
4041
Ok(Some(RedisLeaderLockConfig {
@@ -49,6 +50,7 @@ impl PoATriggerArgs {
4950
retry_delay: retry_delay.into(),
5051
max_retry_delay_offset: max_retry_delay_offset.into(),
5152
max_attempts,
53+
stream_max_len,
5254
}))
5355
} else {
5456
Ok(None)
@@ -159,6 +161,9 @@ struct LeaderLock {
159161
/// Maximum number of acquire attempts per can_produce_block call.
160162
#[clap(long = "poa-leader-lock-max-attempts", env, default_value_t = 3)]
161163
max_attempts: u32,
164+
/// Maximum approximate number of entries retained in the Redis block stream.
165+
#[clap(long = "poa-leader-lock-stream-max-len", env, default_value_t = 1000)]
166+
stream_max_len: u32,
162167
}
163168

164169
#[cfg(test)]
@@ -224,6 +229,7 @@ mod tests {
224229
StdDuration::from_millis(100)
225230
);
226231
assert_eq!(leader_lock.max_attempts, 3);
232+
assert_eq!(leader_lock.stream_max_len, 1000);
227233
}
228234

229235
#[test]

crates/chain-config/Cargo.toml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ anyhow = { workspace = true }
3737
bech32 = { version = "0.9.0", default-features = false, optional = true }
3838
educe = { workspace = true }
3939
fuel-core-storage = { workspace = true, features = ["alloc"] }
40-
fuel-core-types = { workspace = true, default-features = false, features = [
41-
"alloc",
42-
"serde",
43-
] }
40+
fuel-core-types = { workspace = true, default-features = false, features = ["alloc", "serde"] }
4441
itertools = { workspace = true, features = ["use_alloc"] }
4542
parquet = { workspace = true, features = ["zstd"], optional = true }
4643
postcard = { workspace = true, features = ["alloc"] }
@@ -53,11 +50,7 @@ tracing = { version = "0.1", default-features = false, optional = true }
5350
[dev-dependencies]
5451
bytes = { workspace = true }
5552
fuel-core-chain-config = { path = ".", features = ["parquet", "test-helpers"] }
56-
fuel-core-types = { workspace = true, default-features = false, features = [
57-
"alloc",
58-
"random",
59-
"serde",
60-
] }
53+
fuel-core-types = { workspace = true, default-features = false, features = ["alloc", "random", "serde"] }
6154
insta = { workspace = true }
6255
pretty_assertions = { workspace = true }
6356
rand = { workspace = true }

crates/client/Cargo.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ fuel-core-types = { workspace = true, features = ["alloc", "serde"] }
3535
futures = { workspace = true, optional = true }
3636
hex = { workspace = true }
3737
# Included to enable webpki in the eventsource client
38-
hyper-rustls = { version = "0.24", features = [
39-
"webpki-tokio",
40-
], optional = true }
38+
hyper-rustls = { version = "0.24", features = ["webpki-tokio"], optional = true }
4139
itertools = { workspace = true }
4240
postcard = { workspace = true, optional = true }
4341
reqwest = { workspace = true }
@@ -53,9 +51,5 @@ schemafy_lib = { version = "0.5" }
5351
serde_json = { version = "1.0", features = ["raw_value"] }
5452

5553
[dev-dependencies]
56-
fuel-core-types = { workspace = true, features = [
57-
"serde",
58-
"std",
59-
"test-helpers",
60-
] }
54+
fuel-core-types = { workspace = true, features = ["serde", "std", "test-helpers"] }
6155
insta = { workspace = true }

crates/compression/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ fault-proving = ["fuel-core-types/fault-proving"]
2929
[dependencies]
3030
anyhow = { workspace = true }
3131
enum_dispatch = { workspace = true }
32-
fuel-core-types = { workspace = true, features = [
33-
"alloc",
34-
"serde",
35-
"da-compression",
36-
] }
32+
fuel-core-types = { workspace = true, features = ["alloc", "serde", "da-compression"] }
3733
paste = { workspace = true }
3834
rand = { workspace = true, optional = true }
3935
serde = { version = "1.0", features = ["derive"] }

0 commit comments

Comments
 (0)