Documentation ¶
Index ¶
- Constants
- Variables
- func GetObservationResponses(txResp *sdktx.BroadcastTxResponse) (map[string]ObservationResponseStatus, error)
- func SubmitObservationsToContract(ctx context.Context, logger *zap.Logger, ...) (*sdktx.BroadcastTxResponse, error)
- type Accountant
- func (acct *Accountant) Close()
- func (acct *Accountant) FeatureString() string
- func (acct *Accountant) IsMessageCoveredByAccountant(msg *common.MessagePublication) bool
- func (acct *Accountant) Start(ctx context.Context) error
- func (acct *Accountant) SubmitObservation(msg *common.MessagePublication) (bool, error)
- type AccountantWormchainConn
- type BatchTransferStatusResponse
- type MissingObservation
- type MissingObservationsResponse
- type Observation
- type ObservationResponse
- type ObservationResponseStatus
- type ObservationResponses
- type SignatureBytes
- type SignatureType
- type SubmitObservationsMsg
- type SubmitObservationsParams
- type TransferData
- type TransferDetails
- type TransferKey
- type TransferStatus
- type TransferStatusCommitted
- type TransferStatusPending
- type WasmObservation
- type WasmObservationError
Constants ¶
const MsgChannelCapacity = 5 * batchSize
MsgChannelCapacity specifies the capacity of the message channel used to publish messages released from the accountant. This channel should not back up, but if it does, the accountant will start dropping messages, which would require reobservations.
const NTT_PREFIX_END = NTT_PREFIX_OFFSET + 4
const NTT_PREFIX_OFFSET = 136
const PAYLOAD_ID_DELIVERY_INSTRUCTION = uint8(1)
const VAA_KEY_TYPE = 1
const VAA_KEY_TYPE_LENGTH = 2 + 32 + 8
Variables ¶
var NTT_PREFIX = []byte{0x99, 0x4E, 0x54, 0x54}
var NttSubmitObservationPrefix = []byte("ntt_acct_sub_obsfig_00000000000000|")
var SubmitObservationPrefix = []byte("acct_sub_obsfig_000000000000000000|")
var WH_PREFIX = []byte{0x99, 0x45, 0xFF, 0x10}
Functions ¶
func GetObservationResponses ¶
func GetObservationResponses(txResp *sdktx.BroadcastTxResponse) (map[string]ObservationResponseStatus, error)
GetObservationResponses is a free function that extracts the observation responses from a transaction response. It assumes the transaction response is valid (SubmitObservationsToContract() did not return an error).
func SubmitObservationsToContract ¶
func SubmitObservationsToContract( ctx context.Context, logger *zap.Logger, guardianSigner guardiansigner.GuardianSigner, gsIndex uint32, guardianIndex uint32, wormchainConn AccountantWormchainConn, contract string, prefix []byte, msgs []*common.MessagePublication, ) (*sdktx.BroadcastTxResponse, error)
SubmitObservationsToContract is a free function to make a call to the smart contract to submit an observation request. If the submit fails or the result contains an error, it will return the error. If an error is returned, the caller is expected to use GetFailedIndexInBatch() to see which observation in the batch failed.
Types ¶
type Accountant ¶
type Accountant struct {
// contains filtered or unexported fields
}
Accountant is the object that manages the interface to the wormchain accountant smart contract.
func NewAccountant ¶
func NewAccountant( ctx context.Context, logger *zap.Logger, db db.AccountantDB, obsvReqWriteC chan<- *gossipv1.ObservationRequest, contract string, wsUrl string, wormchainConn AccountantWormchainConn, enforceFlag bool, nttContract string, nttWormchainConn AccountantWormchainConn, guardianSigner guardiansigner.GuardianSigner, gst *common.GuardianSetState, msgChan chan<- *common.MessagePublication, env common.Environment, ) *Accountant
NewAccountant creates a new instance of the Accountant object.
func (*Accountant) Close ¶
func (acct *Accountant) Close()
func (*Accountant) FeatureString ¶
func (acct *Accountant) FeatureString() string
func (*Accountant) IsMessageCoveredByAccountant ¶
func (acct *Accountant) IsMessageCoveredByAccountant(msg *common.MessagePublication) bool
IsMessageCoveredByAccountant returns `true` if a message should be processed by the Global Accountant, `false` if not.
func (*Accountant) Start ¶
func (acct *Accountant) Start(ctx context.Context) error
Start initializes the accountant and starts the worker and watcher runnables.
func (*Accountant) SubmitObservation ¶
func (acct *Accountant) SubmitObservation(msg *common.MessagePublication) (bool, error)
SubmitObservation will submit token bridge transfers to the accountant smart contract. This is called from the processor loop when a local observation is received from a watcher. It returns true if the observation can be published immediately, false if not (because it has been submitted to the accountant).
type AccountantWormchainConn ¶
type AccountantWormchainConn interface { Close() SenderAddress() string SubmitQuery(ctx context.Context, contractAddress string, query []byte) ([]byte, error) SignAndBroadcastTx(ctx context.Context, msg sdktypes.Msg) (*sdktx.BroadcastTxResponse, error) BroadcastTxResponseToString(txResp *sdktx.BroadcastTxResponse) string }
type BatchTransferStatusResponse ¶
type BatchTransferStatusResponse struct {
Details []TransferDetails `json:"details"`
}
BatchTransferStatusResponse contains the details returned by the "batch_transfer_status" query.
type MissingObservation ¶
MissingObservation is what is returned for a single missing observation.
func (MissingObservation) String ¶
func (mo MissingObservation) String() string
type MissingObservationsResponse ¶
type MissingObservationsResponse struct {
Missing []MissingObservation `json:"missing"`
}
MissingObservationsResponse is the result returned from the "missing_observations" query.
type Observation ¶
type Observation struct { // The hash of the transaction on the emitter chain in which the transfer was performed. TxHash []byte `json:"tx_hash"` // Seconds since UNIX epoch. Timestamp uint32 `json:"timestamp"` // The nonce for the transfer. Nonce uint32 `json:"nonce"` // The source chain from which this observation was created. EmitterChain uint16 `json:"emitter_chain"` // The address on the source chain that emitted this message. EmitterAddress vaa.Address `json:"emitter_address"` // The sequence number of this observation. Sequence uint64 `json:"sequence"` // The consistency level requested by the emitter. ConsistencyLevel uint8 `json:"consistency_level"` // The serialized tokenbridge payload. Payload []byte `json:"payload"` }
type ObservationResponse ¶
type ObservationResponse struct { Key TransferKey Status ObservationResponseStatus }
type ObservationResponses ¶
type ObservationResponses []ObservationResponse
These are used to parse the response data
type SignatureBytes ¶
type SignatureBytes []uint8
func (SignatureBytes) MarshalJSON ¶
func (sb SignatureBytes) MarshalJSON() ([]byte, error)
type SignatureType ¶
type SignatureType struct { Index uint32 `json:"index"` Signature SignatureBytes `json:"signature"` }
type SubmitObservationsMsg ¶
type SubmitObservationsMsg struct {
Params SubmitObservationsParams `json:"submit_observations"`
}
type SubmitObservationsParams ¶
type SubmitObservationsParams struct { // A serialized `Vec<Observation>`. Multiple observations can be submitted together to reduce transaction overhead. Observations []byte `json:"observations"` // The index of the guardian set used to sign the observations. GuardianSetIndex uint32 `json:"guardian_set_index"` // A signature for `observations`. Signature SignatureType `json:"signature"` }
type TransferData ¶
type TransferData struct { Amount *cosmossdk.Int `json:"amount"` TokenChain uint16 `json:"token_chain"` TokenAddress vaa.Address `json:"token_address"` RecipientChain uint16 `json:"recipient_chain"` }
TransferData contains the detailed data returned for a committed transfer.
type TransferDetails ¶
type TransferDetails struct { Key TransferKey `json:"key"` Status *TransferStatus `json:"status"` }
TransferDetails contains the details returned for a single transfer.
type TransferKey ¶
type TransferKey struct { EmitterChain uint16 `json:"emitter_chain"` EmitterAddress vaa.Address `json:"emitter_address"` Sequence uint64 `json:"sequence"` }
func (TransferKey) String ¶
func (k TransferKey) String() string
type TransferStatus ¶
type TransferStatus struct { Committed *TransferStatusCommitted `json:"committed"` Pending *[]TransferStatusPending `json:"pending"` }
TransferStatus contains the status returned for a transfer.
type TransferStatusCommitted ¶
type TransferStatusCommitted struct { Data TransferData `json:"data"` Digest []byte `json:"digest"` }
TransferStatusCommitted contains the data returned for a committed transfer.
type TransferStatusPending ¶
type TransferStatusPending struct { Digest []byte `json:"digest"` TxHash []byte `json:"tx_hash"` Signatures string `json:"signatures"` GuardianSetIndex uint32 `json:"guardian_set_index"` EmitterChain uint16 `json:"emitter_chain"` }
TransferStatusPending contains the data returned for a committed transfer.
type WasmObservation ¶
type WasmObservation Observation
WasmObservation represents a transfer event from the smart contract.
type WasmObservationError ¶
type WasmObservationError struct { Key TransferKey `json:"key"` Error string `json:"error"` }
WasmObservationError represents an error event from the smart contract.