Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayashsatolia403 committed Aug 27, 2023
1 parent 142e822 commit c24d52b
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 149 deletions.
64 changes: 33 additions & 31 deletions .github/workflows/tokenomics_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,39 @@ jobs:
echo "REPO_SNAPSHOTS_BRANCH=$(echo $(([ -z '${{github.event.inputs.repo_snapshots_branch}}' ] && echo '<CURRENT BRANCH WITH FALLBACK TO CURRENT_SPRINT>') || echo '${{github.event.inputs.repo_snapshots_branch}}'))" >> $GITHUB_ENV
- name: "Deploy 0Chain"
if: github.event_name == 'push' || github.event.inputs.existing_network == ''
uses: 0chain/actions/deploy-0chain@feature/tokenomics_suite
with:
repo_snapshots_branch: current-sprint
kube_config: ${{ secrets[format('DEV{0}KC', env.RUNNER_NUMBER)] }}
teardown_condition: "TESTS_PASSED"
SUBGRAPH_API_URL: ${{ secrets.SUBGRAPH_API_URL }}
TENDERLY_FORK_ID: ${{ secrets.TENDERLY_FORK_ID }}
graphnode_sc: ${{ secrets.GRAPHNODE_SC }}
graphnode_network: ${{ secrets.GRAPHNODE_NETWORK }}
graphnode_ethereum_node_url: https://rpc.tenderly.co/fork/${{ secrets.TENDERLY_FORK_ID }}
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}

- name: "Run Challenge Timings System tests"
uses: 0chain/actions/run-system-tests@feature/tokenomics_suite
with:
repo_snapshots_branch: current-sprint
system_tests_branch: ${{ env.CURRENT_BRANCH }}
network: ${{ env.NETWORK_URL }}
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}
deploy_report_page: true
archive_results: true
run_flaky_tests: false
run_api_system_tests: false
run_cli_system_tests: false
run_tokenomics_system_tests: true
tokenomics_test_filter: ${{ env.TOKENOMICS_CHALLENGE_TIMINGS_TESTS }}
TENDERLY_FORK_ID: ${{ secrets.TENDERLY_FORK_ID }}
run_smoke_tests: ${{ inputs.run_smoke_tests }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}

- name: "Deploy 0Chain"
if: github.event_name == 'push' || github.event.inputs.existing_network == ''
uses: 0chain/actions/deploy-0chain-2b2v@feature/tokenomics_suite
Expand Down Expand Up @@ -244,38 +277,7 @@ jobs:
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}

- name: "Deploy 0Chain"
if: github.event_name == 'push' || github.event.inputs.existing_network == ''
uses: 0chain/actions/deploy-0chain@feature/tokenomics_suite
with:
repo_snapshots_branch: current-sprint
kube_config: ${{ secrets[format('DEV{0}KC', env.RUNNER_NUMBER)] }}
teardown_condition: "TESTS_PASSED"
SUBGRAPH_API_URL: ${{ secrets.SUBGRAPH_API_URL }}
TENDERLY_FORK_ID: ${{ secrets.TENDERLY_FORK_ID }}
graphnode_sc: ${{ secrets.GRAPHNODE_SC }}
graphnode_network: ${{ secrets.GRAPHNODE_NETWORK }}
graphnode_ethereum_node_url: https://rpc.tenderly.co/fork/${{ secrets.TENDERLY_FORK_ID }}
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}

- name: "Run Challenge Timings System tests"
uses: 0chain/actions/run-system-tests@feature/tokenomics_suite
with:
repo_snapshots_branch: current-sprint
system_tests_branch: ${{ env.CURRENT_BRANCH }}
network: ${{ env.NETWORK_URL }}
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}
deploy_report_page: true
archive_results: true
run_flaky_tests: false
run_api_system_tests: false
run_cli_system_tests: false
run_tokenomics_system_tests: true
tokenomics_test_filter: ${{ env.TOKENOMICS_CHALLENGE_TIMINGS_TESTS }}
TENDERLY_FORK_ID: ${{ secrets.TENDERLY_FORK_ID }}
run_smoke_tests: ${{ inputs.run_smoke_tests }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}


