Git Product home page Git Product logo

oracle-contracts's Introduction

Razor network - Contracts

CircleCI Coverage Status

These are the contracts for Razor network.

Prerequisites :

npm

You'll need npm to install the required packages. To install npm , go to this link

Development

Create a .env file from .env.tpl and set the environment variables accordingly.

Running tests

Run npm run test

Test Coverage

Run npm run coverage

Test Lint

Run npm run lint

prettify code

Run npm run lint:sol:fix

Deployment

Using Docker

The easiest way to get a local hardhat instance with deployed contracts is to run a docker container. $ docker-compose up

Local Deployment using hardhat
  1. Create a copy of local environment .env.local from .env.tpl and set the environment variables accordingly
  2. Run hardhat node (npx hardhat node)
  3. Run command deploy:local
  4. Use tenderly to track local transactions: https://github.com/Tenderly/tenderly-cli#export
Polygon Mumbai Testnet Deployment
  1. Create a copy of local environment .env.mumbai from .env.tpl and set the environment variables accordingly
  2. Run command deploy:mumbai

Addresses

We are currently live on Polygon Mumbai Testnet.

Deployed contract addresses can be found here

tenderly

npx hardhat node
npm run deploy:local
npm run deploy:mumbai
npx hardhat test --network localhost          
tenderly export  --export-network hardhat 0x4c30a90c6d2370abaef047fbac5a3f2dd43a9490caae7c79ec700eee600db024

gas Prices across networks

npm run gas

oracle-contracts's People

Contributors

0xcuriousapple avatar adi44 avatar agatsoh avatar ashish10677 avatar dependabot[bot] avatar dev1644 avatar doctoc avatar gauravjain9 avatar hrishikeshio avatar oxhimanshu avatar rajkharvar avatar samag19 avatar semantic-release-bot avatar shekhar2807 avatar shrikant1212 avatar skandabhat avatar yohanelly95 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oracle-contracts's Issues

Duplicate Block proposal

When the block is being proposed for the first time, the contents of the block are pushed twice causing the number of blocks proposed to be 2 instead of 1

separate migrations

all migrations happen in second step. separate migrations over several files.

Staker can get away with increasing stake even though inactive for epochs

Consider a hypothetical example
Suppose Staker stakes in 4000 Epoch and for some reason becomes offline for 9 Epochs. Then comes online again in 4010 Epoch and then increases stake and then in the same Epoch commits and reveals. So in this way he can avoid penalty for not participating for the last 9 Epochs. This is a bug.

Issue to change variable name in StakeManager.sol contract & to check the test case in test file "StakeManager.js" for the same

Issue 1) Suppose there are 4 stakers if a staker (who is not 4th staker) is staking again for second time his unstake after & withdrawAfter must be updated but here in line 15 & 16 the unstake after & withdrawAfter of 4th staker will be updated because numstakers=4.
Issue 2) And also in file "stakemanager.js" the test case "should be able to unstake after unstake lock period" is passing because in test case "Should be able to increase stake" we are making the 1st staker to stake again (2nd time) in the same epoch so the unstake after & withdrawAfter of the 1st staker won't get updated but still the unstake after & withdrawAfter for 1st staker will be (currentEpoch+1) so in next epoch he can unstake. But if we make 1st staker to stake in next epoch the test case "should be able to unstake after unstake lock period" fails.

            function stake (uint256 epoch, uint256 amount) external checkEpoch(epoch) checkState(Constants.commit()) {
            require(stateManager.getState() != Constants.reveal(), "Incorrect state");
            require(amount >= Constants.minStake(), "staked amount is less than minimum stake required");
            require(sch.transferFrom(msg.sender, address(this), amount), "sch transfer failed");
            uint256 stakerId = stakerIds[msg.sender];
            uint256 previousStake = stakers[stakerId].stake;
            if (stakerId == 0) {
             numStakers = numStakers.add(1);
            stakers[numStakers] = Structs.Staker(numStakers, msg.sender, amount, epoch, 0, 0,
            epoch.add(Constants.unstakeLockPeriod()), 0);
            stakerId = numStakers;
            stakerIds[msg.sender] = stakerId;
             }  else {
                      stakers[stakerId].stake = stakers[stakerId].stake.add(amount);

15) stakers[numStakers].unstakeAfter = epoch.add(Constants.unstakeLockPeriod());
16) stakers[numStakers].withdrawAfter = 0;
}
emit Staked(epoch, stakerId, previousStake, stakers[stakerId].stake, now);
}

move build/ out of repo

build can be its own repo. All other razor network repos can refer to that folder.

this needs all dependent razor network repos to be modified.

Migrate from Truffle to Hardhat

There are some benefits using Hardhat instead of Truffle.

  • Speed up Solidity tests runs
  • Utilize Ethers instead of web3
  • Much better and versatile migration system
  • Rich support for good plugins like etherscan verification etc.

Test Resetdispute

while disputing if you input wrong value of the asset then you can call this function to reset the value.

ResultProxy.sol Redundant

Due to the introduction of the Delegator, there is no need for ResultProxy.sol as of now.
Neither ResultProxy.sol is deployed, neither its called by other contracts

Create issue templates

We do not have any issue templates. We need them to make issue reporting more standardised.

Dissolve Constants library, declare constants into contract if needed.

This issue is about to dissolve Constants.sol library, declare constants into the contract if needed.

This has following benefits -:

  • As constants are inlined in Solidity, we would be saving some execution cost too. When we fetch constants from Library it uses delegate call which adds up the cost of tx. (~2000 gas)
  • Almost all of the constants declared in Constnats.sol are exclusive to a single contract, it will improve code readability too.

Upgrade elliptic version to >=6.5.4

Dependabot cannot update elliptic to a non-vulnerable version

The latest possible version that can be installed is 6.5.3 because of the following conflicting dependencies:

@nomiclabs/[email protected] requires [email protected] via a transitive dependency on [email protected]
@nomiclabs/[email protected] requires [email protected] via a transitive dependency on [email protected]
[email protected] requires [email protected] via a transitive dependency on [email protected]
[email protected] requires [email protected] via [email protected]
[email protected] requires [email protected] via a transitive dependency on [email protected]

The earliest fixed version is 6.5.4.

Test unstake and withdraw

Test where staker unstakes and is made to wait for one epoch which is the unstake lock period

  1. test that before unstake lock period staker is not able to unstake
  2. test that after unstake lock period staker is able to unstake

Test where staker unstakes he is made to wait for withdraw lock period after which he able to withdraw staked amount

  1. test that before withdraw lock period staker is not able to withdraw
  2. test that after withdraw lock period staker is able to withdraw the stake amount

What is the purpose of setStakerStake() in StakeManager?

function setStakerStake(uint256 _id, uint256 _stake, string calldata _reason, uint256 _epoch) external onlyWriter {
_setStakerStake(_id, _stake, _reason, _epoch);
}
This Function is not called in any other contracts.
In comments of VoteManager, there is one call of it
So was it created for test purposes only?

Add CI to repo

We need to run tests + other things on pull requests.

Merge sch4 with master

The master branch is outdated. sch4 is the latest and most up to date branch. merge it with master.

Introduce another withdraw lock

Current we have unstake lock and withdraw lock
another lock period is required after unstake if complete, to prevent last minute hit and run attacks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.