Governor contract, castVoteBySig problem

Hey, I hope everybody is ok.
I have a problem with OpenZeppelin Governor contract, namely implementing a vote by signature. All good, except that VoteCast Event contains a voter address, that is out of nowhere. It is generated by an attempt to get a signing address from a signature inside of this function

function castVoteBySig(
    uint256 proposalId,
    uint8 support,
    uint8 v,
    bytes32 r,
    bytes32 s
) public virtual returns (uint256) {
    address voter = ECDSA.recover(
        _hashTypedDataV4(keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support))),
    return _castVote(proposalId, voter, support, "");

Specifically, voter address that I can see in the Event emitted is not known among other addresses in testing environment :slight_smile:
Anybody knows this problem? Will appreciate your help.

Hey @SAN,

If I'm understanding correctly, the VoteCast event is emitting with an unexpected address. Is that correct?

There are multiple possible causes for this, but it all comes down to the fact that ecrecover doesn't revert if it's given a signature, it'll always output an address, so the mismatch should be caused by the off-chain signature processing. Some examples of possible causes are:

  • The domain typehash might be incorrect
  • Interchanging the r and s parameters
  • Incorrect v parameter (27/28)
  • Different proposalId or support signed off-chain to the one supplied to the castVoteBySig function

Hope this helps.

Hey @ernestognw, thanks a lot for your response. It seems you are right. I've also found this - , and it looks like the problem you are talking about.
Working on this.