- name: "Set PR status as ${{ job.status }}"
Expand Down
240 changes: 122 additions & 118 deletions tests/tokenomics_tests/challenge_timings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,127 @@ func TestChallengeTimings(testSetup *testing.T) {
require.Nil(t, err, "Error unmarshalling validator list", strings.Join(output, "\n"))
require.True(t, len(validatorList) > 0, "No validators found in validator list")

t.RunWithTimeout("Case 4: 10 1gb allocation, 100mb each", (500*time.Minute)+(40*time.Second), func(t *test.SystemTest) {
output, err = utils.UpdateStorageSCConfig(t, scOwnerWallet, map[string]string{
"time_unit": "20m",
}, true)
require.Nil(t, err, strings.Join(output, "\n"))

var allocationIDs []string

output, err := utils.CreateWallet(t, configPath)
require.Nil(t, err, "Error registering wallet", strings.Join(output, "\n"))

// range of 10 allocations
for i := 0; i < 10; i++ {
// 1. Create an allocation with 1 data shard and 1 parity shard.
allocationId := utils.SetupAllocationAndReadLock(t, configPath, map[string]interface{}{
"size": 1 * GB,
"tokens": 99,
"data": 1,
"parity": 1,
})

allocationIDs = append(allocationIDs, allocationId)

// Uploading 10% of allocation

remotepath := "/dir/"
filesize := 100 * MB
filename := utils.GenerateRandomTestFileName(t)

err = utils.CreateFileWithSize(filename, int64(filesize))
require.Nil(t, err)

output, err = utils.UploadFile(t, configPath, map[string]interface{}{
// fetch the latest block in the chain
"allocation": allocationId,
"remotepath": remotepath + filepath.Base(filename),
"localpath": filename,
}, true)
require.Nil(t, err, fmt.Sprintf("error uploading file %s", allocationId), strings.Join(output, "\n"))
}

time.Sleep(1 * time.Minute)

result := getChallengeTimings(t, blobberList, allocationIDs)

proofGenTimes := result[0]
txnSubmissions := result[1]
txnVerifications := result[2]

t.Log("proofGenTimes", proofGenTimes)
t.Log("txnSubmissions", txnSubmissions)
t.Log("txnVerifications", txnVerifications)

proofGenTime := result[0]
txnVerificationTime := result[2]

require.True(t, proofGenTime < 350000, "It is taking more than 320000 milliseconds to generate proof")
require.True(t, txnVerificationTime < 15000, "It is taking more than 10000 milliseconds to verify txn")
require.True(t, false, "It is taking more than 10000 milliseconds to verify txn")
})

t.RunWithTimeout("Case 5: 10 10gb allocation, 1gb each", (500*time.Minute)+(40*time.Second), func(t *test.SystemTest) {
output, err = utils.UpdateStorageSCConfig(t, scOwnerWallet, map[string]string{
"time_unit": "20m",
}, true)
require.Nil(t, err, strings.Join(output, "\n"))

var allocationIDs []string

output, err := utils.CreateWallet(t, configPath)
require.Nil(t, err, "Error registering wallet", strings.Join(output, "\n"))

_, err = utils.ExecuteFaucetWithTokens(t, configPath, 99)
require.Nil(t, err, "Error executing faucet with tokens", strings.Join(output, "\n"))

// range of 10 allocations
for i := 0; i < 10; i++ {
// 1. Create an allocation with 1 data shard and 1 parity shard.
allocationId := utils.SetupAllocationAndReadLock(t, configPath, map[string]interface{}{
"size": 10 * GB,
"tokens": 99,
"data": 1,
"parity": 1,
})
allocationIDs = append(allocationIDs, allocationId)

// Uploading 10% of allocation
remotepath := "/dir/"
filesize := 1 * GB
filename := "extra : " + utils.GenerateRandomTestFileName(t)

err = utils.CreateFileWithSize(filename, int64(filesize))
require.Nil(t, err)
output, err = utils.UploadFile(t, configPath, map[string]interface{}{
// fetch the latest block in the chain
"allocation": allocationId,
"remotepath": remotepath + filepath.Base(filename),
"localpath": filename,
}, true)
require.Nil(t, err, fmt.Sprintf("error uploading file %s", allocationId), strings.Join(output, "\n"))
}

time.Sleep(1 * time.Minute)

result := getChallengeTimings(t, blobberList, allocationIDs)
proofGenTimes := result[0]
txnSubmissions := result[1]
txnVerifications := result[2]

t.Log("proofGenTimes", proofGenTimes)
t.Log("txnSubmissions", txnSubmissions)
t.Log("txnVerifications", txnVerifications)

proofGenTime := result[0]
txnVerificationTime := result[2]
require.True(t, proofGenTime < 4200000, "It is taking more than 4000000 milliseconds to generate proof")
require.True(t, txnVerificationTime < 30000, "It is taking more than 30000 milliseconds to verify txn")

require.True(t, false, "It is taking more than 30000 milliseconds to verify txn")
})

t.RunWithTimeout("Case 1: 1 10mb allocation, 1mb each", (500*time.Minute)+(40*time.Second), func(t *test.SystemTest) {
output, err := utils.CreateWallet(t, configPath)
require.Nil(t, err, "Error registering wallet", strings.Join(output, "\n"))
Expand Down Expand Up @@ -195,123 +316,6 @@ func TestChallengeTimings(testSetup *testing.T) {
require.True(t, txnVerificationTime < 10000, "It is taking more than 10000 milliseconds to verify txn")
})

Check failure on line 318 in tests/tokenomics_tests/challenge_timings_test.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary trailing newline (whitespace)
t.RunWithTimeout("Case 4: 10 1gb allocation, 100mb each", (500*time.Minute)+(40*time.Second), func(t *test.SystemTest) {
output, err = utils.UpdateStorageSCConfig(t, scOwnerWallet, map[string]string{
"time_unit": "20m",
}, true)
require.Nil(t, err, strings.Join(output, "\n"))

var allocationIDs []string

output, err := utils.CreateWallet(t, configPath)
require.Nil(t, err, "Error registering wallet", strings.Join(output, "\n"))

// range of 10 allocations
for i := 0; i < 10; i++ {
// 1. Create an allocation with 1 data shard and 1 parity shard.
allocationId := utils.SetupAllocationAndReadLock(t, configPath, map[string]interface{}{
"size": 1 * GB,
"tokens": 99,
"data": 1,
"parity": 1,
})

allocationIDs = append(allocationIDs, allocationId)

// Uploading 10% of allocation

remotepath := "/dir/"
filesize := 100 * MB
filename := utils.GenerateRandomTestFileName(t)

err = utils.CreateFileWithSize(filename, int64(filesize))
require.Nil(t, err)

output, err = utils.UploadFile(t, configPath, map[string]interface{}{
// fetch the latest block in the chain
"allocation": allocationId,
"remotepath": remotepath + filepath.Base(filename),
"localpath": filename,
}, true)
require.Nil(t, err, fmt.Sprintf("error uploading file %s", allocationId), strings.Join(output, "\n"))
}

time.Sleep(1 * time.Minute)

result := getChallengeTimings(t, blobberList, allocationIDs)

proofGenTimes := result[0]
txnSubmissions := result[1]
txnVerifications := result[2]

t.Log("proofGenTimes", proofGenTimes)
t.Log("txnSubmissions", txnSubmissions)
t.Log("txnVerifications", txnVerifications)

proofGenTime := result[0]
txnVerificationTime := result[2]

require.True(t, proofGenTime < 350000, "It is taking more than 320000 milliseconds to generate proof")
require.True(t, txnVerificationTime < 15000, "It is taking more than 10000 milliseconds to verify txn")
})

t.RunWithTimeout("Case 5: 10 10gb allocation, 1gb each", (500*time.Minute)+(40*time.Second), func(t *test.SystemTest) {
output, err = utils.UpdateStorageSCConfig(t, scOwnerWallet, map[string]string{
"time_unit": "20m",
}, true)
require.Nil(t, err, strings.Join(output, "\n"))

var allocationIDs []string

output, err := utils.CreateWallet(t, configPath)
require.Nil(t, err, "Error registering wallet", strings.Join(output, "\n"))

_, err = utils.ExecuteFaucetWithTokens(t, configPath, 99)
require.Nil(t, err, "Error executing faucet with tokens", strings.Join(output, "\n"))

// range of 10 allocations
for i := 0; i < 10; i++ {
// 1. Create an allocation with 1 data shard and 1 parity shard.
allocationId := utils.SetupAllocationAndReadLock(t, configPath, map[string]interface{}{
"size": 10 * GB,
"tokens": 99,
"data": 1,
"parity": 1,
})
allocationIDs = append(allocationIDs, allocationId)

// Uploading 10% of allocation
remotepath := "/dir/"
filesize := 1 * GB
filename := "extra : " + utils.GenerateRandomTestFileName(t)

err = utils.CreateFileWithSize(filename, int64(filesize))
require.Nil(t, err)
output, err = utils.UploadFile(t, configPath, map[string]interface{}{
// fetch the latest block in the chain
"allocation": allocationId,
"remotepath": remotepath + filepath.Base(filename),
"localpath": filename,
}, true)
require.Nil(t, err, fmt.Sprintf("error uploading file %s", allocationId), strings.Join(output, "\n"))
}

time.Sleep(1 * time.Minute)

result := getChallengeTimings(t, blobberList, allocationIDs)
proofGenTimes := result[0]
txnSubmissions := result[1]
txnVerifications := result[2]

t.Log("proofGenTimes", proofGenTimes)
t.Log("txnSubmissions", txnSubmissions)
t.Log("txnVerifications", txnVerifications)

proofGenTime := result[0]
txnVerificationTime := result[2]
require.True(t, proofGenTime < 4200000, "It is taking more than 4000000 milliseconds to generate proof")
require.True(t, txnVerificationTime < 30000, "It is taking more than 30000 milliseconds to verify txn")
})
}
func getChallengeTimings(t *test.SystemTest, blobbers []climodel.BlobberInfo, allocationIDs []string) []int64 {
blobberUrls := make([]string, len(blobbers))
Expand Down Expand Up @@ -351,7 +355,7 @@ func getChallengeTimings(t *test.SystemTest, blobbers []climodel.BlobberInfo, al
continue // Skip this iteration and move to the next blobber
}

proofGenTimes = append(proofGenTimes, challengeTiming.ProofGenTime*1000) // proof gen time in milliseconds
proofGenTimes = append(proofGenTimes, challengeTiming.ProofGenTime) // proof gen time in milliseconds

// Calculate the time difference in milliseconds
txnSubmission := challengeTiming.TxnSubmission.ToTime().Sub(challengeTiming.CreatedAtBlobber.ToTime()).Milliseconds()
Expand Down

0 comments on commit c24d52b

Please sign in to comment.