e2e

package module
v0.0.0-...-a702099 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

README

Blobstream end to end integration test

This directory contains the Blobstream e2e integration tests. It serves as a way to fully test the Blobstream orchestrator and relayer in real network scenarios

Topology

as discussed under #398 The e2e network defined under blobstream_network.go has the following components:

  • 4 Celestia-app nodes that can be validators
  • 4 Orchestrator nodes that will each run aside of a celestia-app
  • 1 Ethereum node. Probably Ganache as it is easier to set up
  • 1 Relayer node that will listen to Celestia chain and relay attestations
  • 1 Deployer node that can deploy a new Blobstream contract when needed.

For more information on the environment variables required to run these tests, please check the docker-compose.yml file and the shell scripts defined under celestia-app directory.

P2P network

In some test scenarios, we only care about running a single orchestrator node. The problem is that in order for the DHT to start putting values, it needs to have at least 1 connected peer. Thus, in our testing scenarios, we create an extra DHT that is used mainly used to create the P2PQuerier, but also to connect to that orchestrator DHT and allow it to run.

// create dht for querying
bootstrapper, err := helpers.ParseAddrInfos(network.Logger, BOOTSTRAPPERS)
HandleNetworkError(t, network, err, false)
_, _, dht := blobstreamtesting.NewTestDHT(ctx, bootstrapper)
defer dht.Close()

with bootstrapper being that orchestrator P2P ID and listening address.

How to run

Requirements

To run the e2e tests, a working installation of docker-compose is needed.

Makefile

A Makefile has been defined under this directory to run the tests, with a test target:

make test
Run a specific test

To run a single test, run the following:

BLOBSTREAM_INTEGRATION_TEST=true go test -mod=readonly -test.timeout 30m -v -run <test_name>
Run all the tests using go directly
BLOBSTREAM_INTEGRATION_TEST=true go test -mod=readonly -test.timeout 30m -v

Common issues

Currently, when the tests are run using the above ways, there are possible issues that might happen.

hanging docker containers after a sudden network stop

If the tests were stopped unexpectedly, for example, sending a SIGINT, ie, ctrl+c, the resources will not be released correctly (might be fixed in the future). This will result in seeing similar logs to the following :

ERROR: for core0  Cannot create container for service core0: Conflict. The container name "/core0" is already in use by container "4bdaf40e2cd26bf549738ea95f53ba49cb5407c3d892b50b5a75e72e08e
3e0a8". You have to remove (or rename) that container to be able to reuse that name.                                                                                                          
Host is already in use by another container                                                                                                                                                   
Creating 626fbf28-7c90-4842-be8e-3346f864b369_ganache_1 ... error                                                                                                                             
                                                                                                                                                                                              
ERROR: for 626fbf28-7c90-4842-be8e-3346f864b369_ganache_1  Cannot start service ganache: driver failed programming external connectivity on endpoint 626fbf28-7c90-4842-be8e-3346f864b369_gana
che_1 (23bf2faf8fbce45f4a112b59183739f294c0e2d4fb208fec89e4805f3d719381): Bind for 0.0.0.0:8545 failed: port is already allocated                                                             
                                                                                                                                                                                              
ERROR: for core0  Cannot create container for service core0: Conflict. The container name "/core0" is already in use by container "4bdaf40e2cd26bf549738ea95f53ba49cb5407c3d892b50b5a75e72e08e
3e0a8". You have to remove (or rename) that container to be able to reuse that name.                                                                                                          
                                                                                                                                                                                              
ERROR: for ganache  Cannot start service ganache: driver failed programming external connectivity on endpoint 626fbf28-7c90-4842-be8e-3346f864b369_ganache_1 (23bf2faf8fbce45f4a112b59183739f294c0e2d4fb208fec89e4805f3d719381): Bind for 0.0.0.0:8545 failed: port is already allocated
Encountered errors while bringing up the project.
Attaching to 626fbf28-7c90-4842-be8e-3346f864b369_ganache_1

To fix it, run the cleanup.sh script under scripts directory :

./scripts/cleanup.sh

NB: This will kill and remove hanging containers and networks related to the executed. But might also delete unrelated ones if they have the same name.

Documentation

Index

Constants

