Skip to content
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

Chain Upgrade Test #163

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
251590c
created upgrade test folder
hannydevelop Aug 22, 2022
0d25ff9
logic for keys creation completed
hannydevelop Aug 24, 2022
3275203
orchestrator file containing instanceName ready
hannydevelop Aug 24, 2022
e65bd35
validator file ready
hannydevelop Aug 24, 2022
27451f5
completed genesis file
hannydevelop Aug 25, 2022
4c3b612
chain.go file ready
hannydevelop Aug 25, 2022
0ecc1c4
setup complete
hannydevelop Aug 25, 2022
b367bdb
chain spinup test successful
hannydevelop Aug 28, 2022
968db1c
test run works
hannydevelop Aug 29, 2022
dcce050
ran golint
hannydevelop Aug 29, 2022
1cc9f31
added SommChainUpgrade to CI
hannydevelop Aug 29, 2022
ab261eb
removed nolint:unparam from upgrade_test
hannydevelop Aug 29, 2022
b760e3b
changed golangci-lint version
hannydevelop Aug 29, 2022
dc541ee
changed package name
hannydevelop Aug 29, 2022
ded2cbc
upgrade test works theoretically
hannydevelop Sep 3, 2022
bd93714
upgrade suite secluded to run v3.1.1
hannydevelop Sep 4, 2022
7ee9737
worked on github job, test should pass
hannydevelop Sep 4, 2022
b916669
updated integration_tests yml and make file
hannydevelop Sep 4, 2022
acd993a
fixed 4.0.1 binary
hannydevelop Sep 5, 2022
8f2bfb3
changed version of sommelier to upgrade
hannydevelop Sep 5, 2022
41c6a43
added somm image to make file
hannydevelop Sep 5, 2022
62a476a
sending to somm cellarfee address to avoid remove module error
hannydevelop Sep 7, 2022
5298b61
chain upgrade for sommelier ready for review
hannydevelop Sep 7, 2022
e80f083
merged main
hannydevelop Nov 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 77 additions & 11 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ on:
branches:
- main
tags:
- 'v*.*.*'
- "v*.*.*"
pull_request:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
ORCHESTRATOR_IMAGE_NAME: ghcr.io/peggyjv/gravity-bridge-orchestrator:main
ETHEREUM_IMAGE: ghcr.io/peggyjv/sommelier-hardhat:v3.1.0
SOMMELIER_IMAGE: ghcr.io/peggyjv/sommelier-sommelier:v3.1.0
ORCHESTRATOR_IMAGE: ghcr.io/peggyjv/gravity-bridge-orchestrator:v0.3.8

jobs:
sommelier-build:
Expand Down Expand Up @@ -109,20 +112,17 @@ jobs:
integration-tests:
environment: CI
runs-on: [self-hosted, linux]
needs: [ sommelier-build, hardhat-build ]
needs: [sommelier-build, hardhat-build]
strategy:
fail-fast: false
matrix:
test_type: [
"Cork",
"ScheduledCork",
]
test_type: ["Cork", "ScheduledCork"]
steps:
# Not needed on self hosted test runner that already has go installed
# - name: Set up Go 1.16
# uses: actions/setup-go@v2
# with:
# go-version: ^1.16
# Not needed on self hosted test runner that already has go installed
# - name: Set up Go 1.16
# uses: actions/setup-go@v2
# with:
# go-version: ^1.16
- name: checkout
uses: actions/checkout@v2
- name: go-cache
Expand Down Expand Up @@ -170,3 +170,69 @@ jobs:
run: ./integration_tests/integration_tests.test -test.failfast -test.v -test.run IntegrationTestSuite -testify.m Test${{ matrix.test_type }}
env:
ARCHIVE_NODE_URL: ${{ secrets.ARCHIVE_NODE_URL }}

upgrade-tests:
environment: CI
runs-on: [self-hosted, linux]
needs: [sommelier-build, hardhat-build]
strategy:
fail-fast: false
matrix:
test_type: ["SommChainUpgrade"]
steps:
# Not needed on self hosted test runner that already has go installed
# - name: Set up Go 1.16
# uses: actions/setup-go@v2
# with:
# go-version: ^1.16
- name: checkout
uses: actions/checkout@v2
- name: go-cache
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: container-login
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: docker sommelier metadata
id: meta-sommelier
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-sommelier
- name: docker hardhat metadata
id: meta-hardhat
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-hardhat
- name: pull sommelier upgrade image
run: docker pull ${{ steps.meta-sommelier.outputs.tags }}
- name: rename sommelier image
run: docker tag ${{ steps.meta-sommelier.outputs.tags }} sommelier:4.0.1
- name: pull hardhat image
run: docker pull ${{ env.ETHEREUM_IMAGE }}
- name: rename hardhat image
run: docker tag ${{ env.ETHEREUM_IMAGE }} ethereum:3.1.0
- name: pull orchestrator image
run: docker pull ${{ env.ORCHESTRATOR_IMAGE }}
- name: rename orchestrator image
run: docker tag ${{ env.ORCHESTRATOR_IMAGE }} orchestrator:3.1.0
- name: pull sommelier 3.1.0 image
run: docker pull ${{ env.SOMMELIER_IMAGE }}
- name: rename sommelier 3.1.0 image
run: docker tag ${{ env.SOMMELIER_IMAGE }} sommelier:3.1.0
- name: clean the slate
run: make e2e_clean_upgrade_slate
- name: build go test binary
run: cd upgrade_tests && go test -c
- name: Run end to end test
run: ./upgrade_tests/upgrade_tests.test -test.failfast -test.v -test.run UpgradeTestSuite -testify.m Test${{ matrix.test_type }}
env:
ARCHIVE_NODE_URL: ${{ secrets.ARCHIVE_NODE_URL }}
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: golangci/golangci-lint-action@master
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.37
version: v1.49
args: --timeout 10m
github-token: ${{ secrets.github_token }}
if: env.GIT_DIFF
55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,58 @@ fail:
@docker logs orchestrator2 > testlogs/orchestrator2.log 2>&1 || true
@docker logs orchestrator3 > testlogs/orchestrator3.log 2>&1 || true
@false


