Skip to content

Instantly share code, notes, and snippets.

@davbo davbo/main.go
Created Mar 8, 2019

What would you like to do?
Example of deadlocking the Trillian memory storage backend with a uninitialized log
package main
import (
stestonly ""
func main() {
th := rfc6962.DefaultHasher
var tree *trillian.Tree
ctx := context.Background()
sp, _ := server.NewStorageProvider("memory", nil)
sp.AdminStorage().ReadWriteTransaction(ctx, func(ctx context.Context, tx storage.AdminTX) error {
tree, _ = tx.CreateTree(ctx, stestonly.LogTree)
return nil
registry := extension.Registry{
AdminStorage: sp.AdminStorage(),
LogStorage: sp.LogStorage(),
timeSource := clock.System
logServer := *server.NewTrillianLogRPCServer(registry, timeSource)
data := []byte(`foo`)
hash, _:= th.HashLeaf(data)
leaf := &trillian.LogLeaf{
MerkleLeafHash: hash,
LeafValue: data,
LeafIdentityHash: hash,
req := &trillian.QueueLeavesRequest{LogId: tree.TreeId, Leaves: []*trillian.LogLeaf{leaf}}
logServer.QueueLeaves(ctx, req) // tx isn't closed
logServer.QueueLeaves(ctx, req) // blocks on acquiring lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.