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

Feat/chain simulator #289

Merged
merged 28 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ff7a36e
first integration test setup with chain simulator
sstanculeanu Feb 29, 2024
8e87a3a
fixed data races
sstanculeanu Feb 29, 2024
7600b1e
reuse code for sc call
sstanculeanu Mar 1, 2024
da545ce
added value on sc call
sstanculeanu Mar 1, 2024
8fd467e
use the same context for the entire test
sstanculeanu Mar 1, 2024
b4ccaf4
refactor the owner keys as well
sstanculeanu Mar 1, 2024
688a7c7
further sc calls, now flow is complete
sstanculeanu Mar 1, 2024
9e24783
removed allValidatorsKeys.pem from tests config
sstanculeanu Mar 1, 2024
ffb78fb
added batch as well
sstanculeanu Mar 1, 2024
27f4245
skip the test
sstanculeanu Mar 4, 2024
20afc76
check esdt balance
sstanculeanu Mar 4, 2024
33d4b1b
fixes after review
sstanculeanu Mar 4, 2024
67a8607
use proper token for esdt checks
sstanculeanu Mar 4, 2024
520463b
Merge pull request #287 from multiversx/chainsimulator_integration
sstanculeanu Mar 5, 2024
a9f6aa2
add an extra swap, mvx back to eth + update contracts
sstanculeanu Mar 5, 2024
34a3820
Merge branch 'feat/chain-simulator' into mvx_to_eth
sstanculeanu Mar 5, 2024
5d693a1
fix after review
sstanculeanu Mar 6, 2024
b865174
added missing file
sstanculeanu Mar 6, 2024
82090d2
updated aggregator.wasm
sstanculeanu Mar 11, 2024
6b4b651
Merge pull request #290 from multiversx/mvx_to_eth
dragos-rebegea Mar 11, 2024
a46173c
Merge branch 'feat/chain-simulator' into fix_data_races
sstanculeanu Mar 11, 2024
f936351
Merge pull request #288 from multiversx/fix_data_races
sstanculeanu Mar 11, 2024
5f93ba8
- integrated new libs
iulianpascalau Jun 4, 2024
49b41a2
- integrated new chain simulator through docker image
iulianpascalau Jun 5, 2024
8e4881f
- renamed workflow
iulianpascalau Jun 5, 2024
41575c7
- renamed the initial workflow
iulianpascalau Jun 5, 2024
2c68002
- added empty line
iulianpascalau Jun 5, 2024
d842b5d
Merge pull request #296 from multiversx/update-feat-chain-simulator-2…
iulianpascalau Jun 6, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
test:
name: Unit
name: Unit & Integration
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/slow-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Tests