#####################
# Upgrade test #
#####################

ORCHESTRATOR_IMAGE := "ghcr.io/peggyjv/gravity-bridge-orchestrator:v0.3.8"
SOMMELIER_IMAGE := "ghcr.io/peggyjv/sommelier-sommelier:v3.1.0"
ETHEREUM_IMAGE := "ghcr.io/peggyjv/sommelier-hardhat:v3.1.0"
SOMM_IMAGE := hannydevelop/sommelier:4.0.1

e2e_build_upgrade_images: e2e_clean_slate
@docker pull $(ORCHESTRATOR_IMAGE)
@docker tag $(ORCHESTRATOR_IMAGE) orchestrator:3.1.0
@docker build -t sommelier:4.0.1 -f Dockerfile .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think you meant to use the SOMM_IMAGE (line 410) var here? Something like "SOMM4_IMAGE" may help disambiguate it from SOMMELIER_IMAGE

Copy link
Contributor Author

@hannydevelop hannydevelop Sep 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that, line 410 isn't necessary, I'm removing that in the next commit. As you can see, it's not used here, or anywhere.

@docker pull $(ORCHESTRATOR_IMAGE)
	@docker tag $(ORCHESTRATOR_IMAGE) orchestrator:3.1.0
	@docker build -t sommelier:4.0.1 -f Dockerfile .
	@docker pull $(ETHEREUM_IMAGE)
	@docker tag $(ETHEREUM_IMAGE) ethereum:3.1.0
	@docker pull $(SOMMELIER_IMAGE)
	@docker tag $(SOMMELIER_IMAGE) sommelier:3.1.0

I was using it to debug

@docker pull $(ETHEREUM_IMAGE)
@docker tag $(ETHEREUM_IMAGE) ethereum:3.1.0
@docker pull $(SOMMELIER_IMAGE)
@docker tag $(SOMMELIER_IMAGE) sommelier:3.1.0
e2e_clean_upgrade_slate:
@docker rm --force \
$(shell docker ps -qa --filter="name=ethereum") \
$(shell docker ps -qa --filter="name=sommelier") \
$(shell docker ps -qa --filter="name=orchestrator") \
1>/dev/null \
2>/dev/null \
|| true
@docker wait \
$(shell docker ps -qa --filter="name=ethereum") \
$(shell docker ps -qa --filter="name=sommelier") \
$(shell docker ps -qa --filter="name=orchestrator") \
1>/dev/null \
2>/dev/null \
|| true
@docker network prune --force 1>/dev/null 2>/dev/null || true
@cd upgrade_tests && go test -c

e2e_test_chain: e2e_clean_upgrade_slate
@upgrade_tests/upgrade_tests.test -test.run TestChain -test.failfast -test.v || make -s fail

e2e_upgrade: e2e_clean_upgrade_slate
@E2E_SKIP_CLEANUP=true upgrade_tests/upgrade_tests.test -test.failfast -test.v -test.run UpgradeTestSuite -testify.m TestSommChainUpgrade || make -s fail

fail:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overwrites another task named fail in the integration tests section, resulting in these logs when running the new e2e commands:

Makefile:445: warning: overriding commands for target `fail'
Makefile:390: warning: ignoring old commands for target `fail'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!!

