/oracles-contract

Oracles contracts

MIT LicenseMIT

Ethereum Oracles smart contract

Ethereum Oracles smart contract to manage notaries in Oracles PoA

Common Oracles contract features checklist

Description Status
1 Initial key is generated only by contract owner good
2 Initial key generation isn't possible after it's generation limit (12) is reached good
3 Initial key has no authority to be a notary good
4 Initial key is invalidated immediately after mining/payout/voting keys are created good
5 Mining/payout/voting keys generation is possible only with valid initial key good
6 Mining/payout/voting keys can be changed by owner anytime good
7 Ballot management is accessed only with valid voting key good
8 Ballot creation isn't possible, if limit of licenses distribution (52) is reached good
9 Ballot creation to add notary isn't possible, if notary is already added to PoA good
10 Ballot creation to add/remove notary isn't possible, if notary was removed from PoA before good
11 Voting is accessed only with valid voting key good
12 Voter is able to vote for the same ballot only once good
13 Voting is prohibited after ballot's expiration good
14 Ballot is successfully finished, if total amount of voters >= 3 good
15 If ballot is successfully finished, removing or adding of notary is started only if amount of votes for > amount of votes against good

Known Ethereum contracts attack vectors checklist

Attack vector Description Status
1 Race Conditions The order of transactions themselves (within a block) is easily subject to manipulation good
1.a Reentrancy Functions can be called repeatedly, before the first invocation of the function was finished good
1.b Cross-function Race Conditions A similar attack using two different functions that share the same state good
1.c Pitfalls in Race Condition Solutions Avoiding of calling functions which call external functions good
2 Timestamp Dependence Timestamp of the block can be manipulated by the miner
3 Integer Overflow and Underflow Usage of unlimited increments can cause such issue good
4 DoS with (Unexpected) Throw Unexpected throw is reached with some contract method for any user, because of malicious user called it before with bad parameters good
5 DoS with Block Gas Limit Block gas limit can be reached, for example, with looping through an array with unknown size and sending send() in a single transaction. Sending should be divided to multiple transactions good

Compiling of Oracles contract

Install dapp cli

  1. git clone https://github.com/oraclesorg/oracles-contract // clone repository

  2. cd oracles-contract/ // move to folder with project

  3. git submodule update --init --recursive // get submodules data

  4. dapp build // compiling of contracts to ./out

Expected result:

./out/Oracles.bin - bytecode of Oracles contract

./out/Oracles.abi - binary interface of Oracles contract

Oracles contract definition

function

addBallot 54453c32

Adds new Ballot

inputs 0 uint256 ballotID

Ballot unique ID

inputs 1 address miningKey

Mining key of notary which is proposed to add or remove

inputs 2 bool addAction

Flag: adding is true, removing is false

inputs 3 string memo

Ballot's memo

function

addInitialKey aff63d5e

Adds initial key

inputs 0 address key

Initial key

function

addValidator 0aeee835

Adds new notary

inputs 0 address miningKey

Notary's mining key

inputs 1 uint256 zip

Notary's zip code

inputs 2 uint256 licenseID

Notary's license ID

inputs 3 uint256 licenseExpiredAt

Notary's expiration date

inputs 4 string fullName

Notary's full name

inputs 5 string streetName

Notary's address

inputs 6 string state

Notary's US state full name

function, constant

ballotCreatedAt b045d117

Gets ballot's creation time

inputs 0 uint256 ballotID

Ballot unique ID

outputs 0 uint256 value

Ballot's creation time

function, constant

ballotIsActive 75f358cc

Checks, if ballot is active

inputs 0 uint256 ballotID

Ballot unique ID

outputs 0 bool value

Ballot's activity: active or not

function, constant

ballotIsVoted 6f2dc1c1

Checks, if ballot is already voted by signer of current transaction

inputs 0 uint256 ballotID

Ballot unique ID

outputs 0 bool value

Ballot is already voted by signer of current transaction: yes or no

function, constant

ballots 5c632b38

inputs 0 uint256
outputs 0 uint256
function, constant

ballotsMapping 32d21d00

inputs 0 uint256
outputs 0 address owner
outputs 1 address miningKey
outputs 2 string memo
outputs 3 uint256 createdAt
outputs 4 uint256 votingStart
outputs 5 uint256 votingDeadline
outputs 6 int256 votesAmmount
outputs 7 int256 result
outputs 8 bool addAction
outputs 9 bool active
function

changeMiningKey 13340668

Changes mining key

inputs 0 address miningKey

Current mining key

inputs 1 address miningKeyNew

New mining key

function

changePayoutKey 181fa47a

Changes payout key

inputs 0 address payoutKey

Current payout key

inputs 1 address payoutKeyNew

New payout key

function

changeVotingKey 51d714a8

Changes voting key

inputs 0 address votingKey

Current voting key

inputs 1 address votingKeyNew

New voting key

function, constant

checkInitialKey 31567174

Checks, if initial key is new or not

