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"
|
||||
|
||||
# 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 "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
|
||||
buildBinary "state_sim", "research/", "-r -d:release", "--validators=128 --slots=40"
|
||||
|
|
|
@ -59,6 +59,7 @@ func makeDeposit*(
|
|||
if skipValidation notin flags:
|
||||
ret.data.signature =
|
||||
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
|
||||
|
|
|
@ -54,7 +54,7 @@ func process_deposit*(
|
|||
# Verify the Merkle branch
|
||||
# TODO enable this check, but don't use doAssert
|
||||
if not is_valid_merkle_branch(
|
||||
hash_tree_root(deposit.data),
|
||||
hash_tree_root(deposit.getDepositMessage),
|
||||
deposit.proof,
|
||||
DEPOSIT_CONTRACT_TREE_DEPTH,
|
||||
state.eth1_deposit_index,
|
||||
|
@ -80,8 +80,8 @@ func process_deposit*(
|
|||
if index == -1:
|
||||
# Verify the deposit signature (proof of possession)
|
||||
if skipValidation notin flags and not bls_verify(
|
||||
pubkey, hash_tree_root(deposit.data).data, deposit.data.signature,
|
||||
compute_domain(DOMAIN_DEPOSIT)):
|
||||
pubkey, hash_tree_root(deposit.getDepositMessage).data,
|
||||
deposit.data.signature, compute_domain(DOMAIN_DEPOSIT)):
|
||||
return false
|
||||
|
||||
# Add validator and balance entries
|
||||
|
|
|
@ -428,6 +428,14 @@ macro fieldMaxLen*(x: typed): untyped =
|
|||
func shortValidatorKey*(state: BeaconState, validatorIdx: int): string =
|
||||
($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.} =
|
||||
proc `+`*(x: typ, y: uint64): typ {.borrow.}
|
||||
proc `-`*(x: typ, y: uint64): typ {.borrow.}
|
||||
|
|
|
@ -17,7 +17,7 @@ import # Unit test
|
|||
./test_beaconstate,
|
||||
./test_block_pool,
|
||||
./test_helpers,
|
||||
#./test_interop, TODO check zcli
|
||||
./test_interop,
|
||||
./test_ssz,
|
||||
./test_state_transition,
|
||||
./test_sync_protocol,
|
||||
|
|
|
@ -25,7 +25,7 @@ func signMockDepositData(
|
|||
# No state --> Genesis
|
||||
deposit_data.signature = bls_sign(
|
||||
key = privkey,
|
||||
msg = deposit_data.hash_tree_root().data,
|
||||
msg = deposit_data.getDepositMessage().hash_tree_root().data,
|
||||
domain = compute_domain(
|
||||
DOMAIN_DEPOSIT,
|
||||
default(array[4, byte]) # Genesis is fork_version 0
|
||||
|
@ -39,7 +39,7 @@ func signMockDepositData(
|
|||
) =
|
||||
deposit_data.signature = bls_sign(
|
||||
key = privkey,
|
||||
msg = deposit_data.hash_tree_root().data,
|
||||
msg = deposit_data.getDepositMessage().hash_tree_root().data,
|
||||
domain = get_domain(
|
||||
state,
|
||||
DOMAIN_DEPOSIT
|
||||
|
|
|
@ -140,7 +140,7 @@ suite "Interop":
|
|||
timedTest "Interop genesis":
|
||||
# Check against https://github.com/protolambda/zcli:
|
||||
# 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]
|
||||
|
||||
for i in 0..<64:
|
||||
|
@ -157,11 +157,10 @@ suite "Interop":
|
|||
|
||||
let expected =
|
||||
when const_preset == "minimal":
|
||||
"75016055f843b92972d647a849168e8c5f559e8d41e05f94fc3f6a9665d1cabb"
|
||||
"5a3bbcae4ab2b4eafded947689fd7bd8214a616ffffd2521befdfe2a3b2f74c0"
|
||||
elif const_preset == "mainnet":
|
||||
"27e4b5dfc67b97fd7d441c60bd5c92851fc1ceebe22435903183d915b3e4e678"
|
||||
"db0a887acd5e201ac579d6cdc0c4932f2a0adf342d84dc5cd11ce959fbce3760"
|
||||
else:
|
||||
"unimplemented"
|
||||
check:
|
||||
hash_tree_root(initialState).data.toHex() == expected
|
||||
true
|
||||
|
|
|
@ -64,7 +64,7 @@ func makeDeposit(i: int, flags: UpdateFlags): Deposit =
|
|||
|
||||
if skipValidation notin flags:
|
||||
result.data.signature =
|
||||
bls_sign(privkey, hash_tree_root(result.data).data,
|
||||
bls_sign(privkey, hash_tree_root(result.getDepositMessage).data,
|
||||
domain)
|
||||
|
||||
func makeInitialDeposits*(
|
||||
|
|
Loading…
Reference in New Issue