Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddy J committed Nov 29, 2023
1 parent 39737b2 commit 80a0675
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
Binary file modified ProofGeneration
Binary file not shown.
9 changes: 3 additions & 6 deletions beacon_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,10 @@ const balanceListMerkleSubtreeNumLayers = uint64(40)
const withdrawalListMerkleSubtreeNumLayers = uint64(4)

// Number of layers for the merkleization of the Beacon State
const BEACON_STATE_MERKLE_SUBTREE_NUM_LAYERS = uint64(5)
const beaconStateMerkleSubtreeNumLayers = uint64(5)

// Number of layers for the merkleization of the Block Roots in the Beacon State
const BLOCK_ROOTS_MERKLE_SUBTREE_NUM_LAYERS = uint64(13)
const blockRootsMerkleSubtreeNumLayers = uint64(13)

// **************Number of fields of various containers**************
const BEACON_STATE_NUM_FIELDS = uint64(28)
const BEACON_BLOCK_HEADER_NUM_FIELDS = uint64(5)
const BEACON_BLOCK_BODY_NUM_FIELDS = uint64(11)
const EXECUTION_PAYLOAD_NUM_FIELDS = uint64(15)
const beaconBlockHeaderNumFields = uint64(5)
6 changes: 3 additions & 3 deletions merkle_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ func TestGetHistoricalSummariesBlockRootsProofProof(t *testing.T) {

currentBeaconStateRoot, _ := currentBeaconState.HashTreeRoot()

historicalBlockHeaderIndex := historicalSummaryIndex<<((historicalSummaryListMerkleSubtreeNumLayers+1)+1+(BLOCK_ROOTS_MERKLE_SUBTREE_NUM_LAYERS)) |
historicalSummaryIndex<<(1+BLOCK_ROOTS_MERKLE_SUBTREE_NUM_LAYERS) |
blockSummaryRootIndex<<(BLOCK_ROOTS_MERKLE_SUBTREE_NUM_LAYERS) | beaconBlockHeaderToVerifyIndex
historicalBlockHeaderIndex := historicalSummaryIndex<<((historicalSummaryListMerkleSubtreeNumLayers+1)+1+(blockRootsMerkleSubtreeNumLayers)) |
historicalSummaryIndex<<(1+blockRootsMerkleSubtreeNumLayers) |
blockSummaryRootIndex<<(blockRootsMerkleSubtreeNumLayers) | beaconBlockHeaderToVerifyIndex

flag := ValidateProof(currentBeaconStateRoot, historicalSummaryBlockHeaderProof, beaconBlockHeaderToVerify, historicalBlockHeaderIndex)
if flag != true {
Expand Down
6 changes: 3 additions & 3 deletions proofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func ProveWithdrawalAgainstExecutionPayload(
}

func ProveBlockRootAgainstBlockRootsList(blockRoots []phase0.Root, blockRootIndex uint64) (Proof, error) {
proof, err := GetProof(blockRoots, blockRootIndex, BLOCK_ROOTS_MERKLE_SUBTREE_NUM_LAYERS)
proof, err := GetProof(blockRoots, blockRootIndex, blockRootsMerkleSubtreeNumLayers)
if err != nil {
return nil, err
}
Expand All @@ -143,7 +143,7 @@ func ProveBeaconTopLevelRootAgainstBeaconState(beaconTopLevelRoots *BeaconStateT
roots[i] = v.(phase0.Root)
}

return GetProof(roots, index, BEACON_STATE_MERKLE_SUBTREE_NUM_LAYERS)
return GetProof(roots, index, beaconStateMerkleSubtreeNumLayers)
}

func ProveWithdrawalAgainstWithdrawalList(withdrawals []*capella.Withdrawal, withdrawalIndex uint8) (Proof, error) {
Expand Down Expand Up @@ -1031,7 +1031,7 @@ func GetExecutionPayloadFieldRoots(executionPayloadFields *capella.ExecutionPayl
}

func GetBlockHeaderFieldRoots(blockHeader *phase0.BeaconBlockHeader) ([]phase0.Root, error) {
blockHeaderContainerRoots := make([]phase0.Root, BEACON_BLOCK_HEADER_NUM_FIELDS)
blockHeaderContainerRoots := make([]phase0.Root, beaconBlockHeaderNumFields)

hh := ssz.NewHasher()

Expand Down

0 comments on commit 80a0675

Please sign in to comment.