Skip to content

Commit

Permalink
storage: Remove revision from GetMerkleNodes (#2391)
Browse files Browse the repository at this point in the history
Log trees always read from the revision corresponding to the root which
is read in the beginning of the transaction. There is no need for it to
make a roundtrip to the application layer.
  • Loading branch information
pav-kv authored Mar 11, 2021
1 parent a9d251b commit bfb7a0d
Show file tree
Hide file tree
Showing 20 changed files with 110 additions and 134 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
* Removed the deprecated crypto.NewSHA256Signer function.
* Finish removing the `LogMetadata.GetUnsequencedCounts()` method.

### Storage refactoring
* `NodeReader.GetMerkleNodes` does not accept revisions anymore. The
implementations must use the transaction's `ReadRevision` instead.
* TODO(pavelkalinnikov): More changes are coming, and will be added here.

## v1.3.13
[Published 2021-02-16](https://github.com/google/trillian/releases/tag/v1.3.13)

Expand Down
2 changes: 1 addition & 1 deletion log/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (s Sequencer) initCompactRangeFromStorage(ctx context.Context, root *types.
storIDs[i] = nodeID
}

nodes, err := tx.GetMerkleNodes(ctx, int64(root.Revision), storIDs)
nodes, err := tx.GetMerkleNodes(ctx, storIDs)
if err != nil {
return nil, fmt.Errorf("failed to get Merkle nodes: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions log/sequencer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func createTestContext(ctrl *gomock.Controller, params testParameters) (testCont
for _, node := range *params.merkleNodesGet {
ids = append(ids, node.NodeID)
}
mockTx.EXPECT().GetMerkleNodes(gomock.Any(), params.writeRevision-1, ids).Return(*params.merkleNodesGet, params.merkleNodesGetError)
mockTx.EXPECT().GetMerkleNodes(gomock.Any(), ids).Return(*params.merkleNodesGet, params.merkleNodesGetError)
}

if params.updatedLeaves != nil {
Expand Down Expand Up @@ -774,7 +774,7 @@ func TestIntegrateBatch_PutTokens(t *testing.T) {
logTX.EXPECT().DequeueLeaves(any, any, any).Return(test.leaves, nil)
logTX.EXPECT().LatestSignedLogRoot(any).Return(testSignedRoot16, nil)
if len(test.leaves) != 0 {
logTX.EXPECT().GetMerkleNodes(any, any, any).Return(compactTree16, nil)
logTX.EXPECT().GetMerkleNodes(any, any).Return(compactTree16, nil)
}
logTX.EXPECT().WriteRevision(gomock.Any()).AnyTimes().Return(int64(testRoot16.Revision+1), nil)
logTX.EXPECT().UpdateSequencedLeaves(any, any).AnyTimes().Return(nil)
Expand Down
16 changes: 2 additions & 14 deletions server/log_rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,14 +456,7 @@ func tryGetConsistencyProof(ctx context.Context, firstTreeSize, secondTreeSize,
if err != nil {
return nil, err
}

// Do all the node fetches at the second tree revision, which is what the node ids were calculated
// against.
rev, err := tx.ReadRevision(ctx)
if err != nil {
return nil, err
}
proof, err := fetchNodesAndBuildProof(ctx, tx, hasher, rev, 0, nodeFetches)
proof, err := fetchNodesAndBuildProof(ctx, tx, hasher, 0, nodeFetches)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -728,12 +721,7 @@ func getInclusionProofForLeafIndex(ctx context.Context, tx storage.ReadOnlyLogTr
if err != nil {
return nil, err
}

rev, err := tx.ReadRevision(ctx)
if err != nil {
return nil, err
}
return fetchNodesAndBuildProof(ctx, tx, hasher, rev, leafIndex, proofNodeIDs)
return fetchNodesAndBuildProof(ctx, tx, hasher, leafIndex, proofNodeIDs)
}

func (t *TrillianLogRPCServer) getTreeAndHasher(ctx context.Context, treeID int64, opts trees.GetOpts) (*trillian.Tree, hashers.LogHasher, error) {
Expand Down
55 changes: 16 additions & 39 deletions server/log_rpc_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ var (

tree1 = addTreeID(stestonly.LogTree, logID1)
getLogRootRequest1 = trillian.GetLatestSignedLogRootRequest{LogId: logID1}
revision1 = int64(5)
root1 = &types.LogRootV1{TimestampNanos: 987654321, RootHash: []byte("A NICE HASH"), TreeSize: 7, Revision: uint64(revision1)}
root1 = &types.LogRootV1{TimestampNanos: 987654321, RootHash: []byte("A NICE HASH"), TreeSize: 7, Revision: uint64(5)}
signedRoot1, _ = fixedSigner.SignLogRoot(root1)

getByHashRequest1 = trillian.GetLeavesByHashRequest{LogId: logID1, LeafHash: [][]byte{leafHash1, leafHash3}}
Expand Down Expand Up @@ -897,9 +896,8 @@ func TestGetProofByHashErrors(t *testing.T) {
tx := storage.NewMockLogTreeTX(c)
s.EXPECT().SnapshotForTree(gomock.Any(), cmpMatcher{tree1}).Return(tx, nil)
tx.EXPECT().LatestSignedLogRoot(gomock.Any()).Return(signedRoot1, nil)
tx.EXPECT().ReadRevision(gomock.Any()).Return(int64(root1.Revision), nil)
tx.EXPECT().GetLeavesByHash(gomock.Any(), [][]byte{leafHash1}, false).Return([]*trillian.LogLeaf{{LeafIndex: 2}}, nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), revision1, nodeIdsInclusionSize7Index2).Return([]tree.Node{}, errors.New("STORAGE"))
tx.EXPECT().GetMerkleNodes(gomock.Any(), nodeIdsInclusionSize7Index2).Return([]tree.Node{}, errors.New("STORAGE"))
tx.EXPECT().Close().Return(nil)
},
req: &getInclusionProofByHashRequest7,
Expand All @@ -911,10 +909,9 @@ func TestGetProofByHashErrors(t *testing.T) {
tx := storage.NewMockLogTreeTX(c)
s.EXPECT().SnapshotForTree(gomock.Any(), cmpMatcher{tree1}).Return(tx, nil)
tx.EXPECT().LatestSignedLogRoot(gomock.Any()).Return(signedRoot1, nil)
tx.EXPECT().ReadRevision(gomock.Any()).Return(int64(root1.Revision), nil)
tx.EXPECT().GetLeavesByHash(gomock.Any(), [][]byte{leafHash1}, false).Return([]*trillian.LogLeaf{{LeafIndex: 2}}, nil)
// The server expects three nodes from storage but we return only two
tx.EXPECT().GetMerkleNodes(gomock.Any(), revision1, nodeIdsInclusionSize7Index2).Return([]tree.Node{{NodeRevision: 3}, {NodeRevision: 2}}, nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), nodeIdsInclusionSize7Index2).Return([]tree.Node{{NodeRevision: 3}, {NodeRevision: 2}}, nil)
tx.EXPECT().Close().Return(nil)
},
req: &getInclusionProofByHashRequest7,
Expand All @@ -926,10 +923,9 @@ func TestGetProofByHashErrors(t *testing.T) {
tx := storage.NewMockLogTreeTX(c)
s.EXPECT().SnapshotForTree(gomock.Any(), cmpMatcher{tree1}).Return(tx, nil)
tx.EXPECT().LatestSignedLogRoot(gomock.Any()).Return(signedRoot1, nil)
tx.EXPECT().ReadRevision(gomock.Any()).Return(int64(root1.Revision), nil)
tx.EXPECT().GetLeavesByHash(gomock.Any(), [][]byte{leafHash1}, false).Return([]*trillian.LogLeaf{{LeafIndex: 2}}, nil)
// We set this up so one of the returned nodes has the wrong ID
tx.EXPECT().GetMerkleNodes(gomock.Any(), revision1, nodeIdsInclusionSize7Index2).Return([]tree.Node{{NodeID: nodeIdsInclusionSize7Index2[0], NodeRevision: 3}, {NodeID: stestonly.MustCreateNodeIDForTreeCoords(4, 5, 64), NodeRevision: 2}, {NodeID: nodeIdsInclusionSize7Index2[2], NodeRevision: 3}}, nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), nodeIdsInclusionSize7Index2).Return([]tree.Node{{NodeID: nodeIdsInclusionSize7Index2[0], NodeRevision: 3}, {NodeID: stestonly.MustCreateNodeIDForTreeCoords(4, 5, 64), NodeRevision: 2}, {NodeID: nodeIdsInclusionSize7Index2[2], NodeRevision: 3}}, nil)
tx.EXPECT().Close().Return(nil)
},
req: &getInclusionProofByHashRequest7,
Expand Down Expand Up @@ -1031,8 +1027,7 @@ func TestGetProofByHash(t *testing.T) {

mockTX.EXPECT().LatestSignedLogRoot(gomock.Any()).Return(signedRoot1, nil)
mockTX.EXPECT().GetLeavesByHash(gomock.Any(), [][]byte{leafHash1}, false).Return(tc.leavesByHashVal, nil)
mockTX.EXPECT().ReadRevision(gomock.Any()).Return(int64(root1.Revision), nil).AnyTimes()
mockTX.EXPECT().GetMerkleNodes(gomock.Any(), revision1, nodeIdsInclusionSize7Index2).Return([]tree.Node{
mockTX.EXPECT().GetMerkleNodes(gomock.Any(), nodeIdsInclusionSize7Index2).Return([]tree.Node{
{NodeID: nodeIdsInclusionSize7Index2[0], NodeRevision: 3, Hash: []byte("nodehash0")},
{NodeID: nodeIdsInclusionSize7Index2[1], NodeRevision: 2, Hash: []byte("nodehash1")},
{NodeID: nodeIdsInclusionSize7Index2[2], NodeRevision: 3, Hash: []byte("nodehash2")},
Expand Down Expand Up @@ -1132,8 +1127,7 @@ func TestGetProofByIndex(t *testing.T) {
tx := storage.NewMockLogTreeTX(c)
s.EXPECT().SnapshotForTree(gomock.Any(), cmpMatcher{tree1}).Return(tx, nil)
tx.EXPECT().LatestSignedLogRoot(gomock.Any()).Return(signedRoot1, nil)
tx.EXPECT().ReadRevision(gomock.Any()).Return(int64(root1.Revision), nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), revision1, nodeIdsInclusionSize7Index2).Return([]tree.Node{}, errors.New("STORAGE"))
tx.EXPECT().GetMerkleNodes(gomock.Any(), nodeIdsInclusionSize7Index2).Return([]tree.Node{}, errors.New("STORAGE"))
tx.EXPECT().Close().Return(nil)
},
req: &getInclusionProofByIndexRequest7,
Expand All @@ -1146,8 +1140,7 @@ func TestGetProofByIndex(t *testing.T) {
s.EXPECT().SnapshotForTree(gomock.Any(), cmpMatcher{tree1}).Return(tx, nil)
// The server expects three nodes from storage but we return only two
tx.EXPECT().LatestSignedLogRoot(gomock.Any()).Return(signedRoot1, nil)
tx.EXPECT().ReadRevision(gomock.Any()).Return(int64(root1.Revision), nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), revision1, nodeIdsInclusionSize7Index2).Return([]tree.Node{{NodeRevision: 3}, {NodeRevision: 2}}, nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), nodeIdsInclusionSize7Index2).Return([]tree.Node{{NodeRevision: 3}, {NodeRevision: 2}}, nil)
tx.EXPECT().Close().Return(nil)
},
req: &getInclusionProofByIndexRequest7,
Expand All @@ -1160,8 +1153,7 @@ func TestGetProofByIndex(t *testing.T) {
s.EXPECT().SnapshotForTree(gomock.Any(), cmpMatcher{tree1}).Return(tx, nil)
// We set this up so one of the returned nodes has the wrong ID
tx.EXPECT().LatestSignedLogRoot(gomock.Any()).Return(signedRoot1, nil)
tx.EXPECT().ReadRevision(gomock.Any()).Return(int64(root1.Revision), nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), revision1, nodeIdsInclusionSize7Index2).Return([]tree.Node{{NodeID: nodeIdsInclusionSize7Index2[0], NodeRevision: 3}, {NodeID: stestonly.MustCreateNodeIDForTreeCoords(4, 5, 64), NodeRevision: 2}, {NodeID: nodeIdsInclusionSize7Index2[2], NodeRevision: 3}}, nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), nodeIdsInclusionSize7Index2).Return([]tree.Node{{NodeID: nodeIdsInclusionSize7Index2[0], NodeRevision: 3}, {NodeID: stestonly.MustCreateNodeIDForTreeCoords(4, 5, 64), NodeRevision: 2}, {NodeID: nodeIdsInclusionSize7Index2[2], NodeRevision: 3}}, nil)
tx.EXPECT().Close().Return(nil)
},
req: &getInclusionProofByIndexRequest7,
Expand All @@ -1173,8 +1165,7 @@ func TestGetProofByIndex(t *testing.T) {
tx := storage.NewMockLogTreeTX(c)
s.EXPECT().SnapshotForTree(gomock.Any(), cmpMatcher{tree1}).Return(tx, nil)
tx.EXPECT().LatestSignedLogRoot(gomock.Any()).Return(signedRoot1, nil)
tx.EXPECT().ReadRevision(gomock.Any()).Return(int64(root1.Revision), nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), revision1, nodeIdsInclusionSize7Index2).Return([]tree.Node{{NodeID: nodeIdsInclusionSize7Index2[0], NodeRevision: 3}, {NodeID: nodeIdsInclusionSize7Index2[1], NodeRevision: 2}, {NodeID: nodeIdsInclusionSize7Index2[2], NodeRevision: 3}}, nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), nodeIdsInclusionSize7Index2).Return([]tree.Node{{NodeID: nodeIdsInclusionSize7Index2[0], NodeRevision: 3}, {NodeID: nodeIdsInclusionSize7Index2[1], NodeRevision: 2}, {NodeID: nodeIdsInclusionSize7Index2[2], NodeRevision: 3}}, nil)
tx.EXPECT().Commit(gomock.Any()).Return(errors.New("COMMIT"))
tx.EXPECT().Close().Return(nil)
},
Expand Down Expand Up @@ -1211,8 +1202,7 @@ func TestGetProofByIndex(t *testing.T) {
tx := storage.NewMockLogTreeTX(c)
s.EXPECT().SnapshotForTree(gomock.Any(), cmpMatcher{tree1}).Return(tx, nil)
tx.EXPECT().LatestSignedLogRoot(gomock.Any()).Return(signedRoot1, nil)
tx.EXPECT().ReadRevision(gomock.Any()).Return(int64(root1.Revision), nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), revision1, nodeIdsInclusionSize7Index2).Return([]tree.Node{
tx.EXPECT().GetMerkleNodes(gomock.Any(), nodeIdsInclusionSize7Index2).Return([]tree.Node{
{NodeID: nodeIdsInclusionSize7Index2[0], NodeRevision: 3, Hash: []byte("nodehash0")},
{NodeID: nodeIdsInclusionSize7Index2[1], NodeRevision: 2, Hash: []byte("nodehash1")},
{NodeID: nodeIdsInclusionSize7Index2[2], NodeRevision: 3, Hash: []byte("nodehash2")},
Expand Down Expand Up @@ -1322,8 +1312,7 @@ func TestGetEntryAndProof(t *testing.T) {
tx := storage.NewMockLogTreeTX(c)
s.EXPECT().SnapshotForTree(gomock.Any(), cmpMatcher{tree1}).Return(tx, nil)
tx.EXPECT().LatestSignedLogRoot(gomock.Any()).Return(signedRoot1, nil)
tx.EXPECT().ReadRevision(gomock.Any()).Return(int64(root1.Revision), nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), revision1, nodeIdsInclusionSize7Index2).Return([]tree.Node{
tx.EXPECT().GetMerkleNodes(gomock.Any(), nodeIdsInclusionSize7Index2).Return([]tree.Node{
{NodeID: nodeIdsInclusionSize7Index2[0], NodeRevision: 3, Hash: []byte("nodehash0")},
{NodeID: nodeIdsInclusionSize7Index2[1], NodeRevision: 2, Hash: []byte("nodehash1")},
{NodeID: nodeIdsInclusionSize7Index2[2], NodeRevision: 3, Hash: []byte("nodehash2")},
Expand All @@ -1340,8 +1329,7 @@ func TestGetEntryAndProof(t *testing.T) {
tx := storage.NewMockLogTreeTX(c)
s.EXPECT().SnapshotForTree(gomock.Any(), cmpMatcher{tree1}).Return(tx, nil)
tx.EXPECT().LatestSignedLogRoot(gomock.Any()).Return(signedRoot1, nil)
tx.EXPECT().ReadRevision(gomock.Any()).Return(int64(root1.Revision), nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), revision1, nodeIdsInclusionSize7Index2).Return([]tree.Node{
tx.EXPECT().GetMerkleNodes(gomock.Any(), nodeIdsInclusionSize7Index2).Return([]tree.Node{
{NodeID: nodeIdsInclusionSize7Index2[0], NodeRevision: 3, Hash: []byte("nodehash0")},
{NodeID: nodeIdsInclusionSize7Index2[1], NodeRevision: 2, Hash: []byte("nodehash1")},
{NodeID: nodeIdsInclusionSize7Index2[2], NodeRevision: 3, Hash: []byte("nodehash2")},
Expand Down Expand Up @@ -1383,8 +1371,7 @@ func TestGetEntryAndProof(t *testing.T) {
tx := storage.NewMockLogTreeTX(c)
s.EXPECT().SnapshotForTree(gomock.Any(), cmpMatcher{tree1}).Return(tx, nil)
tx.EXPECT().LatestSignedLogRoot(gomock.Any()).Return(signedRoot1, nil)
tx.EXPECT().ReadRevision(gomock.Any()).Return(int64(root1.Revision), nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), revision1, nodeIdsInclusionSize7Index2).Return([]tree.Node{
tx.EXPECT().GetMerkleNodes(gomock.Any(), nodeIdsInclusionSize7Index2).Return([]tree.Node{
{NodeID: nodeIdsInclusionSize7Index2[0], NodeRevision: 3, Hash: []byte("nodehash0")},
{NodeID: nodeIdsInclusionSize7Index2[1], NodeRevision: 2, Hash: []byte("nodehash1")},
{NodeID: nodeIdsInclusionSize7Index2[2], NodeRevision: 3, Hash: []byte("nodehash2")},
Expand All @@ -1402,8 +1389,7 @@ func TestGetEntryAndProof(t *testing.T) {
tx := storage.NewMockLogTreeTX(c)
s.EXPECT().SnapshotForTree(gomock.Any(), cmpMatcher{tree1}).Return(tx, nil)
tx.EXPECT().LatestSignedLogRoot(gomock.Any()).Return(signedRoot1, nil)
tx.EXPECT().ReadRevision(gomock.Any()).Return(int64(root1.Revision), nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), revision1, nodeIdsInclusionSize7Index2).Return([]tree.Node{
tx.EXPECT().GetMerkleNodes(gomock.Any(), nodeIdsInclusionSize7Index2).Return([]tree.Node{
{NodeID: nodeIdsInclusionSize7Index2[0], NodeRevision: 3, Hash: []byte("nodehash0")},
{NodeID: nodeIdsInclusionSize7Index2[1], NodeRevision: 2, Hash: []byte("nodehash1")},
{NodeID: nodeIdsInclusionSize7Index2[2], NodeRevision: 3, Hash: []byte("nodehash2")},
Expand Down Expand Up @@ -1446,8 +1432,7 @@ func TestGetEntryAndProof(t *testing.T) {
tx := storage.NewMockLogTreeTX(c)
s.EXPECT().SnapshotForTree(gomock.Any(), cmpMatcher{tree1}).Return(tx, nil)
tx.EXPECT().LatestSignedLogRoot(gomock.Any()).Return(signedRoot1, nil)
tx.EXPECT().ReadRevision(gomock.Any()).Return(int64(root1.Revision), nil)
tx.EXPECT().GetMerkleNodes(gomock.Any(), revision1, nodeIdsInclusionSize7Index2).Return([]tree.Node{
tx.EXPECT().GetMerkleNodes(gomock.Any(), nodeIdsInclusionSize7Index2).Return([]tree.Node{
{NodeID: nodeIdsInclusionSize7Index2[0], NodeRevision: 3, Hash: []byte("nodehash0")},
{NodeID: nodeIdsInclusionSize7Index2[1], NodeRevision: 2, Hash: []byte("nodehash1")},
{NodeID: nodeIdsInclusionSize7Index2[2], NodeRevision: 3, Hash: []byte("nodehash2")},
Expand Down Expand Up @@ -1581,7 +1566,6 @@ type consistProofTest struct {
root *trillian.SignedLogRoot
noRoot bool
rootErr error
noRev bool
nodeIDs []tree.NodeID
nodes []tree.Node
getNodesErr error
Expand All @@ -1598,23 +1582,20 @@ func TestGetConsistencyProof(t *testing.T) {
errStr: "SnapshotFor",
snapErr: errors.New("SnapshotForTree() failed"),
noRoot: true,
noRev: true,
noCommit: true,
},
{
// Storage fails to read the log root, should result in an error.
req: &getConsistencyProofRequest7,
errStr: "LatestSigned",
rootErr: errors.New("LatestSignedLogRoot() failed"),
noRev: true,
noCommit: true,
},
{
// Storage fails to unpack the log root, should result in an error.
req: &getConsistencyProofRequest7,
errStr: "not read current log root",
root: corruptLogRoot,
noRev: true,
noCommit: true,
},
{
Expand Down Expand Up @@ -1659,7 +1640,6 @@ func TestGetConsistencyProof(t *testing.T) {
req: &getConsistencyProofRequest48,
wantHashes: nil,
nodeIDs: nil,
noRev: true,
noCommit: true,
},
{
Expand Down Expand Up @@ -1695,11 +1675,8 @@ func TestGetConsistencyProof(t *testing.T) {
}
mockTX.EXPECT().LatestSignedLogRoot(gomock.Any()).Return(root, test.rootErr)
}
if !test.noRev {
mockTX.EXPECT().ReadRevision(gomock.Any()).Return(int64(root1.Revision), nil)
}
if test.nodeIDs != nil {
mockTX.EXPECT().GetMerkleNodes(gomock.Any(), revision1, test.nodeIDs).Return(test.nodes, test.getNodesErr)
mockTX.EXPECT().GetMerkleNodes(gomock.Any(), test.nodeIDs).Return(test.nodes, test.getNodesErr)
}
if !test.noCommit {
mockTX.EXPECT().Commit(gomock.Any()).Return(test.commitErr)
Expand Down
8 changes: 4 additions & 4 deletions server/proof_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const proofMaxBitLen = 64
// This includes rehashing where necessary to serve proofs for tree sizes between stored tree
// revisions. This code only relies on the NodeReader interface so can be tested without
// a complete storage implementation.
func fetchNodesAndBuildProof(ctx context.Context, tx storage.NodeReader, th hashers.LogHasher, treeRevision, leafIndex int64, proofNodeFetches []merkle.NodeFetch) (*trillian.Proof, error) {
func fetchNodesAndBuildProof(ctx context.Context, tx storage.NodeReader, th hashers.LogHasher, leafIndex int64, proofNodeFetches []merkle.NodeFetch) (*trillian.Proof, error) {
ctx, spanEnd := spanFor(ctx, "fetchNodesAndBuildProof")
defer spanEnd()
proofNodes, err := fetchNodes(ctx, tx, treeRevision, proofNodeFetches)
proofNodes, err := fetchNodes(ctx, tx, proofNodeFetches)
if err != nil {
return nil, err
}
Expand All @@ -58,7 +58,7 @@ func fetchNodesAndBuildProof(ctx context.Context, tx storage.NodeReader, th hash

// fetchNodes extracts the NodeIDs from a list of NodeFetch structs and passes them
// to storage, returning the result after some additional validation checks.
func fetchNodes(ctx context.Context, tx storage.NodeReader, treeRevision int64, fetches []merkle.NodeFetch) ([]tree.Node, error) {
func fetchNodes(ctx context.Context, tx storage.NodeReader, fetches []merkle.NodeFetch) ([]tree.Node, error) {
ctx, spanEnd := spanFor(ctx, "fetchNodes")
defer spanEnd()
proofNodeIDs := make([]tree.NodeID, 0, len(fetches))
Expand All @@ -71,7 +71,7 @@ func fetchNodes(ctx context.Context, tx storage.NodeReader, treeRevision int64,
proofNodeIDs = append(proofNodeIDs, id)
}

proofNodes, err := tx.GetMerkleNodes(ctx, treeRevision, proofNodeIDs)
proofNodes, err := tx.GetMerkleNodes(ctx, proofNodeIDs)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit bfb7a0d

Please sign in to comment.