mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 19:36:44 +01:00
Abstract TxProcessor from StateDB
- Abstract TxProcessor from StateDB - Upgrade to last version of go-merkletree for the key-value DB usage
This commit is contained in:
@@ -3,14 +3,12 @@ package statedb
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
ethCommon "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/hermeznetwork/hermez-node/common"
|
||||
"github.com/hermeznetwork/hermez-node/log"
|
||||
"github.com/hermeznetwork/tracerr"
|
||||
"github.com/iden3/go-iden3-crypto/babyjub"
|
||||
"github.com/iden3/go-merkletree"
|
||||
)
|
||||
|
||||
func concatEthAddrTokenID(addr ethCommon.Address, tokenID common.TokenID) []byte {
|
||||
@@ -136,44 +134,3 @@ func (s *StateDB) GetTokenIDsFromIdxs(idxs []common.Idx) (map[common.TokenID]com
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func siblingsToZKInputFormat(s []*merkletree.Hash) []*big.Int {
|
||||
b := make([]*big.Int, len(s))
|
||||
for i := 0; i < len(s); i++ {
|
||||
b[i] = s[i].BigInt()
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// BJJCompressedTo256BigInts returns a [256]*big.Int array with the bit
|
||||
// representation of the babyjub.PublicKeyComp
|
||||
func BJJCompressedTo256BigInts(pkComp babyjub.PublicKeyComp) [256]*big.Int {
|
||||
var r [256]*big.Int
|
||||
b := pkComp[:]
|
||||
|
||||
for i := 0; i < 256; i++ {
|
||||
if b[i/8]&(1<<(i%8)) == 0 {
|
||||
r[i] = big.NewInt(0)
|
||||
} else {
|
||||
r[i] = big.NewInt(1)
|
||||
}
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// formatAccumulatedFees returns an array of [nFeeAccounts]*big.Int containing
|
||||
// the balance of each FeeAccount, taken from the 'collectedFees' map, in the
|
||||
// order of the 'orderTokenIDs'
|
||||
func formatAccumulatedFees(collectedFees map[common.TokenID]*big.Int, orderTokenIDs []*big.Int) []*big.Int {
|
||||
accFeeOut := make([]*big.Int, len(orderTokenIDs))
|
||||
for i := 0; i < len(orderTokenIDs); i++ {
|
||||
tokenID := common.TokenIDFromBigInt(orderTokenIDs[i])
|
||||
if _, ok := collectedFees[tokenID]; ok {
|
||||
accFeeOut[i] = new(big.Int).Set(collectedFees[tokenID])
|
||||
} else {
|
||||
accFeeOut[i] = big.NewInt(0)
|
||||
}
|
||||
}
|
||||
return accFeeOut
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user