Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/smartcontractkit/chainlink
Browse files Browse the repository at this point in the history
… into chore/include-npm-install-to-evm-contracts
  • Loading branch information
GMSteuart committed Aug 12, 2020
2 parents 7b7b5b6 + 2205188 commit d2ebc92
Show file tree
Hide file tree
Showing 33 changed files with 155 additions and 141 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.8.12] - 2020-08-10

### Fixed

Added a workaround for Infura users who are seeing "error getting balance: header not found".
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.11
0.8.12
7 changes: 7 additions & 0 deletions core/services/head_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"math/big"
"sync"
"sync/atomic"
"testing"
"time"
Expand Down Expand Up @@ -401,8 +402,12 @@ func TestHeadTracker_SwitchesToLongestChain(t *testing.T) {
// This grotesque construction is the only way to do dynamic return values using
// the mock package. We need dynamic returns because we're simulating reorgs.
latestHeadByNumber := make(map[int64]*models.Head)
latestHeadByNumberMu := new(sync.Mutex)

fnCall := ethClient.On("HeaderByNumber", mock.Anything, mock.Anything)
fnCall.RunFn = func(args mock.Arguments) {
latestHeadByNumberMu.Lock()
defer latestHeadByNumberMu.Unlock()
num := args.Get(1).(*big.Int)
head, exists := latestHeadByNumber[num.Int64()]
if !exists {
Expand All @@ -412,7 +417,9 @@ func TestHeadTracker_SwitchesToLongestChain(t *testing.T) {
fnCall.ReturnArguments = mock.Arguments{head, nil}
}
for _, h := range blockHeaders {
latestHeadByNumberMu.Lock()
latestHeadByNumber[h.Number] = h
latestHeadByNumberMu.Unlock()
headers <- h
}

Expand Down
3 changes: 3 additions & 0 deletions evm-contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ NODE_ENV=true yarn truffle test

## Development

Note: Contracts in `src/dev_v0.7` are under active development and not yet stable.
Please use them for testing and development only.

```bash
# Clone Chainlink repository
$ git clone https://github.com/smartcontractkit/chainlink.git
Expand Down
2 changes: 1 addition & 1 deletion evm-contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chainlink/contracts",
"version": "0.0.8",
"version": "0.0.9",
"description": "Smart contracts and their language abstractions for chainlink",
"repository": "https://github.com/smartcontractkit/chainlink",
"author": "Chainlink devs",
Expand Down
10 changes: 10 additions & 0 deletions evm-contracts/src/v0.4/interfaces/FlagsInterface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pragma solidity >=0.4.24;

interface FlagsInterface {
function getFlag(address) external view returns (bool);
function getFlags(address[] calldata) external view returns (bool[] memory);
function raiseFlag(address) external;
function raiseFlags(address[] calldata) external;
function lowerFlags(address[] calldata) external;
function setRaisingAccessController(address) external;
}
10 changes: 10 additions & 0 deletions evm-contracts/src/v0.5/interfaces/FlagsInterface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pragma solidity >=0.5.0;

interface FlagsInterface {
function getFlag(address) external view returns (bool);
function getFlags(address[] calldata) external view returns (bool[] memory);
function raiseFlag(address) external;
function raiseFlags(address[] calldata) external;
function lowerFlags(address[] calldata) external;
function setRaisingAccessController(address) external;
}
2 changes: 1 addition & 1 deletion evm-contracts/src/v0.6/AccessControlledAggregator.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity 0.6.6;

import "./dev/FluxAggregator.sol";
import "./FluxAggregator.sol";
import "./SimpleReadAccessController.sol";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity 0.6.6;

import "../Owned.sol";
import "../interfaces/AggregatorV2V3Interface.sol";
import "./Owned.sol";
import "./interfaces/AggregatorV2V3Interface.sol";

/**
* @title A trusted proxy for updating where current answers are read from
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pragma solidity 0.6.6;

import './AggregatorValidatorInterface.sol';
import '../interfaces/FlagsInterface.sol';
import '../Owned.sol';
import './Owned.sol';
import './CheckedMath.sol';
import './interfaces/AggregatorValidatorInterface.sol';
import './interfaces/FlagsInterface.sol';

/**
* @title The Deviation Flagging Validator contract
Expand Down
2 changes: 1 addition & 1 deletion evm-contracts/src/v0.6/EACAggregatorProxy.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity 0.6.6;

import "./dev/AggregatorProxy.sol";
import "./AggregatorProxy.sol";
import "./interfaces/AccessControllerInterface.sol";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
pragma solidity 0.6.6;

import "../Median.sol";
import "../Owned.sol";
import "../SafeMath128.sol";
import "../SafeMath32.sol";
import "../SafeMath64.sol";
import "../interfaces/AggregatorV2V3Interface.sol";
import "./AggregatorValidatorInterface.sol";
import "../interfaces/LinkTokenInterface.sol";
import "../vendor/SafeMath.sol";
import "./Median.sol";
import "./Owned.sol";
import "./SafeMath128.sol";
import "./SafeMath32.sol";
import "./SafeMath64.sol";
import "./interfaces/AggregatorV2V3Interface.sol";
import "./interfaces/AggregatorValidatorInterface.sol";
import "./interfaces/LinkTokenInterface.sol";
import "./vendor/SafeMath.sol";

/**
* @title The Prepaid Aggregator contract
Expand Down
43 changes: 22 additions & 21 deletions evm-contracts/src/v0.6/VRFConsumerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,19 @@ import "./VRFRequestIDBase.sol";
* *****************************************************************************
* @dev SECURITY CONSIDERATIONS
*
* @dev To increase trust in your contract, the source of your seeds should be
* @dev hard for anyone to influence or predict. Any party who can influence
* @dev them could in principle collude with the oracle (who can instantly
* @dev compute the VRF output for any given seed) to bias the outcomes from
* @dev your contract in their favor. For instance, the block hash is a natural
* @dev choice of seed for many applications, but miners in control of a
* @dev substantial fraction of hashing power and with access to VRF outputs
* @dev could check the result of prospective block hashes as they are mined,
* @dev and decide not to publish a block if they don't like the outcome it will
* @dev lead to.
* @dev Since the ultimate input to the VRF is mixed with the block hash of the
* @dev block in which the request is made, user-provided seeds have no impact
* @dev on its economic security properties. They are only included for API
* @dev compatability with previous versions of this contract.
*
* @dev On the other hand, using block hashes as the seed makes it particularly
* @dev easy to estimate the economic cost to a miner for this kind of cheating
* @dev (namely, the block reward and transaction fees they forgo by refraining
* @dev from publishing a block.)
* @dev Since the block hash of the block which contains the requestRandomness()
* @dev call is mixed into the input to the VRF *last*, a sufficiently powerful
* @dev miner could, in principle, fork the blockchain to evict the block
* @dev containing the request, forcing the request to be included in a
* @dev different block with a different hash, and therefore a different input
* @dev to the VRF. However, such an attack would incur a substantial economic
* @dev cost. This cost scales with the number of blocks the VRF oracle waits
* @dev until it calls fulfillRandomness().
*/
abstract contract VRFConsumerBase is VRFRequestIDBase {

Expand All @@ -103,8 +101,7 @@ abstract contract VRFConsumerBase is VRFRequestIDBase {
/**
* @notice requestRandomness initiates a request for VRF output given _seed
*
* @dev The source of the seed data must be something which the oracle
* @dev cannot anticipate. See "SECURITY CONSIDERATIONS" above.
* @dev See "SECURITY CONSIDERATIONS" above for more information on _seed.
*
* @dev The fulfillRandomness method receives the output, once it's provided
* @dev by the Oracle, and verified by the vrfCoordinator.
Expand All @@ -115,9 +112,9 @@ abstract contract VRFConsumerBase is VRFRequestIDBase {
*
* @param _keyHash ID of public key against which randomness is generated
* @param _fee The amount of LINK to send with the request
* @param _seed Random seed from which output randomness is determined
* @param _seed seed mixed into the input of the VRF
*
* @return requestId which will be returned with the response to this request
* @return requestId unique ID for this request
*
* @dev The returned requestId can be used to distinguish responses to *
* @dev concurrent requests. It is passed as the first argument to
Expand All @@ -127,12 +124,16 @@ abstract contract VRFConsumerBase is VRFRequestIDBase {
public returns (bytes32 requestId)
{
LINK.transferAndCall(vrfCoordinator, _fee, abi.encode(_keyHash, _seed));
// This is the seed actually passed to the VRF in VRFCoordinator
// This is the seed passed to VRFCoordinator. The oracle will mix this with
// the hash of the block containing this request to obtain the seed/input
// which is finally passed to the VRF cryptographic machinery.
uint256 vRFSeed = makeVRFInputSeed(_keyHash, _seed, address(this), nonces[_keyHash]);
// nonces[_keyHash] must stay in sync with
// VRFCoordinator.nonces[_keyHash][this], which was incremented by the above
// successful LINK.transferAndCall (in VRFCoordinator.randomnessRequest)
nonces[_keyHash] = nonces[_keyHash].add(1);
// successful LINK.transferAndCall (in VRFCoordinator.randomnessRequest).
// This provides protection against the user repeating their input
// seed, which would result in a predictable/duplicate output.
nonces[_keyHash] = nonces[_keyHash].add(1);
return makeRequestId(_keyHash, vRFSeed);
}

Expand Down
6 changes: 3 additions & 3 deletions evm-contracts/src/v0.6/VRFCoordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ contract VRFCoordinator is VRF, VRFRequestIDBase {
uint256 nonce = nonces[_keyHash][_sender];
uint256 preSeed = makeVRFInputSeed(_keyHash, _consumerSeed, _sender, nonce);
bytes32 requestId = makeRequestId(_keyHash, preSeed);
// Cryptographically guaranteed by seed including an increasing nonce
// Cryptographically guaranteed by preSeed including an increasing nonce
assert(callbacks[requestId].callbackContract == address(0));
callbacks[requestId].callbackContract = _sender;
assert(_feePaid < 1e27); // Total LINK fits in uint96
Expand Down Expand Up @@ -180,7 +180,7 @@ contract VRFCoordinator is VRF, VRFRequestIDBase {
callback.randomnessFee);

// Forget request. Must precede callback (prevents reentrancy)
delete callbacks[requestId];
delete callbacks[requestId];
callBackWithRandomness(requestId, randomness, callback.callbackContract);

emit RandomnessRequestFulfilled(requestId, randomness);
Expand Down Expand Up @@ -209,7 +209,7 @@ contract VRFCoordinator is VRF, VRFRequestIDBase {
(bool success,) = consumerContract.call(resp);
// Avoid unused-local-variable warning. (success is only present to prevent
// a warning that the return value of consumerContract.call is unused.)
(success);
(success);
}

function getRandomnessFromProof(bytes memory _proof)
Expand Down
19 changes: 7 additions & 12 deletions evm-contracts/src/v0.6/VRFRequestIDBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@ pragma solidity ^0.6.0;
contract VRFRequestIDBase {

/**
* @notice returns the seed which is actually input to the VRF
* @notice returns the seed which is actually input to the VRF coordinator
*
* @dev To prevent repetition of VRF output due to repetition against the
* @dev user-supplied seed, that seed is combined in a hash with the a
* @dev user-specific nonce, and the address of the consuming contract.
*
* @dev Of course, crucial security guranatees would be broken by repetition
* @dev of the user-supplied seed, as all the other inputs can be anticipated
* @dev and the user-specified seed is public once the initial request is
* @dev made, so if the oracle has reason to believe that a user-specified seed
* @dev will be repeated, it may be able to anticipate its future outputs. So
* @dev it may make sense, for certain applications, for the VRF framework to
* @dev simply refuse to operate, if given a seed it's seen before.
* @dev To prevent repetition of VRF output due to repetition of the
* @dev user-supplied seed, that seed is combined in a hash with the
* @dev user-specific nonce, and the address of the consuming contract. The
* @dev risk of repetition is mostly mitigated by inclusion of a blockhash in
* @dev the final seed, but the nonce does protect against repetition in
* @dev requests which are included in a single block.
*
* @param _userSeed VRF seed input provided by user
* @param _requester Address of the requesting contract
Expand Down
2 changes: 1 addition & 1 deletion evm-contracts/src/v0.6/tests/AggregatorValidatorMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity 0.6.6;

import '../dev/AggregatorValidatorInterface.sol';
import '../interfaces/AggregatorValidatorInterface.sol';

contract AggregatorValidatorMock is AggregatorValidatorInterface {
uint256 public previousRoundId;
Expand Down
2 changes: 1 addition & 1 deletion evm-contracts/src/v0.6/tests/CheckedMathTestHelper.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.6.0;

import '../dev/CheckedMath.sol';
import '../CheckedMath.sol';

contract CheckedMathTestHelper {
using CheckedMath for int256;
Expand Down
2 changes: 1 addition & 1 deletion evm-contracts/src/v0.6/tests/FluxAggregatorTestHelper.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.6.0;

import "../dev/FluxAggregator.sol";
import "../FluxAggregator.sol";

contract FluxAggregatorTestHelper {

Expand Down
10 changes: 0 additions & 10 deletions feeds/src/assets/sponsors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ import bancor from './bancor.png'
import bullionix from './bullionix.png'
import gelato from './gelato.png'
import wom from './wom.png'

import consensuscell from './consensuscell.png'
import digitix from './digitix.png'
import ens from './ens.png'
import gamerhash from './gamerhash.png'
import lien from './lien.png'
import sandbank from './sandbank.png'

// Listing Thumbnails
Expand Down Expand Up @@ -60,12 +58,10 @@ import bancorTn from './bancor_tn.png'
import bullionixTn from './bullionix_tn.png'
import gelatoTn from './gelato_tn.png'
import womTn from './wom_tn.png'

import consensuscellTn from './consensuscell_tn.png'
import digitixTn from './digitix_tn.png'
import ensTn from './ens_tn.png'
import gamerhashTn from './gamerhash_tn.png'
import lienTn from './lien_tn.png'
import sandbankTn from './sandbank_tn.png'

export interface SponsorListItem {
Expand Down Expand Up @@ -250,12 +246,6 @@ export const sponsorList: SponsorListItem[] = [
imageLg: gamerhash,
imageTn: gamerhashTn,
},
{
name: 'Lien',
url: 'https://lien.finance',
imageLg: lien,
imageTn: lienTn,
},
{
name: 'Sandbank',
url: 'https://sandbank.io',
Expand Down
3 changes: 1 addition & 2 deletions feeds/src/components/answerHistory/HistoryGraph.d3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as d3 from 'd3'
import { ethers } from 'ethers'
import { formatAnswer } from 'contracts/utils'
import { humanizeUnixTimestamp } from 'utils'

Expand Down Expand Up @@ -224,7 +223,7 @@ export default class HistoryGraph {
.ticks(4)
.tickFormat(f =>
formatAnswer(
ethers.utils.bigNumberify(f),
f,
this.config.multiply,
this.config.decimalPlaces,
this.config.formatDecimalPlaces,
Expand Down
7 changes: 7 additions & 0 deletions feeds/src/components/create/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ const Create: React.FC<CreateProps> = ({ form, history }) => {
{getFieldDecorator('valuePrefix')(<Input placeholder="$" />)}
</Form.Item>

<Form.Item label="Contract Version">
{getFieldDecorator('contractVersion')(
<InputNumber placeholder="1" style={{ width: '100%' }} />,
)}
</Form.Item>

<Form.Item label="Heartbeat (seconds)">
{getFieldDecorator('heartbeat')(
<InputNumber placeholder="600" style={{ width: '100%' }} />,
Expand All @@ -84,6 +90,7 @@ const Create: React.FC<CreateProps> = ({ form, history }) => {
<Select placeholder="Select a Network">
<Option value={Networks.MAINNET}>Mainnet</Option>
<Option value={Networks.ROPSTEN}>Ropsten</Option>
<Option value={Networks.KOVAN}>Kovan</Option>
</Select>,
)}
</Form.Item>
Expand Down
Loading

0 comments on commit d2ebc92

Please sign in to comment.