diff --git a/components/restapi/core/node.go b/components/restapi/core/node.go index cbcf39d49..c1ff22019 100644 --- a/components/restapi/core/node.go +++ b/components/restapi/core/node.go @@ -1,6 +1,8 @@ package core -import "github.com/iotaledger/iota.go/v4/api" +import ( + "github.com/iotaledger/iota.go/v4/api" +) func info() *api.InfoResponse { return &api.InfoResponse{ diff --git a/pkg/protocol/sybilprotection/sybilprotectionv1/performance/performance.go b/pkg/protocol/sybilprotection/sybilprotectionv1/performance/performance.go index 5e19ec195..8103e5a7e 100644 --- a/pkg/protocol/sybilprotection/sybilprotectionv1/performance/performance.go +++ b/pkg/protocol/sybilprotection/sybilprotectionv1/performance/performance.go @@ -104,7 +104,7 @@ func (t *Tracker) TrackCandidateBlock(block *blocks.Block) { t.mutex.Lock() defer t.mutex.Unlock() - if block.Payload().PayloadType() != iotago.PayloadCandidacyAnnouncement { + if payload := block.Payload(); payload == nil || payload.PayloadType() != iotago.PayloadCandidacyAnnouncement { return } diff --git a/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go b/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go index 99cabf7f8..03ef4d676 100644 --- a/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go +++ b/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go @@ -113,7 +113,7 @@ func (o *SybilProtection) TrackBlock(block *blocks.Block) { return } - if block.Payload().PayloadType() != iotago.PayloadCandidacyAnnouncement { + if payload := block.Payload(); payload == nil || payload.PayloadType() != iotago.PayloadCandidacyAnnouncement { return } diff --git a/pkg/testsuite/snapshotcreator/snapshotcreator.go b/pkg/testsuite/snapshotcreator/snapshotcreator.go index a7926cd55..8b608c12b 100644 --- a/pkg/testsuite/snapshotcreator/snapshotcreator.go +++ b/pkg/testsuite/snapshotcreator/snapshotcreator.go @@ -216,6 +216,7 @@ func createGenesisOutput(api iotago.API, genesisTokenAmount iotago.BaseToken, ge return output, nil } + //nolint:nilnil // we want to return nil here return nil, nil } diff --git a/tools/docker-network/docker-compose.yml b/tools/docker-network/docker-compose.yml index b07611e53..013d01e94 100644 --- a/tools/docker-network/docker-compose.yml +++ b/tools/docker-network/docker-compose.yml @@ -38,9 +38,6 @@ services: --prometheus.goMetrics=true --prometheus.processMetrics=true --debugAPI.enabled=true - profiles: - - minimal - - full node-2-validator: image: docker-network-node-1-validator:latest @@ -275,9 +272,6 @@ services: --inx.address=node-1-validator:9029 --restAPI.bindAddress=0.0.0.0:9091 --restAPI.advertiseAddress=inx-indexer:9091 - profiles: - - minimal - - full inx-mqtt: image: iotaledger/inx-mqtt:2.0-alpha @@ -291,9 +285,6 @@ services: command: > --inx.address=node-1-validator:9029 --mqtt.websocket.bindAddress=inx-mqtt:1888 - profiles: - - minimal - - full inx-blockissuer: image: iotaledger/inx-blockissuer:1.0-alpha @@ -313,9 +304,6 @@ services: --restAPI.bindAddress=inx-blockissuer:9086 --blockIssuer.accountAddress=rms1prkursay9fs2qjmfctamd6yxg9x8r3ry47786x0mvwek4qr9xd9d5c6gkun --blockIssuer.proofOfWork.targetTrailingZeros=5 - profiles: - - minimal - - full inx-faucet: image: iotaledger/inx-faucet:2.0-alpha @@ -343,9 +331,6 @@ services: --faucet.baseTokenAmountMaxTarget=5000000000 --faucet.manaAmount=100000000 --faucet.manaAmountMinFaucet=1000000000 - profiles: - - minimal - - full inx-validator-1: image: iotaledger/inx-validator:1.0-alpha @@ -365,9 +350,6 @@ services: --validator.accountAddress=rms1pzg8cqhfxqhq7pt37y8cs4v5u4kcc48lquy2k73ehsdhf5ukhya3y5rx2w6 --validator.candidacyRetryInterval=${CANDIDACY_RETRY_INTERVAL:-10s} --validator.issueCandidacyPayload=${ISSUE_CANDIDACY_PAYLOAD_V1:-true} - profiles: - - minimal - - full inx-validator-2: image: iotaledger/inx-validator:1.0-alpha @@ -447,9 +429,6 @@ services: - "--dashboard.auth.username=${DASHBOARD_USERNAME:-admin}" - "--dashboard.auth.passwordHash=${DASHBOARD_PASSWORD:-0000000000000000000000000000000000000000000000000000000000000000}" - "--dashboard.auth.passwordSalt=${DASHBOARD_SALT:-0000000000000000000000000000000000000000000000000000000000000000}" - profiles: - - minimal - - full inx-dashboard-2: container_name: inx-dashboard-2 diff --git a/tools/docker-network/run.sh b/tools/docker-network/run.sh index cc3051aaf..54153c5b4 100755 --- a/tools/docker-network/run.sh +++ b/tools/docker-network/run.sh @@ -1,31 +1,34 @@ #!/bin/bash # Create a function to join an array of strings by a given character -function join { local IFS="$1"; shift; echo "$*"; } +function join { + local IFS="$1" + shift + echo "$*" +} # Initialize variables MONITORING=0 MINIMAL=0 # Loop over all arguments -for arg in "$@" -do - case $arg in - monitoring=*) - MONITORING="${arg#*=}" - shift - ;; - minimal=*) - MINIMAL="${arg#*=}" - shift - ;; - *) - # Unknown option - echo "Unknown argument: $arg" - echo 'Call with ./run.sh [monitoring=0|1] [minimal=0|1]' - exit 1 - ;; - esac +for arg in "$@"; do + case $arg in + monitoring=*) + MONITORING="${arg#*=}" + shift + ;; + minimal=*) + MINIMAL="${arg#*=}" + shift + ;; + *) + # Unknown option + echo "Unknown argument: $arg" + echo 'Call with ./run.sh [monitoring=0|1] [minimal=0|1]' + exit 1 + ;; + esac done export DOCKER_BUILDKIT=1 @@ -94,7 +97,6 @@ if [ $MONITORING -ne 0 ]; then fi if [ $MINIMAL -ne 0 ]; then - PROFILES+=("minimal") echo "Minimal profile active" else PROFILES+=("full") @@ -102,6 +104,7 @@ else fi export COMPOSE_PROFILES=$(join , ${PROFILES[@]}) + docker compose up echo "Clean up docker resources" diff --git a/tools/docker-network/tests/nil_payload_test.go b/tools/docker-network/tests/nil_payload_test.go new file mode 100644 index 000000000..5f0bb2270 --- /dev/null +++ b/tools/docker-network/tests/nil_payload_test.go @@ -0,0 +1,61 @@ +//go:build dockertests + +package tests + +import ( + "context" + "fmt" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/iotaledger/hive.go/lo" + "github.com/iotaledger/iota-core/pkg/testsuite/mock" + "github.com/iotaledger/iota-core/tools/docker-network/tests/dockertestframework" +) + +// Test_AccountTransitions follows the account state transition flow described in: +// 1. Create account-1. +// 2. Create account-2. +// 3. account-1 requests faucet funds then allots 1000 mana to account-2. +// 4. account-2 requests faucet funds then creates native tokens. +func Test_Payload_Nil_Test(t *testing.T) { + d := dockertestframework.NewDockerTestFramework(t, + dockertestframework.WithProtocolParametersOptions(dockertestframework.ShortSlotsAndEpochsProtocolParametersOptionsFunc()...), + ) + defer d.Stop() + + d.AddValidatorNode("V1", "docker-network-inx-validator-1-1", "http://localhost:8050", "rms1pzg8cqhfxqhq7pt37y8cs4v5u4kcc48lquy2k73ehsdhf5ukhya3y5rx2w6") + d.AddValidatorNode("V2", "docker-network-inx-validator-2-1", "http://localhost:8060", "rms1pqm4xk8e9ny5w5rxjkvtp249tfhlwvcshyr3pc0665jvp7g3hc875k538hl") + d.AddValidatorNode("V3", "docker-network-inx-validator-3-1", "http://localhost:8070", "rms1pp4wuuz0y42caz48vv876qfpmffswsvg40zz8v79sy8cp0jfxm4kunflcgt") + d.AddValidatorNode("V4", "docker-network-inx-validator-4-1", "http://localhost:8040", "rms1pr8cxs3dzu9xh4cduff4dd4cxdthpjkpwmz2244f75m0urslrsvtsshrrjw") + d.AddNode("node5", "docker-network-node-5-1", "http://localhost:8080") + + err := d.Run() + require.NoError(t, err) + + d.WaitUntilNetworkReady() + + ctx, cancel := context.WithCancel(context.Background()) + + // cancel the context when the test is done + t.Cleanup(cancel) + + // create account-1 + accounts := d.CreateAccountsFromFaucet(ctx, 2, "account-1", "account-2") + account1 := accounts[0] + account2 := accounts[1] + + // allot 1000 mana from account-1 to account-2 + fmt.Println("Allotting mana from account-1 to account-2") + d.RequestFaucetFundsAndAllotManaTo(account1.Wallet(), account2.Account(), 1000) + + // create native token + fmt.Println("Creating native token") + d.CreateNativeToken(account1.Wallet(), 5_000_000, 10_000_000_000) + + blk := lo.PanicOnErr(account1.Wallet().CreateBasicBlock(ctx, "something", mock.WithPayload(nil))) + d.SubmitBlock(ctx, blk.ProtocolBlock()) + + d.AwaitEpochFinalized() +} diff --git a/tools/docker-network/tests/run_tests.sh b/tools/docker-network/tests/run_tests.sh index d614ab092..8bbe53ba8 100755 --- a/tools/docker-network/tests/run_tests.sh +++ b/tools/docker-network/tests/run_tests.sh @@ -20,6 +20,8 @@ mkdir -p docker-network-snapshots/ # Allow 'others' to write, so a snapshot can be created via the management API from within docker containers. chmod o+w docker-network-snapshots/ +export COMPOSE_PROFILES="full" + # Allow docker compose to build and cache an image docker compose build --build-arg DOCKER_BUILD_CONTEXT=${DOCKER_BUILD_CONTEXT} --build-arg DOCKERFILE_PATH=${DOCKERFILE_PATH}