mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
Reorganize smart contract types, udate eth tests, etc.
- Move smart contract constants and structs for variables to
common/{ethrollup.go, ethauction.go, ethwdelayer.go}:
- This removes repeated code of the structs for variables
- Allows reusing the constants and variables from all modules without
import cycles
- Remove unused common/scvars.go
- In common.BlockData, split data from each smart contract into a sepparate
field (Rollup, Auction, WDelayer). This affects the structures that til uses
as output, and HistoryDB in the AddBlockSCData.
- In Synchronizer:
- Pass starting block of each smart contract as config, instead of
incorrectly using the genesis block found in the acution constant (which
has a very different meaning)
- Use variable structs from common instead of an internal copy
- Synchronize more stuff (resolve some TODOs)
- Fix some issues found after initial testing with ganache
- In eth:
- In auction.go: Add method to get constants
- Update README to use ganache instead of buidlerevm as local blockchain
for testing
- Update env variables and test vectors to pass the tests with the
deployment in the ganache testnet.
- Use ethereum keys derived from paths (hdwallet) in testing to avoid
hardcoding private keys and generate the same keys from a mnemonic used
in the ganache tesnet.
This commit is contained in:
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/hermeznetwork/hermez-node/db/historydb"
|
||||
"github.com/hermeznetwork/hermez-node/db/l2db"
|
||||
"github.com/hermeznetwork/hermez-node/db/statedb"
|
||||
"github.com/hermeznetwork/hermez-node/eth"
|
||||
"github.com/hermeznetwork/hermez-node/log"
|
||||
"github.com/hermeznetwork/hermez-node/test"
|
||||
"github.com/iden3/go-iden3-crypto/babyjub"
|
||||
@@ -91,32 +90,32 @@ func TestMain(m *testing.M) {
|
||||
l2DB := l2db.NewL2DB(database, 10, 100, 24*time.Hour)
|
||||
test.WipeDB(l2DB.DB()) // this will clean HistoryDB and L2DB
|
||||
// Config (smart contract constants)
|
||||
config.RollupConstants.ExchangeMultiplier = eth.RollupConstExchangeMultiplier
|
||||
config.RollupConstants.ExitIdx = eth.RollupConstExitIDx
|
||||
config.RollupConstants.ReservedIdx = eth.RollupConstReservedIDx
|
||||
config.RollupConstants.ExchangeMultiplier = common.RollupConstExchangeMultiplier
|
||||
config.RollupConstants.ExitIdx = common.RollupConstExitIDx
|
||||
config.RollupConstants.ReservedIdx = common.RollupConstReservedIDx
|
||||
config.RollupConstants.LimitLoadAmount, _ = new(big.Int).SetString("340282366920938463463374607431768211456", 10)
|
||||
config.RollupConstants.LimitL2TransferAmount, _ = new(big.Int).SetString("6277101735386680763835789423207666416102355444464034512896", 10)
|
||||
config.RollupConstants.LimitTokens = eth.RollupConstLimitTokens
|
||||
config.RollupConstants.L1CoordinatorTotalBytes = eth.RollupConstL1CoordinatorTotalBytes
|
||||
config.RollupConstants.L1UserTotalBytes = eth.RollupConstL1UserTotalBytes
|
||||
config.RollupConstants.MaxL1UserTx = eth.RollupConstMaxL1UserTx
|
||||
config.RollupConstants.MaxL1Tx = eth.RollupConstMaxL1Tx
|
||||
config.RollupConstants.InputSHAConstantBytes = eth.RollupConstInputSHAConstantBytes
|
||||
config.RollupConstants.NumBuckets = eth.RollupConstNumBuckets
|
||||
config.RollupConstants.MaxWithdrawalDelay = eth.RollupConstMaxWithdrawalDelay
|
||||
var rollupPublicConstants eth.RollupPublicConstants
|
||||
config.RollupConstants.LimitTokens = common.RollupConstLimitTokens
|
||||
config.RollupConstants.L1CoordinatorTotalBytes = common.RollupConstL1CoordinatorTotalBytes
|
||||
config.RollupConstants.L1UserTotalBytes = common.RollupConstL1UserTotalBytes
|
||||
config.RollupConstants.MaxL1UserTx = common.RollupConstMaxL1UserTx
|
||||
config.RollupConstants.MaxL1Tx = common.RollupConstMaxL1Tx
|
||||
config.RollupConstants.InputSHAConstantBytes = common.RollupConstInputSHAConstantBytes
|
||||
config.RollupConstants.NumBuckets = common.RollupConstNumBuckets
|
||||
config.RollupConstants.MaxWithdrawalDelay = common.RollupConstMaxWithdrawalDelay
|
||||
var rollupPublicConstants common.RollupConstants
|
||||
rollupPublicConstants.AbsoluteMaxL1L2BatchTimeout = 240
|
||||
rollupPublicConstants.HermezAuctionContract = ethCommon.HexToAddress("0x500D1d6A4c7D8Ae28240b47c8FCde034D827fD5e")
|
||||
rollupPublicConstants.HermezGovernanceDAOAddress = ethCommon.HexToAddress("0xeAD9C93b79Ae7C1591b1FB5323BD777E86e150d4")
|
||||
rollupPublicConstants.SafetyAddress = ethCommon.HexToAddress("0xE5904695748fe4A84b40b3fc79De2277660BD1D3")
|
||||
rollupPublicConstants.TokenHEZ = ethCommon.HexToAddress("0xf784709d2317D872237C4bC22f867d1BAe2913AB")
|
||||
rollupPublicConstants.WithdrawDelayerContract = ethCommon.HexToAddress("0xD6C850aeBFDC46D7F4c207e445cC0d6B0919BDBe")
|
||||
var verifier eth.RollupVerifierStruct
|
||||
var verifier common.RollupVerifierStruct
|
||||
verifier.MaxTx = 512
|
||||
verifier.NLevels = 32
|
||||
rollupPublicConstants.Verifiers = append(rollupPublicConstants.Verifiers, verifier)
|
||||
|
||||
var auctionConstants eth.AuctionConstants
|
||||
var auctionConstants common.AuctionConstants
|
||||
auctionConstants.BlocksPerSlot = 40
|
||||
auctionConstants.GenesisBlockNum = 100
|
||||
auctionConstants.GovernanceAddress = ethCommon.HexToAddress("0xeAD9C93b79Ae7C1591b1FB5323BD777E86e150d4")
|
||||
@@ -124,7 +123,7 @@ func TestMain(m *testing.M) {
|
||||
auctionConstants.HermezRollup = ethCommon.HexToAddress("0xEa960515F8b4C237730F028cBAcF0a28E7F45dE0")
|
||||
auctionConstants.TokenHEZ = ethCommon.HexToAddress("0xf784709d2317D872237C4bC22f867d1BAe2913AB")
|
||||
|
||||
var wdelayerConstants eth.WDelayerConstants
|
||||
var wdelayerConstants common.WDelayerConstants
|
||||
wdelayerConstants.HermezRollup = ethCommon.HexToAddress("0xEa960515F8b4C237730F028cBAcF0a28E7F45dE0")
|
||||
wdelayerConstants.MaxEmergencyModeTime = uint64(1000000)
|
||||
wdelayerConstants.MaxWithdrawalDelay = uint64(10000000)
|
||||
|
||||
Reference in New Issue
Block a user