SNS: GenericNervousSystemFunction validator_canister_id and validator_method_name

According to ICSCAN and the snsdemo repo, the Candid for GenericNervousSystemFunction is:

type GenericNervousSystemFunction = record {
  validator_canister_id : opt principal;
  target_canister_id : opt principal;
  validator_method_name : opt text;
  target_method_name : opt text;
};

target_canister_id and target_method_name seem self-explanatory.

What are validator_canister_id and validator_method_name?

1 Like

@mraszyk shared a link the SNS Testflight docs in another thread.

Under Test executing code on SNS managed canisters via SNS proposals it says:

To execute code on SNS managed canisters via SNS proposals, the canisters must expose a pair of public functions (refered to as generic functions in the following):

  • a validation function to validate and render the proposal payload;
  • an execution function to perform an action given the proposal payload.

The validation function must return a value of the Candid type variant { Ok: text; Err: text; }, e.g., Result<String, String> in Rust. If the validation function returns Ok(rendering), then the proposal is submitted and the rendering string is included into the proposal. Otherwise, the proposal submission fails.

The execution function gets the same binary payload as passed to the validation function and its code gets executed if the proposal is accepted. It should not return any value because this return value is ignored.

2 Likes

Hi @mraszyk, I noticed that the validator_canister_id and validator_method_name are optional. Is it valid to leave these unspecified? I think this would be preferable in some cases (to avoid the additional dependency which could theoretically misrepresent a proposal payload, increasing the potential attack surface).

Presumably if the validator is not specified then the payload is regarded as valid and deserialised to the payload display in the proposal (no need to provide an explicit deserialsiation method)?

1 Like

Although the types are optional, you have to provide a validator canister ID and method name, otherwise the generic function is invalid, see, e.g., here.

1 Like