Skip to content

Commit 5673330

Browse files
committed
Prepare truffle environment
1 parent a652785 commit 5673330

8 files changed

+2829
-0
lines changed

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.js]
12+
indent_size = 2

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
build
3+
mochawesome-report
4+
coverage
5+
coverageEnv
6+
scTopics
7+
.DS_Store
8+
coverage.json

contracts/Migrations.sol

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
pragma solidity ^0.4.23;
2+
3+
contract Migrations {
4+
address public owner;
5+
uint public last_completed_migration;
6+
7+
constructor() public {
8+
owner = msg.sender;
9+
}
10+
11+
modifier restricted() {
12+
if (msg.sender == owner) _;
13+
}
14+
15+
function setCompleted(uint completed) public restricted {
16+
last_completed_migration = completed;
17+
}
18+
19+
function upgrade(address new_address) public restricted {
20+
Migrations upgraded = Migrations(new_address);
21+
upgraded.setCompleted(last_completed_migration);
22+
}
23+
}

contracts/ValidatorSet.sol

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
pragma solidity ^0.4.25;
2+
3+
4+
contract ReportingValidatorSet {
5+
struct ValidatorState {
6+
uint256 index; // index in the currentValidators
7+
bool isValidator; // is this a validator
8+
}
9+
10+
address[] internal currentValidators;
11+
mapping(address => ValidatorState) public validatorsState;
12+
13+
event InitiateChange(bytes32 indexed parentHash, address[] newSet);
14+
15+
modifier onlySystem() {
16+
require(msg.sender == 0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE);
17+
_;
18+
}
19+
20+
modifier onlyValidator() {
21+
require(validatorsState[msg.sender].isValidator);
22+
_;
23+
}
24+
25+
constructor() public {
26+
currentValidators.push(address(0x6546ed725e88fa728a908f9ee9d61f50edc40ad6));
27+
currentValidators.push(address(0x1a22d96792666863f429a85623e6d4ca173d26ab));
28+
currentValidators.push(address(0x4579c2a15651609ec44a5fadeaabfc30943b5949));
29+
}
30+
31+
function finalizeChange() public onlySystem {
32+
}
33+
34+
function reportBenign(address _validator, uint256 _blockNumber)
35+
public
36+
onlyValidator
37+
{
38+
}
39+
40+
function reportMalicious(address _validator, uint256 _blockNumber, bytes _proof)
41+
public
42+
onlyValidator
43+
{
44+
}
45+
46+
function getValidators() public view returns(address[]) {
47+
return currentValidators;
48+
}
49+
}

migrations/1_initial_migration.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var Migrations = artifacts.require("./Migrations.sol");
2+
3+
module.exports = function(deployer) {
4+
deployer.deploy(Migrations);
5+
};

0 commit comments

Comments
 (0)