View Source
const (
	CORE0               = "core0"
	CORE0ACCOUNTADDRESS = "celestia198gj5ges3xayhmrtp4wzrjc2wqu2qtz0kavyg2"
	CORE0EVMADDRESS     = "0x966e6f22781EF6a6A82BBB4DB3df8E225DfD9488"
	COREOORCH           = "core0-orch"

	CORE1               = "core1"
	CORE1ACCOUNTADDRESS = "celestia1nmu3r37v7lcx0lr68h9v4vr4m20tqkrwt97wej"
	CORE1EVMADDRESS     = "0x91DEd26b5f38B065FC0204c7929Da1b2A21877Ad"
	CORE1ORCH           = "core1-orch"

	CORE2               = "core2"
	CORE2ACCOUNTADDRESS = "celestia1p236k88sk7tdqgsw539jclmy44vn9m4lk8kqgd"
	CORE2EVMADDRESS     = "0x3d22f0C38251ebdBE92e14BBF1bd2067F1C3b7D7"
	CORE2ORCH           = "core2-orch"

	CORE3               = "core3"
	CORE3ACCOUNTADDRESS = "celestia1d47nxy65684ptn3l8j7dwf5tx3qe5xjcl2qrdj"
	CORE3EVMADDRESS     = "0x3EE99606625E740D8b29C8570d855Eb387F3c790"
	CORE3ORCH           = "core3-orch"

	DEPLOYER = "deployer"
	RELAYER  = "relayer"
	GANACHE  = "ganache"
)
View Source
const TRUE = "true"

Variables

View Source
var BOOTSTRAPPERS = []string{"/ip4/127.0.0.1/tcp/30000/p2p/12D3KooWBSMasWzRSRKXREhediFUwABNZwzJbkZcYz5rYr9Zdmfn"}
View Source
var ErrNetworkStopped = errors.New("network is stopping")

Functions

func ConnectToDHT

func ConnectToDHT(ctx context.Context, h host.Host, dht *p2p.BlobstreamDHT, target peer.AddrInfo) error

func HandleNetworkError

func HandleNetworkError(t *testing.T, network *BlobstreamNetwork, err error, expectError bool)

Types

type BlobstreamNetwork

type BlobstreamNetwork struct {
	ComposePaths  []string
	Identifier    string
	Instance      *testcontainers.LocalDockerCompose
	EVMRPC        string
	TendermintRPC string
	CelestiaGRPC  string
	P2PAddr       string
	EncCfg        encoding.Config
	Logger        tmlog.Logger
	// contains filtered or unexported fields
}

func NewBlobstreamNetwork

func NewBlobstreamNetwork() (*BlobstreamNetwork, error)

func (BlobstreamNetwork) DeleteAll

func (network BlobstreamNetwork) DeleteAll() error

DeleteAll deletes the containers, network and everything related to the cluster.

func (BlobstreamNetwork) DeployBlobstreamContract

func (network BlobstreamNetwork) DeployBlobstreamContract() error

DeployBlobstreamContract uses the Deployer service to deploy a new Blobstream contract based on the existing running network. If no Celestia-app nor ganache is started, it creates them automatically.

func (BlobstreamNetwork) ExecCommand

func (network BlobstreamNetwork) ExecCommand(service Service, command []string) error

func (BlobstreamNetwork) GetCurrentDataCommitmentWindow

func (network BlobstreamNetwork) GetCurrentDataCommitmentWindow(ctx context.Context) (uint64, error)

func (BlobstreamNetwork) GetDataCommitmentConfirm

func (network BlobstreamNetwork) GetDataCommitmentConfirm(
	_ctx context.Context,
	dht *p2p.BlobstreamDHT,
	nonce uint64,
	evmAddr string,
) (*blobstreamtypes.DataCommitmentConfirm, error)

GetDataCommitmentConfirm Returns the data commitment confirm for nonce `nonce` signed by orchestrator whose EVM address is `evmAddr`.

func (BlobstreamNetwork) GetDataCommitmentConfirmByHeight

func (network BlobstreamNetwork) GetDataCommitmentConfirmByHeight(
	_ctx context.Context,
	dht *p2p.BlobstreamDHT,
	height uint64,
	evmAddr string,
) (*blobstreamtypes.DataCommitmentConfirm, error)

GetDataCommitmentConfirmByHeight Returns the data commitment confirm that commits to height `height` signed by orchestrator whose EVM address is `evmAddr`.

func (BlobstreamNetwork) GetLatestAttestationNonce

func (network BlobstreamNetwork) GetLatestAttestationNonce(_ctx context.Context) (uint64, error)

GetLatestAttestationNonce Returns the latest attestation nonce.

func (BlobstreamNetwork) GetLatestDeployedBlobstreamContract

func (network BlobstreamNetwork) GetLatestDeployedBlobstreamContract(_ctx context.Context) (*blobstreamwrapper.Wrappers, error)

func (BlobstreamNetwork) GetLatestDeployedBlobstreamContractWithCustomTimeout

func (network BlobstreamNetwork) GetLatestDeployedBlobstreamContractWithCustomTimeout(
	_ctx context.Context,
	timeout time.Duration,
) (*blobstreamwrapper.Wrappers, error)

func (BlobstreamNetwork) GetLatestValset

func (network BlobstreamNetwork) GetLatestValset(ctx context.Context) (*types.Valset, error)

func (BlobstreamNetwork) GetValsetConfirm

func (network BlobstreamNetwork) GetValsetConfirm(
	_ctx context.Context,
	dht *p2p.BlobstreamDHT,
	nonce uint64,
	evmAddr string,
) (*blobstreamtypes.ValsetConfirm, error)

