Compare commits

..

3 Commits

Author SHA1 Message Date
semantic-release-bot 9bf3aaf07b chore(release): 0.1.0-develop.52 [skip ci]
# [0.1.0-develop.52](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.51...v0.1.0-develop.52) (2023-09-16)

### Features

* add syncFromCheckpoint method ([ccaca65](ccaca65a90))
2023-09-16 02:44:50 +00:00
Derrick Hammer 746e76ecfc
Merge remote-tracking branch 'origin/develop' into develop 2023-09-15 22:43:53 -04:00
Derrick Hammer ccaca65a90
feat: add syncFromCheckpoint method 2023-09-15 22:43:46 -04:00
5 changed files with 26 additions and 4 deletions

View File

@ -1,3 +1,10 @@
# [0.1.0-develop.52](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.51...v0.1.0-develop.52) (2023-09-16)
### Features
* add syncFromCheckpoint method ([ccaca65](https://git.lumeweb.com/LumeWeb/libethsync/commit/ccaca65a900ec75adc1605e5b22caab4182587dd))
# [0.1.0-develop.51](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.50...v0.1.0-develop.51) (2023-09-16) # [0.1.0-develop.51](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.50...v0.1.0-develop.51) (2023-09-16)

4
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@lumeweb/libethsync", "name": "@lumeweb/libethsync",
"version": "0.1.0-develop.51", "version": "0.1.0-develop.52",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@lumeweb/libethsync", "name": "@lumeweb/libethsync",
"version": "0.1.0-develop.51", "version": "0.1.0-develop.52",
"dependencies": { "dependencies": {
"@chainsafe/as-sha256": "^0.3.1", "@chainsafe/as-sha256": "^0.3.1",
"@chainsafe/bls": "7.1.1", "@chainsafe/bls": "7.1.1",

View File

@ -1,6 +1,6 @@
{ {
"name": "@lumeweb/libethsync", "name": "@lumeweb/libethsync",
"version": "0.1.0-develop.51", "version": "0.1.0-develop.52",
"type": "module", "type": "module",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -56,7 +56,7 @@ export default abstract class BaseClient extends EventEmitter {
return this._latestOptimisticUpdate as Uint8Array; return this._latestOptimisticUpdate as Uint8Array;
} }
private _latestPeriod: number = -1; protected _latestPeriod: number = -1;
get latestPeriod(): number { get latestPeriod(): number {
return this._latestPeriod; return this._latestPeriod;

View File

@ -1,6 +1,8 @@
import BaseClient, { BaseClientOptions } from "#baseClient.js"; import BaseClient, { BaseClientOptions } from "#baseClient.js";
import { IProver, IVerifyingProviderConstructor } from "#interfaces.js"; import { IProver, IVerifyingProviderConstructor } from "#interfaces.js";
import { IClientVerifyingProvider } from "#client/verifyingProvider.js"; import { IClientVerifyingProvider } from "#client/verifyingProvider.js";
import { LightClientUpdate } from "#types.js";
import { computeSyncPeriodAtSlot } from "@lodestar/light-client/utils/index.js";
interface Config extends BaseClientOptions { interface Config extends BaseClientOptions {
prover: IProver; prover: IProver;
@ -19,7 +21,10 @@ export default class Client extends BaseClient {
async sync(): Promise<void> { async sync(): Promise<void> {
await super.sync(); await super.sync();
await this.boot();
}
private async boot() {
if (!this.provider) { if (!this.provider) {
const { blockHash, blockNumber } = await this.getNextValidExecutionInfo(); const { blockHash, blockNumber } = await this.getNextValidExecutionInfo();
const factory = this.options.provider; const factory = this.options.provider;
@ -40,6 +45,16 @@ export default class Client extends BaseClient {
} }
} }
public async syncFromCheckpoint(checkpoint: LightClientUpdate) {
this._latestPeriod = computeSyncPeriodAtSlot(
checkpoint.attestedHeader.beacon.slot,
);
this.latestCommittee = checkpoint.nextSyncCommittee.pubkeys;
this.booted = true;
await super.sync();
}
public async rpcCall(method: string, params: any) { public async rpcCall(method: string, params: any) {
return this.provider?.rpcMethod(method, params); return this.provider?.rpcMethod(method, params);
} }