Skip to content

Commit

Permalink
fix: validator selection with multiple MEV chains configured (#952) (#…
Browse files Browse the repository at this point in the history
…954)

Co-authored-by: Christian Lohr <[email protected]>
  • Loading branch information
MechanicalTyler and byte-bandit authored Aug 21, 2023
1 parent d166b24 commit c293ecb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion x/evm/keeper/msg_assigner.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func filterAssignableValidators(validators []valsettypes.Validator, chainID stri
return slice.Filter(validators, func(val valsettypes.Validator) bool {
for _, v := range val.ExternalChainInfos {
if v.ChainReferenceID != chainID {
return false
continue
}

for _, t := range v.Traits {
Expand Down
42 changes: 42 additions & 0 deletions x/evm/keeper/msg_assigner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,48 @@ func TestFilterAssignableValidators(t *testing.T) {
requirements: &xchain.JobRequirements{EnforceMEVRelay: true},
chainID: chainID,
},
{
name: "with MEV set as requirement and multiple chains configured - REGRESSION",
expectedStr: "should return only validators with MEV trait",
validators: []valsettypes.Validator{
{
Address: sdk.ValAddress("validator-1"),
},
{
Address: sdk.ValAddress("validator-2"),
ExternalChainInfos: []*valsettypes.ExternalChainInfo{
{
ChainReferenceID: "other-chain",
Traits: []string{valsettypes.PIGEON_TRAIT_MEV},
},
{
ChainReferenceID: chainID,
Traits: []string{valsettypes.PIGEON_TRAIT_MEV},
},
},
},
{
Address: sdk.ValAddress("validator-3"),
},
},
expected: []valsettypes.Validator{
{
Address: sdk.ValAddress("validator-2"),
ExternalChainInfos: []*valsettypes.ExternalChainInfo{
{
ChainReferenceID: "other-chain",
Traits: []string{valsettypes.PIGEON_TRAIT_MEV},
},
{
ChainReferenceID: chainID,
Traits: []string{valsettypes.PIGEON_TRAIT_MEV},
},
},
},
},
requirements: &xchain.JobRequirements{EnforceMEVRelay: true},
chainID: chainID,
},
}

for k, v := range tests {
Expand Down

0 comments on commit c293ecb

Please sign in to comment.