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

Fix verify challenge smart contract #1850

Merged
merged 11 commits into from
Jan 25, 2023
Merged

Fix verify challenge smart contract #1850

merged 11 commits into from
Jan 25, 2023

Conversation

peterlimg
Copy link
Member

@peterlimg peterlimg commented Nov 30, 2022

Fixes

Changes

  • Verify challenge validator tickets clientIDs and public keys- Checking scam duplication tickets
  • Change to mark challenge as pass only when successed tickets > threshold, i.e required challenge.TotalValidators/2
  • Improve verify challenge process flow to load data from MPT only when needed

TODO

  • Fix system tests
  • Add unit tests

Need to be mentioned in CHANGELOG.md?

Tests

Tasks to complete before merging PR:

  • Ensure system tests are passing. If not Run them manually to check for any regressions 📋
  • Do any new system tests need added to test this change? do any existing system tests need updated? If so create a PR at 0chain/system_test
  • Merge your system tests PR to master AFTER merging this PR

Associated PRs (Link as appropriate):

  • blobber:
  • gosdk:
  • system_test:
  • zboxcli:
  • zwalletcli:
  • Other: ...

@codecov-commenter
Copy link

codecov-commenter commented Nov 30, 2022

Codecov Report

Merging #1850 (b23843e) into staging (8f57e35) will increase coverage by 0.13%.
The diff coverage is 61.42%.

@@             Coverage Diff             @@
##           staging    #1850      +/-   ##
===========================================
+ Coverage    26.43%   26.57%   +0.13%     
===========================================
  Files          370      370              
  Lines        61261    61364     +103     
===========================================
+ Hits         16192    16305     +113     
+ Misses       43145    43116      -29     
- Partials      1924     1943      +19     
Flag Coverage Δ
Unit-Tests 26.57% <61.42%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../go/0chain.net/core/encryption/signature_scheme.go 90.32% <0.00%> (-9.68%) ⬇️
...de/go/0chain.net/smartcontract/storagesc/models.go 55.22% <18.18%> (-0.53%) ⬇️
...go/0chain.net/smartcontract/storagesc/challenge.go 38.13% <70.00%> (+1.28%) ⬆️
code/go/0chain.net/core/datastore/worker.go 97.26% <0.00%> (-2.74%) ⬇️
code/go/0chain.net/chaincore/node/n2n_send.go 31.68% <0.00%> (-0.45%) ⬇️
...chain.net/smartcontract/minersc/benchmark_setup.go 1.19% <0.00%> (-0.03%) ⬇️
...ode/go/0chain.net/smartcontract/dbs/event/event.go 0.00% <0.00%> (ø)
...e/go/0chain.net/smartcontract/dbs/event/process.go 2.33% <0.00%> (ø)
...e/go/0chain.net/smartcontract/dbs/event/rewards.go 0.00% <0.00%> (ø)
.../0chain.net/smartcontract/minersc/miner_eventdb.go 0.00% <0.00%> (ø)
... and 13 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

peterlimg and others added 4 commits December 13, 2022 11:57
Set current round on StartNextRound before adding the VRF to lock the current round. Otherwise, we will miss one future VRF, and if that's the last ticket to meet threshold, we will have to wait soft round timeout.

- on round 100, receive future VRF for round 101, cache it
- start next round (still on round 100 at the moment), create VRF for round 101, and broadcast it to others
- add the created VRF to local meanwhile checking if there are cached future VRF, and process it. So now, we have 2 tickets
- received another ticket, but since the current round is still on 100, we will cache it instead of processing it.
- set current round to 101 when start next round process is finished.
- wait soft round time out to re do the VRF process

So if in StartNextRound method, we set current round to 101 before creating local VRF, the last ticket will not be treated as future ticket and we will process it immediately, and meet the threshold
Copy link
Member

@dabasov dabasov left a comment

Choose a reason for hiding this comment

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

lgtm

@peterlimg peterlimg merged commit 268a9ec into staging Jan 25, 2023
@peterlimg peterlimg deleted the fix/verify-challenge branch January 25, 2023 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants