Skip to content

chore(tests/load): C-chain load testing #3914

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

Merged
merged 238 commits into from
Jun 2, 2025
Merged

chore(tests/load): C-chain load testing #3914

merged 238 commits into from
Jun 2, 2025

Conversation

qdm12
Copy link
Contributor

@qdm12 qdm12 commented Apr 28, 2025

Why this should be merged

This PR adds a load test which can be used to test the C-Chain.

How this works

./scripts/run_task.sh test-load

Configuration of the load test can be found in ./tests/load/c/main/main.go

How this was tested

Need to be documented in RELEASES.md?

N/A

@qdm12 qdm12 force-pushed the qdm12/tests/load branch from 1f7fd9d to e2adf7b Compare April 30, 2025 08:23
@maru-ava
Copy link
Contributor

maru-ava commented May 30, 2025

Please rebase and add a new task running the test with the kube runtime. Would like to see the same job pass running in a local kube cluster as a precursor to running it on a remote cluster.

Scratch that, let's tackle separately.

@maru-ava maru-ava removed the request for review from StephenButtolph May 30, 2025 19:59
@maru-ava maru-ava moved this to Ready 🚦 in avalanchego May 30, 2025
@maru-ava maru-ava added the testing This primarily focuses on testing label May 30, 2025
Copy link
Contributor

@maru-ava maru-ava left a comment

Choose a reason for hiding this comment

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

Hooray!

@joshua-kim joshua-kim moved this from Ready 🚦 to In Progress 🏗️ in avalanchego Jun 2, 2025
Copy link
Contributor

@StephenButtolph StephenButtolph left a comment

Choose a reason for hiding this comment

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

All the comments under tests/load/c can be ignored. The code there is temporary.

address public owner;
mapping(uint256 => uint256) public data;

event ValueUpdated(uint256 newValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

This event is never used, is that intentional?

/// a constructor and simple functions to have a real-like deployed size.
contract Dummy {
uint256 public value;
address public owner;
Copy link
Contributor

Choose a reason for hiding this comment

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

owner is only used in the constructor, is this needed?

Comment on lines +285 to +286
maxFeeCap *big.Int
generateAndIssueTx func(txCtx context.Context, gasFeeCap *big.Int, nonce uint64) (*types.Transaction, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have maxFeeCap as a field on this struct just to pass it into the function defined in this struct? Shouldn't generateAndIssueTx just include this number directly?

return txType{}, errZeroTotalWeight
}

r := rand.UintN(totalWeight) //nolint:gosec
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than disabling gosec entirely, we should disable the specific error.

Suggested change
r := rand.UintN(totalWeight) //nolint:gosec
r := rand.UintN(totalWeight) //#nosec G404

if seed <= 0 {
return nil, errNonpositiveSeed
}
return big.NewInt(rand.Int64N(seed)), nil //nolint:gosec
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return big.NewInt(rand.Int64N(seed)), nil //nolint:gosec
return big.NewInt(rand.Int64N(seed)), nil //#nosec G404

return txType{}, errFailedToSelectTxType
}

func randomNum(seed int64) (*big.Int, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

seed is a pretty confusing name for this. This is actually maximum. That being said, the existence of this function just further complicates the code. All of the places that call this function call it with a constant maximum value (which is always > 0).

imo, we should just get rid of this function and replace:

val, err := randomNum(seed)
if err != nil {
    return err
}
...

with:

val := big.NewInt(rand.Int64N(seed))
...

Comment on lines +295 to +297
if totalWeight == 0 {
return txType{}, errZeroTotalWeight
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth a comment that this ensures that UintN won't panic.

{
name: "zero self transfer",
weight: 1000,
maxFeeCap: big.NewInt(4761904), // equiavelent to 100 ETH which is the maximum value
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like 100 * 1_000_000_000 / params.TxGas would have been more readable

@maru-ava maru-ava added this pull request to the merge queue Jun 2, 2025
Merged via the queue into master with commit 95ab59e Jun 2, 2025
28 checks passed
@maru-ava maru-ava deleted the qdm12/tests/load branch June 2, 2025 19:31
@github-project-automation github-project-automation bot moved this from In Progress 🏗️ to Done 🎉 in avalanchego Jun 2, 2025
samliok pushed a commit that referenced this pull request Jun 3, 2025
Signed-off-by: rodrigo <[email protected]>
Signed-off-by: Elvis <[email protected]>
Co-authored-by: Michael Kaplan <[email protected]>
Co-authored-by: Rodrigo Villar <[email protected]>
Co-authored-by: rodrigo <[email protected]>
Co-authored-by: Elvis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing This primarily focuses on testing
Projects
Status: Done 🎉
Development

Successfully merging this pull request may close these issues.

6 participants