-
-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
part of ChainSafe/lodestar#2046
this is a simple test to calculate hashTreeRoot
it.only("set validator valances", function () {
this.timeout(0);
const originalState = state.getOriginalState();
// cache hashTreeRoot
config.types.BeaconState.hashTreeRoot(originalState);
const balances = Array.from({length: originalState.validators.length}, () => BigInt(31217089836));
let minTime = Number.MAX_SAFE_INTEGER;
let maxTime = 0;
let average = {duration: 0, count: 0};
const MAX_TRY = 10000;
for (let i = 0; i < MAX_TRY; i++) {
const state = config.types.BeaconState.clone(originalState);
state.balances = balances as List<Gwei>;
const start = Date.now();
config.types.BeaconState.hashTreeRoot(state);
const duration = Date.now() - start;
const totalDuration = average.duration * average.count + duration;
const totalCount = average.count + 1;
average.count = totalCount;
average.duration = totalDuration / totalCount;
if (duration < minTime) minTime = duration;
if (duration > maxTime) maxTime = duration;
}
console.log("hashTreeRoot minTime:", minTime, "maxTime:", maxTime, "average:", average.duration, "MAX_TRY:", MAX_TRY);
});this prints out hashTreeRoot minTime: 65 maxTime: 507 average: 80.46129999999977 MAX_TRY: 10000. I notice the max time is very similar to the one we have during a long epoch transition.
we need to investigate why the performance is inconsistent and if we can improve it.
dappliondapplion
Metadata
Metadata
Assignees
Labels
No labels