mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 11:26:44 +01:00
Update Synchronizer (node) implementation
- node:
- Extend config to add initial variables of the smart contracts used as
defaults before they are changed via events.
- In stopped channels, set size 1 so that panics are not witheld until the
node stops completely.
- common:
- In Smart Contract variables, comment:
- `WDelayerVariables.HermezRollupAddress` because it's not needed.
- `RollupVariables.Buckets` because there are no events for it, and for
now it's not used.
- historydb:
- Add functions to get and set smart contract variables.
- db:
- Add `Rollback` function in `utils.go` to reduce boilerplate in sql
transaction rollbacks in defers in db functions.
- Update `rollup_vars` and `auction_vars` (renamed from `consensus_vars`)
table, and add `wdelayer_vars` table.
- synchronizer:
- Synchronize WDelayer
- Handle SC variables properly
- test/ethclient:
- Add essential implementation of WDelayer
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package historydb
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"math"
|
||||
"math/big"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
ethCommon "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/hermeznetwork/hermez-node/common"
|
||||
dbUtils "github.com/hermeznetwork/hermez-node/db"
|
||||
"github.com/hermeznetwork/hermez-node/log"
|
||||
@@ -429,6 +431,52 @@ func TestGetL1UserTxs(t *testing.T) {
|
||||
assert.Equal(t, 0, len(l1UserTxs))
|
||||
}
|
||||
|
||||
func TestSetInitialSCVars(t *testing.T) {
|
||||
test.WipeDB(historyDB.DB())
|
||||
_, _, _, err := historyDB.GetSCVars()
|
||||
assert.Equal(t, sql.ErrNoRows, err)
|
||||
|
||||
//nolint:govet
|
||||
rollup := &common.RollupVariables{
|
||||
0,
|
||||
big.NewInt(10),
|
||||
12,
|
||||
13,
|
||||
}
|
||||
//nolint:govet
|
||||
auction := &common.AuctionVariables{
|
||||
0,
|
||||
ethCommon.BigToAddress(big.NewInt(2)),
|
||||
ethCommon.BigToAddress(big.NewInt(3)),
|
||||
[6]*big.Int{
|
||||
big.NewInt(1), big.NewInt(2), big.NewInt(3),
|
||||
big.NewInt(4), big.NewInt(5), big.NewInt(6),
|
||||
},
|
||||
2,
|
||||
4320,
|
||||
[3]uint16{10, 11, 12},
|
||||
1000,
|
||||
20,
|
||||
}
|
||||
//nolint:govet
|
||||
wDelayer := &common.WDelayerVariables{
|
||||
0,
|
||||
ethCommon.BigToAddress(big.NewInt(2)),
|
||||
ethCommon.BigToAddress(big.NewInt(3)),
|
||||
ethCommon.BigToAddress(big.NewInt(4)),
|
||||
13,
|
||||
14,
|
||||
false,
|
||||
}
|
||||
err = historyDB.SetInitialSCVars(rollup, auction, wDelayer)
|
||||
require.Nil(t, err)
|
||||
dbRollup, dbAuction, dbWDelayer, err := historyDB.GetSCVars()
|
||||
assert.Nil(t, err)
|
||||
require.Equal(t, rollup, dbRollup)
|
||||
require.Equal(t, auction, dbAuction)
|
||||
require.Equal(t, wDelayer, dbWDelayer)
|
||||
}
|
||||
|
||||
// setTestBlocks WARNING: this will delete the blocks and recreate them
|
||||
func setTestBlocks(from, to int64) []common.Block {
|
||||
test.WipeDB(historyDB.DB())
|
||||
|
||||
Reference in New Issue
Block a user