mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
Add zki.ISAccFeeOut generation for circuits compat
- add IntermediateStates AccFeeOut correct generation for circuits
compatibility at ZKInputs
- Fix formatAccumulatedFees
- organize ZKInputs tests to check compatibility with Circom circuits
- Add TestZKInputs2
- which checks ZKInputs for 4 L1 txs + 2 L2Txs with fees
- tested with Hermez Circom circuits
This commit is contained in:
@@ -240,8 +240,8 @@ func (s *StateDB) ProcessTxs(ptc ProcessTxsConfig, coordIdxs []common.Idx, l1use
|
||||
}
|
||||
s.zki.Metadata.L2TxsData = append(s.zki.Metadata.L2TxsData, l2TxData)
|
||||
|
||||
if s.i < nTx-1 {
|
||||
// Intermediate States
|
||||
if s.i < nTx-1 {
|
||||
s.zki.ISOutIdx[s.i] = s.idx.BigInt()
|
||||
s.zki.ISStateRoot[s.i] = s.mt.Root().BigInt()
|
||||
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 {
|
||||
s.zki.ISOutIdx[i] = s.idx.BigInt()
|
||||
s.zki.ISStateRoot[i] = s.mt.Root().BigInt()
|
||||
s.zki.ISAccFeeOut[i] = formatAccumulatedFees(collectedFees, s.zki.FeePlanTokens)
|
||||
}
|
||||
if i >= s.i {
|
||||
s.zki.TxCompressedData[i] = new(big.Int).SetBytes(common.SignatureConstantBytes)
|
||||
|
||||
@@ -170,7 +170,7 @@ func formatAccumulatedFees(collectedFees map[common.TokenID]*big.Int, orderToken
|
||||
for i := 0; i < len(orderTokenIDs); i++ {
|
||||
tokenID := common.TokenIDFromBigInt(orderTokenIDs[i])
|
||||
if _, ok := collectedFees[tokenID]; ok {
|
||||
accFeeOut[i] = collectedFees[tokenID]
|
||||
accFeeOut[i] = new(big.Int).Set(collectedFees[tokenID])
|
||||
} else {
|
||||
accFeeOut[i] = big.NewInt(0)
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user