simibc

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2022 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TryRecvAck

func TryRecvAck(sender *ibctesting.Endpoint, receiver *ibctesting.Endpoint, packet channeltypes.Packet, ack []byte) (err error)

Try to receive an ack on receiver.

func TryRecvPacket

func TryRecvPacket(sender *ibctesting.Endpoint, receiver *ibctesting.Endpoint, packet channeltypes.Packet) (ack []byte, err error)

Try to receive a packet on receiver. Returns ack.

func UpdateReceiverClient

func UpdateReceiverClient(sender *ibctesting.Endpoint, receiver *ibctesting.Endpoint, header *ibctmtypes.Header) (err error)

UpdateReceiverClient is used to send a header to the receiving endpoint and update the client of the respective chain.

Types

type Ack

type Ack struct {
	Ack     []byte
	Packet  channeltypes.Packet
	Commits int
}

Ack represents and ack committed to block state

type OrderedLink struct {
	OutboxPackets map[string][]Packet
	OutboxAcks    map[string][]Ack
}

OrderedLink contains outboxes of packets and acknowledgements and allows fine-grained control over delivery of acks and packets to mimic a real relaying relationship between two chains.

func MakeOrderedLink() OrderedLink

MakeOrderedLink creates a new empty network link.

func (OrderedLink) AddAck

func (n OrderedLink) AddAck(sender string, ack []byte, packet channeltypes.Packet)

AddAck adds an outbound ack, for future delivery to the sender of the packet being acked.

func (OrderedLink) AddPacket

func (n OrderedLink) AddPacket(sender string, packet channeltypes.Packet)

AddPacket adds an outbound packet from the sender to the counterparty.

func (OrderedLink) Commit

func (n OrderedLink) Commit(sender string)

Commit marks a block commit for a chain and will make its outbound packets visible as per the functioning of ibc. In practice it takes 2 commits for a packet to become available for delivery, due to the need for the light client to have block h + 1 for a packet in block h.

func (OrderedLink) ConsumeAcks

func (n OrderedLink) ConsumeAcks(sender string, num int) []Ack

ConsumeAcks returns and internally deletes all acks with 2 or more commits.

func (OrderedLink) ConsumePackets

func (n OrderedLink) ConsumePackets(sender string, num int) []Packet

ConsumePackets returns and internally delets all packets with 2 or more commits.

type Packet

type Packet struct {
	Packet  channeltypes.Packet
	Commits int
}

Packet represents a packet committed to block state

type RelayedPath

type RelayedPath struct {
	Link OrderedLink
	// contains filtered or unexported fields
}

RelayedPath augments ibctesting.Path, giving fine-grained control over delivery of client updates, packet and ack delivery, and chain time and height progression.

func MakeRelayedPath

func MakeRelayedPath(t *testing.T, path *ibctesting.Path) RelayedPath

MakeRelayedPath returns an initialized RelayedPath

func (*RelayedPath) Chain

func (f *RelayedPath) Chain(chainID string) *ibctesting.TestChain

Chain returns the chain with ChainID <chainID>

func (*RelayedPath) DeliverAcks

func (f *RelayedPath) DeliverAcks(chainID string, num int)

DeliverAcks delivers <num> acks to chain

func (*RelayedPath) DeliverPackets

func (f *RelayedPath) DeliverPackets(chainID string, num int)

DeliverPackets delivers <num> packets to chain A real relayer will relay packets from one chain to another chain in two steps. First it will observe sufficiently committed outbound packets on the sender chain. Second, it will submit transactions containing those packets to the receiver chain. This method simulates the second step: sufficiently committed packets that have been already added to the OrderedLink will be delivered. It is necessary to add outbound packets to the link separately.

func (*RelayedPath) EndAndBeginBlock

func (f *RelayedPath) EndAndBeginBlock(chainID string, dt time.Duration, preCommitCallback func())

EndAndBeginBlock calls EndBlock and commits block state, and then increments time and calls BeginBlock, for the chain. preCommitCallback is called after EndBlock and before Commit, allowing access to the sdk.Context after EndBlock.

func (*RelayedPath) UpdateClient

func (f *RelayedPath) UpdateClient(chainID string)

UpdateClient will update the chain light client with each header added to the counterparty chain since the last call.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL