Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New DB design #43

Merged
merged 187 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
187 commits
Select commit Hold shift + click to select a range
0522240
WIP ingest tool.
juagargi Jan 19, 2023
c251889
Use a processor structure instead of plain functions.
juagargi Jan 19, 2023
8d64850
rename MapReduce to processor
juagargi Jan 19, 2023
16a3cc3
Processor handles data parsing and map-reduce ops.
juagargi Jan 19, 2023
0716fe5
Ignore file containing the root hash data
juagargi Jan 19, 2023
f20a0e3
Package cert data into batches.
juagargi Jan 20, 2023
eaa0e73
Add a BatchProcessor.
juagargi Jan 20, 2023
277d003
WIP updating DB with certs
juagargi Jan 20, 2023
3b29c07
Store changes in DB.
juagargi Jan 20, 2023
607bc53
Preparing to do SMT updates.
juagargi Jan 23, 2023
d0b4e2c
Add modified domains to updates table.
juagargi Jan 24, 2023
ee2adc1
Update SMT.
juagargi Jan 24, 2023
c680ee1
Check clashes between batches also using SANs.
juagargi Jan 25, 2023
437d405
New DB structure.
juagargi Jan 27, 2023
b7cf9ea
WIP Insert certificates each in their own record.
juagargi Jan 27, 2023
db4c7b5
add profiling to ingest
juagargi Feb 2, 2023
790edc4
catch sigint
juagargi Feb 2, 2023
aba32b2
Specify num readers and parsers
juagargi Feb 2, 2023
1bb40e6
wip less verbose
juagargi Feb 2, 2023
aadf2b0
update mysql driver
juagargi Feb 7, 2023
b6fb9f4
Use MyISAM
juagargi Feb 7, 2023
3082896
Limit DB connections.
juagargi Feb 7, 2023
a1cc69b
Pipeline overhaul.
juagargi Feb 8, 2023
e655262
Certs table has id as UNIQUE primary key.
juagargi Feb 9, 2023
161db46
Finish all pipelines cleanly.
juagargi Feb 9, 2023
bcc5077
Bump to go 1.18.
juagargi Feb 13, 2023
b966009
Allow two update strategies: overwrite and keep.
juagargi Feb 13, 2023
c2b90c8
Fix bug sending wrong certificate ID sometimes.
juagargi Feb 13, 2023
43b3fee
Add domain_certs, and more fields to certs.
juagargi Feb 14, 2023
c2f9839
Added comment about aio-max-nr in sysctl.conf.
juagargi Feb 14, 2023
ac25da3
Remove recently added domain_certs table.
juagargi Feb 14, 2023
2c5e5d3
domains table indexed by domain, domain_payloads id is a hash.
juagargi Feb 21, 2023
fdca352
Only leaves inserted in domains.
juagargi Feb 21, 2023
f3d80df
Rename files.
juagargi Feb 21, 2023
782b619
Introduce a LRU cache in batch processor.
juagargi Feb 21, 2023
815c42b
Reading single certs checks cache and is done in parallel.
juagargi Feb 21, 2023
b80823e
Bugfix: presence checking in DB of nothing is ok.
juagargi Feb 21, 2023
201fcbc
First version of the presence cache.
juagargi Feb 21, 2023
2db2d46
XXX this code is buggy. WIP.
juagargi Feb 21, 2023
7ac2e4b
Change the cache to a simple RWLock cache.
juagargi Feb 21, 2023
2ab0383
Again the principal/shadow cache, no errors.
juagargi Feb 21, 2023
ebc6c83
Principal/Shadow cache in CSV ingest.
juagargi Feb 23, 2023
ca24cd1
Skip expired certificates.
juagargi Mar 16, 2023
955a61f
New caches package for ingest.
juagargi Mar 16, 2023
15e28f8
Coalesce payloads in one entry per domain.
juagargi Mar 17, 2023
1c00e63
Don't truncate tables on ingest.
juagargi Mar 17, 2023
e12ef44
Fix TruncateAllTables with the correct table names.
juagargi Mar 17, 2023
fe0f417
Adapt SMT updater to the new design.
juagargi Mar 17, 2023
438c93c
WIP new responder and DB functions.
juagargi Mar 17, 2023
dc8936c
Load root in the ingester.
juagargi Mar 20, 2023
72b3934
Compute the Signed Tree Head in the responder.
juagargi Mar 20, 2023
46a6014
Make the create_schema.sh script more modular.
juagargi Mar 20, 2023
d155cbd
Allow the creation of DBs in tests.
juagargi Mar 20, 2023
a1a6ce3
Refactor db package.
juagargi Mar 20, 2023
59cf8d5
Move testdata to tests/.
juagargi Mar 20, 2023
d68a689
Add configurability to the DB package.
juagargi Mar 20, 2023
cb32333
WIP Integration tests with CSV data.
juagargi Mar 21, 2023
bd67ff1
Inserting certificates in DB doesn't require parent payload.
juagargi Mar 21, 2023
e5ad34f
Remove the leaf marker isLeaf areLeaves.
juagargi Mar 22, 2023
7d76ccd
CoalescePayloadsForDirtyDomains in updater, config has a DBName.
juagargi Mar 22, 2023
9a0fe65
Minor changes to mapserver IT.
juagargi Mar 22, 2023
17eff74
Simplify SMT updater.
juagargi Mar 22, 2023
7af1d20
SMT updater partially in updater pkg.
juagargi Mar 22, 2023
0304dbd
Moved SMT update to updater pkg.
juagargi Mar 22, 2023
a816b6a
mapserver IT updates SMT.
juagargi Mar 22, 2023
a06815b
Create pkg/tests and move the tests/pkg/db there.
juagargi Mar 23, 2023
91a7c3a
Allow creation of test DBs during tests.
juagargi Mar 23, 2023
5ca431a
Temporary changes to easily debug unittest.
juagargi Mar 24, 2023
4646f3f
Clarify comments.
juagargi Mar 24, 2023
1d41bc9
Adding new UT for the new responder.
juagargi Mar 24, 2023
479cf01
New stored procedures to coalesce payloads.
juagargi Mar 24, 2023
1e83fe6
WIP extend the responder unit test.
juagargi Mar 24, 2023
80e5706
WIP extend the responder UT
juagargi Mar 28, 2023
0ea092e
Rename some table columns.
juagargi Mar 29, 2023
eff28da
Change coalescing method in DB.
juagargi Apr 4, 2023
bf278f7
Create new table domain_certs.
juagargi Apr 4, 2023
c8588c4
Re-enable the responder UT.
juagargi Apr 4, 2023
5e0d5cf
Two bugfixes: updating domains table and new responder.
juagargi Apr 4, 2023
bbbc13f
Rename column domain_payloads.payload to cert_payload.
juagargi Apr 5, 2023
0e0ece4
Redefining DomainEntry.
juagargi Apr 6, 2023
0807354
Changing util functions to read PEM.
juagargi Apr 6, 2023
a292aaa
Finish changing PEM functions.
juagargi Apr 6, 2023
5b1408f
Preparing the design overhaul of the policies part.
juagargi Apr 6, 2023
4d80a9b
Marshal to/from JSON overhaul preparation.
juagargi Apr 17, 2023
1d1bbbb
Finish JSON (un)marshal overhaul.
juagargi Apr 17, 2023
867c541
CertReader ReadAll.
juagargi Apr 24, 2023
3003f78
CertWriter.
juagargi Apr 24, 2023
6bc6e54
renaming util files without _
juagargi Apr 24, 2023
8d10e64
WIP new DomainEntry.
juagargi Apr 24, 2023
d61e435
WIP changing DomainEntry still
juagargi Apr 25, 2023
36775ba
ToJSON FromJSON also accept lists.
juagargi Apr 26, 2023
68642aa
New JSON functions.
juagargi Apr 29, 2023
70a46f6
More tests functionality.
juagargi May 2, 2023
60942e9
WIP continuing the responder UT.
juagargi May 2, 2023
16f3a6a
Use the IDs instead of payloads for proof.
juagargi May 3, 2023
00af2cb
Add UT for the coalescing in DB.
juagargi May 3, 2023
4a31bfc
When a test DB fails, return the stdout and stderr.
juagargi May 3, 2023
2e4bbe3
PolicyObjectBase has a Raw field with []byte.
juagargi May 3, 2023
3595140
Extending usability of policy objects.
juagargi May 3, 2023
e40a921
PolicyObjectBase has a Subject.
juagargi May 3, 2023
81845fa
Inserting policies.
juagargi May 3, 2023
d412bc7
WIP inserting policies.
juagargi May 4, 2023
07b67d3
Updater modifies certs and policies simultaneously.
juagargi May 4, 2023
17792a7
Fix bug and extend UT to cover it.
juagargi May 4, 2023
bbbd1ff
Extend DB test to cover policy coalescing.
juagargi May 4, 2023
df8df56
Rename certs coalescing stored procecure.
juagargi May 4, 2023
aba6a04
Always also coalesce policies.
juagargi May 4, 2023
6ca7931
Fix bug returning empty cert/pol IDs.
juagargi May 4, 2023
705d521
Simplify Hash functions in common.
juagargi May 4, 2023
93f4891
Functions to fold/unfold IDs into bytes.
juagargi May 4, 2023
6a8bc06
Proofs with certs and policies IDs.
juagargi May 4, 2023
0a46c70
Check PoA as well.
juagargi May 16, 2023
d6db4a8
Test responder STH. Fix bugs.
juagargi May 17, 2023
3298a62
Remove old responder.
juagargi May 17, 2023
fa711c8
Fix logverifier tests pass.
juagargi May 22, 2023
81cc1cf
Cleanup pkg/tests/testdb
juagargi May 22, 2023
a4a0459
Cleanup pkg/tests/testdb and pkg/tests/random .
juagargi May 22, 2023
9c05f92
Fix pkg/pca build.
juagargi May 22, 2023
4e37351
Cleanup pkg/mapserver/common and tests.
juagargi May 22, 2023
dbf7f91
Tests in pkg/mapserver/trie pass again.
juagargi May 22, 2023
ac79f62
WIP temporarily disable some pkg/mapserver/updater tests.
juagargi May 23, 2023
b773cd3
Replace CTX509CertFromFile with CertReader.
juagargi May 23, 2023
0327bab
Replace X509CertFromFile with CertificateFromPEMFile.
juagargi May 23, 2023
a803f00
WIP refactoring crypto and tests.
juagargi May 23, 2023
8c36b85
Created pkg/common/crypto.
juagargi May 23, 2023
aeaab17
Fix bug coalesce not always sorted IDs.
juagargi May 23, 2023
8b69d04
WIP refactoring the updater type.
juagargi May 24, 2023
ad20a9f
Cleanup pkg/mapserver/updater
juagargi May 24, 2023
9627297
Fix build of pkg/domainowner .
juagargi May 24, 2023
d1ac392
Fix build of pkg/grpc/...
juagargi May 24, 2023
0b49463
Simplify connecting to test DB.
juagargi May 24, 2023
3bba090
Get rid of MockDB.
juagargi May 24, 2023
c389f86
Cleanup pkg/db.
juagargi May 24, 2023
e11a6dd
Renamed some DB methods.
juagargi May 24, 2023
d28fc31
Fix test.
juagargi May 31, 2023
f025e72
Add experimental collate function.
juagargi Jun 1, 2023
2867a05
Change collate function with FULL OUTER JOIN.
juagargi Jun 2, 2023
1ae5fcb
Payload functions in DB.
juagargi Jun 2, 2023
63104bb
Fix test function for random policies.
juagargi Jun 2, 2023
ff42961
Call to coalesce function with no parameters.
juagargi Jun 2, 2023
2ca394f
Remove unused tables and procs from schema.
juagargi Jun 2, 2023
93b0a51
Remove unused test function.
juagargi Jun 2, 2023
6b9996c
Cleaned up updater type.
juagargi Jun 2, 2023
ef9177d
Renamed logpicker to logfetcher.
juagargi Jun 2, 2023
dd8e7eb
Remove standalone mapserver benchmarks.
juagargi Jun 5, 2023
c069de0
Remove old unused integration tests.
juagargi Jun 5, 2023
ee5a536
New log fetcher based on google's certificate-transparency client.
juagargi Jun 8, 2023
071e715
Add speed test.
juagargi Jun 8, 2023
9a725d5
Fix bug with stopping.
juagargi Jun 9, 2023
8d3b6e7
Remove unused function, and simplify _if_ condition.
juagargi Jun 13, 2023
99127a3
Fix Check*Exist db functions.
juagargi Jun 13, 2023
7283036
Remove unused, wrong apps as tests under tests/.
juagargi Jun 13, 2023
686c49d
Rename Domain() to Subject() in PolicyObject.
juagargi Jun 13, 2023
297dec9
Add creation functions for policy objects.
juagargi Jun 15, 2023
acb3e8e
Split policies into two interfaces.
juagargi Jun 15, 2023
3e3bce4
Renamed two files.
juagargi Jun 15, 2023
e3bb170
Split policy documents into three files.
juagargi Jun 15, 2023
854060c
Rename Policy to DomainPolicy.
juagargi Jun 16, 2023
0ed7232
Rename MarshallableObject to MarshallableDocument.
juagargi Jun 16, 2023
07aea22
Split policy things into three interfaces/base types.
juagargi Jun 19, 2023
fb065b5
Make Issuer common to all.
juagargi Jun 19, 2023
205902c
Simplify policy interfaces, base objects.
juagargi Jun 19, 2023
03d6719
Added a boolean field in RPC to denote CA or not.
juagargi Jun 20, 2023
0aefcca
Moved SerialNumber to more general.
juagargi Jun 20, 2023
45eb1dc
Rename IsCA to IsIssuer.
juagargi Jun 21, 2023
8109ca6
Rename RPC to PolicyCertificate.
juagargi Jun 21, 2023
b0f138d
Rename and refactor policy objects.
juagargi Jun 22, 2023
b0669e5
New SPTs, new PCA workflow.
juagargi Jun 29, 2023
a14d3f1
Disable print for debug purposes in verifier.
juagargi Jun 29, 2023
fd6dd39
Rename PolicyCertificate.SPTs to SPCTs.
juagargi Jun 29, 2023
b6440c8
PolicyAttributes is not a slice, but just one element.
juagargi Jun 29, 2023
10baf34
Improved comment.
juagargi Jun 29, 2023
42d6f7b
Added field "Domain" to PolicyCertificate.
juagargi Jun 29, 2023
e2c48ae
Add a class diagram of the policy types.
juagargi Jun 30, 2023
c482184
Reproducible and deterministic RSA keys for tests.
juagargi Jul 10, 2023
21f7a00
Including generation of policy certificates for test.
juagargi Jul 10, 2023
d7d7d59
Change format for policy certificates to JSON in the tests.
juagargi Jul 10, 2023
af7517d
Introduced OwnerHash and IssuerHash.
juagargi Jul 11, 2023
a3754a7
Renamed Raw* fields to *Field.
juagargi Jul 11, 2023
0fd670b
Add a signing request for the revocation of pol certs.
juagargi Jul 21, 2023
bf42667
Rename field.
juagargi Jul 21, 2023
e45deb4
Owner and Issuer hash are computed the same way.
juagargi Jul 27, 2023
de17b68
Fix bug in unit test.
juagargi Jul 27, 2023
b5a6e51
CanOwn and CanIssue.
juagargi Jul 27, 2023
73a757e
Document how the hash of the revoked pol cert is computed.
juagargi Jul 27, 2023
7e3bfe3
Reconcile go modules after rebase.
juagargi Aug 4, 2023
d49b6b5
Cleanup create_schema.sh, remove redundant definition.
juagargi Oct 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ build_integration_test:
@go build -o ./bin/test_domainowner_pca_policlog_interaction ./tests/integration/domainowner_pca_policlog_interaction
@go build -o ./bin/test_mapserver ./tests/integration/mapserver
@go build -o ./bin/test_smt ./tests/integration/smt
@go build -o ./bin/test_db ./tests/integration/db
@go build -o ./bin/test_grpc ./tests/integration/grpc_test

