Compare commits
3 Commits
v0.1.0-dev
...
v0.1.0-dev
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | ac54298fa0 | |
Derrick Hammer | 800bf02a19 | |
Derrick Hammer | f24fdc5489 |
|
@ -1,3 +1,5 @@
|
|||
# [0.1.0-develop.6](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.5...v0.1.0-develop.6) (2023-07-11)
|
||||
|
||||
# [0.1.0-develop.5](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.4...v0.1.0-develop.5) (2023-07-11)
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@lumeweb/libethclient",
|
||||
"version": "0.1.0-develop.5",
|
||||
"version": "0.1.0-develop.6",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@lumeweb/libethclient",
|
||||
"version": "0.1.0-develop.5",
|
||||
"version": "0.1.0-develop.6",
|
||||
"dependencies": {
|
||||
"@chainsafe/as-sha256": "^0.3.1",
|
||||
"@chainsafe/bls": "7.1.1",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@lumeweb/libethsync",
|
||||
"version": "0.1.0-develop.5",
|
||||
"version": "0.1.0-develop.6",
|
||||
"type": "module",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -107,10 +107,11 @@ export default class Client extends BaseClient {
|
|||
console.error(`Invalid Optimistic Update: ${verify?.reason}`);
|
||||
return null;
|
||||
}
|
||||
return this.getExecutionFromBlockRoot(
|
||||
updateJSON.data.attested_header.beacon.slot,
|
||||
updateJSON.data.attested_header.beacon.body_root,
|
||||
);
|
||||
|
||||
return {
|
||||
blockHash: toHexString(update.attestedHeader.execution.blockHash),
|
||||
blockNumber: update.attestedHeader.execution.blockNumber,
|
||||
};
|
||||
}
|
||||
|
||||
protected async syncFromGenesis(): Promise<Uint8Array[]> {
|
||||
|
@ -177,33 +178,4 @@ export default class Client extends BaseClient {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private async getExecutionFromBlockRoot(
|
||||
slot: bigint,
|
||||
expectedBlockRoot: Bytes32,
|
||||
): Promise<ExecutionInfo> {
|
||||
const res = await axios.get(`/eth/v2/beacon/blocks/${slot}`);
|
||||
|
||||
if (!res.data) {
|
||||
throw Error(`fetching block failed`);
|
||||
}
|
||||
|
||||
const block = capella.ssz.BeaconBlock.fromJson(res.data.message);
|
||||
const blockRoot = toHexString(
|
||||
capella.ssz.BeaconBlockBody.hashTreeRoot(block.body),
|
||||
);
|
||||
if (blockRoot !== expectedBlockRoot) {
|
||||
throw Error(
|
||||
`block provided by the beacon chain api doesn't match the expected block root`,
|
||||
);
|
||||
}
|
||||
|
||||
this.blockCache.set<any>(Number(slot), block);
|
||||
this.blockHashCache.set<Bytes32>(Number(slot), expectedBlockRoot);
|
||||
|
||||
return {
|
||||
blockHash: toHexString(block.body.executionPayload.blockHash),
|
||||
blockNumber: block.body.executionPayload.blockNumber,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue