-
Notifications
You must be signed in to change notification settings - Fork 195
test: add basic docker E2E which writes headers to DA network #2378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cbcc5d4
wip
chatton b15edc4
wip: working on configuring tastora
chatton 8a43d57
Merge branch 'main' into cian/tastora-basic-test
chatton 0a5f391
chore: adding default configuration
chatton 77cb78f
test passing with local image
chatton 36e9eac
chore: configurable tag via env vars, update workflow to pass the ima…
chatton 2aea365
deps: go mod tidy
chatton c5ee0e1
chore: add name for docker test job
chatton a31f329
deps: bump to tastora v0.0.3
chatton 5e4f5dd
chore: build for additional platforms
chatton 9dc6d97
chore: skip docker tests in test_cover.go
chatton 688b877
fix: return nil instead of continue
chatton 612c424
chore: pr feedback
chatton 5d1501e
Merge branch 'main' into cian/tastora-basic-test
tac0turtle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package docker_e2e | ||
|
||
import ( | ||
"context" | ||
"github.com/celestiaorg/tastora/framework/types" | ||
"testing" | ||
) | ||
|
||
func (s *DockerTestSuite) TestBasicDockerE2E() { | ||
ctx := context.Background() | ||
s.SetupDockerResources() | ||
|
||
var ( | ||
bridgeNode types.DANode | ||
) | ||
|
||
s.T().Run("start celestia chain", func(t *testing.T) { | ||
err := s.celestia.Start(ctx) | ||
s.Require().NoError(err) | ||
}) | ||
|
||
s.T().Run("start bridge node", func(t *testing.T) { | ||
genesisHash := s.getGenesisHash(ctx) | ||
|
||
celestiaNodeHostname, err := s.celestia.GetNodes()[0].GetInternalHostName(ctx) | ||
s.Require().NoError(err) | ||
|
||
bridgeNode = s.daNetwork.GetBridgeNodes()[0] | ||
|
||
s.StartBridgeNode(ctx, bridgeNode, testChainID, genesisHash, celestiaNodeHostname) | ||
}) | ||
|
||
chatton marked this conversation as resolved.
Show resolved
Hide resolved
|
||
s.T().Run("fund da wallet", func(t *testing.T) { | ||
daWallet, err := bridgeNode.GetWallet() | ||
s.Require().NoError(err) | ||
s.T().Logf("da node celestia address: %s", daWallet.GetFormattedAddress()) | ||
|
||
s.FundWallet(ctx, daWallet, 100_000_000_00) | ||
}) | ||
|
||
s.T().Run("start rollkit chain node", func(t *testing.T) { | ||
s.StartRollkitNode(ctx, bridgeNode, s.rollkitChain.GetNodes()[0]) | ||
}) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,270 @@ | ||
package docker_e2e | ||
|
||
import ( | ||
"context" | ||
"cosmossdk.io/math" | ||
"encoding/hex" | ||
"fmt" | ||
"github.com/celestiaorg/go-square/v2/share" | ||
tastoradocker "github.com/celestiaorg/tastora/framework/docker" | ||
"github.com/celestiaorg/tastora/framework/testutil/sdkacc" | ||
"github.com/celestiaorg/tastora/framework/testutil/toml" | ||
tastoratypes "github.com/celestiaorg/tastora/framework/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module/testutil" | ||
"github.com/cosmos/cosmos-sdk/x/auth" | ||
"github.com/cosmos/cosmos-sdk/x/bank" | ||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
"github.com/stretchr/testify/suite" | ||
"go.uber.org/zap/zaptest" | ||
"os" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
const ( | ||
// testChainID is the chain ID used for testing. | ||
// it must be the string "test" as it is handled explicitly in app/node. | ||
testChainID = "test" | ||
) | ||
|
||
func init() { | ||
sdkConf := sdk.GetConfig() | ||
sdkConf.SetBech32PrefixForAccount("celestia", "celestiapub") | ||
sdkConf.Seal() | ||
} | ||
|
||
func TestDockerSuite(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip("skipping due to short mode") | ||
} | ||
suite.Run(t, new(DockerTestSuite)) | ||
} | ||
|
||
type DockerTestSuite struct { | ||
suite.Suite | ||
provider tastoratypes.Provider | ||
celestia tastoratypes.Chain | ||
daNetwork tastoratypes.DataAvailabilityNetwork | ||
rollkitChain tastoratypes.RollkitChain | ||
} | ||
|
||
// ConfigOption is a function type for modifying tastoradocker.Config | ||
type ConfigOption func(*tastoradocker.Config) | ||
|
||
// CreateDockerProvider creates a new tastoratypes.Provider with optional configuration modifications | ||
func (s *DockerTestSuite) CreateDockerProvider(opts ...ConfigOption) tastoratypes.Provider { | ||
t := s.T() | ||
encConfig := testutil.MakeTestEncodingConfig(auth.AppModuleBasic{}, bank.AppModuleBasic{}) | ||
numValidators := 1 | ||
numFullNodes := 0 | ||
client, network := tastoradocker.DockerSetup(t) | ||
|
||
cfg := tastoradocker.Config{ | ||
Logger: zaptest.NewLogger(t), | ||
DockerClient: client, | ||
DockerNetworkID: network, | ||
ChainConfig: &tastoradocker.ChainConfig{ | ||
ConfigFileOverrides: map[string]any{ | ||
"config/app.toml": appOverrides(), | ||
"config/config.toml": configOverrides(), | ||
}, | ||
Type: "celestia", | ||
Name: "celestia", | ||
Version: "v4.0.0-rc6", | ||
NumValidators: &numValidators, | ||
NumFullNodes: &numFullNodes, | ||
ChainID: testChainID, | ||
Images: []tastoradocker.DockerImage{ | ||
{ | ||
Repository: "ghcr.io/celestiaorg/celestia-app", | ||
Version: "v4.0.0-rc6", | ||
UIDGID: "10001:10001", | ||
}, | ||
}, | ||
Bin: "celestia-appd", | ||
Bech32Prefix: "celestia", | ||
Denom: "utia", | ||
CoinType: "118", | ||
GasPrices: "0.025utia", | ||
GasAdjustment: 1.3, | ||
EncodingConfig: &encConfig, | ||
AdditionalStartArgs: []string{ | ||
"--force-no-bbr", | ||
"--grpc.enable", | ||
"--grpc.address", | ||
"0.0.0.0:9090", | ||
"--rpc.grpc_laddr=tcp://0.0.0.0:9098", | ||
"--timeout-commit", "1s", | ||
}, | ||
}, | ||
DataAvailabilityNetworkConfig: &tastoradocker.DataAvailabilityNetworkConfig{ | ||
BridgeNodeCount: 1, | ||
Image: tastoradocker.DockerImage{ | ||
Repository: "ghcr.io/celestiaorg/celestia-node", | ||
Version: "pr-4283", | ||
Comment on lines
+104
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. has a fix which enables the signer type access wallets funded after initialization |
||
UIDGID: "10001:10001", | ||
}, | ||
}, | ||
RollkitChainConfig: &tastoradocker.RollkitChainConfig{ | ||
ChainID: "rollkit-test", | ||
Bin: "testapp", | ||
AggregatorPassphrase: "12345678", | ||
NumNodes: 1, | ||
Image: getRollkitImage(), | ||
}, | ||
} | ||
|
||
for _, opt := range opts { | ||
opt(&cfg) | ||
} | ||
|
||
return tastoradocker.NewProvider(cfg, t) | ||
} | ||
|
||
// getGenesisHash returns the genesis hash of the given chain node. | ||
func (s *DockerTestSuite) getGenesisHash(ctx context.Context) string { | ||
node := s.celestia.GetNodes()[0] | ||
c, err := node.GetRPCClient() | ||
s.Require().NoError(err, "failed to get node client") | ||
|
||
first := int64(1) | ||
block, err := c.Block(ctx, &first) | ||
s.Require().NoError(err, "failed to get block") | ||
|
||
genesisHash := block.Block.Header.Hash().String() | ||
s.Require().NotEmpty(genesisHash, "genesis hash is empty") | ||
return genesisHash | ||
} | ||
|
||
// SetupDockerResources creates a new provider and chain using the given configuration options. | ||
// none of the resources are started. | ||
func (s *DockerTestSuite) SetupDockerResources(opts ...ConfigOption) { | ||
s.provider = s.CreateDockerProvider(opts...) | ||
s.celestia = s.CreateChain() | ||
s.daNetwork = s.CreateDANetwork() | ||
s.rollkitChain = s.CreateRollkitChain() | ||
} | ||
|
||
// CreateChain creates a chain using the provider. | ||
func (s *DockerTestSuite) CreateChain() tastoratypes.Chain { | ||
ctx := context.Background() | ||
|
||
chain, err := s.provider.GetChain(ctx) | ||
s.Require().NoError(err) | ||
|
||
return chain | ||
} | ||
|
||
// CreateDANetwork creates a DA network using the provider | ||
func (s *DockerTestSuite) CreateDANetwork() tastoratypes.DataAvailabilityNetwork { | ||
ctx := context.Background() | ||
|
||
daNetwork, err := s.provider.GetDataAvailabilityNetwork(ctx) | ||
s.Require().NoError(err) | ||
|
||
return daNetwork | ||
} | ||
|
||
// CreateRollkitChain creates a Rollkit chain using the provider | ||
func (s *DockerTestSuite) CreateRollkitChain() tastoratypes.RollkitChain { | ||
ctx := context.Background() | ||
|
||
rollkitChain, err := s.provider.GetRollkitChain(ctx) | ||
s.Require().NoError(err) | ||
|
||
return rollkitChain | ||
} | ||
|
||
// StartBridgeNode initializes and starts a bridge node within the data availability network using the given parameters. | ||
func (s *DockerTestSuite) StartBridgeNode(ctx context.Context, bridgeNode tastoratypes.DANode, chainID string, genesisHash string, celestiaNodeHostname string) { | ||
s.Require().Equal(tastoratypes.BridgeNode, bridgeNode.GetType()) | ||
err := bridgeNode.Start(ctx, | ||
tastoratypes.WithChainID(chainID), | ||
tastoratypes.WithAdditionalStartArguments("--p2p.network", chainID, "--core.ip", celestiaNodeHostname, "--rpc.addr", "0.0.0.0"), | ||
tastoratypes.WithEnvironmentVariables( | ||
map[string]string{ | ||
"CELESTIA_CUSTOM": tastoratypes.BuildCelestiaCustomEnvVar(chainID, genesisHash, ""), | ||
"P2P_NETWORK": chainID, | ||
}, | ||
), | ||
) | ||
s.Require().NoError(err) | ||
} | ||
|
||
// FundWallet transfers the specified amount of utia from the faucet wallet to the target wallet. | ||
func (s *DockerTestSuite) FundWallet(ctx context.Context, wallet tastoratypes.Wallet, amount int64) { | ||
fromAddress, err := sdkacc.AddressFromWallet(s.celestia.GetFaucetWallet()) | ||
s.Require().NoError(err) | ||
|
||
toAddress, err := sdk.AccAddressFromBech32(wallet.GetFormattedAddress()) | ||
s.Require().NoError(err) | ||
|
||
bankSend := banktypes.NewMsgSend(fromAddress, toAddress, sdk.NewCoins(sdk.NewCoin("utia", math.NewInt(amount)))) | ||
_, err = s.celestia.BroadcastMessages(ctx, s.celestia.GetFaucetWallet(), bankSend) | ||
s.Require().NoError(err) | ||
} | ||
|
||
// StartRollkitNode initializes and starts a Rollkit node. | ||
func (s *DockerTestSuite) StartRollkitNode(ctx context.Context, bridgeNode tastoratypes.DANode, rollkitNode tastoratypes.RollkitNode) { | ||
err := rollkitNode.Init(ctx) | ||
s.Require().NoError(err) | ||
|
||
bridgeNodeHostName, err := bridgeNode.GetInternalHostName() | ||
s.Require().NoError(err) | ||
|
||
authToken, err := bridgeNode.GetAuthToken() | ||
s.Require().NoError(err) | ||
|
||
daAddress := fmt.Sprintf("http://%s:26658", bridgeNodeHostName) | ||
err = rollkitNode.Start(ctx, | ||
tac0turtle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"--rollkit.da.address", daAddress, | ||
"--rollkit.da.gas_price", "0.025", | ||
"--rollkit.da.auth_token", authToken, | ||
"--rollkit.rpc.address", "0.0.0.0:7331", // bind to 0.0.0.0 so rpc is reachable from test host. | ||
"--rollkit.da.namespace", generateValidNamespaceHex(), | ||
) | ||
s.Require().NoError(err) | ||
} | ||
|
||
// getRollkitImage returns the Docker image configuration for Rollkit | ||
// Uses ROLLKIT_IMAGE_REPO and ROLLKIT_IMAGE_TAG environment variables if set | ||
func getRollkitImage() tastoradocker.DockerImage { | ||
repo := strings.TrimSpace(os.Getenv("ROLLKIT_IMAGE_REPO")) | ||
if repo == "" { | ||
repo = "ghcr.io/rollkit/rollkit" | ||
} | ||
|
||
tag := strings.TrimSpace(os.Getenv("ROLLKIT_IMAGE_TAG")) | ||
if tag == "" { | ||
tag = "latest" | ||
} | ||
|
||
return tastoradocker.DockerImage{ | ||
Repository: repo, | ||
Version: tag, | ||
UIDGID: "10001:10001", | ||
} | ||
} | ||
|
||
func generateValidNamespaceHex() string { | ||
return hex.EncodeToString(share.RandomBlobNamespaceID()) | ||
} | ||
|
||
// appOverrides enables indexing of transactions so Broadcasting of transactions works | ||
func appOverrides() toml.Toml { | ||
return toml.Toml{ | ||
"tx-index": toml.Toml{ | ||
"indexer": "kv", | ||
}, | ||
} | ||
} | ||
|
||
// configOverrides enables indexing of transactions so Broadcasting of transactions works | ||
func configOverrides() toml.Toml { | ||
return toml.Toml{ | ||
"tx_index": toml.Toml{ | ||
"indexer": "kv", | ||
}, | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.