Skip to content

Commit b778931

Browse files
committed
initial commit for artemis. resolves #88
1 parent 1453437 commit b778931

File tree

136 files changed

+1629
-273
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+1629
-273
lines changed

CLA.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ If you have any questions, you can reach us on [Gitter].
1616

1717
[Gitter]: https://gitter.im/PegaSysEng/artemis
1818
[GitHub]: https://github.com/
19-
[the current version of the CLA]: https://gist.github.com/rojotek/978b48a5e8b68836856a8961d6887992
19+
[the current version of the CLA]: https://gist.github.com/rojotek/978b48a5e8b68836856a8961d6887992

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
FROM openjdk:8-jdk
44

55
# copy application (with libraries inside)
6-
ADD build/install/pantheon /opt/pantheon/
7-
ADD integration-tests/src/test/resources/net/consensys/pantheon/tests/cluster/docker/geth/genesis.json /opt/pantheon/genesis.json
6+
ADD build/install/artemis /opt/artemis/
7+
ADD integration-tests/src/test/resources/net/consensys/artemis/tests/cluster/docker/geth/genesis.json /opt/artemis/genesis.json
88

99
# List Exposed Ports
1010
EXPOSE 8084 8545 30303 30303/udp
1111

1212
# specify default command
13-
ENTRYPOINT ["/opt/pantheon/bin/pantheon"]
13+
ENTRYPOINT ["/opt/artemis/bin/artemis"]

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
of your accepting any such warranty or additional liability.
175175

176176
END OF TERMS AND CONDITIONS
177-
g
177+
178178
APPENDIX: How to apply the Apache License to your work.
179179

180180
To apply the Apache License to your work, attach the following

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
# BeaconChain
1+
# artemis
22

33
[![Build Status](https://jenkins.pegasys.tech/job/Artemis/job/master/badge/icon)](https://jenkins.pegasys.tech/job/Artemis/job/master/)
44
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/PegasysEng/artemis/blob/master/LICENSE)
5-
[ ![Download](https://api.bintray.com/packages/consensys/pegasys-repo/artemis/images/download.svg) ](https://bintray.com/consensys/pegasys-repo/artemis/_latestVersion)
65
[![Gitter chat](https://badges.gitter.im/PegaSysEng/artemis.png)](https://gitter.im/PegaSysEng/artemis)
76

87
Implementation of the Ethereum 2.0 Beacon Chain.
98

10-
Based on the (evolving) [specification](https://notes.ethereum.org/SCIg8AH5SA-O4C1G1LYZHQ?view).
9+
Based on the (evolving) [specification](https://github.com/ethereum/eth2.0-specs/blob/master/specs/core/0_beacon-chain.md).
1110

1211
## Build Instructions
1312

1413
To build, clone this repo and run with `gradle` like so:
1514

1615
```
17-
git clone --recursive https://github.com/ConsenSys/BeaconChain
18-
cd beaconchain
19-
gradle
16+
git clone --recursive https://github.com/PegaSysEng/artemis.git
17+
cd artemis
18+
./gradlew
2019
```
2120

2221
After a successful build, distribution packages will be available in `build/distributions`.
@@ -26,7 +25,7 @@ After a successful build, distribution packages will be available in `build/dist
2625
We use Google's Java coding conventions for the project. To reformat code, run:
2726

2827
```
29-
gradle spotlessApply
28+
./gradlew spotlessApply
3029
```
3130

3231
Code style will be checked automatically during a build.
@@ -35,9 +34,16 @@ Code style will be checked automatically during a build.
3534

3635
All the unit tests are run as part of the build, but can be explicitly triggered with:
3736
```
38-
gradle test
37+
./gradlew test
3938
```
4039
The integration tests can be triggered with:
4140
```
42-
gradle integrationTest
41+
./gradlew integrationTest
42+
```
43+
44+
## Run
45+
46+
You can run the executable from the CLI with this command:
47+
```
48+
./gradlew run
4349
```

artemis/build.gradle

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apply plugin: 'java-library'
2+
3+
jar {
4+
baseName 'artemis'
5+
manifest {
6+
attributes('Implementation-Title': baseName,
7+
'Implementation-Version': project.version)
8+
}
9+
}
10+
11+
dependencies {
12+
implementation project(':crypto')
13+
implementation project(':ethereum:core')
14+
implementation project(':ethereum:rlp')
15+
implementation project(':vrc:vrc')
16+
compile ('org.web3j:core:3.5.0')
17+
18+
implementation 'com.google.guava:guava'
19+
// Disable picocli while the 3.6 release with default enhancement is published.
20+
// The jar is directly inserted until then.
21+
// implementation 'info.picocli:picocli'
22+
compile files('libs/picocli-3.6.0-SNAPSHOT.jar')
23+
implementation 'net.consensys.cava:cava-toml'
24+
implementation 'io.vertx:vertx-core'
25+
implementation 'io.vertx:vertx-web'
26+
implementation 'org.apache.logging.log4j:log4j-api'
27+
28+
runtime 'org.apache.logging.log4j:log4j-core'
29+
30+
testImplementation 'com.squareup.okhttp3:okhttp'
31+
testImplementation 'junit:junit'
32+
testImplementation 'org.awaitility:awaitility'
33+
testImplementation 'org.assertj:assertj-core'
34+
testImplementation 'org.mockito:mockito-core'
35+
compile 'com.google.guava:guava:27.0.1-jre'
36+
37+
test {
38+
testLogging.showStandardStreams = true
39+
}
40+
41+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2018 ConsenSys AG.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package net.consensys.artemis;
15+
16+
import net.consensys.artemis.controllers.ServiceController;
17+
18+
public final class App {
19+
public static void main(final String... args) {
20+
// Process Command Line Args
21+
// Instantiate ServiceController and start event loop
22+
System.out.println(Constants.getConstantsAsString());
23+
ServiceController.init();
24+
ServiceController.start();
25+
26+
}
27+
}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
/*
2+
* Copyright 2018 ConsenSys AG.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package net.consensys.artemis;
15+
16+
import net.consensys.artemis.util.bytes.Bytes32;
17+
18+
public final class Constants {
19+
20+
// The constants below are correct as of spec dated 2018/12/5
21+
22+
// Misc
23+
public static final int SHARD_COUNT = (int) Math.pow(2, 10); // 1,024 Shards
24+
public static final int TARGET_COMMITTEE_SIZE = (int) Math.pow(2, 8); // 256 validators
25+
public static final int EJECTION_BALANCE = (int) Math.pow(2, 4); // 16 Eth
26+
public static final int MAX_BALANCE_CHURN_QUOTIENT = (int) Math.pow(2, 5); // 32
27+
public static final int GWEI_PER_ETH = (int) Math.pow(10, 9); // 1,000,000,000 Wei
28+
public static final int BEACON_CHAIN_SHARD_NUMBER = (int) Math.pow(2, 64) - 1;
29+
public static final String BLS_WITHDRAWAL_PREFIX_BYTE = "0x00";
30+
public static final int MAX_CASPER_VOTES = (int) Math.pow(2, 10); // 1,024 votes
31+
32+
// Deposit contract
33+
// static final Address DEPOSIT_CONTRACT_ADDRESS = Value is still TBD
34+
public static final int DEPOSIT_CONTRACT_TREE_DEPTH = (int) Math.pow(2, 5); // 32
35+
public static final int MIN_DEPOSIT = (int) Math.pow(2, 0); // 1 Eth
36+
public static final int MAX_DEPOSIT = (int) Math.pow(2, 5); // 32 Eth
37+
38+
// Initial values
39+
public static final int INITIAL_FORK_VERSION = 0;
40+
public static final int INITIAL_SLOT_NUMBER = 0;
41+
public static final Bytes32 ZERO_HASH = Bytes32.ZERO;
42+
43+
// Time parameters
44+
public static final int SLOT_DURATION = 6; // 6 seconds
45+
public static final int MIN_ATTESTATION_INCLUSION_DELAY = (int) Math.pow(2, 2); // 4 slots
46+
public static final int EPOCH_LENGTH = (int) Math.pow(2, 6); // 64 slots
47+
public static final int MIN_VALIDATOR_REGISTRY_CHANGE_INTERVAL = (int) Math.pow(2, 8); // 256 slots
48+
public static final int POW_RECEIPT_ROOT_VOTING_PERIOD = (int) Math.pow(2, 10); // 1,024 slots
49+
public static final int SHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD = (int) Math.pow(2, 17); // 131,072 slots
50+
public static final int COLLECTIVE_PENALTY_CALCULATION_PERIOD = (int) Math.pow(2, 20); // 1,048,576 slots
51+
public static final int ZERO_BALANCE_VALIDATOR_TTL = (int) Math.pow(2, 22); // 4,194,304 slots
52+
53+
// Reward and penalty quotients
54+
public static final int BASE_REWARD_QUOTIENT = (int) Math.pow(2, 11); // 2,048
55+
public static final int WHISTLEBLOWER_REWARD_QUOTIENT = (int) Math.pow(2, 9); // 512
56+
public static final int INCLUDER_REWARD_QUOTIENT = (int) Math.pow(2, 3); // 8
57+
public static final int INACTIVITY_PENALTY_QUOTIENT = (int) Math.pow(2, 34); // 131,072
58+
59+
// Status codes
60+
public static final int PENDING_ACTIVATION = 0;
61+
public static final int ACTIVE = 1;
62+
public static final int ACTIVE_PENDING_EXIT = 2;
63+
public static final int EXITED_WITHOUT_PENALTY = 3;
64+
public static final int EXITED_WITH_PENALTY = 4;
65+
66+
// Max operations per block
67+
public static final int MAX_PROPOSER_SLASHINGS = (int) Math.pow(2, 4); // 16
68+
public static final int MAX_CASPER_SLASHINGS = (int) Math.pow(2, 4); // 16
69+
public static final int MAX_ATTESTATIONS = (int) Math.pow(2, 7); // 128
70+
public static final int MAX_DEPOSITS = (int) Math.pow(2, 4); // 16
71+
public static final int MAX_EXITS = (int) Math.pow(2, 4); // 16
72+
73+
74+
// Validator registry delta flags
75+
public static final int ACTIVATION = 0;
76+
public static final int EXIT = 1;
77+
78+
// Signature domains
79+
public static final int DOMAIN_DEPOSIT = 0;
80+
public static final int DOMAIN_ATTESTATION = 1;
81+
public static final int DOMAIN_PROPOSAL = 2;
82+
public static final int DOMAIN_EXIT = 3;
83+
84+
public static String getConstantsAsString() {
85+
return "--Misc--"
86+
+ "\nSHARD_COUNT: " + SHARD_COUNT
87+
+ "\nTARGET_COMMITTEE_SIZE: " + TARGET_COMMITTEE_SIZE
88+
+ "\nMIN_BALANCE: " + EJECTION_BALANCE
89+
+ "\nMAX_BALANCE_CHURN_QUOTIENT: " + MAX_BALANCE_CHURN_QUOTIENT
90+
+ "\nGWEI_PER_ETH: " + GWEI_PER_ETH
91+
+ "\nBEACON_CHAIN_SHARD_NUMBER: " + BEACON_CHAIN_SHARD_NUMBER
92+
+ "\nBLS_WITHDRAWAL_CREDENTIALS: " + BLS_WITHDRAWAL_PREFIX_BYTE
93+
+ "\nMAX_CASPER_VOTES: " + MAX_CASPER_VOTES
94+
95+
+ "\n\n--Deposit contract--"
96+
// + "\nDEPOSIT_CONTRACT_ADDRESS: " + DEPOSIT_CONTRACT_ADDRESS
97+
+ "\nDEPOSIT_CONTRACT_TREE_DEPTH: " + DEPOSIT_CONTRACT_TREE_DEPTH
98+
+ "\nMIN_DEPOSIT: " + MIN_DEPOSIT
99+
+ "\nMAX_DEPOSIT: " + MAX_DEPOSIT
100+
101+
+ "\n\n--Initial values--"
102+
+ "\nINITIAL_FORK_VERSION: " + INITIAL_FORK_VERSION
103+
+ "\nINITIAL_SLOT_NUMBER: " + INITIAL_SLOT_NUMBER
104+
+ "\nZERO_HASH: " + ZERO_HASH
105+
106+
+ "\n\n--Time parameters--"
107+
+ "\nSLOT_DURATION: " + SLOT_DURATION
108+
+ "\nMIN_ATTESTATION_INCLUSION_DELAY: " + MIN_ATTESTATION_INCLUSION_DELAY
109+
+ "\nEPOCH_LENGTH: " + EPOCH_LENGTH
110+
+ "\nMIN_VALIDATOR_REGISTRY_CHANGE_INTERVAL: " + MIN_VALIDATOR_REGISTRY_CHANGE_INTERVAL
111+
+ "\nPOW_RECEIPT_ROOT_VOTING_PERIOD: " + POW_RECEIPT_ROOT_VOTING_PERIOD
112+
+ "\nSHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD: " + SHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD
113+
+ "\nCOLLECTIVE_PENALTY_CALCULATION_PERIOD: " + COLLECTIVE_PENALTY_CALCULATION_PERIOD
114+
+ "\nZERO_BALANCE_VALIDATOR_TTL: " + ZERO_BALANCE_VALIDATOR_TTL
115+
116+
+ "\n\n--Reward and penalty quotients--"
117+
+ "\nBASE_REWARD_QUOTIENT: " + BASE_REWARD_QUOTIENT
118+
+ "\nWHISTLEBLOWER_REWARD_QUOTIENT: " + WHISTLEBLOWER_REWARD_QUOTIENT
119+
+ "\nINCLUDER_REWARD_QUOTIENT: " + INCLUDER_REWARD_QUOTIENT
120+
+ "\nINACTIVITY_PENALTY_QUOTIENT: " + INACTIVITY_PENALTY_QUOTIENT
121+
122+
+ "\n\n--Status codes--"
123+
+ "\nPENDING_ACTIVATION: " + PENDING_ACTIVATION
124+
+ "\nACTIVE: " + ACTIVE
125+
+ "\nACTIVE_PENDING_EXIT: " + ACTIVE_PENDING_EXIT
126+
+ "\nEXITED_WITHOUT_PENALTY: " + EXITED_WITHOUT_PENALTY
127+
+ "\nEXITED_WITH_PENALTY: " + EXITED_WITH_PENALTY
128+
129+
130+
+ "\n\n--Max operations per block--"
131+
+ "\nMAX_PROPOSER_SLASHINGS: " + MAX_PROPOSER_SLASHINGS
132+
+ "\nMAX_CASPER_SLASHINGS: " + MAX_CASPER_SLASHINGS
133+
+ "\nMAX_ATTESTATIONS: " + MAX_ATTESTATIONS
134+
+ "\nMAX_DEPOSITS: " + MAX_DEPOSITS
135+
+ "\nMAX_EXITS: " + MAX_EXITS
136+
137+
138+
+ "\n\n--Validator registry delta flags--"
139+
+ "\nACTIVATION: " + ACTIVATION
140+
+ "\nEXIT: " + EXIT
141+
142+
+ "\n\n--Signature domains--"
143+
+ "\nDOMAIN_DEPOSIT: " + DOMAIN_DEPOSIT
144+
+ "\nDOMAIN_ATTESTATION: " + DOMAIN_ATTESTATION
145+
+ "\nDOMAIN_PROPOSAL: " + DOMAIN_PROPOSAL
146+
+ "\nDOMAIN_EXIT: " + DOMAIN_EXIT
147+
+ "\n";
148+
}
149+
150+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2018 ConsenSys AG.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package net.consensys.artemis.controllers;
15+
16+
import net.consensys.artemis.services.BeaconChainService;
17+
import net.consensys.artemis.services.PowchainService;
18+
import net.consensys.artemis.services.ServiceFactory;
19+
20+
21+
public class ServiceController {
22+
private static final BeaconChainService beaconChainService = ServiceFactory.getInstance(BeaconChainService.class).getInstance();;
23+
private static final PowchainService powchainService = ServiceFactory.getInstance(PowchainService.class).getInstance();
24+
25+
26+
// initialize/register all services
27+
public static void init(){
28+
29+
beaconChainService.init();
30+
powchainService.init();
31+
32+
// Validator Service
33+
34+
// P2P Service
35+
36+
// RPC Service
37+
}
38+
39+
public static void start(){
40+
// start all services
41+
beaconChainService.start();
42+
powchainService.start();
43+
44+
}
45+
46+
public static void stop(){
47+
// stop all services
48+
beaconChainService.stop();
49+
powchainService.stop();
50+
}
51+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2018 ConsenSys AG.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package net.consensys.artemis.datastructures.BeaconChainBlocks;
15+
16+
import net.consensys.artemis.ethereum.core.Hash;
17+
import net.consensys.artemis.util.uint.UInt384;
18+
import net.consensys.artemis.util.uint.UInt64;
19+
20+
public class BeaconBlock {
21+
22+
// Header
23+
private UInt64 slot;
24+
private Hash[] ancestor_hashes;
25+
private Hash state_root;
26+
private Hash randao_reveal;
27+
private Hash candidate_pow_receipt_root;
28+
private UInt384[] signature;
29+
30+
// Body
31+
private BeaconBlockBody body;
32+
33+
34+
public BeaconBlock() {
35+
36+
}
37+
}

0 commit comments

Comments
 (0)