Skip to content

Commit

Permalink
Merge branch 'unstable' into dev/etan/ci-nim2devel
Browse files Browse the repository at this point in the history
  • Loading branch information
etan-status authored Sep 5, 2023
2 parents 9382cca + 8ffb80e commit eda9550
Show file tree
Hide file tree
Showing 17 changed files with 796 additions and 167 deletions.
6 changes: 4 additions & 2 deletions AllTests-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,10 @@ OK: 6/6 Fail: 0/6 Skip: 0/6
```diff
+ Doppelganger for genesis validator OK
+ Doppelganger for validator that activates in same epoch as check OK
+ Dynamic validator set: queryValidatorsSource() test OK
+ Dynamic validator set: updateDynamicValidators() test OK
```
OK: 2/2 Fail: 0/2 Skip: 0/2
OK: 4/4 Fail: 0/4 Skip: 0/4
## Zero signature sanity checks
```diff
+ SSZ serialization roundtrip of SignedBeaconBlockHeader OK
Expand Down Expand Up @@ -700,4 +702,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
OK: 9/9 Fail: 0/9 Skip: 0/9

---TOTAL---
OK: 393/398 Fail: 0/398 Skip: 5/398
OK: 395/400 Fail: 0/400 Skip: 5/400
13 changes: 12 additions & 1 deletion beacon_chain/conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export
defaultEth2TcpPort, enabledLogLevel, ValidIpAddress,
defs, parseCmdArg, completeCmdArg, network_metadata,
el_conf, network, BlockHashOrNumber,
confTomlDefs, confTomlNet, confTomlUri
confTomlDefs, confTomlNet, confTomlUri,
LightClientDataImportMode

declareGauge network_name, "network name", ["name"]

Expand Down Expand Up @@ -165,6 +166,11 @@ type
desc: "Remote Web3Signer URL that will be used as a source of validators"
name: "validators-source"}: Option[string]

validatorsSourceInverval* {.
desc: "Number of minutes between validator list updates"
name: "validators-source-interval"
defaultValue: 60 .}: Natural

secretsDirFlag* {.
desc: "A directory containing validator keystore passwords"
name: "secrets-dir" .}: Option[InputDir]
Expand Down Expand Up @@ -883,6 +889,11 @@ type
desc: "Remote Web3Signer URL that will be used as a source of validators"
name: "validators-source"}: Option[string]

validatorsSourceInverval* {.
desc: "Number of minutes between validator list updates"
name: "validators-source-interval"
defaultValue: 60 .}: Natural

secretsDirFlag* {.
desc: "A directory containing validator keystore passwords"
name: "secrets-dir" .}: Option[InputDir]
Expand Down
9 changes: 8 additions & 1 deletion beacon_chain/gossip_processing/batch_validation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ proc batchVerifyTask(task: ptr BatchTask) {.nimcall.} =

discard task[].signal.fireSync()

proc spawnBatchVerifyTask(tp: Taskpool, task: ptr BatchTask) =
# Inlining this `proc` leads to compilation problems on Nim 2.0
# - Error: cannot generate destructor for generic type: Isolated
# Workaround: Ensure that `tp.spawn` is not used within an `{.async.}` proc
# Possibly related to: https://github.com/nim-lang/Nim/issues/22305
tp.spawn batchVerifyTask(task)

proc batchVerifyAsync*(
verifier: ref BatchVerifier, signal: ThreadSignalPtr,
batch: ref Batch): Future[bool] {.async.} =
Expand All @@ -245,7 +252,7 @@ proc batchVerifyAsync*(
let taskPtr = addr task
doAssert verifier[].taskpool.numThreads > 1,
"Must have at least one separate thread or signal will never be fired"
verifier[].taskpool.spawn batchVerifyTask(taskPtr)
verifier[].taskpool.spawnBatchVerifyTask(taskPtr)
await signal.wait()
task.ok.load()

Expand Down
128 changes: 128 additions & 0 deletions beacon_chain/libnimbus_lc/libnimbus_lc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,26 @@ ETH_RESULT_USE_CHECK
const ETHRoot *ETHExecutionBlockHeaderGetWithdrawalsRoot(
const ETHExecutionBlockHeader *executionBlockHeader);

/**
* Withdrawal sequence.
*/
typedef struct ETHWithdrawals ETHWithdrawals;

/**
* Obtains the withdrawal sequence of a given execution block header.
*
* - The returned value is allocated in the given execution block header.
* It must neither be released nor written to, and the execution block
* header must not be released while the returned value is in use.
*
* @param executionBlockHeader Execution block header.
*
* @return Withdrawal sequence.
*/
ETH_RESULT_USE_CHECK
const ETHWithdrawals *ETHExecutionBlockHeaderGetWithdrawals(
const ETHExecutionBlockHeader *executionBlockHeader);

/**
* Transaction sequence.
*/
Expand Down Expand Up @@ -1765,6 +1785,114 @@ const void *ETHReceiptGetBytes(
const ETHReceipt *receipt,
int *numBytes);

/**
* Indicates the total number of withdrawals in a withdrawal sequence.
*
* - Individual withdrawals may be investigated using `ETHWithdrawalsGet`.
*
* @param withdrawals Withdrawal sequence.
*
* @return Number of available withdrawals.
*/
ETH_RESULT_USE_CHECK
int ETHWithdrawalsGetCount(const ETHWithdrawals *withdrawals);

/**
* Withdrawal.
*/
typedef struct ETHWithdrawal ETHWithdrawal;

/**
* Obtains an individual withdrawal by sequential index
* in a withdrawal sequence.
*
* - The returned value is allocated in the given withdrawal sequence.
* It must neither be released nor written to, and the withdrawal
* sequence must not be released while the returned value is in use.
*
* @param withdrawals Withdrawal sequence.
* @param withdrawalIndex Sequential withdrawal index.
*
* @return Withdrawal.
*/
ETH_RESULT_USE_CHECK
const ETHWithdrawal *ETHWithdrawalsGet(
const ETHWithdrawals *withdrawals,
int withdrawalIndex);

/**
* Obtains the index of a withdrawal.
*
* - The returned value is allocated in the given withdrawal.
* It must neither be released nor written to, and the withdrawal
* must not be released while the returned value is in use.
*
* @param withdrawal Withdrawal.
*
* @return Index.
*/
ETH_RESULT_USE_CHECK
const uint64_t *ETHWithdrawalGetIndex(const ETHWithdrawal *withdrawal);

/**
* Obtains the validator index of a withdrawal.
*
* - The returned value is allocated in the given withdrawal.
* It must neither be released nor written to, and the withdrawal
* must not be released while the returned value is in use.
*
* @param withdrawal Withdrawal.
*
* @return Validator index.
*/
ETH_RESULT_USE_CHECK
const uint64_t *ETHWithdrawalGetValidatorIndex(const ETHWithdrawal *withdrawal);

/**
* Obtains the address of a withdrawal.
*
* - The returned value is allocated in the given withdrawal.
* It must neither be released nor written to, and the withdrawal
* must not be released while the returned value is in use.
*
* @param withdrawal Withdrawal.
*
* @return Address.
*/
ETH_RESULT_USE_CHECK
const ETHExecutionAddress *ETHWithdrawalGetAddress(const ETHWithdrawal *withdrawal);

/**
* Obtains the amount of a withdrawal.
*
* - The returned value is allocated in the given withdrawal.
* It must neither be released nor written to, and the withdrawal
* must not be released while the returned value is in use.
*
* @param withdrawal Withdrawal.
*
* @return Amount.
*/
ETH_RESULT_USE_CHECK
const uint64_t *ETHWithdrawalGetAmount(const ETHWithdrawal *withdrawal);

/**
* Obtains the raw byte representation of a withdrawal.
*
* - The returned value is allocated in the given withdrawal.
* It must neither be released nor written to, and the withdrawal
* must not be released while the returned value is in use.
*
* @param withdrawal Withdrawal.
* @param[out] numBytes Length of buffer.
*
* @return Buffer with raw withdrawal data.
*/
ETH_RESULT_USE_CHECK
const void *ETHWithdrawalGetBytes(
const ETHWithdrawal *withdrawal,
int *numBytes);

#if __has_feature(nullability)
#pragma clang assume_nonnull end
#endif
Expand Down
Loading

0 comments on commit eda9550

Please sign in to comment.