on:
push:
branches: [ main, feat/* ]
pull_request:
branches: [ main, feat/* ]

jobs:
test:
name: Slow
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.20.7
id: go

- name: Check out code
uses: actions/checkout@v3

- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Slow tests
run: make slow-tests
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ test-coverage:
@echo "Running unit tests"
CURRENT_DIRECTORY=$(CURRENT_DIRECTORY) go test -cover -coverprofile=coverage.txt -covermode=atomic -v ${TESTS_TO_RUN}

slow-tests: clean-test
@docker compose -f docker/docker-compose.yml build
@docker compose -f docker/docker-compose.yml up & go test ./integrationTests/... -v -tags slow
@docker compose -f docker/docker-compose.yml down -v

lint-install:
ifeq (,$(wildcard test -f bin/golangci-lint))
@echo "Installing golint"
Expand Down
6 changes: 1 addition & 5 deletions clients/gasManagement/gasStation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ func TestGasStation_RetryMechanism_FailsFirstRequests(t *testing.T) {
time.Sleep(time.Millisecond * 100)
assert.True(t, gs.loopStatus.IsSet())
assert.Equal(t, -1, gs.GetLatestGasPrice())
assert.Equal(t, 1, gs.fetchRetries) // first retry
gasPrice, err := gs.GetCurrentGasPrice()
assert.Equal(t, big.NewInt(0), gasPrice)
assert.Equal(t, ErrLatestGasPricesWereNotFetched, err)
Expand All @@ -238,7 +237,6 @@ func TestGasStation_RetryMechanism_FailsFirstRequests(t *testing.T) {
time.Sleep(time.Millisecond * 100)
assert.True(t, gs.loopStatus.IsSet())
assert.Equal(t, -1, gs.GetLatestGasPrice())
assert.Equal(t, 2, gs.fetchRetries) // second retry
gasPrice, err = gs.GetCurrentGasPrice()
assert.Equal(t, big.NewInt(0), gasPrice)
assert.Equal(t, ErrLatestGasPricesWereNotFetched, err)
Expand All @@ -247,16 +245,14 @@ func TestGasStation_RetryMechanism_FailsFirstRequests(t *testing.T) {
time.Sleep(time.Millisecond * 100)
assert.True(t, gs.loopStatus.IsSet())
assert.Equal(t, -1, gs.GetLatestGasPrice())
assert.Equal(t, 3, gs.fetchRetries) // third retry
gasPrice, err = gs.GetCurrentGasPrice()
assert.Equal(t, big.NewInt(0), gasPrice)
assert.Equal(t, ErrLatestGasPricesWereNotFetched, err)

chanOk <- struct{}{} // response is now ok
time.Sleep(time.Millisecond * 100)
assert.True(t, gs.loopStatus.IsSet())
assert.Equal(t, gs.GetLatestGasPrice(), 81)
assert.Equal(t, gs.fetchRetries, 0)
assert.Equal(t, 81, gs.GetLatestGasPrice())
gasPrice, err = gs.GetCurrentGasPrice()
assert.Equal(t, big.NewInt(int64(gs.GetLatestGasPrice()*args.GasPriceMultiplier)), gasPrice)
assert.Nil(t, err)
Expand Down
4 changes: 4 additions & 0 deletions clients/multiversx/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package multiversx
import (
"context"

"github.com/multiversx/mx-chain-core-go/data/api"
"github.com/multiversx/mx-chain-core-go/data/transaction"
"github.com/multiversx/mx-sdk-go/builders"
"github.com/multiversx/mx-sdk-go/core"
Expand All @@ -18,6 +19,9 @@ type Proxy interface {
GetAccount(ctx context.Context, address core.AddressHandler) (*data.Account, error)
GetNetworkStatus(ctx context.Context, shardID uint32) (*data.NetworkStatus, error)
GetShardOfAddress(ctx context.Context, bech32Address string) (uint32, error)
GetESDTTokenData(ctx context.Context, address core.AddressHandler, tokenIdentifier string, queryOptions api.AccountQueryOptions) (*data.ESDTFungibleTokenData, error)
GetTransactionInfoWithResults(ctx context.Context, hash string) (*data.TransactionInfo, error)
ProcessTransactionStatus(ctx context.Context, hexTxHash string) (transaction.TxStatus, error)
IsInterfaceNil() bool
}

Expand Down
11 changes: 11 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3.9"

services:
multiversx:
image: multiversx/chainsimulator:v1.7.12-fix1
restart: unless-stopped
ports:
- 8085:8085
volumes:
- "../scripts:/docker/scripts"
entrypoint: "./chainsimulator"
8 changes: 4 additions & 4 deletions factory/ethMultiversXBridgeComponents.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,9 @@ func (components *ethMultiversXBridgeComponents) Start() error {
return err
}

go components.startBroadcastJoinRetriesLoop()
var ctx context.Context
ctx, components.cancelFunc = context.WithCancel(context.Background())
go components.startBroadcastJoinRetriesLoop(ctx)

return nil
}
Expand Down Expand Up @@ -772,12 +774,10 @@ func (components *ethMultiversXBridgeComponents) createAntifloodComponents(antif
return antiFloodComponents, nil
}

func (components *ethMultiversXBridgeComponents) startBroadcastJoinRetriesLoop() {
func (components *ethMultiversXBridgeComponents) startBroadcastJoinRetriesLoop(ctx context.Context) {
broadcastTimer := time.NewTimer(components.timeBeforeRepeatJoin)
defer broadcastTimer.Stop()

var ctx context.Context
ctx, components.cancelFunc = context.WithCancel(context.Background())
for {
broadcastTimer.Reset(components.timeBeforeRepeatJoin)

Expand Down
45 changes: 33 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,28 @@ require (
github.com/gin-contrib/cors v1.4.0
github.com/gin-contrib/pprof v1.4.0
github.com/gin-gonic/gin v1.9.1
github.com/multiversx/mx-chain-communication-go v1.0.12
github.com/multiversx/mx-chain-core-go v1.2.18
github.com/multiversx/mx-chain-crypto-go v1.2.9
github.com/multiversx/mx-chain-go v1.6.7
github.com/multiversx/mx-chain-logger-go v1.0.13
github.com/multiversx/mx-sdk-go v1.3.11
github.com/multiversx/mx-chain-communication-go v1.0.14
github.com/multiversx/mx-chain-core-go v1.2.20
github.com/multiversx/mx-chain-crypto-go v1.2.11
github.com/multiversx/mx-chain-go v1.7.12
github.com/multiversx/mx-chain-logger-go v1.0.14
github.com/multiversx/mx-chain-simulator-go v1.7.12
github.com/multiversx/mx-sdk-go v1.4.1
github.com/pelletier/go-toml v1.9.3
github.com/stretchr/testify v1.8.4
github.com/urfave/cli v1.22.10
)

require (
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/TwiN/go-color v1.1.0 // indirect
github.com/beevik/ntp v1.3.0 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/btcutil v1.1.3 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
Expand All @@ -42,13 +45,15 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/denisbrodbeck/machineid v1.0.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/elastic/go-elasticsearch/v7 v7.12.0 // indirect
github.com/elastic/gosigar v0.14.2 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-contrib/static v0.0.1 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
Expand All @@ -63,13 +68,16 @@ require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/gops v0.3.18 // indirect
github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru v0.6.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.2 // indirect
github.com/herumi/bls-go-binary v1.28.2 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/ipfs/boxo v0.8.1 // indirect
Expand Down Expand Up @@ -107,6 +115,7 @@ require (
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand All @@ -122,9 +131,17 @@ require (
github.com/multiformats/go-multistream v0.4.1 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/multiversx/concurrent-map v0.1.4 // indirect
github.com/multiversx/mx-chain-storage-go v1.0.14 // indirect
github.com/multiversx/mx-chain-vm-common-go v1.5.9 // indirect
github.com/onsi/ginkgo/v2 v2.9.7 // indirect
github.com/multiversx/mx-chain-es-indexer-go v1.4.21 // indirect
github.com/multiversx/mx-chain-proxy-go v1.1.48 // indirect
github.com/multiversx/mx-chain-scenario-go v1.4.3 // indirect
github.com/multiversx/mx-chain-storage-go v1.0.15 // indirect
github.com/multiversx/mx-chain-vm-common-go v1.5.12 // indirect
github.com/multiversx/mx-chain-vm-go v1.5.29 // indirect
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.67 // indirect
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.68 // indirect
github.com/multiversx/mx-chain-vm-v1_4-go v1.4.97 // indirect
github.com/multiversx/mx-components-big-int v1.0.0 // indirect
github.com/onsi/ginkgo/v2 v2.11.0 // indirect
github.com/opencontainers/runtime-spec v1.0.2 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
Expand All @@ -148,6 +165,9 @@ require (
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tidwall/gjson v1.14.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
Expand All @@ -165,16 +185,17 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.15.0 // indirect
gonum.org/v1/gonum v0.11.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
Expand Down
Loading
Loading