Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
racytech committed May 7, 2024
2 parents 05f1a96 + 2e99954 commit bbedb40
Show file tree
Hide file tree
Showing 27 changed files with 336 additions and 206 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/qa-clean-exit-block-downloading.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ name: QA - Clean exit (block downloading)
on:
push:
branches:
- 'release/**'
- main
- 'release/3.*'
pull_request:
branches:
- main
- 'release/**'
- 'release/3.*'
types:
- ready_for_review
workflow_dispatch: # Run manually

jobs:
long-running-test:
runs-on: self-hosted
runs-on: [self-hosted, Erigon3]
env:
ERIGON_REFERENCE_DATA_DIR: /opt/erigon-versions/reference-version/datadir
ERIGON_TESTBED_DATA_DIR: /opt/erigon-testbed/datadir
Expand Down Expand Up @@ -51,14 +53,15 @@ jobs:
# Capture monitoring script exit status
test_exit_status=$?

# Save the subsection reached status
echo "::set-output name=test_executed::true"

# Clean up Erigon process if it's still running
if kill -0 $ERIGON_PID 2> /dev/null; then
echo "Terminating Erigon"
kill $ERIGON_PID
wait $ERIGON_PID
else
echo "Erigon has already terminated"
fi

# Check test runner script exit status
Expand All @@ -71,6 +74,7 @@ jobs:
fi

- name: Delete Erigon Testbed Data Directory
if: always()
run: |
rm -rf $ERIGON_TESTBED_DATA_DIR
Expand All @@ -79,13 +83,13 @@ jobs:
python3 $ERIGON_QA_PATH/test_system/db-producer/resume_production.py || true
- name: Save test results
if: always()
if: steps.test_step.outputs.test_executed == 'true'
env:
TEST_RESULT: ${{ steps.test_step.outputs.TEST_RESULT }}
run: python3 $ERIGON_QA_PATH/test_system/qa-tests/uploads/upload_test_results.py --repo erigon --commit $(git rev-parse HEAD) --test_name clean-exit-block-downloading --outcome $TEST_RESULT --result_file ${{ github.workspace }}/result.json

- name: Upload test results
if: always()
if: steps.test_step.outputs.test_executed == 'true'
uses: actions/upload-artifact@v4
with:
name: test-results
Expand Down
25 changes: 15 additions & 10 deletions .github/workflows/qa-clean-exit-snapshot-downloading.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ on:
push:
branches:
- main
- 'release/**'
- 'release/3.*'
pull_request:
branches:
- main
- 'release/**'
- 'release/3.*'
types:
- ready_for_review
workflow_dispatch: # Run manually

jobs:
long-running-test:
Expand All @@ -24,9 +25,10 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4

- name: Clean Erigon Build Directory
- name: Clean Erigon Build & Data Directories
run: |
make clean
rm -rf $ERIGON_DATA_DIR
- name: Build Erigon
run: |
Expand All @@ -48,18 +50,16 @@ jobs:
# Capture monitoring script exit status
test_exit_status=$?

# Save the subsection reached status
echo "::set-output name=test_executed::true"

# Clean up Erigon process if it's still running
if kill -0 $ERIGON_PID 2> /dev/null; then
echo "Terminating Erigon"
kill $ERIGON_PID
wait $ERIGON_PID
else
echo "Erigon has already terminated"
fi

# Clean up Erigon build and data directories
rm -rf $ERIGON_DATA_DIR

# Check test runner script exit status
if [ $test_exit_status -eq 0 ]; then
echo "Tests completed successfully"
Expand All @@ -69,18 +69,23 @@ jobs:
echo "TEST_RESULT=failure" >> "$GITHUB_OUTPUT"
fi

- name: Clean up Erigon data directory
if: always()
run: |
rm -rf $ERIGON_DATA_DIR
- name: Resume the Erigon instance dedicated to db maintenance
run: |
python3 $ERIGON_QA_PATH/test_system/db-producer/resume_production.py || true
- name: Save test results
if: always()
if: steps.test_step.outputs.test_executed == 'true'
env:
TEST_RESULT: ${{ steps.test_step.outputs.TEST_RESULT }}
run: python3 $ERIGON_QA_PATH/test_system/qa-tests/uploads/upload_test_results.py --repo erigon --commit $(git rev-parse HEAD) --test_name clean-exit-snapshot-downloading --outcome $TEST_RESULT --result_file ${{ github.workspace }}/result.json

- name: Upload test results
if: always()
if: steps.test_step.outputs.test_executed == 'true'
uses: actions/upload-artifact@v4
with:
name: test-results
Expand Down
25 changes: 15 additions & 10 deletions .github/workflows/qa-snap-download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ on:

jobs:
long-running-test:
runs-on: self-hosted
runs-on: [self-hosted, Erigon3]
timeout-minutes: 600
env:
ERIGON_DATA_DIR: ${{ github.workspace }}/erigon_data
ERIGON_QA_PATH: /home/qarunner/erigon-qa
Expand All @@ -18,9 +19,10 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4

- name: Clean Erigon Build Directory
- name: Clean Erigon Build & Data Directories
run: |
make clean
rm -rf $ERIGON_DATA_DIR
- name: Build Erigon
run: |
Expand All @@ -35,25 +37,23 @@ jobs:
id: test_step
run: |
set +e # Disable exit on error
# Run Erigon, monitor snapshot downloading and check logs
python3 $ERIGON_QA_PATH/test_system/qa-tests/snap-download/run_and_check_snap_download.py ${{ github.workspace }}/build/bin $ERIGON_DATA_DIR $TOTAL_TIME_SECONDS
# Capture monitoring script exit status
test_exit_status=$?

# Save the subsection reached status
echo "::set-output name=test_executed::true"

# Clean up Erigon process if it's still running
if kill -0 $ERIGON_PID 2> /dev/null; then
echo "Terminating Erigon"
kill $ERIGON_PID
wait $ERIGON_PID
else
echo "Erigon has already terminated"
fi

# Clean up Erigon build and data directories
rm -rf $ERIGON_DATA_DIR

# Check test runner script exit status
if [ $test_exit_status -eq 0 ]; then
echo "Tests completed successfully"
Expand All @@ -63,18 +63,23 @@ jobs:
echo "TEST_RESULT=failure" >> "$GITHUB_OUTPUT"
fi

- name: Clean up Erigon data directory
if: always()
run: |
rm -rf $ERIGON_DATA_DIR
- name: Resume the Erigon instance dedicated to db maintenance
run: |
python3 $ERIGON_QA_PATH/test_system/db-producer/resume_production.py || true
- name: Save test results
if: always()
if: steps.test_step.outputs.test_executed == 'true'
env:
TEST_RESULT: ${{ steps.test_step.outputs.TEST_RESULT }}
run: python3 $ERIGON_QA_PATH/test_system/qa-tests/uploads/upload_test_results.py --repo erigon --commit $(git rev-parse HEAD) --test_name snap-download --outcome $TEST_RESULT --result_file ${{ github.workspace }}/result.json

- name: Upload test results
if: always()
if: steps.test_step.outputs.test_executed == 'true'
uses: actions/upload-artifact@v4
with:
name: test-results
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/qa-tip-tracking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ name: QA - Tip tracking
on:
schedule:
- cron: '0 0 * * *' # Run every day at 00:00 AM UTC
workflow_dispatch: # Run manually

jobs:
long-running-test:
runs-on: self-hosted
runs-on: [self-hosted, Erigon3]
timeout-minutes: 600
env:
ERIGON_REFERENCE_DATA_DIR: /opt/erigon-versions/reference-version/datadir
ERIGON_TESTBED_DATA_DIR: /opt/erigon-testbed/datadir
Expand All @@ -29,7 +31,7 @@ jobs:

- name: Pause the Erigon instance dedicated to db maintenance
run: |
curl -X POST -H "Accept: application/json" -d '{"status": "paused"}' http://localhost:8080/production/default/status || true
python3 $ERIGON_QA_PATH/test_system/db-producer/pause_production.py || true
- name: Restore Erigon Testbed Data Directory
run: |
Expand All @@ -48,13 +50,14 @@ jobs:
# Capture monitoring script exit status
test_exit_status=$?

# Save the subsection reached status
echo "::set-output name=test_executed::true"

# Clean up Erigon process if it's still running
if kill -0 $ERIGON_PID 2> /dev/null; then
echo "Terminating Erigon"
kill $ERIGON_PID
wait $ERIGON_PID
else
echo "Erigon has already terminated"
fi

# Check test runner script exit status
Expand All @@ -67,6 +70,7 @@ jobs:
fi

- name: Delete Erigon Testbed Data Directory
if: always()
run: |
rm -rf $ERIGON_TESTBED_DATA_DIR
Expand All @@ -75,13 +79,13 @@ jobs:
python3 $ERIGON_QA_PATH/test_system/db-producer/resume_production.py || true
- name: Save test results
if: always()
if: steps.test_step.outputs.test_executed == 'true'
env:
TEST_RESULT: ${{ steps.test_step.outputs.TEST_RESULT }}
run: python3 $ERIGON_QA_PATH/test_system/qa-tests/uploads/upload_test_results.py --repo erigon --commit $(git rev-parse HEAD) --test_name tip-tracking --outcome $TEST_RESULT --result_file ${{ github.workspace }}/result.json