inputs 0 address key

Initial key

outputs 0 bool value

Is initial key new or not new

function, constant

checkPayoutKeyValidity dfecd974

Checks, if payout key is active or not

inputs 0 address addr

Payout key

outputs 0 bool value

Is payout key active or not active

function, constant

checkVotingKeyValidity f40d9985

Checks, if voting key is active or not

inputs 0 address addr

Voting key

outputs 0 bool value

Is voting key active or not active

function

createKeys c6232a15

Create production keys for notary

inputs 0 address miningAddr

Mining key

inputs 1 address payoutAddr

Payout key

inputs 2 address votingAddr

Voting key

function, constant

disabledValidators 820e4a24

inputs 0 uint256
outputs 0 address
function, constant

getBallotAction a7666dad

Gets ballot's action

inputs 0 uint256 ballotID

Ballot unique ID

outputs 0 bool value

Ballot's action: adding is true, removing is false

function, constant

getBallotMemo 11fc7f97

Gets ballot's memo

inputs 0 uint256 ballotID

Ballot unique ID

outputs 0 string value

Ballot's memo

function, constant

getBallotMiningKey a88ccf6e

Gets mining key of notary

inputs 0 uint256 ballotID

Ballot unique ID

outputs 0 address value

Mining key of notary

function, constant

getBallotOwner 8334add4

Gets ballot's owner full name

inputs 0 uint256 ballotID

Ballot unique ID

outputs 0 string value

Ballot's owner full name

function, constant

getBallotVotingEnd a59c3408

Gets ballot's voting end date

inputs 0 uint256 ballotID

Ballot unique ID

outputs 0 uint256 value

Ballot's voting end date

function, constant

getBallotVotingStart 2abf367f

Gets ballot's voting start date

inputs 0 uint256 ballotID

Ballot unique ID

outputs 0 uint256 value

Ballot's voting start date

function, constant

getBallots eb87c6dc

Gets active ballots' ids

outputs 0 uint256[] value

Array of active ballots ids

function, constant

getDisabledValidators 3b41c359

Gets disabled notaries addresses

outputs 0 address[] value

Array of disabled notaries addresses

function, constant

getValidatorDisablingDate 83e51bc7

Gets notary's disabling date

inputs 0 address addr

Notary's mining key

outputs 0 uint256 value

Notary's disabling date

function, constant

getValidatorFullName 2c48fd0d

Gets notary's full name

inputs 0 address addr

Notary's mining key

outputs 0 string value

Notary's full name

function, constant

getValidatorLicenseExpiredAt 7d87283a

Gets notary's license expiration date

inputs 0 address addr

Notary's mining key

outputs 0 uint256 value

Notary's license expiration date

function, constant

getValidatorLicenseID 7d667120

Gets notary's license ID

inputs 0 address addr

Notary's mining key

outputs 0 uint256 value

Notary's license ID

function, constant

getValidatorState 5b7d6c36

Gets notary's state full name

inputs 0 address addr

Notary's mining key

outputs 0 string value

Notary's state full name

function, constant

getValidatorStreetName 5f5f43fe

Gets notary's address

inputs 0 address addr

Notary's mining key

outputs 0 string value

Notary's address

function, constant

getValidatorZip e00d1876

Gets notary's zip code

inputs 0 address addr

Notary's mining key

outputs 0 uint256 value

Notary's zip code

function, constant

getValidators b7ab4db5

Gets active notaries addresses

outputs 0 address[] value

Array of active notaries addresses

function, constant

getVotesAgainst b6f61f66

Gets ballot's amount of votes against

inputs 0 uint256 ballotID

Ballot unique ID

outputs 0 int256 value

Ballot's amount of votes against

function, constant

getVotesFor d40b65eb

Gets ballot's amount of votes for

inputs 0 uint256 ballotID

Ballot unique ID

outputs 0 int256 value

Ballot's amount of votes for

function, constant

initialKeys 6bbcdfcd

inputs 0 address
outputs 0 bool isNew
function, constant

miningKeys 20106959

inputs 0 address
outputs 0 bool isActive
function, constant

owner 8da5cb5b

outputs 0 address
function, constant

payoutKeys 40d0f012

inputs 0 address
outputs 0 bool isActive
function, constant

validator 223b3b7a

inputs 0 address
outputs 0 string fullName
outputs 1 string streetName
outputs 2 string state
outputs 3 uint256 zip
outputs 4 uint256 licenseID
outputs 5 uint256 licenseExpiredAt
outputs 6 uint256 disablingDate
outputs 7 string disablingTX
function, constant

validators 35aa2e44

inputs 0 uint256
outputs 0 address
function

vote c9d27afe

Votes

inputs 0 uint256 ballotID

Ballot unique ID

inputs 1 bool accept

Vote for is true, vote against is false

function, constant

votingKeys cbebcbbc

inputs 0 address
outputs 0 bool isActive
function, constant

votingLowerLimit f65fb8ab

outputs 0 uint256