Browse Source

Update ZKInputs for empty batches

- Add TestZKInputsEmpty circom test vectors
- Fix ZKInputsHash OldLastIdx bytearray
feature/sql-semaphore1
arnaucube 4 years ago
parent
commit
2583d35adf
3 changed files with 32 additions and 19 deletions
  1. +3
    -2
      common/zk.go
  2. +1
    -0
      db/statedb/txprocessors.go
  3. +28
    -17
      db/statedb/zkinputsgen_test.go

+ 3
- 2
common/zk.go

@ -431,8 +431,9 @@ func (z ZKInputs) ToHashGlobalData() ([]byte, error) {
// [MAX_NLEVELS bits] oldLastIdx
oldLastIdx := make([]byte, bytesMaxLevels)
copy(oldLastIdx, z.OldLastIdx.Bytes())
b = append(b, SwapEndianness(oldLastIdx)...)
oldLastIdxBytes := z.OldLastIdx.Bytes()
copy(oldLastIdx[len(oldLastIdx)-len(oldLastIdxBytes):], oldLastIdxBytes)
b = append(b, oldLastIdx...)
// [MAX_NLEVELS bits] newLastIdx
newLastIdx := make([]byte, bytesMaxLevels)

+ 1
- 0
db/statedb/txprocessors.go

@ -96,6 +96,7 @@ func (s *StateDB) ProcessTxs(ptc ProcessTxsConfig, coordIdxs []common.Idx, l1use
s.zki = common.NewZKInputs(ptc.MaxTx, ptc.MaxL1Tx, ptc.MaxTx, ptc.MaxFeeTx, ptc.NLevels, s.currentBatch.BigInt())
s.zki.OldLastIdx = s.idx.BigInt()
s.zki.OldStateRoot = s.mt.Root().BigInt()
s.zki.Metadata.NewLastIdxRaw = s.idx
}
// TBD if ExitTree is only in memory or stored in disk, for the moment

+ 28
- 17
db/statedb/zkinputsgen_test.go
File diff suppressed because it is too large
View File


Loading…
Cancel
Save