- name: Upload test results
if: always()
if: steps.test_step.outputs.test_executed == 'true'
uses: actions/upload-artifact@v4
with:
name: test-results
Expand Down
69 changes: 69 additions & 0 deletions accounts/abi/bind/backends/simulated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package backends
import (
"bytes"
"context"
"encoding/binary"
"errors"
"math/big"
"reflect"
Expand All @@ -38,6 +39,7 @@ import (
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/params"
"github.com/stretchr/testify/require"
)

func TestSimulatedBackend(t *testing.T) {
Expand Down Expand Up @@ -1125,3 +1127,70 @@ func TestSimulatedBackend_CallContractRevert(t *testing.T) {
sim.Commit()
}
}

func TestNewSimulatedBackend_AdjustTimeFailWithPostValidationSkip(t *testing.T) {
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
sim := simTestBackend(t, testAddr)
// Create tx and send
amount, _ := uint256.FromBig(big.NewInt(1000))
gasPrice, _ := uint256.FromBig(big.NewInt(1))
signer := types.MakeSigner(params.TestChainConfig, 1, 0)
var tx types.Transaction = types.NewTransaction(0, testAddr, amount, params.TxGas, gasPrice, nil)
signedTx, err := types.SignTx(tx, *signer, testKey)
if err != nil {
t.Errorf("could not sign tx: %v", err)
}
sim.SendTransaction(context.Background(), signedTx) //nolint:errcheck
// AdjustTime should fail on non-empty block
if err = sim.AdjustTime(time.Second); err == nil {
t.Error("Expected adjust time to error on non-empty block")
}
sim.Commit()

prevTime := sim.pendingBlock.Time()
if err = sim.AdjustTime(time.Minute); err != nil {
t.Error(err)
}
newTime := sim.pendingBlock.Time()
if newTime-prevTime != uint64(time.Minute.Seconds()) {
t.Errorf("adjusted time not equal to a minute. prev: %v, new: %v", prevTime, newTime)
}
// Put a transaction after adjusting time
amount2, _ := uint256.FromBig(big.NewInt(1000))
gasPrice2, _ := uint256.FromBig(big.NewInt(1))
var tx2 types.Transaction = types.NewTransaction(1, testAddr, amount2, params.TxGas, gasPrice2, nil)
signedTx2, err := types.SignTx(tx2, *signer, testKey)
if err != nil {
t.Errorf("could not sign tx: %v", err)
}
sim.SendTransaction(context.Background(), signedTx2) //nolint:errcheck
sim.Commit()
newTime = sim.pendingBlock.Time()
if newTime-prevTime >= uint64(time.Minute.Seconds()) {
t.Errorf("time adjusted, but shouldn't be: prev: %v, new: %v", prevTime, newTime)
}
txdb, err := sim.DB().BeginRw(sim.m.Ctx)
require.NoError(t, err)
defer txdb.Rollback()
// Set this artifically to make sure the we do skip post validation
var k [8]byte
var v [8]byte
binary.BigEndian.PutUint64(k[:], 1)
binary.BigEndian.PutUint64(v[:], 0)
require.NoError(t, txdb.Put(kv.MaxTxNum, k[:], v[:]))
require.NoError(t, txdb.Commit())
// Put a transaction after adjusting time
amount3, _ := uint256.FromBig(big.NewInt(1000))
gasPrice3, _ := uint256.FromBig(big.NewInt(1))
var tx3 types.Transaction = types.NewTransaction(2, testAddr, amount3, params.TxGas, gasPrice3, nil)
signedTx3, err := types.SignTx(tx3, *signer, testKey)
if err != nil {
t.Errorf("could not sign tx: %v", err)
}
sim.SendTransaction(context.Background(), signedTx3) //nolint:errcheck
sim.Commit()
newTime = sim.pendingBlock.Time()
if newTime-prevTime >= uint64(time.Minute.Seconds()) {
t.Errorf("time adjusted, but shouldn't be: prev: %v, new: %v", prevTime, newTime)
}
}
3 changes: 2 additions & 1 deletion cmd/downloader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import (
"time"

"github.com/ledgerwatch/erigon-lib/common/dbg"
_ "github.com/ledgerwatch/erigon/core/snaptype" //hack
_ "github.com/ledgerwatch/erigon/core/snaptype" //hack
_ "github.com/ledgerwatch/erigon/polygon/bor/snaptype" //hack

"github.com/anacrolix/torrent/metainfo"
"github.com/c2h5oh/datasize"
Expand Down
Loading

0 comments on commit bbedb40

Please sign in to comment.