Messages

Proposal Submission

Proposals can be submitted by any account via a MsgSubmitProposal transaction.

// MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary
// proposal Content.
message MsgSubmitProposal {
  option (cosmos.msg.v1.signer) = "proposer";

  repeated google.protobuf.Any messages             = 1;
  repeated cosmos.base.v1beta1.Coin initial_deposit = 2 [(gogoproto.nullable) = false];
  string                            proposer        = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
  // metadata is any arbitrary metadata attached to the proposal.
  string metadata = 4;
}

All sdk.Msgs passed into the messages field of a MsgSubmitProposal message must be registered in the app's MsgServiceRouter. Each of these messages must have one signer, namely the gov module account. And finally, the metadata length must not be larger than the maxMetadataLen config passed into the gov keeper.

State modifications:

  • Generate new proposalID

  • Create new Proposal

  • Initialise Proposal's attributes

  • Decrease balance of sender by InitialDeposit

  • If MinDeposit is reached:

    • Push proposalID in ProposalProcessingQueue

  • Transfer InitialDeposit from the Proposer to the governance ModuleAccount

A MsgSubmitProposal transaction can be handled according to the following pseudocode.

Deposit

Once a proposal is submitted, if Proposal.TotalDeposit < ActiveParam.MinDeposit, Atom holders can send MsgDeposit transactions to increase the proposal's deposit.

State modifications:

  • Decrease balance of sender by deposit

  • Add deposit of sender in proposal.Deposits

  • Increase proposal.TotalDeposit by sender's deposit

  • If MinDeposit is reached:

    • Push proposalID in ProposalProcessingQueueEnd

  • Transfer Deposit from the proposer to the governance ModuleAccount

A MsgDeposit transaction has to go through a number of checks to be valid. These checks are outlined in the following pseudocode.

Vote

Once ActiveParam.MinDeposit is reached, voting period starts. From there, bonded Atom holders are able to send MsgVote transactions to cast their vote on the proposal.

State modifications:

  • Record Vote of sender

Note: Gas cost for this message has to take into account the future tallying of the vote in EndBlocker.

Next is a pseudocode outline of the way MsgVote transactions are handled:

Last updated