Compass EVM | Official Paloma Protocol Documentation

Compass EVM

Compass-EVM is a smart contract written in Vyper that allows you to run any other smart contract with arbitrary transaction data. It is as simple as providing the ABI and HEX of the contract you want to control.

The Compass-EVM contract resembles a validator-set multisig with a few tweaks. Even though it is designed to be used with a consensus process on Paloma, the Compass-EVM contract itself encodes nothing about this consensus process. Find the available contract addresses here

Model

An update_valset transaction must be signed by 2/3's of the current valset to be accepted.

Because valsets contain over 100 validators, storing these all on the Ethereum blockchain each time would be quite expensive. Because of this, we only store a hash of the current valset, then let the caller supply the actual addresses, powers, and valset_id. We call this hash the checkpoint. This is done with the function make_checkpoint.

The rest of the new valset is passed in the arguments to this method, but it is only used to recreate the checkpoint of the new valset. If we didn't check the id, it would be possible to pass in the checkpoint directly.

check_validator_signatures

check_validator_signatures takes a valset, an array of signatures, a hash, and a power threshold. It checks that the powers of all the validators that have signed the hash add up to the threshold. This is how we know that the new valset has been approved by at least 2/3s of the current valset. We iterate over the current valset and the array of signatures, which should be the same length. For each validator, we first check if the signature is all zeros. This signifies that it was impossible to obtain a given validator's signature.

If this is the case, we skip to the next validator in the list. Since we only need 2/3s of the signatures, it is not required that every validator sign every time, and skipping them stops any validator from being able to stop working.

If we have a signature for a validator, we verify it, throwing an error if something is wrong. We also increment a cumulative_power counter with the validator's power. Once this is over the threshold, we break out of the loop, verifying the signatures! We throw an error if the loop ends without the threshold being met. Because of the way we break out of the loop once the threshold has been completed, if the valset is sorted by descending power, we can usually skip evaluating the majority of signatures. To take advantage of the gas savings, valsets must be produced by the validators in descending order of power.

Events

We emit two different events, each of which has a distinct purpose. One contains a field called message_id, which is used by the Paloma chain to ensure that the events are not out of order. This should updated each time one of the events is emitted. The other one emits valset_id and checkpoint when valset_id is updated.