mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 11:26:44 +01:00
Merge pull request #535 from hermeznetwork/fix/sync
Fix synchronizer, add verifier index config param
This commit is contained in:
@@ -96,3 +96,4 @@ Coordinator = true
|
|||||||
[Coordinator.Debug]
|
[Coordinator.Debug]
|
||||||
BatchPath = "/tmp/iden3-test/hermez/batchesdebug"
|
BatchPath = "/tmp/iden3-test/hermez/batchesdebug"
|
||||||
LightScrypt = true
|
LightScrypt = true
|
||||||
|
# RollupVerifierIndex = 0
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ type Coordinator struct {
|
|||||||
} `validate:"required"`
|
} `validate:"required"`
|
||||||
ServerProofs []ServerProof `validate:"required"`
|
ServerProofs []ServerProof `validate:"required"`
|
||||||
Circuit struct {
|
Circuit struct {
|
||||||
// VerifierIdx uint8 `validate:"required"`
|
|
||||||
// MaxTx is the maximum number of txs supported by the circuit
|
// MaxTx is the maximum number of txs supported by the circuit
|
||||||
MaxTx int64 `validate:"required"`
|
MaxTx int64 `validate:"required"`
|
||||||
// NLevels is the maximum number of merkle tree levels
|
// NLevels is the maximum number of merkle tree levels
|
||||||
@@ -132,6 +131,10 @@ type Coordinator struct {
|
|||||||
// LightScrypt if set, uses light parameters for the ethereum
|
// LightScrypt if set, uses light parameters for the ethereum
|
||||||
// keystore encryption algorithm.
|
// keystore encryption algorithm.
|
||||||
LightScrypt bool
|
LightScrypt bool
|
||||||
|
// RollupVerifierIndex is the index of the verifier to use in
|
||||||
|
// the Rollup smart contract. The verifier chosen by index
|
||||||
|
// must match with the Circuit parameters.
|
||||||
|
RollupVerifierIndex *int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -799,14 +799,14 @@ func (c *AuctionClient) AuctionEventInit() (*AuctionEventInitialize, int64, erro
|
|||||||
// AuctionEventsByBlock returns the events in a block that happened in the
|
// AuctionEventsByBlock returns the events in a block that happened in the
|
||||||
// Auction Smart Contract.
|
// Auction Smart Contract.
|
||||||
// To query by blockNum, set blockNum >= 0 and blockHash == nil.
|
// To query by blockNum, set blockNum >= 0 and blockHash == nil.
|
||||||
// To query by blockHash, set blockNum == -1 and blockHash != nil.
|
// To query by blockHash set blockHash != nil, and blockNum will be ignored.
|
||||||
// If there are no events in that block the result is nil.
|
// If there are no events in that block the result is nil.
|
||||||
func (c *AuctionClient) AuctionEventsByBlock(blockNum int64,
|
func (c *AuctionClient) AuctionEventsByBlock(blockNum int64,
|
||||||
blockHash *ethCommon.Hash) (*AuctionEvents, error) {
|
blockHash *ethCommon.Hash) (*AuctionEvents, error) {
|
||||||
var auctionEvents AuctionEvents
|
var auctionEvents AuctionEvents
|
||||||
|
|
||||||
var blockNumBigInt *big.Int
|
var blockNumBigInt *big.Int
|
||||||
if blockNum >= 0 {
|
if blockHash == nil {
|
||||||
blockNumBigInt = big.NewInt(blockNum)
|
blockNumBigInt = big.NewInt(blockNum)
|
||||||
}
|
}
|
||||||
query := ethereum.FilterQuery{
|
query := ethereum.FilterQuery{
|
||||||
|
|||||||
@@ -738,14 +738,14 @@ func (c *RollupClient) RollupEventInit() (*RollupEventInitialize, int64, error)
|
|||||||
// RollupEventsByBlock returns the events in a block that happened in the
|
// RollupEventsByBlock returns the events in a block that happened in the
|
||||||
// Rollup Smart Contract.
|
// Rollup Smart Contract.
|
||||||
// To query by blockNum, set blockNum >= 0 and blockHash == nil.
|
// To query by blockNum, set blockNum >= 0 and blockHash == nil.
|
||||||
// To query by blockHash, set blockNum == -1 and blockHash != nil.
|
// To query by blockHash set blockHash != nil, and blockNum will be ignored.
|
||||||
// If there are no events in that block the result is nil.
|
// If there are no events in that block the result is nil.
|
||||||
func (c *RollupClient) RollupEventsByBlock(blockNum int64,
|
func (c *RollupClient) RollupEventsByBlock(blockNum int64,
|
||||||
blockHash *ethCommon.Hash) (*RollupEvents, error) {
|
blockHash *ethCommon.Hash) (*RollupEvents, error) {
|
||||||
var rollupEvents RollupEvents
|
var rollupEvents RollupEvents
|
||||||
|
|
||||||
var blockNumBigInt *big.Int
|
var blockNumBigInt *big.Int
|
||||||
if blockNum >= 0 {
|
if blockHash == nil {
|
||||||
blockNumBigInt = big.NewInt(blockNum)
|
blockNumBigInt = big.NewInt(blockNum)
|
||||||
}
|
}
|
||||||
query := ethereum.FilterQuery{
|
query := ethereum.FilterQuery{
|
||||||
|
|||||||
@@ -426,14 +426,14 @@ func (c *WDelayerClient) WDelayerEventInit() (*WDelayerEventInitialize, int64, e
|
|||||||
// WDelayerEventsByBlock returns the events in a block that happened in the
|
// WDelayerEventsByBlock returns the events in a block that happened in the
|
||||||
// WDelayer Smart Contract.
|
// WDelayer Smart Contract.
|
||||||
// To query by blockNum, set blockNum >= 0 and blockHash == nil.
|
// To query by blockNum, set blockNum >= 0 and blockHash == nil.
|
||||||
// To query by blockHash, set blockNum == -1 and blockHash != nil.
|
// To query by blockHash set blockHash != nil, and blockNum will be ignored.
|
||||||
// If there are no events in that block the result is nil.
|
// If there are no events in that block the result is nil.
|
||||||
func (c *WDelayerClient) WDelayerEventsByBlock(blockNum int64,
|
func (c *WDelayerClient) WDelayerEventsByBlock(blockNum int64,
|
||||||
blockHash *ethCommon.Hash) (*WDelayerEvents, error) {
|
blockHash *ethCommon.Hash) (*WDelayerEvents, error) {
|
||||||
var wdelayerEvents WDelayerEvents
|
var wdelayerEvents WDelayerEvents
|
||||||
|
|
||||||
var blockNumBigInt *big.Int
|
var blockNumBigInt *big.Int
|
||||||
if blockNum >= 0 {
|
if blockHash == nil {
|
||||||
blockNumBigInt = big.NewInt(blockNum)
|
blockNumBigInt = big.NewInt(blockNum)
|
||||||
}
|
}
|
||||||
query := ethereum.FilterQuery{
|
query := ethereum.FilterQuery{
|
||||||
|
|||||||
25
node/node.go
25
node/node.go
@@ -252,7 +252,9 @@ func NewNode(mode Mode, cfg *config.Node) (*Node, error) {
|
|||||||
MaxFeeTx: common.RollupConstMaxFeeIdxCoordinator,
|
MaxFeeTx: common.RollupConstMaxFeeIdxCoordinator,
|
||||||
MaxL1Tx: common.RollupConstMaxL1Tx,
|
MaxL1Tx: common.RollupConstMaxL1Tx,
|
||||||
}
|
}
|
||||||
verifierIdx, err := scConsts.Rollup.FindVerifierIdx(
|
var verifierIdx int
|
||||||
|
if cfg.Coordinator.Debug.RollupVerifierIndex == nil {
|
||||||
|
verifierIdx, err = scConsts.Rollup.FindVerifierIdx(
|
||||||
cfg.Coordinator.Circuit.MaxTx,
|
cfg.Coordinator.Circuit.MaxTx,
|
||||||
cfg.Coordinator.Circuit.NLevels,
|
cfg.Coordinator.Circuit.NLevels,
|
||||||
)
|
)
|
||||||
@@ -260,6 +262,27 @@ func NewNode(mode Mode, cfg *config.Node) (*Node, error) {
|
|||||||
return nil, tracerr.Wrap(err)
|
return nil, tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
log.Infow("Found verifier that matches circuit config", "verifierIdx", verifierIdx)
|
log.Infow("Found verifier that matches circuit config", "verifierIdx", verifierIdx)
|
||||||
|
} else {
|
||||||
|
verifierIdx = *cfg.Coordinator.Debug.RollupVerifierIndex
|
||||||
|
log.Infow("Using debug verifier index from config", "verifierIdx", verifierIdx)
|
||||||
|
if verifierIdx >= len(scConsts.Rollup.Verifiers) {
|
||||||
|
return nil, tracerr.Wrap(
|
||||||
|
fmt.Errorf("verifierIdx (%v) >= "+
|
||||||
|
"len(scConsts.Rollup.Verifiers) (%v)",
|
||||||
|
verifierIdx, len(scConsts.Rollup.Verifiers)))
|
||||||
|
}
|
||||||
|
verifier := scConsts.Rollup.Verifiers[verifierIdx]
|
||||||
|
if verifier.MaxTx != cfg.Coordinator.Circuit.MaxTx ||
|
||||||
|
verifier.NLevels != cfg.Coordinator.Circuit.NLevels {
|
||||||
|
return nil, tracerr.Wrap(
|
||||||
|
fmt.Errorf("Circuit config and verifier params don't match. "+
|
||||||
|
"circuit.MaxTx = %v, circuit.NLevels = %v, "+
|
||||||
|
"verifier.MaxTx = %v, verifier.NLevels = %v",
|
||||||
|
cfg.Coordinator.Circuit.MaxTx, cfg.Coordinator.Circuit.NLevels,
|
||||||
|
verifier.MaxTx, verifier.NLevels,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
coord, err = coordinator.NewCoordinator(
|
coord, err = coordinator.NewCoordinator(
|
||||||
coordinator.Config{
|
coordinator.Config{
|
||||||
|
|||||||
Reference in New Issue
Block a user