Merge pull request #135 from hermeznetwork/feature/synchronizer-sc

Smart Contracts Data Synchronization
This commit is contained in:
Eduard S
2020-09-21 14:40:10 +02:00
committed by GitHub
13 changed files with 437 additions and 94 deletions

View File

@@ -19,7 +19,7 @@ type Batch struct {
StateRoot Hash `meddler:"state_root"`
NumAccounts int `meddler:"num_accounts"`
ExitRoot Hash `meddler:"exit_root"`
ForgeL1TxsNum uint32 `meddler:"forge_l1_txs_num"` // optional, Only when the batch forges L1 txs. Identifier that corresponds to the group of L1 txs forged in the current batch.
ForgeL1TxsNum int64 `meddler:"forge_l1_txs_num"` // optional, Only when the batch forges L1 txs. Identifier that corresponds to the group of L1 txs forged in the current batch.
SlotNum SlotNum `meddler:"slot_num"` // Slot in which the batch is forged
}

View File

@@ -19,7 +19,7 @@ const (
type L1Tx struct {
// Stored in DB: mandatory fileds
TxID TxID
ToForgeL1TxsNum uint32 // toForgeL1TxsNum in which the tx was forged / will be forged
ToForgeL1TxsNum int64 // toForgeL1TxsNum in which the tx was forged / will be forged
Position int
UserOrigin bool // true if the tx was originated by a user, false if it was aoriginated by a coordinator. Note that this differ from the spec for implementation simplification purpposes
FromIdx Idx // FromIdx is used by L1Tx/Deposit to indicate the Idx receiver of the L1Tx.LoadAmount (deposit)

View File

@@ -2,6 +2,7 @@ package common
import (
"math/big"
"time"
eth "github.com/ethereum/go-ethereum/common"
)
@@ -30,6 +31,16 @@ type AuctionVars struct {
AllocationRatio AllocationRatio
}
// WithdrawalDelayerVars contains the Withdrawal Delayer smart contract variables
type WithdrawalDelayerVars struct {
HermezRollupAddress eth.Address
HermezGovernanceDAOAddress eth.Address
WhiteHackGroupAddress eth.Address
WithdrawalDelay uint
EmergencyModeStartingTime time.Time
EmergencyModeEnabled bool
}
// MinBidSlots TODO
type MinBidSlots [6]uint

12
common/syncstatus.go Normal file
View File

@@ -0,0 +1,12 @@
package common
import ethCommon "github.com/ethereum/go-ethereum/common"
// SyncStatus is returned by the Status method of the Synchronizer
type SyncStatus struct {
CurrentBlock int64
CurrentBatch BatchNum
CurrentForgerAddr ethCommon.Address
NextForgerAddr ethCommon.Address
Synchronized bool
}

View File

@@ -54,7 +54,7 @@ type Tx struct {
BatchNum BatchNum `meddler:"batch_num,zeroisnull"` // batchNum in which this tx was forged. If the tx is L2, this must be != 0
EthBlockNum int64 `meddler:"eth_block_num"` // Ethereum Block Number in which this L1Tx was added to the queue
// L1
ToForgeL1TxsNum uint32 `meddler:"to_forge_l1_txs_num"` // toForgeL1TxsNum in which the tx was forged / will be forged
ToForgeL1TxsNum int64 `meddler:"to_forge_l1_txs_num"` // toForgeL1TxsNum in which the tx was forged / will be forged
UserOrigin bool `meddler:"user_origin"` // true if the tx was originated by a user, false if it was aoriginated by a coordinator. Note that this differ from the spec for implementation simplification purpposes
FromEthAddr ethCommon.Address `meddler:"from_eth_addr"`
FromBJJ *babyjub.PublicKey `meddler:"from_bjj"`