Browse Source

Merge pull request #334 from hermeznetwork/feature/test-zkinputs2

Add zki.ISAccFeeOut generation for circuits compat
feature/sql-semaphore1
Eduard S 4 years ago
committed by GitHub
parent
commit
f229f49f0e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 220 additions and 68 deletions
  1. +2
    -1
      db/statedb/txprocessors.go
  2. +1
    -1
      db/statedb/utils.go
  3. +217
    -66
      db/statedb/zkinputsgen_test.go

+ 2
- 1
db/statedb/txprocessors.go

@ -240,8 +240,8 @@ func (s *StateDB) ProcessTxs(ptc ProcessTxsConfig, coordIdxs []common.Idx, l1use
} }
s.zki.Metadata.L2TxsData = append(s.zki.Metadata.L2TxsData, l2TxData) s.zki.Metadata.L2TxsData = append(s.zki.Metadata.L2TxsData, l2TxData)
// Intermediate States
if s.i < nTx-1 { if s.i < nTx-1 {
// Intermediate States
s.zki.ISOutIdx[s.i] = s.idx.BigInt() s.zki.ISOutIdx[s.i] = s.idx.BigInt()
s.zki.ISStateRoot[s.i] = s.mt.Root().BigInt() s.zki.ISStateRoot[s.i] = s.mt.Root().BigInt()
s.zki.ISAccFeeOut[s.i] = formatAccumulatedFees(collectedFees, s.zki.FeePlanTokens) s.zki.ISAccFeeOut[s.i] = formatAccumulatedFees(collectedFees, s.zki.FeePlanTokens)
@ -268,6 +268,7 @@ func (s *StateDB) ProcessTxs(ptc ProcessTxsConfig, coordIdxs []common.Idx, l1use
if i < int(ptc.MaxTx)-1 { if i < int(ptc.MaxTx)-1 {
s.zki.ISOutIdx[i] = s.idx.BigInt() s.zki.ISOutIdx[i] = s.idx.BigInt()
s.zki.ISStateRoot[i] = s.mt.Root().BigInt() s.zki.ISStateRoot[i] = s.mt.Root().BigInt()
s.zki.ISAccFeeOut[i] = formatAccumulatedFees(collectedFees, s.zki.FeePlanTokens)
} }
if i >= s.i { if i >= s.i {
s.zki.TxCompressedData[i] = new(big.Int).SetBytes(common.SignatureConstantBytes) s.zki.TxCompressedData[i] = new(big.Int).SetBytes(common.SignatureConstantBytes)

+ 1
- 1
db/statedb/utils.go

@ -170,7 +170,7 @@ func formatAccumulatedFees(collectedFees map[common.TokenID]*big.Int, orderToken
for i := 0; i < len(orderTokenIDs); i++ { for i := 0; i < len(orderTokenIDs); i++ {
tokenID := common.TokenIDFromBigInt(orderTokenIDs[i]) tokenID := common.TokenIDFromBigInt(orderTokenIDs[i])
if _, ok := collectedFees[tokenID]; ok { if _, ok := collectedFees[tokenID]; ok {
accFeeOut[i] = collectedFees[tokenID]
accFeeOut[i] = new(big.Int).Set(collectedFees[tokenID])
} else { } else {
accFeeOut[i] = big.NewInt(0) accFeeOut[i] = big.NewInt(0)
} }

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


Loading…
Cancel
Save