drop_cacheTable:
Expand Down
214 changes: 0 additions & 214 deletions cmd/ingest/batch.go

This file was deleted.

12 changes: 12 additions & 0 deletions cmd/ingest/cache/cache.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package cache

import "github.com/netsec-ethz/fpki/pkg/common"

type Cache interface {
Contains(*common.SHA256Output) bool
AddIDs([]*common.SHA256Output)
}

func NewNoCache() NoCache {
return NoCache{}
}
13 changes: 13 additions & 0 deletions cmd/ingest/cache/noCache.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package cache

import "github.com/netsec-ethz/fpki/pkg/common"

type NoCache struct{}

// Contains always returns false (the item is never in cache).
func (NoCache) Contains(*common.SHA256Output) bool {
return false
}

// AddIDs doesn't do anything.
func (NoCache) AddIDs([]*common.SHA256Output) {}
88 changes: 88 additions & 0 deletions cmd/ingest/cache/presenceCache.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package cache

import (
"sync"

"github.com/netsec-ethz/fpki/pkg/common"
"go.uber.org/atomic"
)

const initialNumberOfElements = 1000000 // 1 million

// PresenceCache is, for now, just a set. It will consume memory unstoppably.
type PresenceCache struct {
sets [2]set // A regular set and its "shadow" (always a copy)
currentIdx atomic.Uint32 // The index of the current set.
readerCount [2]atomic.Int32 // How many routines reading from sets[0]

addingMu sync.Mutex
}

type set map[common.SHA256Output]struct{}

func NewPresenceCache() *PresenceCache {

sets := [...]set{
make(set, initialNumberOfElements),
make(set, initialNumberOfElements),
}
return &PresenceCache{
sets: sets,
// currentIdx: *atomic.NewUint32(0),
}
}

func (c *PresenceCache) Contains(id *common.SHA256Output) bool {
// To avoid race conditions, we must double check that the index didn't change before we were
// able to increment the reader counter. If it changed, repeat the operation.
for {
idx := c.currentIdx.Load()
c.readerCount[idx].Inc()
if c.currentIdx.Load() != idx {
// The writting routine won the race: unroll increment and repeat operation.
c.readerCount[idx].Dec()
continue
}
defer c.readerCount[idx].Dec()
s := c.sets[int(idx)]
_, ok := s[*id]
return ok
}
}

// AddIDs is thread safe.
func (c *PresenceCache) AddIDs(ids []*common.SHA256Output) {
c.addingMu.Lock()
defer c.addingMu.Unlock()

// Futex until all the readers have left the shadow (should almost always be noop).
for {
if c.readerCount[1].Load() == 0 {
break
}
// fmt.Println("shadow busy")
}
// Copy the local contents to the shadow.
for _, id := range ids {
c.sets[1][*id] = struct{}{}
}
// Modify the pointer to the set.
c.currentIdx.Store(1)
// Futex until all the readers have left current.
for {
if c.readerCount[0].Load() == 0 {
break
}
// fmt.Println("principal busy")
}
// Copy to current.
for _, id := range ids {
c.sets[0][*id] = struct{}{}
}
// Point back current.
c.currentIdx.Store(0)
}

func (c *PresenceCache) Size() int {
return len(c.sets[0])
}
Loading