mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-06 19:06:42 +01:00
Add circuit configuration to node config
- Remove MaxL1CoordTxs parameter from the TxSelector because this parameter doesn't exist - Use ChainID in l1tx byte encoding - Pass txprocessor configuration to batch builder via an existing parameter
This commit is contained in:
@@ -1,56 +1,14 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
ethCommon "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/hermeznetwork/tracerr"
|
||||
)
|
||||
|
||||
// RollupVars contain the Rollup smart contract variables
|
||||
// type RollupVars struct {
|
||||
// EthBlockNum uint64
|
||||
// ForgeL1Timeout *big.Int
|
||||
// FeeL1UserTx *big.Int
|
||||
// FeeAddToken *big.Int
|
||||
// TokensHEZ eth.Address
|
||||
// Governance eth.Address
|
||||
// }
|
||||
|
||||
// AuctionVars contain the Auction smart contract variables
|
||||
// type AuctionVars struct {
|
||||
// EthBlockNum uint64
|
||||
// SlotDeadline uint
|
||||
// CloseAuctionSlots uint
|
||||
// OpenAuctionSlots uint
|
||||
// Governance eth.Address
|
||||
// MinBidSlots MinBidSlots
|
||||
// Outbidding int
|
||||
// DonationAddress eth.Address
|
||||
// GovernanceAddress eth.Address
|
||||
// AllocationRatio AllocationRatio
|
||||
// }
|
||||
|
||||
// WithdrawDelayerVars contains the Withdrawal Delayer smart contract variables
|
||||
// type WithdrawDelayerVars struct {
|
||||
// HermezRollupAddress eth.Address
|
||||
// HermezGovernanceAddress eth.Address
|
||||
// EmergencyCouncilAddress eth.Address
|
||||
// WithdrawalDelay uint
|
||||
// EmergencyModeStartingTime time.Time
|
||||
// EmergencyModeEnabled bool
|
||||
// }
|
||||
|
||||
// MinBidSlots TODO
|
||||
// type MinBidSlots [6]uint
|
||||
//
|
||||
// // AllocationRatio TODO
|
||||
// type AllocationRatio struct {
|
||||
// Donation uint
|
||||
// Burn uint
|
||||
// Forger uint
|
||||
// }
|
||||
|
||||
const (
|
||||
// RollupConstMaxFeeIdxCoordinator is the maximum number of tokens the
|
||||
// coordinator can use to collect fees (determines the number of tokens
|
||||
@@ -146,6 +104,18 @@ type RollupConstants struct {
|
||||
WithdrawDelayerContract ethCommon.Address `json:"withdrawDelayerContract"`
|
||||
}
|
||||
|
||||
// FindVerifierIdx tries to find a matching verifier in the RollupConstants and
|
||||
// returns its index
|
||||
func (c *RollupConstants) FindVerifierIdx(MaxTx, NLevels int64) (int, error) {
|
||||
for i, verifier := range c.Verifiers {
|
||||
if verifier.MaxTx == MaxTx && verifier.NLevels == NLevels {
|
||||
return i, nil
|
||||
}
|
||||
}
|
||||
return 0, tracerr.Wrap(fmt.Errorf("verifier not found for MaxTx: %v, NLevels: %v",
|
||||
MaxTx, NLevels))
|
||||
}
|
||||
|
||||
// BucketParams are the parameter variables of each Bucket of Rollup Smart
|
||||
// Contract
|
||||
type BucketParams struct {
|
||||
|
||||
@@ -176,7 +176,7 @@ func (tx L1Tx) Tx() Tx {
|
||||
// [ 16 bits ] chainId // 2 bytes
|
||||
// [ 32 bits ] empty (signatureConstant) // 4 bytes
|
||||
// Total bits compressed data: 241 bits // 31 bytes in *big.Int representation
|
||||
func (tx L1Tx) TxCompressedData() (*big.Int, error) {
|
||||
func (tx L1Tx) TxCompressedData(chainID uint16) (*big.Int, error) {
|
||||
amountFloat16, err := NewFloat16(tx.Amount)
|
||||
if err != nil {
|
||||
return nil, tracerr.Wrap(err)
|
||||
@@ -196,7 +196,7 @@ func (tx L1Tx) TxCompressedData() (*big.Int, error) {
|
||||
return nil, tracerr.Wrap(err)
|
||||
}
|
||||
copy(b[19:25], fromIdxBytes[:])
|
||||
copy(b[25:27], []byte{0, 0}) // TODO this will be generated by the ChainID config parameter
|
||||
binary.BigEndian.PutUint16(b[25:27], chainID)
|
||||
copy(b[27:31], SignatureConstantBytes[:])
|
||||
|
||||
bi := new(big.Int).SetBytes(b[:])
|
||||
|
||||
@@ -56,7 +56,8 @@ func TestL1TxCompressedData(t *testing.T) {
|
||||
Amount: big.NewInt(4),
|
||||
TokenID: 5,
|
||||
}
|
||||
txCompressedData, err := tx.TxCompressedData()
|
||||
chainID := uint16(0)
|
||||
txCompressedData, err := tx.TxCompressedData(chainID)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// test vector value generated from javascript implementation
|
||||
|
||||
Reference in New Issue
Block a user