merge self limiter
This commit is contained in:
commit
4d0b0f681d
73
Cargo.lock
generated
73
Cargo.lock
generated
@ -570,6 +570,7 @@ dependencies = [
|
|||||||
"eth1",
|
"eth1",
|
||||||
"eth2",
|
"eth2",
|
||||||
"eth2_hashing",
|
"eth2_hashing",
|
||||||
|
"eth2_network_config",
|
||||||
"eth2_ssz",
|
"eth2_ssz",
|
||||||
"eth2_ssz_derive",
|
"eth2_ssz_derive",
|
||||||
"eth2_ssz_types",
|
"eth2_ssz_types",
|
||||||
@ -581,6 +582,7 @@ dependencies = [
|
|||||||
"hex",
|
"hex",
|
||||||
"int_to_bytes",
|
"int_to_bytes",
|
||||||
"itertools",
|
"itertools",
|
||||||
|
"kzg",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"lighthouse_metrics",
|
"lighthouse_metrics",
|
||||||
"logging",
|
"logging",
|
||||||
@ -600,6 +602,8 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"slasher",
|
"slasher",
|
||||||
"slog",
|
"slog",
|
||||||
|
"slog-async",
|
||||||
|
"slog-term",
|
||||||
"sloggers",
|
"sloggers",
|
||||||
"slot_clock",
|
"slot_clock",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
@ -640,6 +644,7 @@ dependencies = [
|
|||||||
"node_test_rig",
|
"node_test_rig",
|
||||||
"sensitive_url",
|
"sensitive_url",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"slasher",
|
"slasher",
|
||||||
"slog",
|
"slog",
|
||||||
"store",
|
"store",
|
||||||
@ -896,6 +901,15 @@ dependencies = [
|
|||||||
"pkg-config",
|
"pkg-config",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "c-kzg"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/ethereum/c-kzg-4844?rev=69f6155d7524247be9d3f54ab3bfbe33a0345622#69f6155d7524247be9d3f54ab3bfbe33a0345622"
|
||||||
|
dependencies = [
|
||||||
|
"hex",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cached_tree_hash"
|
name = "cached_tree_hash"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@ -1829,7 +1843,7 @@ dependencies = [
|
|||||||
"enr",
|
"enr",
|
||||||
"fnv",
|
"fnv",
|
||||||
"futures",
|
"futures",
|
||||||
"hashlink",
|
"hashlink 0.7.0",
|
||||||
"hex",
|
"hex",
|
||||||
"hkdf",
|
"hkdf",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
@ -2205,6 +2219,8 @@ dependencies = [
|
|||||||
"enr",
|
"enr",
|
||||||
"eth2_config",
|
"eth2_config",
|
||||||
"eth2_ssz",
|
"eth2_ssz",
|
||||||
|
"kzg",
|
||||||
|
"serde_json",
|
||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"types",
|
"types",
|
||||||
@ -3048,6 +3064,15 @@ dependencies = [
|
|||||||
"hashbrown 0.11.2",
|
"hashbrown 0.11.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashlink"
|
||||||
|
version = "0.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa"
|
||||||
|
dependencies = [
|
||||||
|
"hashbrown 0.12.3",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "headers"
|
name = "headers"
|
||||||
version = "0.3.8"
|
version = "0.3.8"
|
||||||
@ -3710,6 +3735,23 @@ dependencies = [
|
|||||||
"tiny-keccak",
|
"tiny-keccak",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "kzg"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"arbitrary",
|
||||||
|
"c-kzg",
|
||||||
|
"derivative",
|
||||||
|
"eth2_hashing",
|
||||||
|
"eth2_serde_utils",
|
||||||
|
"eth2_ssz",
|
||||||
|
"eth2_ssz_derive",
|
||||||
|
"hex",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
"tree_hash",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
@ -3740,11 +3782,13 @@ dependencies = [
|
|||||||
"environment",
|
"environment",
|
||||||
"eth1_test_rig",
|
"eth1_test_rig",
|
||||||
"eth2",
|
"eth2",
|
||||||
|
"eth2_hashing",
|
||||||
"eth2_network_config",
|
"eth2_network_config",
|
||||||
"eth2_ssz",
|
"eth2_ssz",
|
||||||
"eth2_wallet",
|
"eth2_wallet",
|
||||||
"genesis",
|
"genesis",
|
||||||
"int_to_bytes",
|
"int_to_bytes",
|
||||||
|
"kzg",
|
||||||
"lighthouse_network",
|
"lighthouse_network",
|
||||||
"lighthouse_version",
|
"lighthouse_version",
|
||||||
"log",
|
"log",
|
||||||
@ -4309,9 +4353,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libsqlite3-sys"
|
name = "libsqlite3-sys"
|
||||||
version = "0.22.2"
|
version = "0.25.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "290b64917f8b0cb885d9de0f9959fe1f775d7fa12f1da2db9001c1c8ab60f89d"
|
checksum = "29f835d03d717946d28b1d1ed632eb6f0e24a299388ee623d0c23118d3e8a7fa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
@ -6058,9 +6102,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "r2d2_sqlite"
|
name = "r2d2_sqlite"
|
||||||
version = "0.18.0"
|
version = "0.21.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9d24607049214c5e42d3df53ac1d8a23c34cc6a5eefe3122acb2c72174719959"
|
checksum = "b4f5d0337e99cd5cacd91ffc326c6cc9d8078def459df560c4f9bf9ba4a51034"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"r2d2",
|
"r2d2",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
@ -6419,16 +6463,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rusqlite"
|
name = "rusqlite"
|
||||||
version = "0.25.4"
|
version = "0.28.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5c4b1eaf239b47034fb450ee9cdedd7d0226571689d8823030c4b6c2cb407152"
|
checksum = "01e213bc3ecb39ac32e81e51ebe31fd888a940515173e3a18a35f8c6e896422a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"fallible-iterator",
|
"fallible-iterator",
|
||||||
"fallible-streaming-iterator",
|
"fallible-streaming-iterator",
|
||||||
"hashlink",
|
"hashlink 0.8.1",
|
||||||
"libsqlite3-sys",
|
"libsqlite3-sys",
|
||||||
"memchr",
|
|
||||||
"smallvec",
|
"smallvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -6792,16 +6835,6 @@ dependencies = [
|
|||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde-big-array"
|
|
||||||
version = "0.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "18b20e7752957bbe9661cff4e0bb04d183d0948cdab2ea58cdb9df36a61dfe62"
|
|
||||||
dependencies = [
|
|
||||||
"serde",
|
|
||||||
"serde_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_array_query"
|
name = "serde_array_query"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@ -8295,6 +8328,7 @@ dependencies = [
|
|||||||
"hex",
|
"hex",
|
||||||
"int_to_bytes",
|
"int_to_bytes",
|
||||||
"itertools",
|
"itertools",
|
||||||
|
"kzg",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"maplit",
|
"maplit",
|
||||||
@ -8308,7 +8342,6 @@ dependencies = [
|
|||||||
"rusqlite",
|
"rusqlite",
|
||||||
"safe_arith",
|
"safe_arith",
|
||||||
"serde",
|
"serde",
|
||||||
"serde-big-array",
|
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_with",
|
"serde_with",
|
||||||
|
@ -68,6 +68,7 @@ pub struct OutboundRateLimiterConfig {
|
|||||||
pub(super) blocks_by_range_quota: Quota,
|
pub(super) blocks_by_range_quota: Quota,
|
||||||
pub(super) blocks_by_root_quota: Quota,
|
pub(super) blocks_by_root_quota: Quota,
|
||||||
pub(super) blobs_by_range_quota: Quota,
|
pub(super) blobs_by_range_quota: Quota,
|
||||||
|
pub(super) blobs_by_root_quota: Quota,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OutboundRateLimiterConfig {
|
impl OutboundRateLimiterConfig {
|
||||||
@ -80,6 +81,7 @@ impl OutboundRateLimiterConfig {
|
|||||||
pub const DEFAULT_BLOCKS_BY_ROOT_QUOTA: Quota = Quota::n_every(128, 10);
|
pub const DEFAULT_BLOCKS_BY_ROOT_QUOTA: Quota = Quota::n_every(128, 10);
|
||||||
pub const DEFAULT_BLOBS_BY_RANGE_QUOTA: Quota =
|
pub const DEFAULT_BLOBS_BY_RANGE_QUOTA: Quota =
|
||||||
Quota::n_every(methods::MAX_REQUEST_BLOBS_SIDECARS, 10);
|
Quota::n_every(methods::MAX_REQUEST_BLOBS_SIDECARS, 10);
|
||||||
|
pub const DEFAULT_BLOBS_BY_ROOT_QUOTA: Quota = Quota::n_every(128, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for OutboundRateLimiterConfig {
|
impl Default for OutboundRateLimiterConfig {
|
||||||
@ -92,6 +94,7 @@ impl Default for OutboundRateLimiterConfig {
|
|||||||
blocks_by_range_quota: Self::DEFAULT_BLOCKS_BY_RANGE_QUOTA,
|
blocks_by_range_quota: Self::DEFAULT_BLOCKS_BY_RANGE_QUOTA,
|
||||||
blocks_by_root_quota: Self::DEFAULT_BLOCKS_BY_ROOT_QUOTA,
|
blocks_by_root_quota: Self::DEFAULT_BLOCKS_BY_ROOT_QUOTA,
|
||||||
blobs_by_range_quota: Self::DEFAULT_BLOBS_BY_RANGE_QUOTA,
|
blobs_by_range_quota: Self::DEFAULT_BLOBS_BY_RANGE_QUOTA,
|
||||||
|
blobs_by_root_quota: Self::DEFAULT_BLOBS_BY_ROOT_QUOTA,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,6 +119,7 @@ impl Debug for OutboundRateLimiterConfig {
|
|||||||
.field("blocks_by_range", fmt_q!(&self.blocks_by_range_quota))
|
.field("blocks_by_range", fmt_q!(&self.blocks_by_range_quota))
|
||||||
.field("blocks_by_root", fmt_q!(&self.blocks_by_root_quota))
|
.field("blocks_by_root", fmt_q!(&self.blocks_by_root_quota))
|
||||||
.field("blobs_by_range", fmt_q!(&self.blobs_by_range_quota))
|
.field("blobs_by_range", fmt_q!(&self.blobs_by_range_quota))
|
||||||
|
.field("blobs_by_root", fmt_q!(&self.blobs_by_root_quota))
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,6 +139,7 @@ impl FromStr for OutboundRateLimiterConfig {
|
|||||||
let mut blocks_by_range_quota = None;
|
let mut blocks_by_range_quota = None;
|
||||||
let mut blocks_by_root_quota = None;
|
let mut blocks_by_root_quota = None;
|
||||||
let mut blobs_by_range_quota = None;
|
let mut blobs_by_range_quota = None;
|
||||||
|
let mut blobs_by_root_quota = None;
|
||||||
for proto_def in s.split(';') {
|
for proto_def in s.split(';') {
|
||||||
let ProtocolQuota { protocol, quota } = proto_def.parse()?;
|
let ProtocolQuota { protocol, quota } = proto_def.parse()?;
|
||||||
let quota = Some(quota);
|
let quota = Some(quota);
|
||||||
@ -143,9 +148,10 @@ impl FromStr for OutboundRateLimiterConfig {
|
|||||||
Protocol::Goodbye => goodbye_quota = goodbye_quota.or(quota),
|
Protocol::Goodbye => goodbye_quota = goodbye_quota.or(quota),
|
||||||
Protocol::BlocksByRange => blocks_by_range_quota = blocks_by_range_quota.or(quota),
|
Protocol::BlocksByRange => blocks_by_range_quota = blocks_by_range_quota.or(quota),
|
||||||
Protocol::BlocksByRoot => blocks_by_root_quota = blocks_by_root_quota.or(quota),
|
Protocol::BlocksByRoot => blocks_by_root_quota = blocks_by_root_quota.or(quota),
|
||||||
|
Protocol::BlobsByRange => blobs_by_range_quota = blobs_by_range_quota.or(quota),
|
||||||
|
Protocol::BlobsByRoot => blobs_by_root_quota = blobs_by_root_quota.or(quota),
|
||||||
Protocol::Ping => ping_quota = ping_quota.or(quota),
|
Protocol::Ping => ping_quota = ping_quota.or(quota),
|
||||||
Protocol::MetaData => meta_data_quota = meta_data_quota.or(quota),
|
Protocol::MetaData => meta_data_quota = meta_data_quota.or(quota),
|
||||||
Protocol::BlobsByRange => blobs_by_range_quota = blobs_by_range_quota.or(quota),
|
|
||||||
Protocol::LightClientBootstrap => return Err("Lighthouse does not send LightClientBootstrap requests. Quota should not be set."),
|
Protocol::LightClientBootstrap => return Err("Lighthouse does not send LightClientBootstrap requests. Quota should not be set."),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,6 +166,7 @@ impl FromStr for OutboundRateLimiterConfig {
|
|||||||
.unwrap_or(Self::DEFAULT_BLOCKS_BY_ROOT_QUOTA),
|
.unwrap_or(Self::DEFAULT_BLOCKS_BY_ROOT_QUOTA),
|
||||||
blobs_by_range_quota: blobs_by_range_quota
|
blobs_by_range_quota: blobs_by_range_quota
|
||||||
.unwrap_or(Self::DEFAULT_BLOBS_BY_RANGE_QUOTA),
|
.unwrap_or(Self::DEFAULT_BLOBS_BY_RANGE_QUOTA),
|
||||||
|
blobs_by_root_quota: blobs_by_root_quota.unwrap_or(Self::DEFAULT_BLOBS_BY_ROOT_QUOTA),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,8 +183,10 @@ pub enum Protocol {
|
|||||||
#[strum(serialize = "beacon_blocks_by_root")]
|
#[strum(serialize = "beacon_blocks_by_root")]
|
||||||
BlocksByRoot,
|
BlocksByRoot,
|
||||||
/// The `BlobsByRange` protocol name.
|
/// The `BlobsByRange` protocol name.
|
||||||
|
#[strum(serialize = "blobs_sidecars_by_range")]
|
||||||
BlobsByRange,
|
BlobsByRange,
|
||||||
/// The `BlobsByRoot` protocol name.
|
/// The `BlobsByRoot` protocol name.
|
||||||
|
#[strum(serialize = "beacon_block_and_blobs_sidecar_by_root")]
|
||||||
BlobsByRoot,
|
BlobsByRoot,
|
||||||
/// The `Ping` protocol name.
|
/// The `Ping` protocol name.
|
||||||
Ping,
|
Ping,
|
||||||
|
@ -61,6 +61,7 @@ impl<Id: ReqId, TSpec: EthSpec> SelfRateLimiter<Id, TSpec> {
|
|||||||
blocks_by_range_quota,
|
blocks_by_range_quota,
|
||||||
blocks_by_root_quota,
|
blocks_by_root_quota,
|
||||||
blobs_by_range_quota,
|
blobs_by_range_quota,
|
||||||
|
blobs_by_root_quota,
|
||||||
} = config;
|
} = config;
|
||||||
|
|
||||||
let limiter = RateLimiter::builder()
|
let limiter = RateLimiter::builder()
|
||||||
@ -71,6 +72,7 @@ impl<Id: ReqId, TSpec: EthSpec> SelfRateLimiter<Id, TSpec> {
|
|||||||
.set_quota(Protocol::BlocksByRange, blocks_by_range_quota)
|
.set_quota(Protocol::BlocksByRange, blocks_by_range_quota)
|
||||||
.set_quota(Protocol::BlocksByRoot, blocks_by_root_quota)
|
.set_quota(Protocol::BlocksByRoot, blocks_by_root_quota)
|
||||||
.set_quota(Protocol::BlobsByRange, blobs_by_range_quota)
|
.set_quota(Protocol::BlobsByRange, blobs_by_range_quota)
|
||||||
|
.set_quota(Protocol::BlobsByRoot, blobs_by_root_quota)
|
||||||
// Manually set the LightClientBootstrap quota, since we use the same rate limiter for
|
// Manually set the LightClientBootstrap quota, since we use the same rate limiter for
|
||||||
// inbound and outbound requests, and the LightClientBootstrap is an only inbound
|
// inbound and outbound requests, and the LightClientBootstrap is an only inbound
|
||||||
// protocol.
|
// protocol.
|
||||||
|
Loading…
Reference in New Issue
Block a user