-
Notifications
You must be signed in to change notification settings - Fork 138
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
chore: Add integration for equivocation with CometMock #1192
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1604,18 +1604,7 @@ func (tr TestRun) setValidatorDowntime(chain chainID, validator validatorID, dow | |
|
||
if tr.useCometmock { | ||
// send set_signing_status either to down or up for validator | ||
var validatorAddress string | ||
if chain == chainID("provi") { | ||
validatorAddress = tr.getValidatorKeyAddressFromString(tr.validatorConfigs[validator].privValidatorKey) | ||
} else { | ||
var valAddressString string | ||
if tr.validatorConfigs[validator].useConsumerKey { | ||
valAddressString = tr.validatorConfigs[validator].consumerPrivValidatorKey | ||
} else { | ||
valAddressString = tr.validatorConfigs[validator].privValidatorKey | ||
} | ||
validatorAddress = tr.getValidatorKeyAddressFromString(valAddressString) | ||
} | ||
validatorAddress := tr.GetValidatorAddress(chain, validator) | ||
|
||
method := "set_signing_status" | ||
params := fmt.Sprintf(`{"private_key_address":"%s","status":"%s"}`, validatorAddress, lastArg) | ||
|
@@ -1648,6 +1637,22 @@ func (tr TestRun) setValidatorDowntime(chain chainID, validator validatorID, dow | |
} | ||
} | ||
|
||
func (tr TestRun) GetValidatorAddress(chain chainID, validator validatorID) string { | ||
var validatorAddress string | ||
if chain == chainID("provi") { | ||
validatorAddress = tr.getValidatorKeyAddressFromString(tr.validatorConfigs[validator].privValidatorKey) | ||
} else { | ||
var valAddressString string | ||
if tr.validatorConfigs[validator].useConsumerKey { | ||
valAddressString = tr.validatorConfigs[validator].consumerPrivValidatorKey | ||
} else { | ||
valAddressString = tr.validatorConfigs[validator].privValidatorKey | ||
} | ||
validatorAddress = tr.getValidatorKeyAddressFromString(valAddressString) | ||
} | ||
return validatorAddress | ||
} | ||
|
||
type unjailValidatorAction struct { | ||
provider chainID | ||
validator validatorID | ||
|
@@ -1795,15 +1800,28 @@ func (tr TestRun) invokeDoublesignSlash( | |
action doublesignSlashAction, | ||
verbose bool, | ||
) { | ||
chainConfig := tr.chainConfigs[action.chain] | ||
//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. | ||
bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, "/bin/bash", | ||
"/testnet-scripts/cause-doublesign.sh", chainConfig.binaryName, string(action.validator), | ||
string(chainConfig.chainId), chainConfig.ipPrefix).CombinedOutput() | ||
if err != nil { | ||
log.Fatal(err, "\n", string(bz)) | ||
if !tr.useCometmock { | ||
chainConfig := tr.chainConfigs[action.chain] | ||
//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. | ||
bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, "/bin/bash", | ||
"/testnet-scripts/cause-doublesign.sh", chainConfig.binaryName, string(action.validator), | ||
string(chainConfig.chainId), chainConfig.ipPrefix).CombinedOutput() | ||
if err != nil { | ||
log.Fatal(err, "\n", string(bz)) | ||
} | ||
tr.waitBlocks("provi", 10, 2*time.Minute) | ||
} else { // tr.useCometMock | ||
validatorAddress := tr.GetValidatorAddress(action.chain, action.validator) | ||
|
||
method := "cause_double_sign" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sweet! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious where the script lives that actually handles There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a cometmock RPC method, it does not live here. It's a feature of cometmock |
||
params := fmt.Sprintf(`{"private_key_address":"%s"}`, validatorAddress) | ||
|
||
address := tr.getQueryNodeRPCAddress(action.chain) | ||
|
||
tr.curlJsonRPCRequest(method, params, address) | ||
tr.waitBlocks(action.chain, 1, 10*time.Second) | ||
return | ||
} | ||
tr.waitBlocks("provi", 10, 2*time.Minute) | ||
} | ||
|
||
type assignConsumerPubKeyAction struct { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all of this is great and very exciting.
However a small suggestion, maybe we refactor the
main.go
flag parsing so that--cometmock-happy-path
uses go relayer by default so the flag does not need to be specified.The flag could just be
-cometmock-happy-path --use-cometmock
.This can also be done as part of a larger refactor, I'm just asking for opinions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why it is not like this is that the gorelayer can be used without cometmock, too.
(just not CometMock without the Gorelayer)
I suggest leaving it as it, in the anticipation that one day CometMock can be used with hermes, too (and it does not seem too bad until then to have it as-is)
Lmk if this sounds convincing to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it seems implicit that if you're specifying
--cometmock-happy-path
, both--use-cometmock
and--use-gorelayer
would default to trueThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls note that PR #1191 is changing the way tests can be selected.
Keeping selection of tests and infra seperated regarding parameters is better from a usablity perspective (full flexibility with reduced set of option).
I'd be in favor in not renaming the 'test case' and rather not having 'cometmock' in the name as it leads to assumptions that infra/test setup is using cometmock which is not the case. Running --short-happy-path --use-cometmock (with or without implicit usage of --use-gorelayer) is clearer IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good approach to take.