Skip to content

Commit

Permalink
feat: make coprocessor sync interval configurable
Browse files Browse the repository at this point in the history
- Currently, this value is hardcoded to 10s. This could be too long,
  leading to artificial delay in the ciphertext being available in the
  coprocessor db.

- Now, make it configurable via environment variable.
  • Loading branch information
manoranjith committed Dec 4, 2024
1 parent b729cf8 commit 80390b1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion fhevm-engine/fhevm-go-coproc/fhevm/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ type ApiImpl struct {
store *SqliteComputationStore
address common.Address
aclContractAddress common.Address
flushInterval time.Duration
}

type SessionImpl struct {
Expand Down Expand Up @@ -429,10 +430,18 @@ func InitCoprocessor() (CoprocessorApi, error) {
}
aclContractAddress := common.HexToAddress(aclContractAddressHex)

coprocessorSyncIntervalString := os.Getenv("FHEVM_COPROCESSOR_SYNC_INTERVAL")
coprocessorSyncInterval, err := time.ParseDuration(coprocessorSyncIntervalString)
if err != nil {
return nil, fmt.Errorf("parsing FHEVM_COPROCESSOR_SYNC_INTERVAL (%s): %w", coprocessorSyncIntervalString, err)
}
fmt.Printf("Using coprocessor sync interval %s\n", coprocessorSyncInterval.String())

apiImpl := ApiImpl{
store: ciphertextDb,
address: fhevmContractAddress,
aclContractAddress: aclContractAddress,
flushInterval: coprocessorSyncInterval,
}

// background job to submit computations to coprocessor
Expand All @@ -448,7 +457,7 @@ func scheduleCoprocessorFlushes(impl *ApiImpl) {
// timer to send polling for messages every 10 seconds
go func() {
for {
time.Sleep(time.Millisecond * 10000)
time.Sleep(impl.flushInterval)
select {
case impl.store.jobChannel <- true:
default:
Expand Down

0 comments on commit 80390b1

Please sign in to comment.