Compare commits

...

4 Commits

Author SHA1 Message Date
semantic-release-bot 26e29924ce chore(release): 0.1.0-develop.15 [skip ci]
# [0.1.0-develop.15](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.14...v0.1.0-develop.15) (2023-07-11)

### Bug Fixes

* implement isValidLightClientHeader ([6f07421](6f07421fe8))
2023-07-11 07:27:42 +00:00
Derrick Hammer 7932fbbf12
Merge remote-tracking branch 'origin/develop' into develop 2023-07-11 03:26:48 -04:00
Derrick Hammer c90c3db973
chore: update LICENSE 2023-07-11 03:26:40 -04:00
Derrick Hammer 6f07421fe8
fix: implement isValidLightClientHeader 2023-07-11 03:24:38 -04:00
5 changed files with 42 additions and 6 deletions

View File

@ -1,3 +1,10 @@
# [0.1.0-develop.15](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.14...v0.1.0-develop.15) (2023-07-11)
### Bug Fixes
* implement isValidLightClientHeader ([6f07421](https://git.lumeweb.com/LumeWeb/libethsync/commit/6f07421fe80f008255cbe472204d8530e2bb3352))
# [0.1.0-develop.14](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.13...v0.1.0-develop.14) (2023-07-11) # [0.1.0-develop.14](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.13...v0.1.0-develop.14) (2023-07-11)

View File

@ -1,6 +1,7 @@
MIT License MIT License
Copyright (c) <year> <copyright holders> Copyright (c) 2023 Hammer Technologies LLC
Copyright (c) 2022 Shresth Agrawal
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

4
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@lumeweb/libethclient", "name": "@lumeweb/libethclient",
"version": "0.1.0-develop.14", "version": "0.1.0-develop.15",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@lumeweb/libethclient", "name": "@lumeweb/libethclient",
"version": "0.1.0-develop.14", "version": "0.1.0-develop.15",
"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.14", "version": "0.1.0-develop.15",
"type": "module", "type": "module",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -1,4 +1,9 @@
import { createBeaconConfig } from "@lodestar/config"; import {
createBeaconConfig,
BeaconConfig,
ChainForkConfig,
} from "@lodestar/config";
import { allForks } from "@lodestar/types";
import { BEACON_SYNC_SUPER_MAJORITY, mainnetConfig } from "./constants.js"; import { BEACON_SYNC_SUPER_MAJORITY, mainnetConfig } from "./constants.js";
import { networksChainConfig } from "@lodestar/config/networks"; import { networksChainConfig } from "@lodestar/config/networks";
import { fromHexString } from "@chainsafe/ssz"; import { fromHexString } from "@chainsafe/ssz";
@ -9,7 +14,14 @@ import axiosRetry from "axios-retry";
import axios from "axios"; import axios from "axios";
import { digest } from "@chainsafe/as-sha256"; import { digest } from "@chainsafe/as-sha256";
import { concatBytes } from "@noble/hashes/utils"; import { concatBytes } from "@noble/hashes/utils";
import { deserializeSyncCommittee } from "@lodestar/light-client/utils"; import {
deserializeSyncCommittee,
isValidMerkleBranch,
} from "@lodestar/light-client/utils";
import {
BLOCK_BODY_EXECUTION_PAYLOAD_DEPTH as EXECUTION_PAYLOAD_DEPTH,
BLOCK_BODY_EXECUTION_PAYLOAD_INDEX as EXECUTION_PAYLOAD_INDEX,
} from "@lodestar/params";
export function getDefaultClientConfig() { export function getDefaultClientConfig() {
const chainConfig = createBeaconConfig( const chainConfig = createBeaconConfig(
@ -103,3 +115,19 @@ export async function getConsensusOptimisticUpdate() {
return update.data; return update.data;
} }
function isValidLightClientHeader(
config: ChainForkConfig,
header: allForks.LightClientHeader,
): boolean {
return isValidMerkleBranch(
config
.getExecutionForkTypes(header.beacon.slot)
.ExecutionPayloadHeader.hashTreeRoot(
(header as capella.LightClientHeader).execution,
),
(header as capella.LightClientHeader).executionBranch,
EXECUTION_PAYLOAD_DEPTH,
EXECUTION_PAYLOAD_INDEX,
header.beacon.bodyRoot,
);
}