mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-09 22:06:21 +00:00
fix genesis interop by fixing deposit signature handling; add TRACE-level compilation to CI
This commit is contained in:
parent
746659bdc6
commit
417f96213d
@ -54,11 +54,11 @@ task test, "Run all tests":
|
|||||||
buildBinary "test_fixture_ssz_generic_types", "tests/official/", "-r -d:release -d:chronicles_log_level=DEBUG"
|
buildBinary "test_fixture_ssz_generic_types", "tests/official/", "-r -d:release -d:chronicles_log_level=DEBUG"
|
||||||
|
|
||||||
# Consensus object SSZ tests
|
# Consensus object SSZ tests
|
||||||
buildBinary "test_fixture_ssz_consensus_objects", "tests/official/", "-r -d:release -d:chronicles_log_level=DEBUG -d:const_preset=minimal"
|
buildBinary "test_fixture_ssz_consensus_objects", "tests/official/", "-r -d:release -d:chronicles_log_level=TRACE -d:const_preset=minimal"
|
||||||
buildBinary "test_fixture_ssz_consensus_objects", "tests/official/", "-r -d:release -d:chronicles_log_level=DEBUG -d:const_preset=mainnet"
|
buildBinary "test_fixture_ssz_consensus_objects", "tests/official/", "-r -d:release -d:chronicles_log_level=DEBUG -d:const_preset=mainnet"
|
||||||
|
|
||||||
buildBinary "all_fixtures_require_ssz", "tests/official/", "-r -d:release -d:chronicles_log_level=DEBUG -d:const_preset=minimal"
|
buildBinary "all_fixtures_require_ssz", "tests/official/", "-r -d:release -d:chronicles_log_level=DEBUG -d:const_preset=minimal"
|
||||||
buildBinary "all_fixtures_require_ssz", "tests/official/", "-r -d:release -d:chronicles_log_level=DEBUG -d:const_preset=mainnet"
|
buildBinary "all_fixtures_require_ssz", "tests/official/", "-r -d:release -d:chronicles_log_level=TRACE -d:const_preset=mainnet"
|
||||||
|
|
||||||
# State sim; getting into 4th epoch useful to trigger consensus checks
|
# State sim; getting into 4th epoch useful to trigger consensus checks
|
||||||
buildBinary "state_sim", "research/", "-r -d:release", "--validators=128 --slots=40"
|
buildBinary "state_sim", "research/", "-r -d:release", "--validators=128 --slots=40"
|
||||||
|
@ -59,6 +59,7 @@ func makeDeposit*(
|
|||||||
if skipValidation notin flags:
|
if skipValidation notin flags:
|
||||||
ret.data.signature =
|
ret.data.signature =
|
||||||
bls_sign(
|
bls_sign(
|
||||||
privkey, hash_tree_root(ret.data).data, compute_domain(DOMAIN_DEPOSIT))
|
privkey, hash_tree_root(ret.getDepositMessage).data,
|
||||||
|
compute_domain(DOMAIN_DEPOSIT))
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
@ -54,7 +54,7 @@ func process_deposit*(
|
|||||||
# Verify the Merkle branch
|
# Verify the Merkle branch
|
||||||
# TODO enable this check, but don't use doAssert
|
# TODO enable this check, but don't use doAssert
|
||||||
if not is_valid_merkle_branch(
|
if not is_valid_merkle_branch(
|
||||||
hash_tree_root(deposit.data),
|
hash_tree_root(deposit.getDepositMessage),
|
||||||
deposit.proof,
|
deposit.proof,
|
||||||
DEPOSIT_CONTRACT_TREE_DEPTH,
|
DEPOSIT_CONTRACT_TREE_DEPTH,
|
||||||
state.eth1_deposit_index,
|
state.eth1_deposit_index,
|
||||||
@ -80,8 +80,8 @@ func process_deposit*(
|
|||||||
if index == -1:
|
if index == -1:
|
||||||
# Verify the deposit signature (proof of possession)
|
# Verify the deposit signature (proof of possession)
|
||||||
if skipValidation notin flags and not bls_verify(
|
if skipValidation notin flags and not bls_verify(
|
||||||
pubkey, hash_tree_root(deposit.data).data, deposit.data.signature,
|
pubkey, hash_tree_root(deposit.getDepositMessage).data,
|
||||||
compute_domain(DOMAIN_DEPOSIT)):
|
deposit.data.signature, compute_domain(DOMAIN_DEPOSIT)):
|
||||||
return false
|
return false
|
||||||
|
|
||||||
# Add validator and balance entries
|
# Add validator and balance entries
|
||||||
|
@ -428,6 +428,14 @@ macro fieldMaxLen*(x: typed): untyped =
|
|||||||
func shortValidatorKey*(state: BeaconState, validatorIdx: int): string =
|
func shortValidatorKey*(state: BeaconState, validatorIdx: int): string =
|
||||||
($state.validators[validatorIdx].pubkey)[0..7]
|
($state.validators[validatorIdx].pubkey)[0..7]
|
||||||
|
|
||||||
|
func getDepositMessage*(depositData: DepositData): DepositMessage =
|
||||||
|
result.pubkey = depositData.pubkey
|
||||||
|
result.amount = depositData.amount
|
||||||
|
result.withdrawal_credentials = depositData.withdrawal_credentials
|
||||||
|
|
||||||
|
func getDepositMessage*(deposit: Deposit): DepositMessage =
|
||||||
|
deposit.data.getDepositMessage
|
||||||
|
|
||||||
template ethTimeUnit(typ: type) {.dirty.} =
|
template ethTimeUnit(typ: type) {.dirty.} =
|
||||||
proc `+`*(x: typ, y: uint64): typ {.borrow.}
|
proc `+`*(x: typ, y: uint64): typ {.borrow.}
|
||||||
proc `-`*(x: typ, y: uint64): typ {.borrow.}
|
proc `-`*(x: typ, y: uint64): typ {.borrow.}
|
||||||
|
@ -17,7 +17,7 @@ import # Unit test
|
|||||||
./test_beaconstate,
|
./test_beaconstate,
|
||||||
./test_block_pool,
|
./test_block_pool,
|
||||||
./test_helpers,
|
./test_helpers,
|
||||||
#./test_interop, TODO check zcli
|
./test_interop,
|
||||||
./test_ssz,
|
./test_ssz,
|
||||||
./test_state_transition,
|
./test_state_transition,
|
||||||
./test_sync_protocol,
|
./test_sync_protocol,
|
||||||
|
@ -25,7 +25,7 @@ func signMockDepositData(
|
|||||||
# No state --> Genesis
|
# No state --> Genesis
|
||||||
deposit_data.signature = bls_sign(
|
deposit_data.signature = bls_sign(
|
||||||
key = privkey,
|
key = privkey,
|
||||||
msg = deposit_data.hash_tree_root().data,
|
msg = deposit_data.getDepositMessage().hash_tree_root().data,
|
||||||
domain = compute_domain(
|
domain = compute_domain(
|
||||||
DOMAIN_DEPOSIT,
|
DOMAIN_DEPOSIT,
|
||||||
default(array[4, byte]) # Genesis is fork_version 0
|
default(array[4, byte]) # Genesis is fork_version 0
|
||||||
@ -39,7 +39,7 @@ func signMockDepositData(
|
|||||||
) =
|
) =
|
||||||
deposit_data.signature = bls_sign(
|
deposit_data.signature = bls_sign(
|
||||||
key = privkey,
|
key = privkey,
|
||||||
msg = deposit_data.hash_tree_root().data,
|
msg = deposit_data.getDepositMessage().hash_tree_root().data,
|
||||||
domain = get_domain(
|
domain = get_domain(
|
||||||
state,
|
state,
|
||||||
DOMAIN_DEPOSIT
|
DOMAIN_DEPOSIT
|
||||||
|
@ -140,7 +140,7 @@ suite "Interop":
|
|||||||
timedTest "Interop genesis":
|
timedTest "Interop genesis":
|
||||||
# Check against https://github.com/protolambda/zcli:
|
# Check against https://github.com/protolambda/zcli:
|
||||||
# zcli keys generate --to 64 | zcli genesis mock --genesis-time 1570500000 > /tmp/state.ssz
|
# zcli keys generate --to 64 | zcli genesis mock --genesis-time 1570500000 > /tmp/state.ssz
|
||||||
# zcli hash-tree-root /tmp.state.ssz
|
# zcli hash-tree-root state /tmp/state.ssz
|
||||||
var deposits: seq[Deposit]
|
var deposits: seq[Deposit]
|
||||||
|
|
||||||
for i in 0..<64:
|
for i in 0..<64:
|
||||||
@ -157,11 +157,10 @@ suite "Interop":
|
|||||||
|
|
||||||
let expected =
|
let expected =
|
||||||
when const_preset == "minimal":
|
when const_preset == "minimal":
|
||||||
"75016055f843b92972d647a849168e8c5f559e8d41e05f94fc3f6a9665d1cabb"
|
"5a3bbcae4ab2b4eafded947689fd7bd8214a616ffffd2521befdfe2a3b2f74c0"
|
||||||
elif const_preset == "mainnet":
|
elif const_preset == "mainnet":
|
||||||
"27e4b5dfc67b97fd7d441c60bd5c92851fc1ceebe22435903183d915b3e4e678"
|
"db0a887acd5e201ac579d6cdc0c4932f2a0adf342d84dc5cd11ce959fbce3760"
|
||||||
else:
|
else:
|
||||||
"unimplemented"
|
"unimplemented"
|
||||||
check:
|
check:
|
||||||
hash_tree_root(initialState).data.toHex() == expected
|
hash_tree_root(initialState).data.toHex() == expected
|
||||||
true
|
|
||||||
|
@ -64,7 +64,7 @@ func makeDeposit(i: int, flags: UpdateFlags): Deposit =
|
|||||||
|
|
||||||
if skipValidation notin flags:
|
if skipValidation notin flags:
|
||||||
result.data.signature =
|
result.data.signature =
|
||||||
bls_sign(privkey, hash_tree_root(result.data).data,
|
bls_sign(privkey, hash_tree_root(result.getDepositMessage).data,
|
||||||
domain)
|
domain)
|
||||||
|
|
||||||
func makeInitialDeposits*(
|
func makeInitialDeposits*(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user