Skip to content

Commit

Permalink
vochain/app.go: SetZkCircuit during beginBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
altergui committed Nov 28, 2023
1 parent 6145558 commit 117d7a4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions vochain/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
lru "github.com/hashicorp/golang-lru/v2"
"go.vocdoni.io/dvote/crypto/zk/circuit"
"go.vocdoni.io/dvote/test/testcommon/testutil"
"go.vocdoni.io/dvote/vochain/genesis"
"go.vocdoni.io/dvote/vochain/ist"
vstate "go.vocdoni.io/dvote/vochain/state"
"go.vocdoni.io/dvote/vochain/transaction"
Expand Down Expand Up @@ -259,6 +260,7 @@ func (app *BaseApplication) beginBlock(t time.Time, height uint32) {
app.State.Rollback()
app.startBlockTimestamp.Store(t.Unix())
app.State.SetHeight(height)
app.SetZkCircuit()
go app.State.CachePurge(height)
app.State.OnBeginBlock(vstate.BeginBlock{
Height: int64(height),
Expand Down Expand Up @@ -351,6 +353,15 @@ func (app *BaseApplication) Genesis() *tmtypes.GenesisDoc {
return app.genesisInfo
}

// SetZkCircuit updates the ZkCircuit if planned at the current height
func (app *BaseApplication) SetZkCircuit() {
if genesis, found := genesis.Genesis[app.ChainID()]; found {
if tag, found := genesis.Circuits[app.Height()]; found {
app.SetCircuitConfigTag(tag)
}
}
}

// SetCircuitConfigTag sets the current BaseApplication circuit config tag
// attribute to the provided one and loads the circuit configuration based on
// it. The available circuit config tags are defined in
Expand Down

0 comments on commit 117d7a4

Please sign in to comment.