@echo 'test failed; dumping container logs into ./testlogs for review'
@docker logs ethereum > testlogs/ethereum.log 2>&1 || true
@docker logs sommelier0 > testlogs/sommelier0.log 2>&1 || true
@docker logs sommelier1 > testlogs/sommelier1.log 2>&1 || true
@docker logs sommelier2 > testlogs/sommelier2.log 2>&1 || true
@docker logs sommelier3 > testlogs/sommelier3.log 2>&1 || true
@docker logs orchestrator0 > testlogs/orchestrator0.log 2>&1 || true
@docker logs orchestrator1 > testlogs/orchestrator1.log 2>&1 || true
@docker logs orchestrator2 > testlogs/orchestrator2.log 2>&1 || true
@docker logs orchestrator3 > testlogs/orchestrator3.log 2>&1 || true
@false
3 changes: 2 additions & 1 deletion app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ func (app *SommelierApp) ExportAppStateAndValidators(

// prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated
// in favour of export at a block height
//
// in favour of export at a block height
func (app *SommelierApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
applyAllowedAddrs := false

Expand Down
6 changes: 3 additions & 3 deletions integration_tests/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (c *chain) configDir() string {
return fmt.Sprintf("%s/%s", c.dataDir, c.id)
}

func (c *chain) createAndInitValidators(count int) error { // nolint:unused
func (c *chain) createAndInitValidators(count int) error { //nolint:unused
for i := 0; i < count; i++ {
node := c.createValidator(i)

Expand Down Expand Up @@ -144,7 +144,7 @@ func (c *chain) createAndInitValidatorsWithMnemonics(mnemonics []string) error {
return nil
}

func (c *chain) createAndInitOrchestrators(count int) error { // nolint:unused
func (c *chain) createAndInitOrchestrators(count int) error { //nolint:unused
mnemonics := make([]string, count)
for i := 0; i < count; i++ {
mnemonic, err := createMnemonic()
Expand Down Expand Up @@ -194,7 +194,7 @@ func (c *chain) createOrchestrator(index int) *orchestrator {
}
}

func (c *chain) clientContext(nodeURI string, kb *keyring.Keyring, fromName string, fromAddr sdk.AccAddress) (*client.Context, error) { // nolint:unparam
func (c *chain) clientContext(nodeURI string, kb *keyring.Keyring, fromName string, fromAddr sdk.AccAddress) (*client.Context, error) { //nolint:unparam
amino := codec.NewLegacyAmino()
interfaceRegistry := sdkTypes.NewInterfaceRegistry()
interfaceRegistry.RegisterImplementations((*sdk.Msg)(nil),
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func getGenDoc(path string) (*tmtypes.GenesisDoc, error) {
return doc, nil
}

func addGenesisAccount(path, moniker, amountStr string, accAddr sdk.AccAddress) error { // nolint:unparam
func addGenesisAccount(path, moniker, amountStr string, accAddr sdk.AccAddress) error { //nolint:unparam
serverCtx := server.NewDefaultContext()
config := serverCtx.Config

Expand Down
2 changes: 1 addition & 1 deletion integration_tests/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
hdwallet "github.com/miguelmota/go-ethereum-hdwallet"
)

func createMnemonic() (string, error) { // nolint:unused
func createMnemonic() (string, error) { //nolint:unused
entropySeed, err := bip39.NewEntropy(256)
if err != nil {
return "", err
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (s *IntegrationTestSuite) TearDownSuite() {
s.Require().NoError(s.dockerPool.RemoveNetwork(s.dockerNetwork))
}

func (s *IntegrationTestSuite) initNodes(nodeCount int) { // nolint:unused
func (s *IntegrationTestSuite) initNodes(nodeCount int) { //nolint:unused
s.Require().NoError(s.chain.createAndInitValidators(nodeCount))
s.Require().NoError(s.chain.createAndInitOrchestrators(nodeCount))

Expand Down Expand Up @@ -196,7 +196,7 @@ func (s *IntegrationTestSuite) initNodesWithMnemonics(mnemonics ...string) {
}
}

func (s *IntegrationTestSuite) initEthereum() { // nolint:unused
func (s *IntegrationTestSuite) initEthereum() { //nolint:unused
// generate ethereum keys for validators add them to the ethereum genesis
ethGenesis := EthereumGenesis{
Difficulty: "0x400",
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (v *validator) createKeyFromMnemonic(name, mnemonic string, passphrase stri
return nil
}

func (v *validator) createKey(name string) error { // nolint:unused
func (v *validator) createKey(name string) error { //nolint:unused
mnemonic, err := createMnemonic()
if err != nil {
return err
Expand All @@ -176,7 +176,7 @@ func (v *validator) createKey(name string) error { // nolint:unused
return v.createKeyFromMnemonic(name, mnemonic, "")
}

func (v *validator) generateEthereumKey() error { // nolint:unused
func (v *validator) generateEthereumKey() error { //nolint:unused
privateKey, err := crypto.GenerateKey()
if err != nil {
return err
Expand Down
10 changes: 10 additions & 0 deletions upgrade_tests/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
I couldn't find a way to spin up the chain, using their version number. I've initated an upgrade module, containing the `go.mod` and `go.sum` files. Here's how this suite works:

- Seclude suite to conform previous chain version.
- Run upgrade to current version.
- Interact with upgraded version to ensure upgrade was successful.

## Usage For Testing New Upgrades
- Change Sommelier and Gravity versions in `go.mod`.
- Work on suite setup files to reflect changes in Sommelier and Gravity.
- Build docker image of the upgrade version.
Loading