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

[TrafficControl] Scale spam sample weight by request size #21373

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

williampsmith
Copy link
Contributor

Description

Describe the changes or additions included in this PR.

Test plan

How did you test the new or updated feature?


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:

Copy link

vercel bot commented Feb 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 28, 2025 1:31am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Feb 28, 2025 1:31am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Feb 28, 2025 1:31am

async move {
if let Some(traffic_controller) = traffic_controller {
let client = req.extensions().get::<IpAddr>().cloned();
if let Err(response) = handle_traffic_req(&traffic_controller, &client).await {
response
} else {
// Scale the weight based on the request size
let spam_weight = if policy_config.unwrap().weight_spam_by_request_size {
println!("TESTING -- weighting spam by request size");
Copy link
Contributor

Choose a reason for hiding this comment

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

don't want to merge this i assume

let params_count = req.params.as_ref().and_then(|p| {
let raw_value = p.get();
let params: Option<Vec<serde_json::Value>> =
serde_json::from_str(raw_value).ok();
Copy link
Contributor

Choose a reason for hiding this comment

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

this won't handle nested params, right? I no it is a bit more fragile and has a lot of boilerplate but i wonder if the request handler needs to explicitly determine a param count?

) {
println!("TESTING -- spam_weight: {:?}", spam_weight);
Copy link
Contributor

Choose a reason for hiding this comment

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

debugging code

@mystenmark
Copy link
Contributor

oh sorry i didn't notice this was a draft. ignore my comments for now

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.

2 participants