Skip to content

feat(Vm): add deterministic shuffling vm.shuffle(salt) #10664

Open
@0xClandestine

Description

@0xClandestine

Component

Forge

Describe the feature you would like

Thanks again for adding vm.sort() and vm.shuffle()!

One use case that’s come up frequently: I often work with two corresponding arrays (like strategies[i] and balances[i]) and need to shuffle them in sync to maintain their index alignment. Currently, there’s no built-in way to ensure two shuffles apply the same permutation.

It would be incredibly useful if vm.shuffle() accepted an optional salt parameter for deterministic shuffling. That way, we could do something like:

uint256 salt = vm.randomUint();
vm.shuffle(strategies, salt);
vm.shuffle(balances, salt);

This would make it much easier to preserve relationships across parallel arrays during randomized testing.

Additional context

#10171

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions