Config CI + use Milagro BLS signatures
This commit is contained in:
parent
ca4082b316
commit
99a394e084
|
@ -1,12 +1,15 @@
|
|||
packageName = "beacon_chain"
|
||||
version = "0.0.1"
|
||||
author = "Status Research & Development GmbH"
|
||||
description = ""
|
||||
description = "Eth2.0 research implementation of the beacon chain"
|
||||
license = "MIT or Apache License 2.0"
|
||||
srcDir = "src"
|
||||
|
||||
### Dependencies
|
||||
requires "nim >= 0.18.0"
|
||||
requires "nim >= 0.18.0",
|
||||
"eth_common",
|
||||
"nimcrypto",
|
||||
"https://github.com/status-im/nim-milagro-crypto#master"
|
||||
|
||||
### Helper functions
|
||||
proc test(name: string, defaultLang = "c") =
|
||||
|
|
|
@ -5,13 +5,24 @@
|
|||
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import intsets, eth_common, math, stint
|
||||
import
|
||||
intsets, eth_common, math, stint
|
||||
|
||||
import milagro_crypto
|
||||
# nimble install https://github.com/status-im/nim-milagro-crypto@#master
|
||||
# Defines
|
||||
# - SigKey (private/secret key) (48 bytes)
|
||||
# - Signature and AggregatedSignature (97 bytes)
|
||||
# - VerKey (public key) and AggregatedVerKey (192 bytes)
|
||||
|
||||
# Implementation based on WIP spec https://notes.ethereum.org/SCIg8AH5SA-O4C1G1LYZHQ?view
|
||||
# ⚠ Spec is updated very often, implementation might quickly be outdated
|
||||
|
||||
type
|
||||
Blake2_256_Digest* = Hash256 # TODO change to Blake2b-512[0 ..< 32] see https://github.com/status-im/nim-beacon-chain/issues/3
|
||||
# Alias
|
||||
BLSPublicKey* = VerKey
|
||||
BLSaggregateSig* = AggregatedSignature
|
||||
Blake2_256_Digest* = Hash256 # TODO change to Blake2b-512[0 ..< 32] see https://github.com/status-im/nim-beacon-chain/issues/3
|
||||
Uint24* = range[0'u32 .. 0xFFFFFF'u32] # TODO: wrap-around
|
||||
|
||||
BeaconBlock* = object
|
||||
|
@ -47,7 +58,7 @@ type
|
|||
committee*: seq[Uint24] # Validator indices
|
||||
|
||||
ValidatorRecord* = object
|
||||
pubkey*: BLSPublicKey # The validator's public key
|
||||
pubkey*: VerKey # The validator's public key
|
||||
withdrawal_shard*: int16 # What shard the validator's balance will be sent to after withdrawal
|
||||
withdrawal_address*: EthAddress # And what address
|
||||
randao_commitment*: Blake2_256_Digest # The validator's current RANDAO beacon commitment
|
||||
|
@ -60,10 +71,6 @@ type
|
|||
slot: int64 # What slot
|
||||
hash: Blake2_256_Digest # The block hash
|
||||
|
||||
BLSPublicKey* = object
|
||||
# Stub for BLS signature
|
||||
data: array[32, byte]
|
||||
|
||||
AttestationRecord* = object
|
||||
slot*: int64 # Slot number
|
||||
shard_id*: int16 # Shard ID
|
||||
|
@ -74,7 +81,7 @@ type
|
|||
attester_bitfield*: IntSet # Who is participating
|
||||
justified_slot*: int64
|
||||
justified_block_hash: Blake2_256_Digest
|
||||
aggregateSig*: seq[BLSPublicKey] # The actual signature
|
||||
aggregateSig*: BLSaggregateSig # The actual signature
|
||||
|
||||
# Note:
|
||||
# We use IntSet from Nim Standard library which are efficient sparse bitsets.
|
||||
|
|
|
@ -20,10 +20,13 @@
|
|||
|
||||
{.warning: "The official spec at https://notes.ethereum.org/SCIg8AH5SA-O4C1G1LYZHQ# is not fully defining state transitions.".}
|
||||
|
||||
import ./datatypes, ./private/helpers, intsets
|
||||
import
|
||||
./datatypes, ./private/helpers,
|
||||
intsets,
|
||||
milagro_crypto # nimble install https://github.com/status-im/nim-milagro-crypto@#master
|
||||
|
||||
|
||||
func process_block(active_state: ActiveState, crystallized_state: CrystallizedState, blck: BeaconBlock, slot: int64) =
|
||||
func process_block*(active_state: ActiveState, crystallized_state: CrystallizedState, blck: BeaconBlock, slot: int64) =
|
||||
# TODO: unfinished spec
|
||||
|
||||
for attestation in blck.attestations:
|
||||
|
@ -63,3 +66,4 @@ func process_block(active_state: ActiveState, crystallized_state: CrystallizedSt
|
|||
|
||||
# Verify that the slot % len(get_indices_for_slot(crystallized_state, slot-1)[0])'th attester in get_indices_for_slot(crystallized_state, slot-1)[0]is part of at least one of the AttestationRecord objects; this attester can be considered to be the proposer of the block.
|
||||
# TODO
|
||||
|
||||
|
|
|
@ -5,12 +5,6 @@
|
|||
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import unittest,
|
||||
../src/beacon_chain
|
||||
|
||||
suite "Your first test suite":
|
||||
test "Your first test":
|
||||
block: # independant block of subtest
|
||||
discard
|
||||
block:
|
||||
discard
|
||||
import
|
||||
./test_ssz,
|
||||
./test_block_processing
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# beacon_chain
|
||||
# Copyright (c) 2018 Status Research & Development GmbH
|
||||
# Licensed and distributed under either of
|
||||
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
|
||||
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
unittest,
|
||||
../beacon_chain/[datatypes, state_transition]
|
||||
|
||||
suite "Block processing":
|
||||
## For now just test that we can compile and execute block processing with mock data.
|
||||
|
||||
test "Mock process_block":
|
||||
let actState = ActiveState()
|
||||
let crystState = CrystallizedState()
|
||||
let blck = BeaconBlock()
|
||||
let slot = 10
|
||||
|
||||
actState.process_block(crystState, blck, slot)
|
Loading…
Reference in New Issue