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

Vault Staking Implementation #103

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Vault Staking Implementation #103

wants to merge 14 commits into from

Conversation

apptreeso
Copy link
Contributor

@apptreeso apptreeso commented May 17, 2022

close #93
close #105

@apptreeso apptreeso self-assigned this May 17, 2022
@apptreeso apptreeso requested a review from gupadhyaya May 17, 2022 00:23
@gupadhyaya gupadhyaya requested a review from hashmesan May 18, 2022 20:01
@hashmesan
Copy link

hashmesan commented May 25, 2022

Code looks good to me.

Some tests are failing though..

32 tests passed
5 tests failing

> truffle test
Using network 'test'.


Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.

Warning: Potentially unsafe deployment of OneBtc

    You are using the `unsafeAllow.external-library-linking` flag to include external libraries.
    Make sure you have manually checked that the linked libraries are upgrade safe.

OneBtc deployed at  0xdE2dcA4714440F1F701aFC8465FD81d16E3Eb3Ed
VaultReserve deployed at  0x625eAB31B67F0b70cB7e2eF0F8F5783C50A0fdc0
VaultReward deployed at  0xF8267E6d5A0216Cb996E4af770495323266Df105


  Contract: Collateral unit test
    ✓ init totalCollateral is zero
    ✓ Error on lockCollateral with 0 amount (68ms)
    ✓ LockCollateral with 1 Gwei amount (52ms)
    ✓ after lock: totalCollateral equal 1 Gwei
    ✓ after lock: freeCollateral equal 1 Gwei
    ✓ ReleaseCollateral 0.5 Gwei (72ms)
    ✓ after release: totalCollateral equal 0.5 Gwei
    ✓ after release: freeCollateral equal 0.5 Gwei
    ✓ SlashCollateral 0.2 Gwei to new account (62ms)
    ✓ after slash: totalCollateral equal 0.3 Gwei
    ✓ after slash: 1Vault freeCollateral equal 0.3 Gwei

  Contract: ExchangeRateOracle unit test
    ✓ setExchangeRate, getExchangeRate (161ms)
    ✓ collateralToWrapped (49ms)
    ✓ wrappedToCollateral (47ms)

  Contract: Issue unit test
    1) "before all" hook for "Error on requestIssue with the insufficient griefing collateral"

  Contract: BitcoinKeyDerivation:On-Chain Key Derivation Scheme
    ✓ key derivate (86669ms)

  Contract: issue/redeem test
    2) "before all" hook for "vault register test"

  Contract: Redeem unit test
    3) "before all" hook for "Register Vault with 10 ONE Collateral"

  Contract: Replace unit test
    4) "before all" hook for "Register OLD Vault with 10 Wei Collateral"

  Contract: transaction parse test
    ✓ extractTx and validateTxout (235ms)
    ✓ validateTxout with wrong requestId (190ms)
    ✓ validateTxout with less amount (159ms)
    ✓ validateTxout with more amount (170ms)
    ✓ validateTxout with wrong receiver (167ms)
    ✓ validateTxout without requestId (274ms)

  Contract: VaultRegistry unit test
    5) "before all" hook for "register new vault"

  Contract: VaultReward unit test
Warning: Potentially unsafe deployment of OneBtc

    You are using the `unsafeAllow.external-library-linking` flag to include external libraries.
    Make sure you have manually checked that the linked libraries are upgrade safe.

    ✓ initialize VaultReward with OneBtc address
    ✓ extendVaultLockPeriod (123ms)
    ✓ Error on withdrawal if the vault lock period is not expired (58ms)
    ✓ Errer on extendVaultLockPeriod with mismatched msg.sender (67ms)
    ✓ Errer on extendVaultLockPeriod with invalid lock period (71ms)
    ✓ updateVaultAccClaimableRewards on the second extendVaultLockPeriod (202ms)
    ✓ getClaimableRewards (120ms)
    ✓ updateVaultAccClaimableRewards on collateral change (391ms)
    ✓ claimRewards (255ms)
    ✓ claimRewardsAndLock (427ms)
    ✓ withdraw if the vault lock period is expired (149ms)


  32 passing (2m)
  5 failing

  1) Contract: Issue unit test
       "before all" hook for "Error on requestIssue with the insufficient griefing collateral":
     Error: Contract `OneBtc` is not upgrade safe

