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

Add zki.ISAccFeeOut generation for circuits compat
This commit is contained in:
Eduard S
2020-12-09 15:34:07 +01:00
committed by GitHub
3 changed files with 220 additions and 68 deletions

View File

@@ -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)
if s.i < nTx-1 {
// Intermediate States // Intermediate States
if s.i < nTx-1 {
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)

View File

@@ -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)
} }

File diff suppressed because one or more lines are too long