Documentation ¶
Overview ¶
Package types contains common types
Index ¶
- Constants
- func EncodeAgentStatus(agentStatus AgentStatus) ([]byte, error)
- func EncodeAttestation(attestation Attestation) ([]byte, error)
- func EncodeBaseMessage(m BaseMessage) ([]byte, error)
- func EncodeChainGas(chainGas ChainGas) ([]byte, error)
- func EncodeGasData(gasData GasData) ([]byte, error)
- func EncodeHeader(header Header) ([]byte, error)
- func EncodeMessage(m Message) ([]byte, error)
- func EncodeRequest(m Request) ([]byte, error)
- func EncodeSignature(sig Signature) ([]byte, error)
- func EncodeSnapshot(snapshot Snapshot) ([]byte, error)
- func EncodeState(state State) ([]byte, error)
- func EncodeTips(tips Tips) ([]byte, error)
- func HashRawBytes(rawBytes []byte) (common.Hash, error)
- func TotalTips(tips Tips) *big.Int
- type AgentFlagType
- type AgentStatus
- type Attestation
- type AttestationSubmitted
- type BaseMessage
- type ChainGas
- type ChainType
- type CommittedMessage
- type CommittedMessageEncoder
- type GasData
- type Header
- type Message
- type MessageFlag
- type NotaryAttestation
- type Proof
- type ProofEncoder
- type Request
- type Signature
- type Snapshot
- type State
- type Tips
Constants ¶
const ( // BaseMessageTipsOffset is the tips offset. BaseMessageTipsOffset = 0 // BaseMessageSenderOffset is the sender offset. BaseMessageSenderOffset = 32 // BaseMessageRecipientOffset is the recipient offset. BaseMessageRecipientOffset = 64 // BaseMessageRequestOffset is the request offset. BaseMessageRequestOffset = BaseMessageRecipientOffset + TipsSize // BaseMessageContentOffset is the content offset. BaseMessageContentOffset = BaseMessageRequestOffset + RequestSize )
const ( // MessageFlagSize if the size in bytes of a message flag. MessageFlagSize = 1 // MessageHeaderSize is the size in bytes of a message header. MessageHeaderSize = 4*4 + MessageFlagSize )
const ( // VersionOffset is the offset of the version. VersionOffset = 0 // GasLimitOffset if the offset of the gas limit. GasLimitOffset = 4 // GasDropOffset is the gas drop offset. GasDropOffset = 12 // RequestSize is the size of the request. RequestSize = 24 )
const ( // MessageBodyOffset is the message body offset. MessageBodyOffset = MessageHeaderSize )
const SignatureLength = int(65)
SignatureLength for ecdsa signature.
const (
// TipsSize is the size of the tips in bytes.
TipsSize = 8 * 4
)
Variables ¶
This section is empty.
Functions ¶
func EncodeAgentStatus ¶ added in v0.0.171
func EncodeAgentStatus(agentStatus AgentStatus) ([]byte, error)
EncodeAgentStatus encodes a agent status.
func EncodeAttestation ¶
func EncodeAttestation(attestation Attestation) ([]byte, error)
EncodeAttestation encodes an attestation.
func EncodeBaseMessage ¶ added in v0.0.171
func EncodeBaseMessage(m BaseMessage) ([]byte, error)
EncodeBaseMessage encodes a base message.
func EncodeChainGas ¶ added in v0.0.171
EncodeChainGas encodes a chaingas.
func EncodeGasData ¶ added in v0.0.171
EncodeGasData encodes a gasdata.
func EncodeHeader ¶
EncodeHeader encodes a message header.
func EncodeRequest ¶ added in v0.0.171
EncodeRequest encodes a request.
func EncodeSignature ¶
EncodeSignature encodes a signature.
func EncodeSnapshot ¶ added in v0.0.130
EncodeSnapshot encodes a snapshot.
func EncodeState ¶ added in v0.0.130
EncodeState encodes a state.
func HashRawBytes ¶ added in v0.0.58
HashRawBytes takes the raw bytes and produces a hash.
Types ¶
type AgentFlagType ¶ added in v0.0.185
type AgentFlagType uint8
AgentFlagType is the type for the Agent Status Flag.
const ( // AgentFlagUnknown means agent is not part of agent set. AgentFlagUnknown AgentFlagType = iota // AgentFlagActive means agent is active. AgentFlagActive // AgentFlagUnstaking means agent is unstaking. AgentFlagUnstaking // AgentFlagResting means agent has staked but not currently doing any work. AgentFlagResting // AgentFlagFraudulent means agent has been accused of fraud and is awaiting fraud resolution. AgentFlagFraudulent // AgentFlagSlashed means that the agent has been slashed and will not be a part of agent set in the next epoch. AgentFlagSlashed )
func (AgentFlagType) String ¶ added in v0.0.185
func (i AgentFlagType) String() string
type AgentStatus ¶ added in v0.0.171
type AgentStatus interface { // Flag is the current status flag of the agent. Flag() uint8 // Domain that agent is assigned to. Domain() uint32 // Index of the agent in list of agents. Index() uint32 }
AgentStatus is the agent status interface.
func DecodeAgentStatus ¶ added in v0.0.171
func DecodeAgentStatus(toDecode []byte) (AgentStatus, error)
DecodeAgentStatus decodes an agent status.
func NewAgentStatus ¶ added in v0.0.171
func NewAgentStatus(flag uint8, domain, index uint32) AgentStatus
NewAgentStatus creates a new agent status.
type Attestation ¶
type Attestation interface { // SnapshotRoot is the root of the Snapshot Merkle Tree. SnapshotRoot() [32]byte // DataHash is the agent root and SnapGasHash combined into a single hash. DataHash() [32]byte // Nonce is the attestation nonce. Nonce() uint32 // BlockNumber is the block number when the attestation was created in Summit. BlockNumber() *big.Int // Timestamp is the timestamp when the attestation was created in Summit. Timestamp() *big.Int // SignAttestation signs the attestation SignAttestation(ctx context.Context, signer signer.Signer) (signer.Signature, []byte, common.Hash, error) }
Attestation is the attestation interface.
func DecodeAttestation ¶
func DecodeAttestation(toDecode []byte) (Attestation, error)
DecodeAttestation decodes an attestation.
func NewAttestation ¶
func NewAttestation(snapshotRoot [32]byte, dataHash [32]byte, nonce uint32, blockNumber *big.Int, timestamp *big.Int) Attestation
NewAttestation creates a new attestation.
type AttestationSubmitted ¶
type AttestationSubmitted interface { // Notary gets the notary of the attestation. Notary() common.Hash // Attestation gets the raw bytes of the attestation. Attestation() []byte }
AttestationSubmitted is the type emitted by the AttestationCollector when an attestation is submitted.
func NewAttestationSubmitted ¶
func NewAttestationSubmitted(notary common.Hash, attestation []byte) AttestationSubmitted
NewAttestationSubmitted creates a new attestation submitted type.
type BaseMessage ¶ added in v0.0.171
type BaseMessage interface { // Sender address on origin chain. Sender() [32]byte // Recipient address on destination chain. Recipient() [32]byte // Tips paid on the origin chain. Tips() Tips // Request gets the message request. Request() Request // Content to be passed to recipient. Content() []byte // BodyLeaf gets the message body. BodyLeaf() ([]byte, error) // Leaf gets the message leaf. Leaf() ([32]byte, error) }
BaseMessage is an interface that contains the base message.
func DecodeBaseMessage ¶ added in v0.0.171
func DecodeBaseMessage(toDecode []byte) (BaseMessage, error)
DecodeBaseMessage decodes a base message typed mem view.
func NewBaseMessage ¶ added in v0.0.171
func NewBaseMessage(sender, recipient [32]byte, tips Tips, request Request, content []byte) BaseMessage
NewBaseMessage creates a new message from fields passed in.
type ChainGas ¶ added in v0.0.171
type ChainGas interface { // GasData is the gas data for the chain. GasData() GasData // Domain is domain id of the chain. Domain() uint32 }
ChainGas is the ChainGas interface.
func DecodeChainGas ¶ added in v0.0.171
DecodeChainGas decodes a chainGas.
func NewChainGas ¶ added in v0.0.171
NewChainGas creates a new chaingas.
type ChainType ¶
type ChainType uint8
ChainType is the type of chain being used (e.g. evm).
const ( // EVM is a chain that conforms to the evm standard. EVM ChainType = 0 )
func AllChainTypes ¶
func AllChainTypes() []ChainType
AllChainTypes gets all chain types for the chain.
type CommittedMessage ¶
type CommittedMessage interface { // Message is the fully detailed message that was committed Message() []byte // Leaf gets a leaf Leaf() [32]byte // Encode encodes a message Encode() ([]byte, error) }
CommittedMessage is the message that got committed.
func DecodeCommittedMessage ¶
func DecodeCommittedMessage(rawMessage []byte) (CommittedMessage, error)
DecodeCommittedMessage decodes a committed message into a struct.
func NewCommittedMessage ¶
func NewCommittedMessage(message []byte) CommittedMessage
NewCommittedMessage creates a new committed message.
type CommittedMessageEncoder ¶
CommittedMessageEncoder is used to export fields for struct encoding.
type GasData ¶ added in v0.0.171
type GasData interface { // GasPrice is the gas price for the chain (in Wei per gas unit). GasPrice() uint16 // DataPrice is the calldata price (in Wei per byte of content). DataPrice() uint16 // ExecBuffer is the tx fee safety buffer for message execution (in Wei). ExecBuffer() uint16 // AmortAttCost is the amortized cost for attestation submission (in Wei). AmortAttCost() uint16 // EtherPrice is the chain's Ether Price / Mainnet Ether Price (in BWAD). EtherPrice() uint16 // Markup is the markup for the message execution (in BWAD). Markup() uint16 }
GasData is the GasData interface.
func DecodeGasData ¶ added in v0.0.171
DecodeGasData decodes a gasData.
func NewGasData ¶ added in v0.0.171
NewGasData creates a new gasdata.
type Header ¶
type Header interface { // Flag is the flag of the message Flag() MessageFlag // OriginDomain is the origin domain of the message OriginDomain() uint32 // Nonce is the nonce of the message Nonce() uint32 // DestinationDomain is the destination domain of the message DestinationDomain() uint32 // OptimisticSeconds is the optimistic time period of the message in seconds OptimisticSeconds() uint32 // Leaf is the leaf of the header. Leaf() ([32]byte, error) }
Header contains information of a message.
func DecodeHeader ¶
DecodeHeader decodes a header from a byte slice.
type Message ¶
type Message interface { // Header gets the message header Header() Header // BaseMessage is the base message if the flag indicates the type is a base message BaseMessage() BaseMessage // Body gets the message body Body() []byte // OriginDomain returns the Slip-44 ID OriginDomain() uint32 // Nonce is the count of all previous messages to the destination Nonce() uint32 // DestinationDomain is the slip-44 id of the destination DestinationDomain() uint32 // ToLeaf converts a leaf to a keccac256 ToLeaf() (leaf [32]byte, err error) // OptimisticSeconds gets the optimistic seconds count OptimisticSeconds() uint32 }
Message is an interface that contains the message.
func DecodeMessage ¶
DecodeMessage decodes a message from a byte slice.
func NewMessage ¶
func NewMessage(header Header, baseMessage BaseMessage, body []byte) Message
NewMessage creates a new message from fields passed in. TODO: Set up different initializers. One for BaseMessage and one for ManagerMessage.
func NewMessageFromBaseMessage ¶ added in v0.0.184
func NewMessageFromBaseMessage(header Header, baseMessage BaseMessage) (Message, error)
NewMessageFromBaseMessage creates a generic message given a base message.
type MessageFlag ¶ added in v0.0.171
type MessageFlag uint8
MessageFlag indicates if the message is normal "Base" message or "Manager" message.
const ( // MessageFlagBase is the normal message that has tips. MessageFlagBase MessageFlag = iota // MessageFlagManager is manager message and will not have tips. MessageFlagManager )
type NotaryAttestation ¶ added in v0.0.171
type NotaryAttestation interface { // AttPayload is raw bytes of the attestation payload. AttPayload() []byte // AgentRoot is the agent root. AgentRoot() [32]byte // SnapGas is the snap gas. SnapGas() []*big.Int // Attestation is the decoded attestation from the AttPayload Attestation() Attestation }
NotaryAttestation is the notary attestation interface.
func NewNotaryAttestation ¶ added in v0.0.171
func NewNotaryAttestation(attPayload []byte, agentRoot [32]byte, snapGas []*big.Int) (NotaryAttestation, error)
NewNotaryAttestation creates a new notary attestation.
type Proof ¶
type Proof interface { // Leaf is the leaf in the proof Leaf() common.Hash // Index is the index in the tree Index() uint32 // Path is the merkle branch Path() common.Hash // Encode encodes a message Encode() ([]byte, error) }
Proof is a merkle proof object. The leaf it's path to the root and its index in the tree.
type ProofEncoder ¶
ProofEncoder is exported to allow proofs to be encoded/deoded from binary.
type Request ¶ added in v0.0.171
type Request interface { // Version is the base message version to pass to the recipient. Version() uint32 // GasLimit is the minimum amount of gas units to supply for execution. GasLimit() uint64 // GasDrop is the minimum amount of gas token to drop to the recipient. GasDrop() *big.Int }
Request is an interface that contains the request from the base message.
func DecodeRequest ¶ added in v0.0.171
DecodeRequest decodes a request typed mem view.
type Signature ¶
type Signature interface { // V gets the v value of the signature V() *big.Int // R is the r value of the signature R() *big.Int // S is the s value of the signature S() *big.Int }
Signature creates a new signature.
func DecodeSignature ¶
DecodeSignature decodes a signature.
func NewSignature ¶
NewSignature creates a new signature.
type Snapshot ¶ added in v0.0.130
type Snapshot interface { // States are the states of the snapshot. States() []State // SnapshotRootAndProofs returns the snapshot root, calculated from the states, as well as each state's proof. SnapshotRootAndProofs() ([32]byte, [][][]byte, error) // SignSnapshot returns the signature of the snapshot payload signed by the signer SignSnapshot(ctx context.Context, signer signer.Signer) (signer.Signature, []byte, common.Hash, error) }
Snapshot is the snapshot interface.
func DecodeSnapshot ¶ added in v0.0.130
DecodeSnapshot decodes a snapshot.
func NewSnapshot ¶ added in v0.0.130
NewSnapshot creates a new snapshot.
type State ¶ added in v0.0.130
type State interface { // Root is the root of the Origin Merkle Tree. Root() [32]byte // Origin is the domain where Origin is located. Origin() uint32 // Nonce is the amount of sent messages. Nonce() uint32 // BlockNumber is the block of the last sent message. BlockNumber() *big.Int // Timestamp is the unix time of the last sent message. Timestamp() *big.Int // GasData is the gas data from the chain's gas oracle. GasData() GasData // Hash returns the hash of the state. Hash() ([32]byte, error) // SubLeaves returns the left and right sub-leaves of the state. SubLeaves() (leftLeaf, rightLeaf [32]byte, err error) }
State is the state interface.
func DecodeState ¶ added in v0.0.130
DecodeState decodes a state.
type Tips ¶
type Tips interface { // SummitTip gets the tips for the agent work on summit SummitTip() *big.Int // AttestationTip gets the tips for the doing the attestation AttestationTip() *big.Int // ExecutionTip gets the tips for executing the message ExecutionTip() *big.Int // DeliveryTip gets the tips for delivering the message receipt to summit DeliveryTip() *big.Int }
Tips contain tips used for scientizing different agents.
func DecodeTips ¶
DecodeTips decodes a tips typed mem view.