Closed mixmasala closed 9 months ago
So it looks lik the json decoder is instructed to skip the inherited common.Config fields. I think the fix looks like this:
diff --git a/server/config.go b/server/config.go
index eea7a20..67a2e6b 100644
--- a/server/config.go
+++ b/server/config.go
@@ -11,7 +11,7 @@ import (
// Config represents the configuration needed to start a Talek server.
// configurations can be generated through util/talekutil
type Config struct {
- *common.Config `json:"-"`
+ *common.Config
// How many read requests should be made of the PIR server at a time?
ReadBatch int
And then usage is like so:
185418d0a9ae:/build/talek/cli/talekutil# rm *.json
185418d0a9ae:/build/talek/cli/talekutil# go build && ./talekutil --common --outfile common.json
185418d0a9ae:/build/talek/cli/talekutil# ./talekutil --incommon common.json --replica --outfile replica.json
185418d0a9ae:/build/talek/cli/talekutil# cd ../talekreplica/
185418d0a9ae:/build/talek/cli/talekreplica# ./talekreplica -f ../talekutil/common.json -c ../talekutil/replica.json
2023-07-26 12:29:15.271544 I | ---------------------
2023-07-26 12:29:15.271959 I | --- Talek Replica ---
2023-07-26 12:29:15.271984 I | ---------------------
2023-07-26 12:29:15.272096 I | Arguments:
2023-07-26 12:29:15.272125 I | config=../talekutil/replica.json
2023-07-26 12:29:15.272146 I | backing=cpu.0
2023-07-26 12:29:15.273472 I | Using the following configuration:
2023-07-26 12:29:15.273578 I | serverConfig=server.Config{Config:(*common.Config)(0xc0000e61e0), ReadBatch:8, WriteInterval:1000000000, ReadInterval:1000000000, TrustDomain:(*common.TrustDomainConfig)(0xc000110750), TrustDomainIndex:0}
2023-07-26 12:29:15.273655 I | serverConfig.Config=&common.Config{NumBuckets:0x400, BucketDepth:0x4, DataSize:0x400, BloomFalsePositive:0.042, WriteInterval:1000000000, ReadInterval:1000000000, InterestMultiple:0xa, InterestSeed:5577006791947779410, MaxLoadFactor:0.95, LoadFactorStep:0.05}
[CPU Shard (cpu.0)] INFO: 2023/07/26 12:29:15 shard_cpu.go:76: NewShardCPU(CPU Shard (cpu.0)) finished
2023-07-26 12:29:15.299724 I | Running.
But note that doing this puts the common.Config fields into the server.Config, so it isn't really necessary to have a separate common.Config file. Thoughts? I'm not very familiar with this project so I'm not sure what the intent was.
i think common config was separate because since it's shared / global that file would be put publicly / also provided to clients, while the rest of server config is specific to a given server operator.
I can c
So it looks lik the json decoder is instructed to skip the inherited common.Config fields. I think the fix looks like this:
diff --git a/server/config.go b/server/config.go index eea7a20..67a2e6b 100644 --- a/server/config.go +++ b/server/config.go @@ -11,7 +11,7 @@ import ( // Config represents the configuration needed to start a Talek server. // configurations can be generated through util/talekutil type Config struct { - *common.Config `json:"-"` + *common.Config // How many read requests should be made of the PIR server at a time? ReadBatch int
And then usage is like so:
185418d0a9ae:/build/talek/cli/talekutil# rm *.json 185418d0a9ae:/build/talek/cli/talekutil# go build && ./talekutil --common --outfile common.json 185418d0a9ae:/build/talek/cli/talekutil# ./talekutil --incommon common.json --replica --outfile replica.json 185418d0a9ae:/build/talek/cli/talekutil# cd ../talekreplica/ 185418d0a9ae:/build/talek/cli/talekreplica# ./talekreplica -f ../talekutil/common.json -c ../talekutil/replica.json 2023-07-26 12:29:15.271544 I | --------------------- 2023-07-26 12:29:15.271959 I | --- Talek Replica --- 2023-07-26 12:29:15.271984 I | --------------------- 2023-07-26 12:29:15.272096 I | Arguments: 2023-07-26 12:29:15.272125 I | config=../talekutil/replica.json 2023-07-26 12:29:15.272146 I | backing=cpu.0 2023-07-26 12:29:15.273472 I | Using the following configuration: 2023-07-26 12:29:15.273578 I | serverConfig=server.Config{Config:(*common.Config)(0xc0000e61e0), ReadBatch:8, WriteInterval:1000000000, ReadInterval:1000000000, TrustDomain:(*common.TrustDomainConfig)(0xc000110750), TrustDomainIndex:0} 2023-07-26 12:29:15.273655 I | serverConfig.Config=&common.Config{NumBuckets:0x400, BucketDepth:0x4, DataSize:0x400, BloomFalsePositive:0.042, WriteInterval:1000000000, ReadInterval:1000000000, InterestMultiple:0xa, InterestSeed:5577006791947779410, MaxLoadFactor:0.95, LoadFactorStep:0.05} [CPU Shard (cpu.0)] INFO: 2023/07/26 12:29:15 shard_cpu.go:76: NewShardCPU(CPU Shard (cpu.0)) finished 2023-07-26 12:29:15.299724 I | Running.
This does fix the serialization issue. There is a similar issue with libtalek.ClientConfig - where cli/talekclient needs the common.Config fields, so serializing a ClientConfig to json doesn't produce a usable config. See #95
fixed with #95
For some reason the json serialization of server.Config doesn't include common.Config:
The file written to outfile doesn't contain the Config section key, however:
Not sure why this occurs.