*: Linking external libraries like `VaultRegistryLib` is not yet supported
    Use libraries with internal functions only, or skip this check with the `unsafeAllowLinkedLibraries` flag 
    if you have manually checked that the libraries are upgrade safe
    https://zpl.in/upgrades/error-006
      at assertUpgradeSafe (node_modules/@openzeppelin/upgrades-core/src/validate/query.ts:19:11)
      at deployImpl (node_modules/@openzeppelin/truffle-upgrades/src/utils/deploy-impl.ts:104:20)
      at deployProxyImpl (node_modules/@openzeppelin/truffle-upgrades/src/utils/deploy-impl.ts:70:10)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
      at deployProxy (node_modules/@openzeppelin/truffle-upgrades/src/deploy-proxy.ts:42:26)
      at Context.<anonymous> (test/Issue.test.js:34:19)

  2) Contract: issue/redeem test
       "before all" hook for "vault register test":
     Error: Contract `OneBtc` is not upgrade safe

*: Linking external libraries like `VaultRegistryLib` is not yet supported
    Use libraries with internal functions only, or skip this check with the `unsafeAllowLinkedLibraries` flag 
    if you have manually checked that the libraries are upgrade safe
    https://zpl.in/upgrades/error-006
      at assertUpgradeSafe (node_modules/@openzeppelin/upgrades-core/src/validate/query.ts:19:11)
      at deployImpl (node_modules/@openzeppelin/truffle-upgrades/src/utils/deploy-impl.ts:104:20)
      at deployProxyImpl (node_modules/@openzeppelin/truffle-upgrades/src/utils/deploy-impl.ts:70:10)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
      at deployProxy (node_modules/@openzeppelin/truffle-upgrades/src/deploy-proxy.ts:42:26)
      at Context.<anonymous> (test/OneBTC.test.js:34:23)

  3) Contract: Redeem unit test
       "before all" hook for "Register Vault with 10 ONE Collateral":
     Error: Contract `OneBtc` is not upgrade safe

*: Linking external libraries like `VaultRegistryLib` is not yet supported
    Use libraries with internal functions only, or skip this check with the `unsafeAllowLinkedLibraries` flag 
    if you have manually checked that the libraries are upgrade safe
    https://zpl.in/upgrades/error-006
      at assertUpgradeSafe (node_modules/@openzeppelin/upgrades-core/src/validate/query.ts:19:11)
      at deployImpl (node_modules/@openzeppelin/truffle-upgrades/src/utils/deploy-impl.ts:104:20)
      at deployProxyImpl (node_modules/@openzeppelin/truffle-upgrades/src/utils/deploy-impl.ts:70:10)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
      at deployProxy (node_modules/@openzeppelin/truffle-upgrades/src/deploy-proxy.ts:42:26)
      at Context.<anonymous> (test/Redeem.test.js:34:19)

  4) Contract: Replace unit test
       "before all" hook for "Register OLD Vault with 10 Wei Collateral":
     Error: Contract `OneBtc` is not upgrade safe

*: Linking external libraries like `VaultRegistryLib` is not yet supported
    Use libraries with internal functions only, or skip this check with the `unsafeAllowLinkedLibraries` flag 
    if you have manually checked that the libraries are upgrade safe
    https://zpl.in/upgrades/error-006
      at assertUpgradeSafe (node_modules/@openzeppelin/upgrades-core/src/validate/query.ts:19:11)
      at deployImpl (node_modules/@openzeppelin/truffle-upgrades/src/utils/deploy-impl.ts:104:20)
      at deployProxyImpl (node_modules/@openzeppelin/truffle-upgrades/src/utils/deploy-impl.ts:70:10)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
      at deployProxy (node_modules/@openzeppelin/truffle-upgrades/src/deploy-proxy.ts:42:26)
      at Context.<anonymous> (test/Replace.js:34:19)

  5) Contract: VaultRegistry unit test
       "before all" hook for "register new vault":
     Error: VaultRegistryTestWrapper contains unresolved libraries. You must deploy and link the following libraries before you can deploy a new version of VaultRegistryTestWrapper: VaultRegistryLib
      at Context.<anonymous> (test/VaultRegistry.js:23:60)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)

@gupadhyaya gupadhyaya requested a review from potvik May 30, 2022 18:20
@hashmesan
Copy link

I fixed it on my branch.. The old tests are missing the VaultReward, and VaultReserve. I have a deployHelper that takes care of the complex deployment : https://github.com/harmony-one/onebtc/pull/101/files#diff-c221a15fc85b042945076d4e178f7b02c4a228c27cc26359950c1153b6e624b1

@apptreeso apptreeso marked this pull request as ready for review June 9, 2022 15:47
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.

Staking unit tests and bug fixing staking for increase collateral
2 participants