Skip to content

Commit

Permalink
Bump witness library and fix storage (#359)
Browse files Browse the repository at this point in the history
Core witness API removed compact range support, so this needed to be removed from storage here.
  • Loading branch information
mhutchinson authored Nov 13, 2024
1 parent ca2364e commit 83dace7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/transparency-dev/armored-witness-os v0.3.0
github.com/transparency-dev/formats v0.0.0-20241003145927-a04dcc2a37e4
github.com/transparency-dev/serverless-log v0.0.0-20240408141044-5d483a81bdb7
github.com/transparency-dev/witness v0.0.0-20241104170145-1b7aedbc4a2b
github.com/transparency-dev/witness v0.0.0-20241112120223-bd45d190b37b
github.com/usbarmory/GoTEE v0.0.0-20240913144333-7e62563c0628
github.com/usbarmory/imx-enet v0.0.0-20240304151238-5b3010d57ea3
github.com/usbarmory/tamago v0.0.0-20240924114619-273d67cd811d
Expand Down Expand Up @@ -46,10 +46,10 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/transparency-dev/merkle v0.0.3-0.20240919113952-3c979d16ee14 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/time v0.7.0 // indirect
golang.org/x/time v0.8.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ github.com/transparency-dev/merkle v0.0.3-0.20240919113952-3c979d16ee14 h1:K8JqF
github.com/transparency-dev/merkle v0.0.3-0.20240919113952-3c979d16ee14/go.mod h1:EoKPjljyIALg1rldsJwRQVKOJO7sLd6eUqki19ruI80=
github.com/transparency-dev/serverless-log v0.0.0-20240408141044-5d483a81bdb7 h1:Caqvx+/b2hpuK5dHLMtKxoNsNhSf6JsT9m+7Xgk1z6Y=
github.com/transparency-dev/serverless-log v0.0.0-20240408141044-5d483a81bdb7/go.mod h1:A+cQ9EQeah/Ua7JaMOAAKkCfyDZPsq74o+UgwqQEPsQ=
github.com/transparency-dev/witness v0.0.0-20241104170145-1b7aedbc4a2b h1:fMqvcSDfjz9Nlhges1bDJjxdlPuxqgU/4LmoSr2Or7I=
github.com/transparency-dev/witness v0.0.0-20241104170145-1b7aedbc4a2b/go.mod h1:vvM7SPr5Jb7U9K+XILcuuWrPJPhe1lTMZg7Db/NtuEI=
github.com/transparency-dev/witness v0.0.0-20241112120223-bd45d190b37b h1:JSzWMbe8CLtAxIihjvkXbQKN2tFRSpTk0MHIlfxvaaA=
github.com/transparency-dev/witness v0.0.0-20241112120223-bd45d190b37b/go.mod h1:wiWDLKmQqGetLLythJZjC9vxKT5aWUkVHuonMA8RTqk=
github.com/usbarmory/GoTEE v0.0.0-20240913144333-7e62563c0628 h1:PGlLJYe1YMmzmSYXhEkOSXSrQjV/mXk6CNk5LTgnndM=
github.com/usbarmory/GoTEE v0.0.0-20240913144333-7e62563c0628/go.mod h1:solbXmDpRv6u6CmfHiFi3rwsYoTlZXToith669WnvgM=
github.com/usbarmory/imx-enet v0.0.0-20240304151238-5b3010d57ea3 h1:o6ixndtlZMRKOXcDCc2Mw6lSu1f79jmIaSY0wyzkmq4=
Expand All @@ -90,16 +90,16 @@ golang.org/x/crypto/x509roots/fallback v0.0.0-20230623170555-183630ada7e0 h1:8O7
golang.org/x/crypto/x509roots/fallback v0.0.0-20230623170555-183630ada7e0/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ=
golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0=
Expand Down
20 changes: 9 additions & 11 deletions trusted_applet/internal/storage/persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,46 +161,44 @@ type logRecord struct {
Proof []byte
}

// GetLatest returns the latest checkpoint and its compact range (if applicable).
// GetLatest returns the latest checkpoint.
// If no checkpoint exists, it must return codes.NotFound.
func (s *slotOps) GetLatest() ([]byte, []byte, error) {
func (s *slotOps) GetLatest() ([]byte, error) {
s.mu.RLock()
defer s.mu.RUnlock()

// TODO(al): workaround for storage assumption - see comment in ReadOps above.
if s.slot == nil {
return nil, nil, status.Error(codes.NotFound, "no checkpoint for log")
return nil, status.Error(codes.NotFound, "no checkpoint for log")
}

b, t, err := s.slot.Read()
if err != nil {
klog.Warningf("Read failed: %v", err)
return nil, nil, fmt.Errorf("failed to read data: %v", err)
return nil, fmt.Errorf("failed to read data: %v", err)
}
s.writeToken = t
if len(b) == 0 {
klog.Warningf("No checkpoint")
return nil, nil, status.Error(codes.NotFound, "no checkpoint for log")
return nil, status.Error(codes.NotFound, "no checkpoint for log")
}
lr := logRecord{}
if err := yaml.Unmarshal(b, &lr); err != nil {
klog.Warningf("Unmarshal failed: %v", err)
return nil, nil, fmt.Errorf("failed to unmarshal data: %v", err)
return nil, fmt.Errorf("failed to unmarshal data: %v", err)
}
klog.V(2).Infof("read:\n%s", lr.Checkpoint)
return lr.Checkpoint, lr.Proof, nil
return lr.Checkpoint, nil
}

// Set sets a new checkpoint and (optional) compact range
// for the log. This commits the state to persistence.
// Set sets a new checkpoint for the log. This commits the state to persistence.
// After this call, only Close() should be called on this object.
func (s *slotOps) Set(checkpointRaw []byte, compactRange []byte) error {
func (s *slotOps) Set(checkpointRaw []byte) error {
s.mu.Lock()
defer s.mu.Unlock()

lr := logRecord{
Checkpoint: checkpointRaw,
Proof: compactRange,
}

klog.V(2).Infof("writing with token %d:\n%s", s.writeToken, lr.Checkpoint)
Expand Down

0 comments on commit 83dace7

Please sign in to comment.