GetValsetConfirm Returns the valset confirm for nonce `nonce` signed by orchestrator whose EVM address is `evmAddr`.

func (BlobstreamNetwork) GetValsetContainingVals

func (network BlobstreamNetwork) GetValsetContainingVals(_ctx context.Context, number int) (*types.Valset, error)

GetValsetContainingVals Gets the last valset that contains a certain number of validator. This is used after enabling orchestrators not to sign unless they belong to some valset. Thus, any nonce after the returned valset should be signed by all orchestrators.

func (BlobstreamNetwork) KillAll

func (network BlobstreamNetwork) KillAll() error

KillAll kills all the containers.

func (BlobstreamNetwork) PrintLogs

func (network BlobstreamNetwork) PrintLogs()

func (BlobstreamNetwork) Start

func (network BlobstreamNetwork) Start(service Service) error

Start starts a service from the `Service` enum. Make sure to call `Stop`, in the end, to release the resources.

func (BlobstreamNetwork) StartAll

func (network BlobstreamNetwork) StartAll() error

StartAll starts the whole Blobstream cluster with multiple validators, orchestrators and a relayer Make sure to release the resources after finishing by calling the `StopAll()` method.

func (BlobstreamNetwork) StartBase

func (network BlobstreamNetwork) StartBase() error

StartBase starts the very minimal component to have a network. It consists of starting `core0` as it is the genesis validator, and the docker network will be created along with it, allowing more containers to join it.

func (BlobstreamNetwork) StartMinimal

func (network BlobstreamNetwork) StartMinimal() error

StartMinimal starts a network containing: 1 validator, 1 orchestrator, 1 relayer and a ganache instance.

func (BlobstreamNetwork) StartMultiple

func (network BlobstreamNetwork) StartMultiple(services ...Service) error

StartMultiple start multiple services. Make sure to call `Stop`, in the end, to release the resources.

func (BlobstreamNetwork) Stop

func (network BlobstreamNetwork) Stop(service Service) error

func (BlobstreamNetwork) StopAll

func (network BlobstreamNetwork) StopAll() error

StopAll stops the network and leaves the containers created. This allows to resume execution from the point where they stopped.

func (BlobstreamNetwork) StopMultiple

func (network BlobstreamNetwork) StopMultiple(services ...Service) error

StopMultiple start multiple services. Make sure to call `Stop` or `StopMultiple`, in the end, to release the resources.

func (BlobstreamNetwork) UpdateDataCommitmentWindow

func (network BlobstreamNetwork) UpdateDataCommitmentWindow(ctx context.Context, newWindow uint64) error

func (BlobstreamNetwork) WaitForBlock

func (network BlobstreamNetwork) WaitForBlock(_ctx context.Context, height int64) error

func (BlobstreamNetwork) WaitForBlockWithCustomTimeout

func (network BlobstreamNetwork) WaitForBlockWithCustomTimeout(
	_ctx context.Context,
	height int64,
	timeout time.Duration,
) error

func (BlobstreamNetwork) WaitForEventNonce

func (network BlobstreamNetwork) WaitForEventNonce(ctx context.Context, bridge *blobstreamwrapper.Wrappers, n uint64) error

func (BlobstreamNetwork) WaitForNodeToStart

func (network BlobstreamNetwork) WaitForNodeToStart(_ctx context.Context, rpcAddr string) error

func (BlobstreamNetwork) WaitForOrchestratorToStart

func (network BlobstreamNetwork) WaitForOrchestratorToStart(_ctx context.Context, dht *p2p.BlobstreamDHT, evmAddr string) (uint64, uint64, error)

WaitForOrchestratorToStart waits for the orchestrator having the evm address `evmAddr` to sign the first data commitment (could be upgraded to get any signature, either valset or data commitment, and for any nonce, but would require adding a new method to the querier. Don't think it is worth it now as the number of valsets that will be signed is trivial and reaching 0 would be in no time). Returns the height and the nonce of some attestation that the orchestrator signed.

func (BlobstreamNetwork) WaitForRelayerToStart

func (network BlobstreamNetwork) WaitForRelayerToStart(_ctx context.Context, bridge *blobstreamwrapper.Wrappers) error

func (BlobstreamNetwork) WasAttestationSigned

func (network BlobstreamNetwork) WasAttestationSigned(
	_ctx context.Context,
	dht *p2p.BlobstreamDHT,
	nonce uint64,
	evmAddress string,
) (bool, error)

WasAttestationSigned Returns true if the attestation confirm exist.

type Service

type Service int64
const (
	Core0 Service = iota
	Core0Orch
	Core1
	Core1Orch
	Core2
	Core2Orch
	Core3
	Core3Orch
	Deployer
	Relayer
	Ganache
)

Jump to

Keyboard shortcuts

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