mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +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:
@@ -25,20 +25,21 @@ type AuctionConstants struct {
|
||||
|
||||
// AuctionVariables are the variables of the Auction Smart Contract
|
||||
type AuctionVariables struct {
|
||||
EthBlockNum int64 `json:"ethereumBlockNum" meddler:"eth_block_num"`
|
||||
// Boot Coordinator Address
|
||||
DonationAddress ethCommon.Address `json:"donationAddress" meddler:"donation_address"`
|
||||
DonationAddress ethCommon.Address `json:"donationAddress" meddler:"donation_address" validate:"required"`
|
||||
// Boot Coordinator Address
|
||||
BootCoordinator ethCommon.Address `json:"bootCoordinator" meddler:"boot_coordinator"`
|
||||
BootCoordinator ethCommon.Address `json:"bootCoordinator" meddler:"boot_coordinator" validate:"required"`
|
||||
// The minimum bid value in a series of 6 slots
|
||||
DefaultSlotSetBid [6]*big.Int `json:"defaultSlotSetBid" meddler:"default_slot_set_bid,json"`
|
||||
DefaultSlotSetBid [6]*big.Int `json:"defaultSlotSetBid" meddler:"default_slot_set_bid,json" validate:"required"`
|
||||
// Distance (#slots) to the closest slot to which you can bid ( 2 Slots = 2 * 40 Blocks = 20 min )
|
||||
ClosedAuctionSlots uint16 `json:"closedAuctionSlots" meddler:"closed_auction_slots"`
|
||||
ClosedAuctionSlots uint16 `json:"closedAuctionSlots" meddler:"closed_auction_slots" validate:"required"`
|
||||
// Distance (#slots) to the farthest slot to which you can bid (30 days = 4320 slots )
|
||||
OpenAuctionSlots uint16 `json:"openAuctionSlots" meddler:"open_auction_slots"`
|
||||
OpenAuctionSlots uint16 `json:"openAuctionSlots" meddler:"open_auction_slots" validate:"required"`
|
||||
// How the HEZ tokens deposited by the slot winner are distributed (Burn: 40% - Donation: 40% - HGT: 20%)
|
||||
AllocationRatio [3]uint16 `json:"allocationRatio" meddler:"allocation_ratio,json"`
|
||||
AllocationRatio [3]uint16 `json:"allocationRatio" meddler:"allocation_ratio,json" validate:"required"`
|
||||
// Minimum outbid (percentage) over the previous one to consider it valid
|
||||
Outbidding uint16 `json:"outbidding" meddler:"outbidding"`
|
||||
Outbidding uint16 `json:"outbidding" meddler:"outbidding" validate:"required"`
|
||||
// Number of blocks at the end of a slot in which any coordinator can forge if the winner has not forged one before
|
||||
SlotDeadline uint8 `json:"slotDeadline" meddler:"slot_deadline"`
|
||||
SlotDeadline uint8 `json:"slotDeadline" meddler:"slot_deadline" validate:"required"`
|
||||
}
|
||||
|
||||
@@ -157,8 +157,9 @@ type Bucket struct {
|
||||
|
||||
// RollupVariables are the variables of the Rollup Smart Contract
|
||||
type RollupVariables struct {
|
||||
FeeAddToken *big.Int `json:"feeAddToken" meddler:"fee_addtoken"`
|
||||
ForgeL1L2BatchTimeout int64 `json:"forgeL1L2BatchTimeout" meddler:"forge_l1l2_timeout"`
|
||||
WithdrawalDelay uint64 `json:"withdrawalDelay" meddler:"withdrawal_delay"`
|
||||
Buckets [RollupConstNumBuckets]Bucket `json:"buckets" meddler:"buckets,json"`
|
||||
EthBlockNum int64 `json:"ethereumBlockNum" meddler:"eth_block_num"`
|
||||
FeeAddToken *big.Int `json:"feeAddToken" meddler:"fee_add_token,bigint" validate:"required"`
|
||||
ForgeL1L2BatchTimeout int64 `json:"forgeL1L2BatchTimeout" meddler:"forge_l1_timeout" validate:"required"`
|
||||
WithdrawalDelay uint64 `json:"withdrawalDelay" meddler:"withdrawal_delay" validate:"required"`
|
||||
// Buckets [RollupConstNumBuckets]Bucket `json:"buckets" meddler:"buckets,json"`
|
||||
}
|
||||
|
||||
@@ -14,11 +14,12 @@ type WDelayerConstants struct {
|
||||
|
||||
// WDelayerVariables are the variables of the Withdrawal Delayer Smart Contract
|
||||
type WDelayerVariables struct {
|
||||
HermezRollupAddress ethCommon.Address `json:"hermezRollupAddress" meddler:"rollup_address"`
|
||||
HermezGovernanceDAOAddress ethCommon.Address `json:"hermezGovernanceDAOAddress" meddler:"govdao_address"`
|
||||
WhiteHackGroupAddress ethCommon.Address `json:"whiteHackGroupAddress" meddler:"whg_address"`
|
||||
HermezKeeperAddress ethCommon.Address `json:"hermezKeeperAddress" meddler:"keeper_address"`
|
||||
WithdrawalDelay uint64 `json:"withdrawalDelay" meddler:"withdrawal_delay"`
|
||||
EthBlockNum int64 `json:"ethereumBlockNum" meddler:"eth_block_num"`
|
||||
// HermezRollupAddress ethCommon.Address `json:"hermezRollupAddress" meddler:"rollup_address"`
|
||||
HermezGovernanceDAOAddress ethCommon.Address `json:"hermezGovernanceDAOAddress" meddler:"govdao_address" validate:"required"`
|
||||
WhiteHackGroupAddress ethCommon.Address `json:"whiteHackGroupAddress" meddler:"whg_address" validate:"required"`
|
||||
HermezKeeperAddress ethCommon.Address `json:"hermezKeeperAddress" meddler:"keeper_address" validate:"required"`
|
||||
WithdrawalDelay uint64 `json:"withdrawalDelay" meddler:"withdrawal_delay" validate:"required"`
|
||||
EmergencyModeStartingTime uint64 `json:"emergencyModeStartingTime" meddler:"emergency_start_time"`
|
||||
EmergencyMode bool `json:"emergencyMode" meddler:"emergency_mode"`
|
||||
}
|
||||
|
||||
@@ -282,5 +282,7 @@ func L1CoordinatorTxFromBytes(b []byte) (*L1Tx, error) {
|
||||
return nil, err
|
||||
}
|
||||
tx.FromEthAddr = crypto.PubkeyToAddress(*pubKey)
|
||||
tx.Amount = big.NewInt(0)
|
||||
tx.LoadAmount = big.NewInt(0)
|
||||
return tx, nil
|
||||
}
|
||||
|
||||
@@ -158,6 +158,8 @@ func TestL1CoordinatorTxByteParsers(t *testing.T) {
|
||||
TokenID: 231,
|
||||
FromBJJ: pk,
|
||||
FromEthAddr: fromEthAddr,
|
||||
Amount: big.NewInt(0),
|
||||
LoadAmount: big.NewInt(0),
|
||||
}
|
||||
|
||||
bytesCoordinatorL1, err := l1Tx.BytesCoordinatorTx(signature)
|
||||
|
||||
Reference in New Issue
Block a user