|
@ -203,7 +203,8 @@ type ZKInputs struct { |
|
|
// account creation type.
|
|
|
// account creation type.
|
|
|
ISOutIdx []*big.Int `json:"imOutIdx"` // uint64 (max nLevels bits), len: [nTx - 1]
|
|
|
ISOutIdx []*big.Int `json:"imOutIdx"` // uint64 (max nLevels bits), len: [nTx - 1]
|
|
|
// rollup-tx
|
|
|
// rollup-tx
|
|
|
// ISStateRoot root at the moment of the Tx (once processed), the state root value once the Tx is processed into the state tree
|
|
|
|
|
|
|
|
|
// ISStateRoot root at the moment of the Tx (once processed), the state
|
|
|
|
|
|
// root value once the Tx is processed into the state tree
|
|
|
ISStateRoot []*big.Int `json:"imStateRoot"` // Hash, len: [nTx - 1]
|
|
|
ISStateRoot []*big.Int `json:"imStateRoot"` // Hash, len: [nTx - 1]
|
|
|
// ISExitTree root at the moment (once processed) of the Tx the value
|
|
|
// ISExitTree root at the moment (once processed) of the Tx the value
|
|
|
// once the Tx is processed into the exit tree
|
|
|
// once the Tx is processed into the exit tree
|
|
@ -211,10 +212,12 @@ type ZKInputs struct { |
|
|
// ISAccFeeOut accumulated fees once the Tx is processed. Contains the
|
|
|
// ISAccFeeOut accumulated fees once the Tx is processed. Contains the
|
|
|
// array of FeeAccount Balances at each moment of each Tx processed.
|
|
|
// array of FeeAccount Balances at each moment of each Tx processed.
|
|
|
ISAccFeeOut [][]*big.Int `json:"imAccFeeOut"` // big.Int, len: [nTx - 1][maxFeeIdxs]
|
|
|
ISAccFeeOut [][]*big.Int `json:"imAccFeeOut"` // big.Int, len: [nTx - 1][maxFeeIdxs]
|
|
|
// fee-tx
|
|
|
|
|
|
// ISStateRootFee root at the moment of the Tx (once processed), the state root value once the Tx is processed into the state tree
|
|
|
|
|
|
|
|
|
// fee-tx:
|
|
|
|
|
|
// ISStateRootFee root at the moment of the Tx (once processed), the
|
|
|
|
|
|
// state root value once the Tx is processed into the state tree
|
|
|
ISStateRootFee []*big.Int `json:"imStateRootFee"` // Hash, len: [maxFeeIdxs - 1]
|
|
|
ISStateRootFee []*big.Int `json:"imStateRootFee"` // Hash, len: [maxFeeIdxs - 1]
|
|
|
// ISInitStateRootFee state root once all L1-L2 tx are processed (before computing the fees-tx)
|
|
|
|
|
|
|
|
|
// ISInitStateRootFee state root once all L1-L2 tx are processed
|
|
|
|
|
|
// (before computing the fees-tx)
|
|
|
ISInitStateRootFee *big.Int `json:"imInitStateRootFee"` // Hash
|
|
|
ISInitStateRootFee *big.Int `json:"imInitStateRootFee"` // Hash
|
|
|
// ISFinalAccFee final accumulated fees (before computing the fees-tx).
|
|
|
// ISFinalAccFee final accumulated fees (before computing the fees-tx).
|
|
|
// Contains the final values of the ISAccFeeOut parameter
|
|
|
// Contains the final values of the ISAccFeeOut parameter
|
|
@ -283,8 +286,8 @@ func NewZKInputs(nTx, maxL1Tx, maxTx, maxFeeIdxs, nLevels uint32, currentNumBatc |
|
|
zki := &ZKInputs{} |
|
|
zki := &ZKInputs{} |
|
|
zki.Metadata.NTx = nTx |
|
|
zki.Metadata.NTx = nTx |
|
|
zki.Metadata.MaxFeeIdxs = maxFeeIdxs |
|
|
zki.Metadata.MaxFeeIdxs = maxFeeIdxs |
|
|
zki.Metadata.NLevels = nLevels |
|
|
|
|
|
zki.Metadata.MaxLevels = uint32(48) //nolint:gomnd
|
|
|
zki.Metadata.MaxLevels = uint32(48) //nolint:gomnd
|
|
|
|
|
|
zki.Metadata.NLevels = nLevels |
|
|
zki.Metadata.MaxL1Tx = maxL1Tx |
|
|
zki.Metadata.MaxL1Tx = maxL1Tx |
|
|
zki.Metadata.MaxTx = maxTx |
|
|
zki.Metadata.MaxTx = maxTx |
|
|
|
|
|
|
|
@ -424,6 +427,7 @@ func (z ZKInputs) HashGlobalData() (*big.Int, error) { |
|
|
func (z ZKInputs) ToHashGlobalData() ([]byte, error) { |
|
|
func (z ZKInputs) ToHashGlobalData() ([]byte, error) { |
|
|
var b []byte |
|
|
var b []byte |
|
|
bytesMaxLevels := int(z.Metadata.MaxLevels / 8) //nolint:gomnd
|
|
|
bytesMaxLevels := int(z.Metadata.MaxLevels / 8) //nolint:gomnd
|
|
|
|
|
|
bytesNLevels := int(z.Metadata.NLevels / 8) //nolint:gomnd
|
|
|
|
|
|
|
|
|
// [MAX_NLEVELS bits] oldLastIdx
|
|
|
// [MAX_NLEVELS bits] oldLastIdx
|
|
|
oldLastIdx := make([]byte, bytesMaxLevels) |
|
|
oldLastIdx := make([]byte, bytesMaxLevels) |
|
@ -490,16 +494,10 @@ func (z ZKInputs) ToHashGlobalData() ([]byte, error) { |
|
|
|
|
|
|
|
|
// [NLevels * MAX_TOKENS_FEE bits] feeTxsData
|
|
|
// [NLevels * MAX_TOKENS_FEE bits] feeTxsData
|
|
|
for i := 0; i < len(z.FeeIdxs); i++ { |
|
|
for i := 0; i < len(z.FeeIdxs); i++ { |
|
|
var r []byte |
|
|
|
|
|
|
|
|
|
|
|
padding := make([]byte, bytesMaxLevels/4) //nolint:gomnd
|
|
|
|
|
|
r = append(r, padding...) |
|
|
|
|
|
|
|
|
|
|
|
feeIdx := make([]byte, bytesMaxLevels/2) //nolint:gomnd
|
|
|
|
|
|
|
|
|
feeIdx := make([]byte, bytesNLevels) //nolint:gomnd
|
|
|
feeIdxBytes := z.FeeIdxs[i].Bytes() |
|
|
feeIdxBytes := z.FeeIdxs[i].Bytes() |
|
|
copy(feeIdx[len(feeIdx)-len(feeIdxBytes):], feeIdxBytes[:]) |
|
|
copy(feeIdx[len(feeIdx)-len(feeIdxBytes):], feeIdxBytes[:]) |
|
|
r = append(r, feeIdx...) |
|
|
|
|
|
b = append(b, r...) |
|
|
|
|
|
|
|
|
b = append(b, feeIdx...) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// [16 bits] chainID
|
|
|
// [16 bits] chainID
|
|
|