mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 11:26:44 +01:00
Merge pull request #325 from hermeznetwork/feature/ethclient-up-ev
Update ethclient
This commit is contained in:
@@ -369,6 +369,7 @@ func TestMain(m *testing.M) {
|
|||||||
Outbidding: uint16(1),
|
Outbidding: uint16(1),
|
||||||
SlotDeadline: uint8(20),
|
SlotDeadline: uint8(20),
|
||||||
BootCoordinator: ethCommon.HexToAddress("0x1111111111111111111111111111111111111111"),
|
BootCoordinator: ethCommon.HexToAddress("0x1111111111111111111111111111111111111111"),
|
||||||
|
BootCoordinatorURL: "https://boot.coordinator.io",
|
||||||
ClosedAuctionSlots: uint16(2),
|
ClosedAuctionSlots: uint16(2),
|
||||||
OpenAuctionSlots: uint16(5),
|
OpenAuctionSlots: uint16(5),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ func getConfigTest() Config {
|
|||||||
var rollupPublicConstants common.RollupConstants
|
var rollupPublicConstants common.RollupConstants
|
||||||
rollupPublicConstants.AbsoluteMaxL1L2BatchTimeout = 240
|
rollupPublicConstants.AbsoluteMaxL1L2BatchTimeout = 240
|
||||||
rollupPublicConstants.HermezAuctionContract = ethCommon.HexToAddress("0x500D1d6A4c7D8Ae28240b47c8FCde034D827fD5e")
|
rollupPublicConstants.HermezAuctionContract = ethCommon.HexToAddress("0x500D1d6A4c7D8Ae28240b47c8FCde034D827fD5e")
|
||||||
rollupPublicConstants.HermezGovernanceDAOAddress = ethCommon.HexToAddress("0xeAD9C93b79Ae7C1591b1FB5323BD777E86e150d4")
|
rollupPublicConstants.HermezGovernanceAddress = ethCommon.HexToAddress("0xeAD9C93b79Ae7C1591b1FB5323BD777E86e150d4")
|
||||||
rollupPublicConstants.SafetyAddress = ethCommon.HexToAddress("0xE5904695748fe4A84b40b3fc79De2277660BD1D3")
|
|
||||||
rollupPublicConstants.TokenHEZ = ethCommon.HexToAddress("0xf784709d2317D872237C4bC22f867d1BAe2913AB")
|
rollupPublicConstants.TokenHEZ = ethCommon.HexToAddress("0xf784709d2317D872237C4bC22f867d1BAe2913AB")
|
||||||
rollupPublicConstants.WithdrawDelayerContract = ethCommon.HexToAddress("0xD6C850aeBFDC46D7F4c207e445cC0d6B0919BDBe")
|
rollupPublicConstants.WithdrawDelayerContract = ethCommon.HexToAddress("0xD6C850aeBFDC46D7F4c207e445cC0d6B0919BDBe")
|
||||||
var verifier common.RollupVerifierStruct
|
var verifier common.RollupVerifierStruct
|
||||||
|
|||||||
@@ -2697,6 +2697,10 @@ components:
|
|||||||
- $ref: '#/components/schemas/EthereumAddress'
|
- $ref: '#/components/schemas/EthereumAddress'
|
||||||
- description: Ethereum address of the boot coordinator.
|
- description: Ethereum address of the boot coordinator.
|
||||||
- example: "0x997dc4262BCDbf85190C01c996b4C06a461d2430"
|
- example: "0x997dc4262BCDbf85190C01c996b4C06a461d2430"
|
||||||
|
bootCoordinatorUrl:
|
||||||
|
type: string
|
||||||
|
description: Boot Coordinator URL
|
||||||
|
example: "https://boot.coordinator.io"
|
||||||
slotDeadline:
|
slotDeadline:
|
||||||
type: integer
|
type: integer
|
||||||
description: Number of blocks after the beginning of a slot after which any coordinator can forge if the winner has not forged any batch in that slot.
|
description: Number of blocks after the beginning of a slot after which any coordinator can forge if the winner has not forged any batch in that slot.
|
||||||
@@ -2733,6 +2737,7 @@ components:
|
|||||||
required:
|
required:
|
||||||
- ethereumBlockNum
|
- ethereumBlockNum
|
||||||
- bootCoordinator
|
- bootCoordinator
|
||||||
|
- bootCoordinatorUrl
|
||||||
- slotDeadline
|
- slotDeadline
|
||||||
- closedAuctionSlots
|
- closedAuctionSlots
|
||||||
- openAuctionSlots
|
- openAuctionSlots
|
||||||
@@ -2804,21 +2809,16 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
ethereumBlockNum:
|
ethereumBlockNum:
|
||||||
$ref: '#/components/schemas/EthBlockNum'
|
$ref: '#/components/schemas/EthBlockNum'
|
||||||
hermezGovernanceDAOAddress:
|
hermezGovernanceAddress:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/components/schemas/EthereumAddress'
|
- $ref: '#/components/schemas/EthereumAddress'
|
||||||
- description: Ethereum address of the governance DAO.
|
- description: Ethereum address of the governance.
|
||||||
- example: "0x667dc4262BCDbf85190C01c996b4C06a461d2430"
|
- example: "0x667dc4262BCDbf85190C01c996b4C06a461d2430"
|
||||||
whiteHackGroupAddress:
|
emergencyCouncilAddress:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/components/schemas/EthereumAddress'
|
- $ref: '#/components/schemas/EthereumAddress'
|
||||||
- description: Ethereum Address that can claim the funds in an emergency when the maximum emergency mode time is exceeded.
|
- description: Ethereum Address that can claim the funds in an emergency when the maximum emergency mode time is exceeded.
|
||||||
- example: "0x557dc4262BCDbf85190C01c996b4C06a461d2430"
|
- example: "0x557dc4262BCDbf85190C01c996b4C06a461d2430"
|
||||||
hermezKeeperAddress:
|
|
||||||
allOf:
|
|
||||||
- $ref: '#/components/schemas/EthereumAddress'
|
|
||||||
- description: Ethereum Address that can enable emergency mode and modify the delay to make a withdrawal.
|
|
||||||
- example: "0x557dc4262BCDbf85190C01c996b4C06a461d2430"
|
|
||||||
withdrawalDelay:
|
withdrawalDelay:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/components/schemas/EthBlockNum'
|
- $ref: '#/components/schemas/EthBlockNum'
|
||||||
@@ -2835,9 +2835,8 @@ components:
|
|||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- ethereumBlockNum
|
- ethereumBlockNum
|
||||||
- hermezGovernanceDAOAddress
|
- hermezGovernanceAddress
|
||||||
- whiteHackGroupAddress
|
- emergencyCouncilAddress
|
||||||
- hermezKeeperAddress
|
|
||||||
- withdrawalDelay
|
- withdrawalDelay
|
||||||
- emergencyModeStartingTime
|
- emergencyModeStartingTime
|
||||||
- emergencyMode
|
- emergencyMode
|
||||||
@@ -2925,16 +2924,11 @@ components:
|
|||||||
- $ref: '#/components/schemas/EthereumAddress'
|
- $ref: '#/components/schemas/EthereumAddress'
|
||||||
- description: Ethereum address of the auction smart contract.
|
- description: Ethereum address of the auction smart contract.
|
||||||
- example: "0x111dc4262BCDbf85190C01c996b4C06a461d2430"
|
- example: "0x111dc4262BCDbf85190C01c996b4C06a461d2430"
|
||||||
hermezGovernanceDAOAddress:
|
hermezGovernanceAddress:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/components/schemas/EthereumAddress'
|
- $ref: '#/components/schemas/EthereumAddress'
|
||||||
- description: Ethereum address of the governanceDAO.
|
- description: Ethereum address of the governance.
|
||||||
- example: "0x222dc4262BCDbf85190C01c996b4C06a461d2430"
|
- example: "0x222dc4262BCDbf85190C01c996b4C06a461d2430"
|
||||||
safetyAddress:
|
|
||||||
allOf:
|
|
||||||
- $ref: '#/components/schemas/EthereumAddress'
|
|
||||||
- description: Ethereum address of the safety.
|
|
||||||
- example: "0x333dc4262BCDbf85190C01c996b4C06a461d2430"
|
|
||||||
withdrawDelayerContract:
|
withdrawDelayerContract:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/components/schemas/EthereumAddress'
|
- $ref: '#/components/schemas/EthereumAddress'
|
||||||
@@ -2945,8 +2939,7 @@ components:
|
|||||||
- absoluteMaxL1L2BatchTimeout
|
- absoluteMaxL1L2BatchTimeout
|
||||||
- verifiers
|
- verifiers
|
||||||
- hermezAuctionContract
|
- hermezAuctionContract
|
||||||
- hermezGovernanceDAOAddress
|
- hermezGovernanceAddress
|
||||||
- safetyAddress
|
|
||||||
- withdrawDelayerContract
|
- withdrawDelayerContract
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
maxFeeIdxCoordinator:
|
maxFeeIdxCoordinator:
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ type AuctionConstants struct {
|
|||||||
// HermezRollup smartcontract address
|
// HermezRollup smartcontract address
|
||||||
HermezRollup ethCommon.Address `json:"hermezRollup"`
|
HermezRollup ethCommon.Address `json:"hermezRollup"`
|
||||||
// Hermez Governanze Token smartcontract address who controls some parameters and collects HEZ fee
|
// Hermez Governanze Token smartcontract address who controls some parameters and collects HEZ fee
|
||||||
// Only for test
|
|
||||||
GovernanceAddress ethCommon.Address `json:"governanceAddress"`
|
GovernanceAddress ethCommon.Address `json:"governanceAddress"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,10 +53,12 @@ func (c *AuctionConstants) RelativeBlock(blockNum int64) int64 {
|
|||||||
// AuctionVariables are the variables of the Auction Smart Contract
|
// AuctionVariables are the variables of the Auction Smart Contract
|
||||||
type AuctionVariables struct {
|
type AuctionVariables struct {
|
||||||
EthBlockNum int64 `json:"ethereumBlockNum" meddler:"eth_block_num"`
|
EthBlockNum int64 `json:"ethereumBlockNum" meddler:"eth_block_num"`
|
||||||
// Boot Coordinator Address
|
// Donation Address
|
||||||
DonationAddress ethCommon.Address `json:"donationAddress" meddler:"donation_address" validate:"required"`
|
DonationAddress ethCommon.Address `json:"donationAddress" meddler:"donation_address" validate:"required"`
|
||||||
// Boot Coordinator Address
|
// Boot Coordinator Address
|
||||||
BootCoordinator ethCommon.Address `json:"bootCoordinator" meddler:"boot_coordinator" validate:"required"`
|
BootCoordinator ethCommon.Address `json:"bootCoordinator" meddler:"boot_coordinator" validate:"required"`
|
||||||
|
// Boot Coordinator URL
|
||||||
|
BootCoordinatorURL string `json:"bootCoordinatorUrl" meddler:"boot_coordinator_url" validate:"required"`
|
||||||
// The minimum bid value in a series of 6 slots
|
// The minimum bid value in a series of 6 slots
|
||||||
DefaultSlotSetBid [6]*big.Int `json:"defaultSlotSetBid" meddler:"default_slot_set_bid,json" validate:"required"`
|
DefaultSlotSetBid [6]*big.Int `json:"defaultSlotSetBid" meddler:"default_slot_set_bid,json" validate:"required"`
|
||||||
// SlotNum at which the new default_slot_set_bid applies
|
// SlotNum at which the new default_slot_set_bid applies
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ import (
|
|||||||
// WithdrawDelayerVars contains the Withdrawal Delayer smart contract variables
|
// WithdrawDelayerVars contains the Withdrawal Delayer smart contract variables
|
||||||
// type WithdrawDelayerVars struct {
|
// type WithdrawDelayerVars struct {
|
||||||
// HermezRollupAddress eth.Address
|
// HermezRollupAddress eth.Address
|
||||||
// HermezGovernanceDAOAddress eth.Address
|
// HermezGovernanceAddress eth.Address
|
||||||
// WhiteHackGroupAddress eth.Address
|
// EmergencyCouncilAddress eth.Address
|
||||||
// WithdrawalDelay uint
|
// WithdrawalDelay uint
|
||||||
// EmergencyModeStartingTime time.Time
|
// EmergencyModeStartingTime time.Time
|
||||||
// EmergencyModeEnabled bool
|
// EmergencyModeEnabled bool
|
||||||
@@ -142,8 +142,7 @@ type RollupConstants struct {
|
|||||||
TokenHEZ ethCommon.Address `json:"tokenHEZ"`
|
TokenHEZ ethCommon.Address `json:"tokenHEZ"`
|
||||||
Verifiers []RollupVerifierStruct `json:"verifiers"`
|
Verifiers []RollupVerifierStruct `json:"verifiers"`
|
||||||
HermezAuctionContract ethCommon.Address `json:"hermezAuctionContract"`
|
HermezAuctionContract ethCommon.Address `json:"hermezAuctionContract"`
|
||||||
HermezGovernanceDAOAddress ethCommon.Address `json:"hermezGovernanceDAOAddress"`
|
HermezGovernanceAddress ethCommon.Address `json:"hermezGovernanceAddress"`
|
||||||
SafetyAddress ethCommon.Address `json:"safetyAddress"`
|
|
||||||
WithdrawDelayerContract ethCommon.Address `json:"withdrawDelayerContract"`
|
WithdrawDelayerContract ethCommon.Address `json:"withdrawDelayerContract"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,8 @@ type WDelayerConstants struct {
|
|||||||
type WDelayerVariables struct {
|
type WDelayerVariables struct {
|
||||||
EthBlockNum int64 `json:"ethereumBlockNum" meddler:"eth_block_num"`
|
EthBlockNum int64 `json:"ethereumBlockNum" meddler:"eth_block_num"`
|
||||||
// HermezRollupAddress ethCommon.Address `json:"hermezRollupAddress" meddler:"rollup_address"`
|
// HermezRollupAddress ethCommon.Address `json:"hermezRollupAddress" meddler:"rollup_address"`
|
||||||
HermezGovernanceDAOAddress ethCommon.Address `json:"hermezGovernanceDAOAddress" meddler:"govdao_address" validate:"required"`
|
HermezGovernanceAddress ethCommon.Address `json:"hermezGovernanceAddress" meddler:"gov_address" validate:"required"`
|
||||||
WhiteHackGroupAddress ethCommon.Address `json:"whiteHackGroupAddress" meddler:"whg_address" validate:"required"`
|
EmergencyCouncilAddress ethCommon.Address `json:"emergencyCouncilAddress" meddler:"emg_address" validate:"required"`
|
||||||
HermezKeeperAddress ethCommon.Address `json:"hermezKeeperAddress" meddler:"keeper_address" validate:"required"`
|
|
||||||
WithdrawalDelay uint64 `json:"withdrawalDelay" meddler:"withdrawal_delay" validate:"required"`
|
WithdrawalDelay uint64 `json:"withdrawalDelay" meddler:"withdrawal_delay" validate:"required"`
|
||||||
EmergencyModeStartingTime uint64 `json:"emergencyModeStartingTime" meddler:"emergency_start_time"`
|
EmergencyModeStartingTime uint64 `json:"emergencyModeStartingTime" meddler:"emergency_start_time"`
|
||||||
EmergencyMode bool `json:"emergencyMode" meddler:"emergency_mode"`
|
EmergencyMode bool `json:"emergencyMode" meddler:"emergency_mode"`
|
||||||
|
|||||||
@@ -217,6 +217,29 @@ func (tx *L1Tx) BytesDataAvailability(nLevels uint32) ([]byte, error) {
|
|||||||
return b[:], nil
|
return b[:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// L1TxFromDataAvailability decodes a L1Tx from []byte (Data Availability)
|
||||||
|
func L1TxFromDataAvailability(b []byte, nLevels uint32) (*L1Tx, error) {
|
||||||
|
idxLen := nLevels / 8 //nolint:gomnd
|
||||||
|
|
||||||
|
fromIdxBytes := b[0:idxLen]
|
||||||
|
toIdxBytes := b[idxLen : idxLen*2]
|
||||||
|
amountBytes := b[idxLen*2 : idxLen*2+2]
|
||||||
|
|
||||||
|
l1tx := L1Tx{}
|
||||||
|
fromIdx, err := IdxFromBytes(ethCommon.LeftPadBytes(fromIdxBytes, 6))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
l1tx.FromIdx = fromIdx
|
||||||
|
toIdx, err := IdxFromBytes(ethCommon.LeftPadBytes(toIdxBytes, 6))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
l1tx.ToIdx = toIdx
|
||||||
|
l1tx.EffectiveAmount = Float16FromBytes(amountBytes).BigInt()
|
||||||
|
return &l1tx, nil
|
||||||
|
}
|
||||||
|
|
||||||
// BytesGeneric returns the generic representation of a L1Tx. This method is
|
// BytesGeneric returns the generic representation of a L1Tx. This method is
|
||||||
// used to compute the []byte representation of a L1UserTx, and also to compute
|
// used to compute the []byte representation of a L1UserTx, and also to compute
|
||||||
// the L1TxData for the ZKInputs (at the HashGlobalInputs), using this method
|
// the L1TxData for the ZKInputs (at the HashGlobalInputs), using this method
|
||||||
|
|||||||
@@ -87,6 +87,33 @@ func TestBytesDataAvailability(t *testing.T) {
|
|||||||
assert.Equal(t, "0000000200000003000400", hex.EncodeToString(txCompressedData))
|
assert.Equal(t, "0000000200000003000400", hex.EncodeToString(txCompressedData))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestL1TxFromDataAvailability(t *testing.T) {
|
||||||
|
tx := L1Tx{
|
||||||
|
FromIdx: 2,
|
||||||
|
ToIdx: 3,
|
||||||
|
Amount: big.NewInt(4),
|
||||||
|
}
|
||||||
|
txCompressedData, err := tx.BytesDataAvailability(32)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
l1tx, err := L1TxFromDataAvailability(txCompressedData, 32)
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, tx.FromIdx, l1tx.FromIdx)
|
||||||
|
assert.Equal(t, tx.ToIdx, l1tx.ToIdx)
|
||||||
|
|
||||||
|
tx = L1Tx{
|
||||||
|
FromIdx: 2,
|
||||||
|
ToIdx: 3,
|
||||||
|
EffectiveAmount: big.NewInt(4),
|
||||||
|
}
|
||||||
|
txCompressedData, err = tx.BytesDataAvailability(32)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
l1tx, err = L1TxFromDataAvailability(txCompressedData, 32)
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, tx.FromIdx, l1tx.FromIdx)
|
||||||
|
assert.Equal(t, tx.ToIdx, l1tx.ToIdx)
|
||||||
|
assert.Equal(t, tx.EffectiveAmount, l1tx.EffectiveAmount)
|
||||||
|
}
|
||||||
|
|
||||||
func TestL1userTxByteParsers(t *testing.T) {
|
func TestL1userTxByteParsers(t *testing.T) {
|
||||||
var pkComp babyjub.PublicKeyComp
|
var pkComp babyjub.PublicKeyComp
|
||||||
pkCompL := []byte("0x56ca90f80d7c374ae7485e9bcc47d4ac399460948da6aeeb899311097925a72c")
|
pkCompL := []byte("0x56ca90f80d7c374ae7485e9bcc47d4ac399460948da6aeeb899311097925a72c")
|
||||||
|
|||||||
@@ -134,8 +134,8 @@ func (tx L2Tx) BytesDataAvailability(nLevels uint32) ([]byte, error) {
|
|||||||
return b[:], nil
|
return b[:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// L2TxFromBytes decodes a L1Tx from []byte
|
// L2TxFromBytesDataAvailability decodes a L2Tx from []byte (Data Availability)
|
||||||
func L2TxFromBytes(b []byte, nLevels int) (*L2Tx, error) {
|
func L2TxFromBytesDataAvailability(b []byte, nLevels int) (*L2Tx, error) {
|
||||||
idxLen := nLevels / 8 //nolint:gomnd
|
idxLen := nLevels / 8 //nolint:gomnd
|
||||||
tx := &L2Tx{}
|
tx := &L2Tx{}
|
||||||
var err error
|
var err error
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func TestL2TxByteParsers(t *testing.T) {
|
|||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
assert.Equal(t, expected, hex.EncodeToString(encodedData))
|
assert.Equal(t, expected, hex.EncodeToString(encodedData))
|
||||||
|
|
||||||
decodedData, err := L2TxFromBytes(encodedData, 32)
|
decodedData, err := L2TxFromBytesDataAvailability(encodedData, 32)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
assert.Equal(t, l2Tx, decodedData)
|
assert.Equal(t, l2Tx, decodedData)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -654,6 +654,7 @@ func exampleInitSCVars() (*common.RollupVariables, *common.AuctionVariables, *co
|
|||||||
0,
|
0,
|
||||||
ethCommon.BigToAddress(big.NewInt(2)),
|
ethCommon.BigToAddress(big.NewInt(2)),
|
||||||
ethCommon.BigToAddress(big.NewInt(3)),
|
ethCommon.BigToAddress(big.NewInt(3)),
|
||||||
|
"https://boot.coord.com",
|
||||||
[6]*big.Int{
|
[6]*big.Int{
|
||||||
big.NewInt(1), big.NewInt(2), big.NewInt(3),
|
big.NewInt(1), big.NewInt(2), big.NewInt(3),
|
||||||
big.NewInt(4), big.NewInt(5), big.NewInt(6),
|
big.NewInt(4), big.NewInt(5), big.NewInt(6),
|
||||||
@@ -670,7 +671,6 @@ func exampleInitSCVars() (*common.RollupVariables, *common.AuctionVariables, *co
|
|||||||
0,
|
0,
|
||||||
ethCommon.BigToAddress(big.NewInt(2)),
|
ethCommon.BigToAddress(big.NewInt(2)),
|
||||||
ethCommon.BigToAddress(big.NewInt(3)),
|
ethCommon.BigToAddress(big.NewInt(3)),
|
||||||
ethCommon.BigToAddress(big.NewInt(4)),
|
|
||||||
13,
|
13,
|
||||||
14,
|
14,
|
||||||
false,
|
false,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ CREATE TABLE coordinator (
|
|||||||
bidder_addr BYTEA NOT NULL,
|
bidder_addr BYTEA NOT NULL,
|
||||||
forger_addr BYTEA NOT NULL,
|
forger_addr BYTEA NOT NULL,
|
||||||
eth_block_num BIGINT NOT NULL REFERENCES block (eth_block_num) ON DELETE CASCADE,
|
eth_block_num BIGINT NOT NULL REFERENCES block (eth_block_num) ON DELETE CASCADE,
|
||||||
url VARCHAR(200) NOT NULL
|
url BYTEA NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE batch (
|
CREATE TABLE batch (
|
||||||
@@ -537,6 +537,7 @@ CREATE TABLE auction_vars (
|
|||||||
eth_block_num BIGINT PRIMARY KEY REFERENCES block (eth_block_num) ON DELETE CASCADE,
|
eth_block_num BIGINT PRIMARY KEY REFERENCES block (eth_block_num) ON DELETE CASCADE,
|
||||||
donation_address BYTEA NOT NULL,
|
donation_address BYTEA NOT NULL,
|
||||||
boot_coordinator BYTEA NOT NULL,
|
boot_coordinator BYTEA NOT NULL,
|
||||||
|
boot_coordinator_url BYTEA NOT NULL,
|
||||||
default_slot_set_bid BYTEA NOT NULL,
|
default_slot_set_bid BYTEA NOT NULL,
|
||||||
default_slot_set_bid_slot_num BIGINT NOT NULL, -- slot_num after which the new default_slot_set_bid applies
|
default_slot_set_bid_slot_num BIGINT NOT NULL, -- slot_num after which the new default_slot_set_bid applies
|
||||||
closed_auction_slots INT NOT NULL,
|
closed_auction_slots INT NOT NULL,
|
||||||
@@ -548,9 +549,8 @@ CREATE TABLE auction_vars (
|
|||||||
|
|
||||||
CREATE TABLE wdelayer_vars (
|
CREATE TABLE wdelayer_vars (
|
||||||
eth_block_num BIGINT PRIMARY KEY REFERENCES block (eth_block_num) ON DELETE CASCADE,
|
eth_block_num BIGINT PRIMARY KEY REFERENCES block (eth_block_num) ON DELETE CASCADE,
|
||||||
govdao_address BYTEA NOT NULL,
|
gov_address BYTEA NOT NULL,
|
||||||
whg_address BYTEA NOT NULL,
|
emg_address BYTEA NOT NULL,
|
||||||
keeper_address BYTEA NOT NULL,
|
|
||||||
withdrawal_delay BIGINT NOT NULL,
|
withdrawal_delay BIGINT NOT NULL,
|
||||||
emergency_start_time BIGINT NOT NULL,
|
emergency_start_time BIGINT NOT NULL,
|
||||||
emergency_mode BOOLEAN NOT NULL
|
emergency_mode BOOLEAN NOT NULL
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ The first step is to clone the github repository where the contracts are located
|
|||||||
|
|
||||||
While the prepared deployment is not found to master, branch in repository must be changed:
|
While the prepared deployment is not found to master, branch in repository must be changed:
|
||||||
|
|
||||||
`git checkout feature/newDeploymentScript-ethclient` (tested with commit `af4c93916d6cd93d866c121cc63b6a6794f649b2`)
|
`git checkout feature/newDeploymentScript-eth` (tested with commit `6335252b073dc59afafc45040dae8630c72ecdf3`)
|
||||||
|
|
||||||
Now, install the dependencies:
|
Now, install the dependencies:
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ Now, in a terminal start a local blockchain with ganache:
|
|||||||
```
|
```
|
||||||
Once ganache is ready, in another terminal run the deployment in the local ganache network:
|
Once ganache is ready, in another terminal run the deployment in the local ganache network:
|
||||||
```
|
```
|
||||||
npx buidler run --network ganache test-deployment.js
|
npx buidler run --network localhostMnemonic test-deployment.js
|
||||||
```
|
```
|
||||||
|
|
||||||
An output file necessary for the next step is obtained: `deploy-output`.
|
An output file necessary for the next step is obtained: `deploy-output`.
|
||||||
@@ -42,13 +42,13 @@ They must be taken from the output file of the previous step.
|
|||||||
They can be provided by file called `.env`:
|
They can be provided by file called `.env`:
|
||||||
|
|
||||||
```
|
```
|
||||||
GENESIS_BLOCK=97
|
GENESIS_BLOCK=98
|
||||||
AUCTION="0x5E0816F0f8bC560cB2B9e9C87187BeCac8c2021F"
|
AUCTION="0x317113D2593e3efF1FfAE0ba2fF7A61861Df7ae5"
|
||||||
AUCTION_TEST="0x56D4563E85477AC8Aa6a3b980b831DDb18a826ec"
|
AUCTION_TEST="0x2b7dEe2CF60484325716A1c6A193519c8c3b19F3"
|
||||||
TOKENHEZ="0x2b7dEe2CF60484325716A1c6A193519c8c3b19F3"
|
TOKENHEZ="0x5D94e3e7aeC542aB0F9129B9a7BAdeb5B3Ca0f77"
|
||||||
HERMEZ="0x6F4e99522F4eB37e0B73D0C0373147893EF12fD5"
|
HERMEZ="0x8EEaea23686c319133a7cC110b840d1591d9AeE0"
|
||||||
WDELAYER="0x5D94e3e7aeC542aB0F9129B9a7BAdeb5B3Ca0f77"
|
WDELAYER="0x5E0816F0f8bC560cB2B9e9C87187BeCac8c2021F"
|
||||||
WDELAYER_TEST="0xdc05EFc3029024068FCc86f05323411f14D69280"
|
WDELAYER_TEST="0xc8F466fFeF9E9788fb363c2F4fBDdF2cAe477805"
|
||||||
```
|
```
|
||||||
|
|
||||||
> An example is found in `hermez-node/eth/.env.example`
|
> An example is found in `hermez-node/eth/.env.example`
|
||||||
@@ -59,4 +59,4 @@ And then run test from `hermez-node/eth/`:
|
|||||||
|
|
||||||
Or they can be provided as a parameter in the command that runs the test:
|
Or they can be provided as a parameter in the command that runs the test:
|
||||||
|
|
||||||
`INTEGRATION=1 GENESIS_BLOCK=97 AUCTION="0x5E0816F0f8bC560cB2B9e9C87187BeCac8c2021F" AUCTION_TEST="0x56D4563E85477AC8Aa6a3b980b831DDb18a826ec" TOKENHEZ="0x2b7dEe2CF60484325716A1c6A193519c8c3b19F3" HERMEZ="0x6F4e99522F4eB37e0B73D0C0373147893EF12fD5" WDELAYER="0x5D94e3e7aeC542aB0F9129B9a7BAdeb5B3Ca0f77" WDELAYER_TEST="0xdc05EFc3029024068FCc86f05323411f14D69280" go test`
|
`INTEGRATION=1 GENESIS_BLOCK=98 AUCTION="0x317113D2593e3efF1FfAE0ba2fF7A61861Df7ae5" AUCTION_TEST="0x2b7dEe2CF60484325716A1c6A193519c8c3b19F3" TOKENHEZ="0x5D94e3e7aeC542aB0F9129B9a7BAdeb5B3Ca0f77" HERMEZ="0x8EEaea23686c319133a7cC110b840d1591d9AeE0" WDELAYER="0x5E0816F0f8bC560cB2B9e9C87187BeCac8c2021F" WDELAYER_TEST="0xc8F466fFeF9E9788fb363c2F4fBDdF2cAe477805" go test`
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ func NewSlotState() *SlotState {
|
|||||||
return &SlotState{
|
return &SlotState{
|
||||||
Bidder: ethCommon.Address{},
|
Bidder: ethCommon.Address{},
|
||||||
Fulfilled: false,
|
Fulfilled: false,
|
||||||
|
ForgerCommitment: false,
|
||||||
BidAmount: big.NewInt(0),
|
BidAmount: big.NewInt(0),
|
||||||
ClosedMinBid: big.NewInt(0),
|
ClosedMinBid: big.NewInt(0),
|
||||||
}
|
}
|
||||||
@@ -85,6 +86,7 @@ type AuctionEventNewDonationAddress struct {
|
|||||||
// AuctionEventNewBootCoordinator is an event of the Auction Smart Contract
|
// AuctionEventNewBootCoordinator is an event of the Auction Smart Contract
|
||||||
type AuctionEventNewBootCoordinator struct {
|
type AuctionEventNewBootCoordinator struct {
|
||||||
NewBootCoordinator ethCommon.Address
|
NewBootCoordinator ethCommon.Address
|
||||||
|
NewBootCoordinatorURL string
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuctionEventNewOpenAuctionSlots is an event of the Auction Smart Contract
|
// AuctionEventNewOpenAuctionSlots is an event of the Auction Smart Contract
|
||||||
@@ -187,7 +189,7 @@ type AuctionInterface interface {
|
|||||||
AuctionGetAllocationRatio() ([3]uint16, error)
|
AuctionGetAllocationRatio() ([3]uint16, error)
|
||||||
AuctionSetDonationAddress(newDonationAddress ethCommon.Address) (*types.Transaction, error)
|
AuctionSetDonationAddress(newDonationAddress ethCommon.Address) (*types.Transaction, error)
|
||||||
AuctionGetDonationAddress() (*ethCommon.Address, error)
|
AuctionGetDonationAddress() (*ethCommon.Address, error)
|
||||||
AuctionSetBootCoordinator(newBootCoordinator ethCommon.Address) (*types.Transaction, error)
|
AuctionSetBootCoordinator(newBootCoordinator ethCommon.Address, newBootCoordinatorURL string) (*types.Transaction, error)
|
||||||
AuctionGetBootCoordinator() (*ethCommon.Address, error)
|
AuctionGetBootCoordinator() (*ethCommon.Address, error)
|
||||||
AuctionChangeDefaultSlotSetBid(slotSet int64, newInitialMinBid *big.Int) (*types.Transaction, error)
|
AuctionChangeDefaultSlotSetBid(slotSet int64, newInitialMinBid *big.Int) (*types.Transaction, error)
|
||||||
|
|
||||||
@@ -408,11 +410,11 @@ func (c *AuctionClient) AuctionGetDonationAddress() (donationAddress *ethCommon.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AuctionSetBootCoordinator is the interface to call the smart contract function
|
// AuctionSetBootCoordinator is the interface to call the smart contract function
|
||||||
func (c *AuctionClient) AuctionSetBootCoordinator(newBootCoordinator ethCommon.Address) (tx *types.Transaction, err error) {
|
func (c *AuctionClient) AuctionSetBootCoordinator(newBootCoordinator ethCommon.Address, newBootCoordinatorURL string) (tx *types.Transaction, err error) {
|
||||||
if tx, err = c.client.CallAuth(
|
if tx, err = c.client.CallAuth(
|
||||||
0,
|
0,
|
||||||
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
return c.auction.SetBootCoordinator(auth, newBootCoordinator)
|
return c.auction.SetBootCoordinator(auth, newBootCoordinator, newBootCoordinatorURL)
|
||||||
},
|
},
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, tracerr.Wrap(fmt.Errorf("Failed setting bootCoordinator: %w", err))
|
return nil, tracerr.Wrap(fmt.Errorf("Failed setting bootCoordinator: %w", err))
|
||||||
@@ -642,6 +644,10 @@ func (c *AuctionClient) AuctionConstants() (auctionConstants *common.AuctionCons
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return tracerr.Wrap(err)
|
return tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
|
auctionConstants.GovernanceAddress, err = c.auction.GovernanceAddress(nil)
|
||||||
|
if err != nil {
|
||||||
|
return tracerr.Wrap(err)
|
||||||
|
}
|
||||||
auctionConstants.TokenHEZ, err = c.auction.TokenHEZ(nil)
|
auctionConstants.TokenHEZ, err = c.auction.TokenHEZ(nil)
|
||||||
return tracerr.Wrap(err)
|
return tracerr.Wrap(err)
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@@ -663,6 +669,10 @@ func (c *AuctionClient) AuctionVariables() (auctionVariables *common.AuctionVari
|
|||||||
return tracerr.Wrap(err)
|
return tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
auctionVariables.BootCoordinator = *bootCoordinator
|
auctionVariables.BootCoordinator = *bootCoordinator
|
||||||
|
auctionVariables.BootCoordinatorURL, err = c.auction.BootCoordinatorURL(nil)
|
||||||
|
if err != nil {
|
||||||
|
return tracerr.Wrap(err)
|
||||||
|
}
|
||||||
auctionVariables.ClosedAuctionSlots, err = c.AuctionGetClosedAuctionSlots()
|
auctionVariables.ClosedAuctionSlots, err = c.AuctionGetClosedAuctionSlots()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return tracerr.Wrap(err)
|
return tracerr.Wrap(err)
|
||||||
@@ -703,7 +713,7 @@ var (
|
|||||||
logAuctionNewClosedAuctionSlots = crypto.Keccak256Hash([]byte("NewClosedAuctionSlots(uint16)"))
|
logAuctionNewClosedAuctionSlots = crypto.Keccak256Hash([]byte("NewClosedAuctionSlots(uint16)"))
|
||||||
logAuctionNewOutbidding = crypto.Keccak256Hash([]byte("NewOutbidding(uint16)"))
|
logAuctionNewOutbidding = crypto.Keccak256Hash([]byte("NewOutbidding(uint16)"))
|
||||||
logAuctionNewDonationAddress = crypto.Keccak256Hash([]byte("NewDonationAddress(address)"))
|
logAuctionNewDonationAddress = crypto.Keccak256Hash([]byte("NewDonationAddress(address)"))
|
||||||
logAuctionNewBootCoordinator = crypto.Keccak256Hash([]byte("NewBootCoordinator(address)"))
|
logAuctionNewBootCoordinator = crypto.Keccak256Hash([]byte("NewBootCoordinator(address,string)"))
|
||||||
logAuctionNewOpenAuctionSlots = crypto.Keccak256Hash([]byte("NewOpenAuctionSlots(uint16)"))
|
logAuctionNewOpenAuctionSlots = crypto.Keccak256Hash([]byte("NewOpenAuctionSlots(uint16)"))
|
||||||
logAuctionNewAllocationRatio = crypto.Keccak256Hash([]byte("NewAllocationRatio(uint16[3])"))
|
logAuctionNewAllocationRatio = crypto.Keccak256Hash([]byte("NewAllocationRatio(uint16[3])"))
|
||||||
logAuctionSetCoordinator = crypto.Keccak256Hash([]byte("SetCoordinator(address,address,string)"))
|
logAuctionSetCoordinator = crypto.Keccak256Hash([]byte("SetCoordinator(address,address,string)"))
|
||||||
@@ -780,6 +790,9 @@ func (c *AuctionClient) AuctionEventsByBlock(blockNum int64) (*AuctionEvents, *e
|
|||||||
auctionEvents.NewDonationAddress = append(auctionEvents.NewDonationAddress, newDonationAddress)
|
auctionEvents.NewDonationAddress = append(auctionEvents.NewDonationAddress, newDonationAddress)
|
||||||
case logAuctionNewBootCoordinator:
|
case logAuctionNewBootCoordinator:
|
||||||
var newBootCoordinator AuctionEventNewBootCoordinator
|
var newBootCoordinator AuctionEventNewBootCoordinator
|
||||||
|
if err := c.contractAbi.Unpack(&newBootCoordinator, "NewBootCoordinator", vLog.Data); err != nil {
|
||||||
|
return nil, nil, tracerr.Wrap(err)
|
||||||
|
}
|
||||||
newBootCoordinator.NewBootCoordinator = ethCommon.BytesToAddress(vLog.Topics[1].Bytes())
|
newBootCoordinator.NewBootCoordinator = ethCommon.BytesToAddress(vLog.Topics[1].Bytes())
|
||||||
auctionEvents.NewBootCoordinator = append(auctionEvents.NewBootCoordinator, newBootCoordinator)
|
auctionEvents.NewBootCoordinator = append(auctionEvents.NewBootCoordinator, newBootCoordinator)
|
||||||
case logAuctionNewOpenAuctionSlots:
|
case logAuctionNewOpenAuctionSlots:
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ func TestAuctionConstants(t *testing.T) {
|
|||||||
assert.Equal(t, auctionConstants.HermezRollup, hermezRollupTestAddressConst)
|
assert.Equal(t, auctionConstants.HermezRollup, hermezRollupTestAddressConst)
|
||||||
assert.Equal(t, auctionConstants.InitialMinimalBidding, INITMINBID)
|
assert.Equal(t, auctionConstants.InitialMinimalBidding, INITMINBID)
|
||||||
assert.Equal(t, auctionConstants.TokenHEZ, tokenHEZAddressConst)
|
assert.Equal(t, auctionConstants.TokenHEZ, tokenHEZAddressConst)
|
||||||
|
assert.Equal(t, auctionConstants.GovernanceAddress, governanceAddressConst)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAuctionVariables(t *testing.T) {
|
func TestAuctionVariables(t *testing.T) {
|
||||||
@@ -199,8 +200,10 @@ func TestAuctionSetDonationAddress(t *testing.T) {
|
|||||||
|
|
||||||
func TestAuctionSetBootCoordinator(t *testing.T) {
|
func TestAuctionSetBootCoordinator(t *testing.T) {
|
||||||
newBootCoordinator := governanceAddressConst
|
newBootCoordinator := governanceAddressConst
|
||||||
|
bootCoordinatorURL := "https://boot.coordinator2.io"
|
||||||
|
newBootCoordinatorURL := "https://boot.coordinator2.io"
|
||||||
|
|
||||||
_, err := auctionClientTest.AuctionSetBootCoordinator(newBootCoordinator)
|
_, err := auctionClientTest.AuctionSetBootCoordinator(newBootCoordinator, newBootCoordinatorURL)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
bootCoordinator, err := auctionClientTest.AuctionGetBootCoordinator()
|
bootCoordinator, err := auctionClientTest.AuctionGetBootCoordinator()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
@@ -210,7 +213,8 @@ func TestAuctionSetBootCoordinator(t *testing.T) {
|
|||||||
auctionEvents, _, err := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
|
auctionEvents, _, err := auctionClientTest.AuctionEventsByBlock(currentBlockNum)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
assert.Equal(t, newBootCoordinator, auctionEvents.NewBootCoordinator[0].NewBootCoordinator)
|
assert.Equal(t, newBootCoordinator, auctionEvents.NewBootCoordinator[0].NewBootCoordinator)
|
||||||
_, err = auctionClientTest.AuctionSetBootCoordinator(bootCoordinatorAddressConst)
|
assert.Equal(t, newBootCoordinatorURL, auctionEvents.NewBootCoordinator[0].NewBootCoordinatorURL)
|
||||||
|
_, err = auctionClientTest.AuctionSetBootCoordinator(bootCoordinatorAddressConst, bootCoordinatorURL)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ abigen --abi=HEZ.abi --bin=HEZ.bin --pkg=HEZ --out=HEZ.go
|
|||||||
You must compile the contracts to get the `.bin` and `.abi` files. The contracts used are in the repo: https://github.com/hermeznetwork/contracts
|
You must compile the contracts to get the `.bin` and `.abi` files. The contracts used are in the repo: https://github.com/hermeznetwork/contracts
|
||||||
|
|
||||||
Branch: `feature/newDeploymentScript`
|
Branch: `feature/newDeploymentScript`
|
||||||
Specifically they have been processed in the commit with hash: `4489f8e7fe4dd17cf22f1e96741b09bdf81946d8`
|
Specifically they have been processed in the commit with hash: `254dc035142c56553d6d4ee9b2ea9d97259357c2`
|
||||||
|
|
||||||
Versions:
|
Versions:
|
||||||
```
|
```
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -64,21 +64,12 @@ var (
|
|||||||
|
|
||||||
bootCoordinatorAccount *accounts.Account
|
bootCoordinatorAccount *accounts.Account
|
||||||
bootCoordinatorAddressConst ethCommon.Address
|
bootCoordinatorAddressConst ethCommon.Address
|
||||||
|
|
||||||
safetyAccount *accounts.Account
|
|
||||||
safetyAddressConst ethCommon.Address
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ethereum Accounts
|
// Ethereum Accounts
|
||||||
var (
|
var (
|
||||||
hermezGovernanceDAOAccount *accounts.Account
|
emergencyCouncilAccount *accounts.Account
|
||||||
hermezGovernanceDAOAddressConst ethCommon.Address
|
emergencyCouncilAddressConst ethCommon.Address
|
||||||
|
|
||||||
whiteHackGroupAccount *accounts.Account
|
|
||||||
whiteHackGroupAddressConst ethCommon.Address
|
|
||||||
|
|
||||||
hermezKeeperAccount *accounts.Account
|
|
||||||
hermezKeeperAddressConst ethCommon.Address
|
|
||||||
|
|
||||||
governanceAccount *accounts.Account
|
governanceAccount *accounts.Account
|
||||||
governanceAddressConst ethCommon.Address
|
governanceAddressConst ethCommon.Address
|
||||||
@@ -96,9 +87,7 @@ var (
|
|||||||
var (
|
var (
|
||||||
ks *keystore.KeyStore
|
ks *keystore.KeyStore
|
||||||
ethClient *ethclient.Client
|
ethClient *ethclient.Client
|
||||||
ethereumClientWhite *EthereumClient
|
ethereumClientEmergencyCouncil *EthereumClient
|
||||||
ethereumClientKep *EthereumClient
|
|
||||||
ethereumClientGovDAO *EthereumClient
|
|
||||||
ethereumClientAux *EthereumClient
|
ethereumClientAux *EthereumClient
|
||||||
ethereumClientAux2 *EthereumClient
|
ethereumClientAux2 *EthereumClient
|
||||||
ethereumClientHermez *EthereumClient
|
ethereumClientHermez *EthereumClient
|
||||||
@@ -163,14 +152,11 @@ func TestMain(m *testing.M) {
|
|||||||
// into the keystore
|
// into the keystore
|
||||||
bootCoordinatorAccount, bootCoordinatorAddressConst = genAcc(w, ks, 0)
|
bootCoordinatorAccount, bootCoordinatorAddressConst = genAcc(w, ks, 0)
|
||||||
governanceAccount, governanceAddressConst = genAcc(w, ks, 1)
|
governanceAccount, governanceAddressConst = genAcc(w, ks, 1)
|
||||||
safetyAccount, safetyAddressConst = genAcc(w, ks, 2)
|
emergencyCouncilAccount, emergencyCouncilAddressConst = genAcc(w, ks, 2)
|
||||||
hermezKeeperAccount, hermezKeeperAddressConst = genAcc(w, ks, 6)
|
donationAccount, donationAddressConst = genAcc(w, ks, 3)
|
||||||
hermezGovernanceDAOAccount, hermezGovernanceDAOAddressConst = genAcc(w, ks, 7)
|
hermezRollupTestAccount, hermezRollupTestAddressConst = genAcc(w, ks, 4)
|
||||||
whiteHackGroupAccount, whiteHackGroupAddressConst = genAcc(w, ks, 8)
|
auxAccount, auxAddressConst = genAcc(w, ks, 5)
|
||||||
donationAccount, donationAddressConst = genAcc(w, ks, 9)
|
aux2Account, aux2AddressConst = genAcc(w, ks, 6)
|
||||||
aux2Account, aux2AddressConst = genAcc(w, ks, 11)
|
|
||||||
hermezRollupTestAccount, hermezRollupTestAddressConst = genAcc(w, ks, 12)
|
|
||||||
auxAccount, auxAddressConst = genAcc(w, ks, 13)
|
|
||||||
|
|
||||||
ethClient, err = ethclient.Dial(ethClientDialURL)
|
ethClient, err = ethclient.Dial(ethClientDialURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -200,9 +186,7 @@ func TestMain(m *testing.M) {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ethereumClientKep = NewEthereumClient(ethClient, hermezKeeperAccount, ks, nil)
|
ethereumClientEmergencyCouncil = NewEthereumClient(ethClient, emergencyCouncilAccount, ks, nil)
|
||||||
ethereumClientWhite = NewEthereumClient(ethClient, whiteHackGroupAccount, ks, nil)
|
|
||||||
ethereumClientGovDAO = NewEthereumClient(ethClient, hermezGovernanceDAOAccount, ks, nil)
|
|
||||||
ethereumClientAux = NewEthereumClient(ethClient, auxAccount, ks, nil)
|
ethereumClientAux = NewEthereumClient(ethClient, auxAccount, ks, nil)
|
||||||
ethereumClientAux2 = NewEthereumClient(ethClient, aux2Account, ks, nil)
|
ethereumClientAux2 = NewEthereumClient(ethClient, aux2Account, ks, nil)
|
||||||
ethereumClientHermez = NewEthereumClient(ethClient, hermezRollupTestAccount, ks, nil)
|
ethereumClientHermez = NewEthereumClient(ethClient, hermezRollupTestAccount, ks, nil)
|
||||||
|
|||||||
295
eth/rollup.go
295
eth/rollup.go
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum"
|
"github.com/ethereum/go-ethereum"
|
||||||
@@ -58,7 +59,7 @@ type RollupEventL1UserTx struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RollupEventL1UserTxAux is an event of the Rollup Smart Contract
|
// RollupEventL1UserTxAux is an event of the Rollup Smart Contract
|
||||||
type RollupEventL1UserTxAux struct {
|
type rollupEventL1UserTxAux struct {
|
||||||
ToForgeL1TxsNum uint64 // QueueIndex *big.Int
|
ToForgeL1TxsNum uint64 // QueueIndex *big.Int
|
||||||
Position uint8 // TransactionIndex *big.Int
|
Position uint8 // TransactionIndex *big.Int
|
||||||
L1UserTx []byte
|
L1UserTx []byte
|
||||||
@@ -75,6 +76,7 @@ type RollupEventForgeBatch struct {
|
|||||||
BatchNum int64
|
BatchNum int64
|
||||||
// Sender ethCommon.Address
|
// Sender ethCommon.Address
|
||||||
EthTxHash ethCommon.Hash
|
EthTxHash ethCommon.Hash
|
||||||
|
L1UserTxsLen uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
// RollupEventUpdateForgeL1L2BatchTimeout is an event of the Rollup Smart Contract
|
// RollupEventUpdateForgeL1L2BatchTimeout is an event of the Rollup Smart Contract
|
||||||
@@ -95,6 +97,52 @@ type RollupEventWithdraw struct {
|
|||||||
TxHash ethCommon.Hash // Hash of the transaction that generated this event
|
TxHash ethCommon.Hash // Hash of the transaction that generated this event
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type rollupEventUpdateBucketWithdrawAux struct {
|
||||||
|
NumBucket uint8
|
||||||
|
BlockStamp *big.Int
|
||||||
|
Withdrawals *big.Int
|
||||||
|
}
|
||||||
|
|
||||||
|
// RollupEventUpdateBucketWithdraw is an event of the Rollup Smart Contract
|
||||||
|
type RollupEventUpdateBucketWithdraw struct {
|
||||||
|
NumBucket int
|
||||||
|
BlockStamp int64 // blockNum
|
||||||
|
Withdrawals *big.Int
|
||||||
|
}
|
||||||
|
|
||||||
|
// RollupEventUpdateWithdrawalDelay is an event of the Rollup Smart Contract
|
||||||
|
type RollupEventUpdateWithdrawalDelay struct {
|
||||||
|
NewWithdrawalDelay uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
// RollupUpdateBucketsParameters are the bucket parameters used in an update
|
||||||
|
type RollupUpdateBucketsParameters struct {
|
||||||
|
CeilUSD *big.Int
|
||||||
|
Withdrawals *big.Int
|
||||||
|
BlockWithdrawalRate *big.Int
|
||||||
|
MaxWithdrawals *big.Int
|
||||||
|
}
|
||||||
|
|
||||||
|
type rollupEventUpdateBucketsParametersAux struct {
|
||||||
|
ArrayBuckets [common.RollupConstNumBuckets][4]*big.Int
|
||||||
|
}
|
||||||
|
|
||||||
|
// RollupEventUpdateBucketsParameters is an event of the Rollup Smart Contract
|
||||||
|
type RollupEventUpdateBucketsParameters struct {
|
||||||
|
// ArrayBuckets [common.RollupConstNumBuckets][4]*big.Int
|
||||||
|
ArrayBuckets [common.RollupConstNumBuckets]RollupUpdateBucketsParameters
|
||||||
|
}
|
||||||
|
|
||||||
|
// RollupEventUpdateTokenExchange is an event of the Rollup Smart Contract
|
||||||
|
type RollupEventUpdateTokenExchange struct {
|
||||||
|
AddressArray []ethCommon.Address
|
||||||
|
ValueArray []uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
// RollupEventSafeMode is an event of the Rollup Smart Contract
|
||||||
|
type RollupEventSafeMode struct {
|
||||||
|
}
|
||||||
|
|
||||||
// RollupEvents is the list of events in a block of the Rollup Smart Contract
|
// RollupEvents is the list of events in a block of the Rollup Smart Contract
|
||||||
type RollupEvents struct {
|
type RollupEvents struct {
|
||||||
L1UserTx []RollupEventL1UserTx
|
L1UserTx []RollupEventL1UserTx
|
||||||
@@ -103,6 +151,11 @@ type RollupEvents struct {
|
|||||||
UpdateForgeL1L2BatchTimeout []RollupEventUpdateForgeL1L2BatchTimeout
|
UpdateForgeL1L2BatchTimeout []RollupEventUpdateForgeL1L2BatchTimeout
|
||||||
UpdateFeeAddToken []RollupEventUpdateFeeAddToken
|
UpdateFeeAddToken []RollupEventUpdateFeeAddToken
|
||||||
Withdraw []RollupEventWithdraw
|
Withdraw []RollupEventWithdraw
|
||||||
|
UpdateWithdrawalDelay []RollupEventUpdateWithdrawalDelay
|
||||||
|
UpdateBucketWithdraw []RollupEventUpdateBucketWithdraw
|
||||||
|
UpdateBucketsParameters []RollupEventUpdateBucketsParameters
|
||||||
|
UpdateTokenExchange []RollupEventUpdateTokenExchange
|
||||||
|
SafeMode []RollupEventSafeMode
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRollupEvents creates an empty RollupEvents with the slices initialized.
|
// NewRollupEvents creates an empty RollupEvents with the slices initialized.
|
||||||
@@ -122,6 +175,7 @@ type RollupForgeBatchArgs struct {
|
|||||||
NewLastIdx int64
|
NewLastIdx int64
|
||||||
NewStRoot *big.Int
|
NewStRoot *big.Int
|
||||||
NewExitRoot *big.Int
|
NewExitRoot *big.Int
|
||||||
|
L1UserTxs []common.L1Tx
|
||||||
L1CoordinatorTxs []common.L1Tx
|
L1CoordinatorTxs []common.L1Tx
|
||||||
L1CoordinatorTxsAuths [][]byte // Authorization for accountCreations for each L1CoordinatorTx
|
L1CoordinatorTxsAuths [][]byte // Authorization for accountCreations for each L1CoordinatorTx
|
||||||
L2TxsData []common.L2Tx
|
L2TxsData []common.L2Tx
|
||||||
@@ -135,12 +189,12 @@ type RollupForgeBatchArgs struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RollupForgeBatchArgsAux are the arguments to the ForgeBatch function in the Rollup Smart Contract
|
// RollupForgeBatchArgsAux are the arguments to the ForgeBatch function in the Rollup Smart Contract
|
||||||
type RollupForgeBatchArgsAux struct {
|
type rollupForgeBatchArgsAux struct {
|
||||||
NewLastIdx *big.Int
|
NewLastIdx *big.Int
|
||||||
NewStRoot *big.Int
|
NewStRoot *big.Int
|
||||||
NewExitRoot *big.Int
|
NewExitRoot *big.Int
|
||||||
EncodedL1CoordinatorTx []byte
|
EncodedL1CoordinatorTx []byte
|
||||||
L2TxsData []byte
|
L1L2TxsData []byte
|
||||||
FeeIdxCoordinator []byte
|
FeeIdxCoordinator []byte
|
||||||
// Circuit selector
|
// Circuit selector
|
||||||
VerifierIdx uint8
|
VerifierIdx uint8
|
||||||
@@ -181,7 +235,7 @@ type RollupInterface interface {
|
|||||||
|
|
||||||
RollupConstants() (*common.RollupConstants, error)
|
RollupConstants() (*common.RollupConstants, error)
|
||||||
RollupEventsByBlock(blockNum int64) (*RollupEvents, *ethCommon.Hash, error)
|
RollupEventsByBlock(blockNum int64) (*RollupEvents, *ethCommon.Hash, error)
|
||||||
RollupForgeBatchArgs(ethCommon.Hash) (*RollupForgeBatchArgs, *ethCommon.Address, error)
|
RollupForgeBatchArgs(ethCommon.Hash, uint16) (*RollupForgeBatchArgs, *ethCommon.Address, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -240,6 +294,7 @@ func (c *RollupClient) RollupForgeBatch(args *RollupForgeBatchArgs) (tx *types.T
|
|||||||
nLevels := rollupConst.Verifiers[args.VerifierIdx].NLevels
|
nLevels := rollupConst.Verifiers[args.VerifierIdx].NLevels
|
||||||
lenBytes := nLevels / 8 //nolint:gomnd
|
lenBytes := nLevels / 8 //nolint:gomnd
|
||||||
newLastIdx := big.NewInt(int64(args.NewLastIdx))
|
newLastIdx := big.NewInt(int64(args.NewLastIdx))
|
||||||
|
// L1CoordinatorBytes
|
||||||
var l1CoordinatorBytes []byte
|
var l1CoordinatorBytes []byte
|
||||||
for i := 0; i < len(args.L1CoordinatorTxs); i++ {
|
for i := 0; i < len(args.L1CoordinatorTxs); i++ {
|
||||||
l1 := args.L1CoordinatorTxs[i]
|
l1 := args.L1CoordinatorTxs[i]
|
||||||
@@ -249,15 +304,33 @@ func (c *RollupClient) RollupForgeBatch(args *RollupForgeBatchArgs) (tx *types.T
|
|||||||
}
|
}
|
||||||
l1CoordinatorBytes = append(l1CoordinatorBytes, bytesl1[:]...)
|
l1CoordinatorBytes = append(l1CoordinatorBytes, bytesl1[:]...)
|
||||||
}
|
}
|
||||||
var l2DataBytes []byte
|
// L1L2TxData
|
||||||
|
var l1l2TxData []byte
|
||||||
|
for i := 0; i < len(args.L1UserTxs); i++ {
|
||||||
|
l1User := args.L1UserTxs[i]
|
||||||
|
bytesl1User, err := l1User.BytesDataAvailability(uint32(nLevels))
|
||||||
|
if err != nil {
|
||||||
|
return nil, tracerr.Wrap(err)
|
||||||
|
}
|
||||||
|
l1l2TxData = append(l1l2TxData, bytesl1User[:]...)
|
||||||
|
}
|
||||||
|
for i := 0; i < len(args.L1CoordinatorTxs); i++ {
|
||||||
|
l1Coord := args.L1CoordinatorTxs[i]
|
||||||
|
bytesl1Coord, err := l1Coord.BytesDataAvailability(uint32(nLevels))
|
||||||
|
if err != nil {
|
||||||
|
return nil, tracerr.Wrap(err)
|
||||||
|
}
|
||||||
|
l1l2TxData = append(l1l2TxData, bytesl1Coord[:]...)
|
||||||
|
}
|
||||||
for i := 0; i < len(args.L2TxsData); i++ {
|
for i := 0; i < len(args.L2TxsData); i++ {
|
||||||
l2 := args.L2TxsData[i]
|
l2 := args.L2TxsData[i]
|
||||||
bytesl2, err := l2.BytesDataAvailability(uint32(nLevels))
|
bytesl2, err := l2.BytesDataAvailability(uint32(nLevels))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, tracerr.Wrap(err)
|
return nil, tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
l2DataBytes = append(l2DataBytes, bytesl2[:]...)
|
l1l2TxData = append(l1l2TxData, bytesl2[:]...)
|
||||||
}
|
}
|
||||||
|
// FeeIdxCoordinator
|
||||||
var feeIdxCoordinator []byte
|
var feeIdxCoordinator []byte
|
||||||
if len(args.FeeIdxCoordinator) > common.RollupConstMaxFeeIdxCoordinator {
|
if len(args.FeeIdxCoordinator) > common.RollupConstMaxFeeIdxCoordinator {
|
||||||
return nil, tracerr.Wrap(fmt.Errorf("len(args.FeeIdxCoordinator) > %v",
|
return nil, tracerr.Wrap(fmt.Errorf("len(args.FeeIdxCoordinator) > %v",
|
||||||
@@ -274,7 +347,7 @@ func (c *RollupClient) RollupForgeBatch(args *RollupForgeBatchArgs) (tx *types.T
|
|||||||
}
|
}
|
||||||
feeIdxCoordinator = append(feeIdxCoordinator, bytesFeeIdx[len(bytesFeeIdx)-int(lenBytes):]...)
|
feeIdxCoordinator = append(feeIdxCoordinator, bytesFeeIdx[len(bytesFeeIdx)-int(lenBytes):]...)
|
||||||
}
|
}
|
||||||
return c.hermez.ForgeBatch(auth, newLastIdx, args.NewStRoot, args.NewExitRoot, l1CoordinatorBytes, l2DataBytes, feeIdxCoordinator, args.VerifierIdx, args.L1Batch, args.ProofA, args.ProofB, args.ProofC)
|
return c.hermez.ForgeBatch(auth, newLastIdx, args.NewStRoot, args.NewExitRoot, l1CoordinatorBytes, l1l2TxData, feeIdxCoordinator, args.VerifierIdx, args.L1Batch, args.ProofA, args.ProofB, args.ProofC)
|
||||||
},
|
},
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, tracerr.Wrap(fmt.Errorf("Failed forge batch: %w", err))
|
return nil, tracerr.Wrap(fmt.Errorf("Failed forge batch: %w", err))
|
||||||
@@ -317,7 +390,7 @@ func (c *RollupClient) RollupWithdrawMerkleProof(fromBJJ *babyjub.PublicKey, tok
|
|||||||
pkCompL := fromBJJ.Compress()
|
pkCompL := fromBJJ.Compress()
|
||||||
pkCompB := common.SwapEndianness(pkCompL[:])
|
pkCompB := common.SwapEndianness(pkCompL[:])
|
||||||
babyPubKey := new(big.Int).SetBytes(pkCompB)
|
babyPubKey := new(big.Int).SetBytes(pkCompB)
|
||||||
numExitRootB := big.NewInt(numExitRoot)
|
numExitRootB := uint32(numExitRoot)
|
||||||
idxBig := big.NewInt(idx)
|
idxBig := big.NewInt(idx)
|
||||||
return c.hermez.WithdrawMerkleProof(auth, tokenID, amount, babyPubKey, numExitRootB, siblings, idxBig, instantWithdraw)
|
return c.hermez.WithdrawMerkleProof(auth, tokenID, amount, babyPubKey, numExitRootB, siblings, idxBig, instantWithdraw)
|
||||||
},
|
},
|
||||||
@@ -338,9 +411,14 @@ func (c *RollupClient) RollupL1UserTxERC20ETH(fromBJJ *babyjub.PublicKey, fromId
|
|||||||
if tx, err = c.client.CallAuth(
|
if tx, err = c.client.CallAuth(
|
||||||
0,
|
0,
|
||||||
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
var babyPubKey *big.Int
|
||||||
|
if fromBJJ != nil {
|
||||||
pkCompL := fromBJJ.Compress()
|
pkCompL := fromBJJ.Compress()
|
||||||
pkCompB := common.SwapEndianness(pkCompL[:])
|
pkCompB := common.SwapEndianness(pkCompL[:])
|
||||||
babyPubKey := new(big.Int).SetBytes(pkCompB)
|
babyPubKey = new(big.Int).SetBytes(pkCompB)
|
||||||
|
} else {
|
||||||
|
babyPubKey = big.NewInt(0)
|
||||||
|
}
|
||||||
fromIdxBig := big.NewInt(fromIdx)
|
fromIdxBig := big.NewInt(fromIdx)
|
||||||
toIdxBig := big.NewInt(toIdx)
|
toIdxBig := big.NewInt(toIdx)
|
||||||
loadAmountF, err := common.NewFloat16(loadAmount)
|
loadAmountF, err := common.NewFloat16(loadAmount)
|
||||||
@@ -369,9 +447,14 @@ func (c *RollupClient) RollupL1UserTxERC20Permit(fromBJJ *babyjub.PublicKey, fro
|
|||||||
if tx, err = c.client.CallAuth(
|
if tx, err = c.client.CallAuth(
|
||||||
0,
|
0,
|
||||||
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
var babyPubKey *big.Int
|
||||||
|
if fromBJJ != nil {
|
||||||
pkCompL := fromBJJ.Compress()
|
pkCompL := fromBJJ.Compress()
|
||||||
pkCompB := common.SwapEndianness(pkCompL[:])
|
pkCompB := common.SwapEndianness(pkCompL[:])
|
||||||
babyPubKey := new(big.Int).SetBytes(pkCompB)
|
babyPubKey = new(big.Int).SetBytes(pkCompB)
|
||||||
|
} else {
|
||||||
|
babyPubKey = big.NewInt(0)
|
||||||
|
}
|
||||||
fromIdxBig := big.NewInt(fromIdx)
|
fromIdxBig := big.NewInt(fromIdx)
|
||||||
toIdxBig := big.NewInt(toIdx)
|
toIdxBig := big.NewInt(toIdx)
|
||||||
loadAmountF, err := common.NewFloat16(loadAmount)
|
loadAmountF, err := common.NewFloat16(loadAmount)
|
||||||
@@ -454,6 +537,78 @@ func (c *RollupClient) RollupUpdateFeeAddToken(newFeeAddToken *big.Int) (tx *typ
|
|||||||
return tx, nil
|
return tx, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RollupUpdateBucketsParameters is the interface to call the smart contract function
|
||||||
|
func (c *RollupClient) RollupUpdateBucketsParameters(
|
||||||
|
arrayBuckets [common.RollupConstNumBuckets]RollupUpdateBucketsParameters,
|
||||||
|
) (tx *types.Transaction, err error) {
|
||||||
|
params := [common.RollupConstNumBuckets][4]*big.Int{}
|
||||||
|
for i, bucket := range arrayBuckets {
|
||||||
|
params[i][0] = bucket.CeilUSD
|
||||||
|
params[i][1] = bucket.Withdrawals
|
||||||
|
params[i][2] = bucket.BlockWithdrawalRate
|
||||||
|
params[i][3] = bucket.MaxWithdrawals
|
||||||
|
}
|
||||||
|
if tx, err = c.client.CallAuth(
|
||||||
|
12500000, //nolint:gomnd
|
||||||
|
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
return c.hermez.UpdateBucketsParameters(auth, params)
|
||||||
|
},
|
||||||
|
); err != nil {
|
||||||
|
return nil, tracerr.Wrap(fmt.Errorf("Failed update Buckets Parameters: %w", err))
|
||||||
|
}
|
||||||
|
return tx, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RollupUpdateTokenExchange is the interface to call the smart contract function
|
||||||
|
func (c *RollupClient) RollupUpdateTokenExchange(addressArray []ethCommon.Address, valueArray []uint64) (tx *types.Transaction, err error) {
|
||||||
|
if tx, err = c.client.CallAuth(
|
||||||
|
0,
|
||||||
|
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
return c.hermez.UpdateTokenExchange(auth, addressArray, valueArray)
|
||||||
|
},
|
||||||
|
); err != nil {
|
||||||
|
return nil, tracerr.Wrap(fmt.Errorf("Failed update Token Exchange: %w", err))
|
||||||
|
}
|
||||||
|
return tx, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RollupUpdateWithdrawalDelay is the interface to call the smart contract function
|
||||||
|
func (c *RollupClient) RollupUpdateWithdrawalDelay(newWithdrawalDelay int64) (tx *types.Transaction, err error) {
|
||||||
|
if tx, err = c.client.CallAuth(
|
||||||
|
0,
|
||||||
|
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
return c.hermez.UpdateWithdrawalDelay(auth, uint64(newWithdrawalDelay))
|
||||||
|
},
|
||||||
|
); err != nil {
|
||||||
|
return nil, tracerr.Wrap(fmt.Errorf("Failed update WithdrawalDelay: %w", err))
|
||||||
|
}
|
||||||
|
return tx, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RollupSafeMode is the interface to call the smart contract function
|
||||||
|
func (c *RollupClient) RollupSafeMode() (tx *types.Transaction, err error) {
|
||||||
|
if tx, err = c.client.CallAuth(
|
||||||
|
0,
|
||||||
|
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
return c.hermez.SafeMode(auth)
|
||||||
|
},
|
||||||
|
); err != nil {
|
||||||
|
return nil, tracerr.Wrap(fmt.Errorf("Failed update Safe Mode: %w", err))
|
||||||
|
}
|
||||||
|
return tx, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RollupInstantWithdrawalViewer is the interface to call the smart contract function
|
||||||
|
func (c *RollupClient) RollupInstantWithdrawalViewer(tokenAddress ethCommon.Address, amount *big.Int) (instantAllowed bool, err error) {
|
||||||
|
if err := c.client.Call(func(ec *ethclient.Client) error {
|
||||||
|
instantAllowed, err = c.hermez.InstantWithdrawalViewer(nil, tokenAddress, amount)
|
||||||
|
return tracerr.Wrap(err)
|
||||||
|
}); err != nil {
|
||||||
|
return false, tracerr.Wrap(err)
|
||||||
|
}
|
||||||
|
return instantAllowed, nil
|
||||||
|
}
|
||||||
|
|
||||||
// RollupConstants returns the Constants of the Rollup Smart Contract
|
// RollupConstants returns the Constants of the Rollup Smart Contract
|
||||||
func (c *RollupClient) RollupConstants() (rollupConstants *common.RollupConstants, err error) {
|
func (c *RollupClient) RollupConstants() (rollupConstants *common.RollupConstants, err error) {
|
||||||
rollupConstants = new(common.RollupConstants)
|
rollupConstants = new(common.RollupConstants)
|
||||||
@@ -481,11 +636,7 @@ func (c *RollupClient) RollupConstants() (rollupConstants *common.RollupConstant
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return tracerr.Wrap(err)
|
return tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
rollupConstants.HermezGovernanceDAOAddress, err = c.hermez.HermezGovernanceDAOAddress(nil)
|
rollupConstants.HermezGovernanceAddress, err = c.hermez.HermezGovernanceAddress(nil)
|
||||||
if err != nil {
|
|
||||||
return tracerr.Wrap(err)
|
|
||||||
}
|
|
||||||
rollupConstants.SafetyAddress, err = c.hermez.SafetyAddress(nil)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return tracerr.Wrap(err)
|
return tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
@@ -498,12 +649,17 @@ func (c *RollupClient) RollupConstants() (rollupConstants *common.RollupConstant
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logHermezL1UserTxEvent = crypto.Keccak256Hash([]byte("L1UserTxEvent(uint64,uint8,bytes)"))
|
logHermezL1UserTxEvent = crypto.Keccak256Hash([]byte("L1UserTxEvent(uint32,uint8,bytes)"))
|
||||||
logHermezAddToken = crypto.Keccak256Hash([]byte("AddToken(address,uint32)"))
|
logHermezAddToken = crypto.Keccak256Hash([]byte("AddToken(address,uint32)"))
|
||||||
logHermezForgeBatch = crypto.Keccak256Hash([]byte("ForgeBatch(uint64)"))
|
logHermezForgeBatch = crypto.Keccak256Hash([]byte("ForgeBatch(uint32,uint16)"))
|
||||||
logHermezUpdateForgeL1L2BatchTimeout = crypto.Keccak256Hash([]byte("UpdateForgeL1L2BatchTimeout(uint8)"))
|
logHermezUpdateForgeL1L2BatchTimeout = crypto.Keccak256Hash([]byte("UpdateForgeL1L2BatchTimeout(uint8)"))
|
||||||
logHermezUpdateFeeAddToken = crypto.Keccak256Hash([]byte("UpdateFeeAddToken(uint256)"))
|
logHermezUpdateFeeAddToken = crypto.Keccak256Hash([]byte("UpdateFeeAddToken(uint256)"))
|
||||||
logHermezWithdrawEvent = crypto.Keccak256Hash([]byte("WithdrawEvent(uint48,uint48,bool)"))
|
logHermezWithdrawEvent = crypto.Keccak256Hash([]byte("WithdrawEvent(uint48,uint32,bool)"))
|
||||||
|
logHermezUpdateBucketWithdraw = crypto.Keccak256Hash([]byte("UpdateBucketWithdraw(uint8,uint256,uint256)"))
|
||||||
|
logHermezUpdateWithdrawalDelay = crypto.Keccak256Hash([]byte("UpdateWithdrawalDelay(uint64)"))
|
||||||
|
logHermezUpdateBucketsParameters = crypto.Keccak256Hash([]byte("UpdateBucketsParameters(uint256[4][" + strconv.Itoa(common.RollupConstNumBuckets) + "])"))
|
||||||
|
logHermezUpdateTokenExchange = crypto.Keccak256Hash([]byte("UpdateTokenExchange(address[],uint64[])"))
|
||||||
|
logHermezSafeMode = crypto.Keccak256Hash([]byte("SafeMode()"))
|
||||||
)
|
)
|
||||||
|
|
||||||
// RollupEventsByBlock returns the events in a block that happened in the Rollup Smart Contract
|
// RollupEventsByBlock returns the events in a block that happened in the Rollup Smart Contract
|
||||||
@@ -534,7 +690,7 @@ func (c *RollupClient) RollupEventsByBlock(blockNum int64) (*RollupEvents, *ethC
|
|||||||
}
|
}
|
||||||
switch vLog.Topics[0] {
|
switch vLog.Topics[0] {
|
||||||
case logHermezL1UserTxEvent:
|
case logHermezL1UserTxEvent:
|
||||||
var L1UserTxAux RollupEventL1UserTxAux
|
var L1UserTxAux rollupEventL1UserTxAux
|
||||||
var L1UserTx RollupEventL1UserTx
|
var L1UserTx RollupEventL1UserTx
|
||||||
err := c.contractAbi.Unpack(&L1UserTxAux, "L1UserTxEvent", vLog.Data)
|
err := c.contractAbi.Unpack(&L1UserTxAux, "L1UserTxEvent", vLog.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -560,6 +716,10 @@ func (c *RollupClient) RollupEventsByBlock(blockNum int64) (*RollupEvents, *ethC
|
|||||||
rollupEvents.AddToken = append(rollupEvents.AddToken, addToken)
|
rollupEvents.AddToken = append(rollupEvents.AddToken, addToken)
|
||||||
case logHermezForgeBatch:
|
case logHermezForgeBatch:
|
||||||
var forgeBatch RollupEventForgeBatch
|
var forgeBatch RollupEventForgeBatch
|
||||||
|
err := c.contractAbi.Unpack(&forgeBatch, "ForgeBatch", vLog.Data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, tracerr.Wrap(err)
|
||||||
|
}
|
||||||
forgeBatch.BatchNum = new(big.Int).SetBytes(vLog.Topics[1][:]).Int64()
|
forgeBatch.BatchNum = new(big.Int).SetBytes(vLog.Topics[1][:]).Int64()
|
||||||
forgeBatch.EthTxHash = vLog.TxHash
|
forgeBatch.EthTxHash = vLog.TxHash
|
||||||
// forgeBatch.Sender = vLog.Address
|
// forgeBatch.Sender = vLog.Address
|
||||||
@@ -593,6 +753,49 @@ func (c *RollupClient) RollupEventsByBlock(blockNum int64) (*RollupEvents, *ethC
|
|||||||
}
|
}
|
||||||
withdraw.TxHash = vLog.TxHash
|
withdraw.TxHash = vLog.TxHash
|
||||||
rollupEvents.Withdraw = append(rollupEvents.Withdraw, withdraw)
|
rollupEvents.Withdraw = append(rollupEvents.Withdraw, withdraw)
|
||||||
|
case logHermezUpdateBucketWithdraw:
|
||||||
|
var updateBucketWithdrawAux rollupEventUpdateBucketWithdrawAux
|
||||||
|
var updateBucketWithdraw RollupEventUpdateBucketWithdraw
|
||||||
|
err := c.contractAbi.Unpack(&updateBucketWithdrawAux, "UpdateBucketWithdraw", vLog.Data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, tracerr.Wrap(err)
|
||||||
|
}
|
||||||
|
updateBucketWithdraw.Withdrawals = updateBucketWithdrawAux.Withdrawals
|
||||||
|
updateBucketWithdraw.NumBucket = int(new(big.Int).SetBytes(vLog.Topics[1][:]).Int64())
|
||||||
|
updateBucketWithdraw.BlockStamp = new(big.Int).SetBytes(vLog.Topics[2][:]).Int64()
|
||||||
|
rollupEvents.UpdateBucketWithdraw = append(rollupEvents.UpdateBucketWithdraw, updateBucketWithdraw)
|
||||||
|
|
||||||
|
case logHermezUpdateWithdrawalDelay:
|
||||||
|
var withdrawalDelay RollupEventUpdateWithdrawalDelay
|
||||||
|
err := c.contractAbi.Unpack(&withdrawalDelay, "UpdateWithdrawalDelay", vLog.Data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, tracerr.Wrap(err)
|
||||||
|
}
|
||||||
|
rollupEvents.UpdateWithdrawalDelay = append(rollupEvents.UpdateWithdrawalDelay, withdrawalDelay)
|
||||||
|
case logHermezUpdateBucketsParameters:
|
||||||
|
var bucketsParametersAux rollupEventUpdateBucketsParametersAux
|
||||||
|
var bucketsParameters RollupEventUpdateBucketsParameters
|
||||||
|
err := c.contractAbi.Unpack(&bucketsParametersAux, "UpdateBucketsParameters", vLog.Data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, tracerr.Wrap(err)
|
||||||
|
}
|
||||||
|
for i, bucket := range bucketsParametersAux.ArrayBuckets {
|
||||||
|
bucketsParameters.ArrayBuckets[i].CeilUSD = bucket[0]
|
||||||
|
bucketsParameters.ArrayBuckets[i].Withdrawals = bucket[1]
|
||||||
|
bucketsParameters.ArrayBuckets[i].BlockWithdrawalRate = bucket[2]
|
||||||
|
bucketsParameters.ArrayBuckets[i].MaxWithdrawals = bucket[3]
|
||||||
|
}
|
||||||
|
rollupEvents.UpdateBucketsParameters = append(rollupEvents.UpdateBucketsParameters, bucketsParameters)
|
||||||
|
case logHermezUpdateTokenExchange:
|
||||||
|
var tokensExchange RollupEventUpdateTokenExchange
|
||||||
|
err := c.contractAbi.Unpack(&tokensExchange, "UpdateTokenExchange", vLog.Data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, tracerr.Wrap(err)
|
||||||
|
}
|
||||||
|
rollupEvents.UpdateTokenExchange = append(rollupEvents.UpdateTokenExchange, tokensExchange)
|
||||||
|
case logHermezSafeMode:
|
||||||
|
var safeMode RollupEventSafeMode
|
||||||
|
rollupEvents.SafeMode = append(rollupEvents.SafeMode, safeMode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &rollupEvents, blockHash, nil
|
return &rollupEvents, blockHash, nil
|
||||||
@@ -600,7 +803,7 @@ func (c *RollupClient) RollupEventsByBlock(blockNum int64) (*RollupEvents, *ethC
|
|||||||
|
|
||||||
// RollupForgeBatchArgs returns the arguments used in a ForgeBatch call in the
|
// RollupForgeBatchArgs returns the arguments used in a ForgeBatch call in the
|
||||||
// Rollup Smart Contract in the given transaction, and the sender address.
|
// Rollup Smart Contract in the given transaction, and the sender address.
|
||||||
func (c *RollupClient) RollupForgeBatchArgs(ethTxHash ethCommon.Hash) (*RollupForgeBatchArgs, *ethCommon.Address, error) {
|
func (c *RollupClient) RollupForgeBatchArgs(ethTxHash ethCommon.Hash, l1UserTxsLen uint16) (*RollupForgeBatchArgs, *ethCommon.Address, error) {
|
||||||
tx, _, err := c.client.client.TransactionByHash(context.Background(), ethTxHash)
|
tx, _, err := c.client.client.TransactionByHash(context.Background(), ethTxHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, tracerr.Wrap(err)
|
return nil, nil, tracerr.Wrap(err)
|
||||||
@@ -619,7 +822,7 @@ func (c *RollupClient) RollupForgeBatchArgs(ethTxHash ethCommon.Hash) (*RollupFo
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, tracerr.Wrap(err)
|
return nil, nil, tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
var aux RollupForgeBatchArgsAux
|
var aux rollupForgeBatchArgsAux
|
||||||
if err := method.Inputs.Unpack(&aux, txData[4:]); err != nil {
|
if err := method.Inputs.Unpack(&aux, txData[4:]); err != nil {
|
||||||
return nil, nil, tracerr.Wrap(err)
|
return nil, nil, tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
@@ -637,8 +840,40 @@ func (c *RollupClient) RollupForgeBatchArgs(ethTxHash ethCommon.Hash) (*RollupFo
|
|||||||
L2TxsData: []common.L2Tx{},
|
L2TxsData: []common.L2Tx{},
|
||||||
FeeIdxCoordinator: []common.Idx{},
|
FeeIdxCoordinator: []common.Idx{},
|
||||||
}
|
}
|
||||||
numTxsL1 := len(aux.EncodedL1CoordinatorTx) / common.L1CoordinatorTxBytesLen
|
rollupConsts, err := c.RollupConstants()
|
||||||
for i := 0; i < numTxsL1; i++ {
|
if err != nil {
|
||||||
|
return nil, nil, tracerr.Wrap(err)
|
||||||
|
}
|
||||||
|
nLevels := rollupConsts.Verifiers[rollupForgeBatchArgs.VerifierIdx].NLevels
|
||||||
|
lenL1L2TxsBytes := int((nLevels/8)*2 + 2 + 1)
|
||||||
|
numBytesL1TxUser := int(l1UserTxsLen) * lenL1L2TxsBytes
|
||||||
|
numTxsL1Coord := len(aux.EncodedL1CoordinatorTx) / common.L1CoordinatorTxBytesLen
|
||||||
|
numBytesL1TxCoord := numTxsL1Coord * lenL1L2TxsBytes
|
||||||
|
numBeginL2Tx := numBytesL1TxCoord + numBytesL1TxUser
|
||||||
|
l1UserTxsData := []byte{}
|
||||||
|
if l1UserTxsLen > 0 {
|
||||||
|
l1UserTxsData = aux.L1L2TxsData[:numBytesL1TxUser]
|
||||||
|
}
|
||||||
|
for i := 0; i < int(l1UserTxsLen); i++ {
|
||||||
|
l1Tx, err := common.L1TxFromDataAvailability(l1UserTxsData[i*lenL1L2TxsBytes:(i+1)*lenL1L2TxsBytes], uint32(nLevels))
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, tracerr.Wrap(err)
|
||||||
|
}
|
||||||
|
rollupForgeBatchArgs.L1UserTxs = append(rollupForgeBatchArgs.L1UserTxs, *l1Tx)
|
||||||
|
}
|
||||||
|
l2TxsData := []byte{}
|
||||||
|
if numBeginL2Tx < len(aux.L1L2TxsData) {
|
||||||
|
l2TxsData = aux.L1L2TxsData[numBeginL2Tx:]
|
||||||
|
}
|
||||||
|
numTxsL2 := len(l2TxsData) / lenL1L2TxsBytes
|
||||||
|
for i := 0; i < numTxsL2; i++ {
|
||||||
|
l2Tx, err := common.L2TxFromBytesDataAvailability(l2TxsData[i*lenL1L2TxsBytes:(i+1)*lenL1L2TxsBytes], int(nLevels))
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, tracerr.Wrap(err)
|
||||||
|
}
|
||||||
|
rollupForgeBatchArgs.L2TxsData = append(rollupForgeBatchArgs.L2TxsData, *l2Tx)
|
||||||
|
}
|
||||||
|
for i := 0; i < numTxsL1Coord; i++ {
|
||||||
bytesL1Coordinator := aux.EncodedL1CoordinatorTx[i*common.L1CoordinatorTxBytesLen : (i+1)*common.L1CoordinatorTxBytesLen]
|
bytesL1Coordinator := aux.EncodedL1CoordinatorTx[i*common.L1CoordinatorTxBytesLen : (i+1)*common.L1CoordinatorTxBytesLen]
|
||||||
var signature []byte
|
var signature []byte
|
||||||
v := bytesL1Coordinator[0]
|
v := bytesL1Coordinator[0]
|
||||||
@@ -654,20 +889,6 @@ func (c *RollupClient) RollupForgeBatchArgs(ethTxHash ethCommon.Hash) (*RollupFo
|
|||||||
rollupForgeBatchArgs.L1CoordinatorTxs = append(rollupForgeBatchArgs.L1CoordinatorTxs, *l1Tx)
|
rollupForgeBatchArgs.L1CoordinatorTxs = append(rollupForgeBatchArgs.L1CoordinatorTxs, *l1Tx)
|
||||||
rollupForgeBatchArgs.L1CoordinatorTxsAuths = append(rollupForgeBatchArgs.L1CoordinatorTxsAuths, signature)
|
rollupForgeBatchArgs.L1CoordinatorTxsAuths = append(rollupForgeBatchArgs.L1CoordinatorTxsAuths, signature)
|
||||||
}
|
}
|
||||||
rollupConsts, err := c.RollupConstants()
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, tracerr.Wrap(err)
|
|
||||||
}
|
|
||||||
nLevels := rollupConsts.Verifiers[rollupForgeBatchArgs.VerifierIdx].NLevels
|
|
||||||
lenL2TxsBytes := int((nLevels/8)*2 + 2 + 1)
|
|
||||||
numTxsL2 := len(aux.L2TxsData) / lenL2TxsBytes
|
|
||||||
for i := 0; i < numTxsL2; i++ {
|
|
||||||
l2Tx, err := common.L2TxFromBytes(aux.L2TxsData[i*lenL2TxsBytes:(i+1)*lenL2TxsBytes], int(nLevels))
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, tracerr.Wrap(err)
|
|
||||||
}
|
|
||||||
rollupForgeBatchArgs.L2TxsData = append(rollupForgeBatchArgs.L2TxsData, *l2Tx)
|
|
||||||
}
|
|
||||||
lenFeeIdxCoordinatorBytes := int(nLevels / 8) //nolint:gomnd
|
lenFeeIdxCoordinatorBytes := int(nLevels / 8) //nolint:gomnd
|
||||||
numFeeIdxCoordinator := len(aux.FeeIdxCoordinator) / lenFeeIdxCoordinatorBytes
|
numFeeIdxCoordinator := len(aux.FeeIdxCoordinator) / lenFeeIdxCoordinatorBytes
|
||||||
for i := 0; i < numFeeIdxCoordinator; i++ {
|
for i := 0; i < numFeeIdxCoordinator; i++ {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
137
eth/wdelayer.go
137
eth/wdelayer.go
@@ -58,19 +58,14 @@ type WDelayerEventEscapeHatchWithdrawal struct {
|
|||||||
Amount *big.Int
|
Amount *big.Int
|
||||||
}
|
}
|
||||||
|
|
||||||
// WDelayerEventNewHermezKeeperAddress an event of the WithdrawalDelayer Smart Contract
|
// WDelayerEventNewEmergencyCouncil an event of the WithdrawalDelayer Smart Contract
|
||||||
type WDelayerEventNewHermezKeeperAddress struct {
|
type WDelayerEventNewEmergencyCouncil struct {
|
||||||
NewHermezKeeperAddress ethCommon.Address
|
NewEmergencyCouncil ethCommon.Address
|
||||||
}
|
}
|
||||||
|
|
||||||
// WDelayerEventNewWhiteHackGroupAddress an event of the WithdrawalDelayer Smart Contract
|
// WDelayerEventNewHermezGovernanceAddress an event of the WithdrawalDelayer Smart Contract
|
||||||
type WDelayerEventNewWhiteHackGroupAddress struct {
|
type WDelayerEventNewHermezGovernanceAddress struct {
|
||||||
NewWhiteHackGroupAddress ethCommon.Address
|
NewHermezGovernanceAddress ethCommon.Address
|
||||||
}
|
|
||||||
|
|
||||||
// WDelayerEventNewHermezGovernanceDAOAddress an event of the WithdrawalDelayer Smart Contract
|
|
||||||
type WDelayerEventNewHermezGovernanceDAOAddress struct {
|
|
||||||
NewHermezGovernanceDAOAddress ethCommon.Address
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WDelayerEvents is the lis of events in a block of the WithdrawalDelayer Smart Contract
|
// WDelayerEvents is the lis of events in a block of the WithdrawalDelayer Smart Contract
|
||||||
@@ -80,9 +75,8 @@ type WDelayerEvents struct {
|
|||||||
EmergencyModeEnabled []WDelayerEventEmergencyModeEnabled
|
EmergencyModeEnabled []WDelayerEventEmergencyModeEnabled
|
||||||
NewWithdrawalDelay []WDelayerEventNewWithdrawalDelay
|
NewWithdrawalDelay []WDelayerEventNewWithdrawalDelay
|
||||||
EscapeHatchWithdrawal []WDelayerEventEscapeHatchWithdrawal
|
EscapeHatchWithdrawal []WDelayerEventEscapeHatchWithdrawal
|
||||||
NewHermezKeeperAddress []WDelayerEventNewHermezKeeperAddress
|
NewEmergencyCouncil []WDelayerEventNewEmergencyCouncil
|
||||||
NewWhiteHackGroupAddress []WDelayerEventNewWhiteHackGroupAddress
|
NewHermezGovernanceAddress []WDelayerEventNewHermezGovernanceAddress
|
||||||
NewHermezGovernanceDAOAddress []WDelayerEventNewHermezGovernanceDAOAddress
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWDelayerEvents creates an empty WDelayerEvents with the slices initialized.
|
// NewWDelayerEvents creates an empty WDelayerEvents with the slices initialized.
|
||||||
@@ -93,9 +87,8 @@ func NewWDelayerEvents() WDelayerEvents {
|
|||||||
EmergencyModeEnabled: make([]WDelayerEventEmergencyModeEnabled, 0),
|
EmergencyModeEnabled: make([]WDelayerEventEmergencyModeEnabled, 0),
|
||||||
NewWithdrawalDelay: make([]WDelayerEventNewWithdrawalDelay, 0),
|
NewWithdrawalDelay: make([]WDelayerEventNewWithdrawalDelay, 0),
|
||||||
EscapeHatchWithdrawal: make([]WDelayerEventEscapeHatchWithdrawal, 0),
|
EscapeHatchWithdrawal: make([]WDelayerEventEscapeHatchWithdrawal, 0),
|
||||||
NewHermezKeeperAddress: make([]WDelayerEventNewHermezKeeperAddress, 0),
|
NewEmergencyCouncil: make([]WDelayerEventNewEmergencyCouncil, 0),
|
||||||
NewWhiteHackGroupAddress: make([]WDelayerEventNewWhiteHackGroupAddress, 0),
|
NewHermezGovernanceAddress: make([]WDelayerEventNewHermezGovernanceAddress, 0),
|
||||||
NewHermezGovernanceDAOAddress: make([]WDelayerEventNewHermezGovernanceDAOAddress, 0),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,12 +98,12 @@ type WDelayerInterface interface {
|
|||||||
// Smart Contract Methods
|
// Smart Contract Methods
|
||||||
//
|
//
|
||||||
|
|
||||||
WDelayerGetHermezGovernanceDAOAddress() (*ethCommon.Address, error)
|
WDelayerGetHermezGovernanceAddress() (*ethCommon.Address, error)
|
||||||
WDelayerSetHermezGovernanceDAOAddress(newAddress ethCommon.Address) (*types.Transaction, error)
|
WDelayerTransferGovernance(newAddress ethCommon.Address) (*types.Transaction, error)
|
||||||
WDelayerGetHermezKeeperAddress() (*ethCommon.Address, error)
|
WDelayerClaimGovernance() (*types.Transaction, error)
|
||||||
WDelayerSetHermezKeeperAddress(newAddress ethCommon.Address) (*types.Transaction, error)
|
WDelayerGetEmergencyCouncil() (*ethCommon.Address, error)
|
||||||
WDelayerGetWhiteHackGroupAddress() (*ethCommon.Address, error)
|
WDelayerTransferEmergencyCouncil(newAddress ethCommon.Address) (*types.Transaction, error)
|
||||||
WDelayerSetWhiteHackGroupAddress(newAddress ethCommon.Address) (*types.Transaction, error)
|
WDelayerClaimEmergencyCouncil() (*types.Transaction, error)
|
||||||
WDelayerIsEmergencyMode() (bool, error)
|
WDelayerIsEmergencyMode() (bool, error)
|
||||||
WDelayerGetWithdrawalDelay() (*big.Int, error)
|
WDelayerGetWithdrawalDelay() (*big.Int, error)
|
||||||
WDelayerGetEmergencyModeStartingTime() (*big.Int, error)
|
WDelayerGetEmergencyModeStartingTime() (*big.Int, error)
|
||||||
@@ -155,77 +148,78 @@ func NewWDelayerClient(client *EthereumClient, address ethCommon.Address) (*WDel
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// WDelayerGetHermezGovernanceDAOAddress is the interface to call the smart contract function
|
// WDelayerGetHermezGovernanceAddress is the interface to call the smart contract function
|
||||||
func (c *WDelayerClient) WDelayerGetHermezGovernanceDAOAddress() (hermezGovernanceDAOAddress *ethCommon.Address, err error) {
|
func (c *WDelayerClient) WDelayerGetHermezGovernanceAddress() (hermezGovernanceAddress *ethCommon.Address, err error) {
|
||||||
var _hermezGovernanceDAOAddress ethCommon.Address
|
var _hermezGovernanceAddress ethCommon.Address
|
||||||
if err := c.client.Call(func(ec *ethclient.Client) error {
|
if err := c.client.Call(func(ec *ethclient.Client) error {
|
||||||
_hermezGovernanceDAOAddress, err = c.wdelayer.GetHermezGovernanceDAOAddress(nil)
|
_hermezGovernanceAddress, err = c.wdelayer.GetHermezGovernanceAddress(nil)
|
||||||
return tracerr.Wrap(err)
|
return tracerr.Wrap(err)
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, tracerr.Wrap(err)
|
return nil, tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
return &_hermezGovernanceDAOAddress, nil
|
return &_hermezGovernanceAddress, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// WDelayerSetHermezGovernanceDAOAddress is the interface to call the smart contract function
|
// WDelayerTransferGovernance is the interface to call the smart contract function
|
||||||
func (c *WDelayerClient) WDelayerSetHermezGovernanceDAOAddress(newAddress ethCommon.Address) (tx *types.Transaction, err error) {
|
func (c *WDelayerClient) WDelayerTransferGovernance(newAddress ethCommon.Address) (tx *types.Transaction, err error) {
|
||||||
if tx, err = c.client.CallAuth(
|
if tx, err = c.client.CallAuth(
|
||||||
0,
|
0,
|
||||||
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
return c.wdelayer.SetHermezGovernanceDAOAddress(auth, newAddress)
|
return c.wdelayer.TransferGovernance(auth, newAddress)
|
||||||
},
|
},
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, tracerr.Wrap(fmt.Errorf("Failed setting hermezGovernanceDAOAddress: %w", err))
|
return nil, tracerr.Wrap(fmt.Errorf("Failed transfer hermezGovernanceAddress: %w", err))
|
||||||
}
|
}
|
||||||
return tx, nil
|
return tx, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// WDelayerGetHermezKeeperAddress is the interface to call the smart contract function
|
// WDelayerClaimGovernance is the interface to call the smart contract function
|
||||||
func (c *WDelayerClient) WDelayerGetHermezKeeperAddress() (hermezKeeperAddress *ethCommon.Address, err error) {
|
func (c *WDelayerClient) WDelayerClaimGovernance() (tx *types.Transaction, err error) {
|
||||||
var _hermezKeeperAddress ethCommon.Address
|
|
||||||
if err := c.client.Call(func(ec *ethclient.Client) error {
|
|
||||||
_hermezKeeperAddress, err = c.wdelayer.GetHermezKeeperAddress(nil)
|
|
||||||
return tracerr.Wrap(err)
|
|
||||||
}); err != nil {
|
|
||||||
return nil, tracerr.Wrap(err)
|
|
||||||
}
|
|
||||||
return &_hermezKeeperAddress, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// WDelayerSetHermezKeeperAddress is the interface to call the smart contract function
|
|
||||||
func (c *WDelayerClient) WDelayerSetHermezKeeperAddress(newAddress ethCommon.Address) (tx *types.Transaction, err error) {
|
|
||||||
if tx, err = c.client.CallAuth(
|
if tx, err = c.client.CallAuth(
|
||||||
0,
|
0,
|
||||||
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
return c.wdelayer.SetHermezKeeperAddress(auth, newAddress)
|
return c.wdelayer.ClaimGovernance(auth)
|
||||||
},
|
},
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, tracerr.Wrap(fmt.Errorf("Failed setting hermezKeeperAddress: %w", err))
|
return nil, tracerr.Wrap(fmt.Errorf("Failed claim hermezGovernanceAddress: %w", err))
|
||||||
}
|
}
|
||||||
return tx, nil
|
return tx, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// WDelayerGetWhiteHackGroupAddress is the interface to call the smart contract function
|
// WDelayerGetEmergencyCouncil is the interface to call the smart contract function
|
||||||
func (c *WDelayerClient) WDelayerGetWhiteHackGroupAddress() (whiteHackGroupAddress *ethCommon.Address, err error) {
|
func (c *WDelayerClient) WDelayerGetEmergencyCouncil() (emergencyCouncilAddress *ethCommon.Address, err error) {
|
||||||
var _whiteHackGroupAddress ethCommon.Address
|
var _emergencyCouncilAddress ethCommon.Address
|
||||||
if err := c.client.Call(func(ec *ethclient.Client) error {
|
if err := c.client.Call(func(ec *ethclient.Client) error {
|
||||||
_whiteHackGroupAddress, err = c.wdelayer.GetWhiteHackGroupAddress(nil)
|
_emergencyCouncilAddress, err = c.wdelayer.GetEmergencyCouncil(nil)
|
||||||
return tracerr.Wrap(err)
|
return tracerr.Wrap(err)
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, tracerr.Wrap(err)
|
return nil, tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
return &_whiteHackGroupAddress, nil
|
return &_emergencyCouncilAddress, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// WDelayerSetWhiteHackGroupAddress is the interface to call the smart contract function
|
// WDelayerTransferEmergencyCouncil is the interface to call the smart contract function
|
||||||
func (c *WDelayerClient) WDelayerSetWhiteHackGroupAddress(newAddress ethCommon.Address) (tx *types.Transaction, err error) {
|
func (c *WDelayerClient) WDelayerTransferEmergencyCouncil(newAddress ethCommon.Address) (tx *types.Transaction, err error) {
|
||||||
if tx, err = c.client.CallAuth(
|
if tx, err = c.client.CallAuth(
|
||||||
0,
|
0,
|
||||||
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
return c.wdelayer.SetWhiteHackGroupAddress(auth, newAddress)
|
return c.wdelayer.TransferEmergencyCouncil(auth, newAddress)
|
||||||
},
|
},
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, tracerr.Wrap(fmt.Errorf("Failed setting whiteHackGroupAddress: %w", err))
|
return nil, tracerr.Wrap(fmt.Errorf("Failed transfer EmergencyCouncil: %w", err))
|
||||||
|
}
|
||||||
|
return tx, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// WDelayerClaimEmergencyCouncil is the interface to call the smart contract function
|
||||||
|
func (c *WDelayerClient) WDelayerClaimEmergencyCouncil() (tx *types.Transaction, err error) {
|
||||||
|
if tx, err = c.client.CallAuth(
|
||||||
|
0,
|
||||||
|
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
return c.wdelayer.ClaimEmergencyCouncil(auth)
|
||||||
|
},
|
||||||
|
); err != nil {
|
||||||
|
return nil, tracerr.Wrap(fmt.Errorf("Failed claim EmergencyCouncil: %w", err))
|
||||||
}
|
}
|
||||||
return tx, nil
|
return tx, nil
|
||||||
}
|
}
|
||||||
@@ -370,9 +364,8 @@ var (
|
|||||||
logWDelayerEmergencyModeEnabled = crypto.Keccak256Hash([]byte("EmergencyModeEnabled()"))
|
logWDelayerEmergencyModeEnabled = crypto.Keccak256Hash([]byte("EmergencyModeEnabled()"))
|
||||||
logWDelayerNewWithdrawalDelay = crypto.Keccak256Hash([]byte("NewWithdrawalDelay(uint64)"))
|
logWDelayerNewWithdrawalDelay = crypto.Keccak256Hash([]byte("NewWithdrawalDelay(uint64)"))
|
||||||
logWDelayerEscapeHatchWithdrawal = crypto.Keccak256Hash([]byte("EscapeHatchWithdrawal(address,address,address,uint256)"))
|
logWDelayerEscapeHatchWithdrawal = crypto.Keccak256Hash([]byte("EscapeHatchWithdrawal(address,address,address,uint256)"))
|
||||||
logWDelayerNewHermezKeeperAddress = crypto.Keccak256Hash([]byte("NewHermezKeeperAddress(address)"))
|
logWDelayerNewEmergencyCouncil = crypto.Keccak256Hash([]byte("NewEmergencyCouncil(address)"))
|
||||||
logWDelayerNewWhiteHackGroupAddress = crypto.Keccak256Hash([]byte("NewWhiteHackGroupAddress(address)"))
|
logWDelayerNewHermezGovernanceAddress = crypto.Keccak256Hash([]byte("NewHermezGovernanceAddress(address)"))
|
||||||
logWDelayerNewHermezGovernanceDAOAddress = crypto.Keccak256Hash([]byte("NewHermezGovernanceDAOAddress(address)"))
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// WDelayerEventsByBlock returns the events in a block that happened in the
|
// WDelayerEventsByBlock returns the events in a block that happened in the
|
||||||
@@ -449,29 +442,21 @@ func (c *WDelayerClient) WDelayerEventsByBlock(blockNum int64) (*WDelayerEvents,
|
|||||||
escapeHatchWithdrawal.Token = ethCommon.BytesToAddress(vLog.Topics[3].Bytes())
|
escapeHatchWithdrawal.Token = ethCommon.BytesToAddress(vLog.Topics[3].Bytes())
|
||||||
wdelayerEvents.EscapeHatchWithdrawal = append(wdelayerEvents.EscapeHatchWithdrawal, escapeHatchWithdrawal)
|
wdelayerEvents.EscapeHatchWithdrawal = append(wdelayerEvents.EscapeHatchWithdrawal, escapeHatchWithdrawal)
|
||||||
|
|
||||||
case logWDelayerNewHermezKeeperAddress:
|
case logWDelayerNewEmergencyCouncil:
|
||||||
var keeperAddress WDelayerEventNewHermezKeeperAddress
|
var emergencyCouncil WDelayerEventNewEmergencyCouncil
|
||||||
err := c.contractAbi.Unpack(&keeperAddress, "NewHermezKeeperAddress", vLog.Data)
|
err := c.contractAbi.Unpack(&emergencyCouncil, "NewEmergencyCouncil", vLog.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, tracerr.Wrap(err)
|
return nil, nil, tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
wdelayerEvents.NewHermezKeeperAddress = append(wdelayerEvents.NewHermezKeeperAddress, keeperAddress)
|
wdelayerEvents.NewEmergencyCouncil = append(wdelayerEvents.NewEmergencyCouncil, emergencyCouncil)
|
||||||
|
|
||||||
case logWDelayerNewWhiteHackGroupAddress:
|
case logWDelayerNewHermezGovernanceAddress:
|
||||||
var whiteHackGroupAddress WDelayerEventNewWhiteHackGroupAddress
|
var governanceAddress WDelayerEventNewHermezGovernanceAddress
|
||||||
err := c.contractAbi.Unpack(&whiteHackGroupAddress, "NewWhiteHackGroupAddress", vLog.Data)
|
err := c.contractAbi.Unpack(&governanceAddress, "NewHermezGovernanceAddress", vLog.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, tracerr.Wrap(err)
|
return nil, nil, tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
wdelayerEvents.NewWhiteHackGroupAddress = append(wdelayerEvents.NewWhiteHackGroupAddress, whiteHackGroupAddress)
|
wdelayerEvents.NewHermezGovernanceAddress = append(wdelayerEvents.NewHermezGovernanceAddress, governanceAddress)
|
||||||
|
|
||||||
case logWDelayerNewHermezGovernanceDAOAddress:
|
|
||||||
var governanceDAOAddress WDelayerEventNewHermezGovernanceDAOAddress
|
|
||||||
err := c.contractAbi.Unpack(&governanceDAOAddress, "NewHermezGovernanceDAOAddress", vLog.Data)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, tracerr.Wrap(err)
|
|
||||||
}
|
|
||||||
wdelayerEvents.NewHermezGovernanceDAOAddress = append(wdelayerEvents.NewHermezGovernanceDAOAddress, governanceDAOAddress)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &wdelayerEvents, blockHash, nil
|
return &wdelayerEvents, blockHash, nil
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ import (
|
|||||||
var wdelayerClient *WDelayerClient
|
var wdelayerClient *WDelayerClient
|
||||||
var wdelayerClientTest *WDelayerClient
|
var wdelayerClientTest *WDelayerClient
|
||||||
|
|
||||||
// var wdelayerClientKep *WDelayerClient
|
|
||||||
|
|
||||||
var initWithdrawalDelay = big.NewInt(60)
|
var initWithdrawalDelay = big.NewInt(60)
|
||||||
var newWithdrawalDelay = big.NewInt(79)
|
var newWithdrawalDelay = big.NewInt(79)
|
||||||
var maxEmergencyModeTime = time.Hour * 24 * 7 * 26
|
var maxEmergencyModeTime = time.Hour * 24 * 7 * 26
|
||||||
@@ -27,78 +25,59 @@ func TestWDelayerConstants(t *testing.T) {
|
|||||||
assert.Equal(t, hermezRollupTestAddressConst, wDelayerConstants.HermezRollup)
|
assert.Equal(t, hermezRollupTestAddressConst, wDelayerConstants.HermezRollup)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWDelayerGetHermezGovernanceDAOAddress(t *testing.T) {
|
func TestWDelayerGetHermezGovernanceAddress(t *testing.T) {
|
||||||
governanceAddress, err := wdelayerClientTest.WDelayerGetHermezGovernanceDAOAddress()
|
governanceAddress, err := wdelayerClientTest.WDelayerGetHermezGovernanceAddress()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
assert.Equal(t, &hermezGovernanceDAOAddressConst, governanceAddress)
|
assert.Equal(t, &governanceAddressConst, governanceAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWDelayerSetHermezGovernanceDAOAddress(t *testing.T) {
|
func TestWDelayerSetHermezGovernanceAddress(t *testing.T) {
|
||||||
wdelayerClientGov, err := NewWDelayerClient(ethereumClientGovDAO, wdelayerTestAddressConst)
|
wdelayerClientAux, err := NewWDelayerClient(ethereumClientAux, wdelayerTestAddressConst)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
_, err = wdelayerClientGov.WDelayerSetHermezGovernanceDAOAddress(auxAddressConst)
|
_, err = wdelayerClientTest.WDelayerTransferGovernance(auxAddressConst)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
auxAddress, err := wdelayerClientTest.WDelayerGetHermezGovernanceDAOAddress()
|
_, err = wdelayerClientAux.WDelayerClaimGovernance()
|
||||||
|
require.Nil(t, err)
|
||||||
|
auxAddress, err := wdelayerClientTest.WDelayerGetHermezGovernanceAddress()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
assert.Equal(t, &auxAddressConst, auxAddress)
|
assert.Equal(t, &auxAddressConst, auxAddress)
|
||||||
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
|
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
wdelayerEvents, _, err := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
|
wdelayerEvents, _, err := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
assert.Equal(t, auxAddressConst, wdelayerEvents.NewHermezGovernanceDAOAddress[0].NewHermezGovernanceDAOAddress)
|
assert.Equal(t, auxAddressConst, wdelayerEvents.NewHermezGovernanceAddress[0].NewHermezGovernanceAddress)
|
||||||
|
_, err = wdelayerClientAux.WDelayerTransferGovernance(governanceAddressConst)
|
||||||
|
require.Nil(t, err)
|
||||||
|
_, err = wdelayerClientTest.WDelayerClaimGovernance()
|
||||||
|
require.Nil(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWDelayerGetEmergencyCouncil(t *testing.T) {
|
||||||
|
emergencyCouncil, err := wdelayerClientTest.WDelayerGetEmergencyCouncil()
|
||||||
|
require.Nil(t, err)
|
||||||
|
assert.Equal(t, &emergencyCouncilAddressConst, emergencyCouncil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWDelayerSetEmergencyCouncil(t *testing.T) {
|
||||||
|
wdelayerClientEmergencyCouncil, err := NewWDelayerClient(ethereumClientEmergencyCouncil, wdelayerTestAddressConst)
|
||||||
|
require.Nil(t, err)
|
||||||
wdelayerClientAux, err := NewWDelayerClient(ethereumClientAux, wdelayerTestAddressConst)
|
wdelayerClientAux, err := NewWDelayerClient(ethereumClientAux, wdelayerTestAddressConst)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
_, err = wdelayerClientAux.WDelayerSetHermezGovernanceDAOAddress(hermezGovernanceDAOAddressConst)
|
_, err = wdelayerClientEmergencyCouncil.WDelayerTransferEmergencyCouncil(auxAddressConst)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
}
|
_, err = wdelayerClientAux.WDelayerClaimEmergencyCouncil()
|
||||||
|
|
||||||
func TestWDelayerGetHermezKeeperAddress(t *testing.T) {
|
|
||||||
keeperAddress, err := wdelayerClientTest.WDelayerGetHermezKeeperAddress()
|
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
assert.Equal(t, &hermezKeeperAddressConst, keeperAddress)
|
auxAddress, err := wdelayerClientTest.WDelayerGetEmergencyCouncil()
|
||||||
}
|
|
||||||
|
|
||||||
func TestWDelayerSetHermezKeeperAddress(t *testing.T) {
|
|
||||||
wdelayerClientKep, err := NewWDelayerClient(ethereumClientKep, wdelayerTestAddressConst)
|
|
||||||
require.Nil(t, err)
|
|
||||||
_, err = wdelayerClientKep.WDelayerSetHermezKeeperAddress(auxAddressConst)
|
|
||||||
require.Nil(t, err)
|
|
||||||
auxAddress, err := wdelayerClientTest.WDelayerGetHermezKeeperAddress()
|
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
assert.Equal(t, &auxAddressConst, auxAddress)
|
assert.Equal(t, &auxAddressConst, auxAddress)
|
||||||
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
|
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
wdelayerEvents, _, err := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
|
wdelayerEvents, _, err := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
assert.Equal(t, auxAddressConst, wdelayerEvents.NewHermezKeeperAddress[0].NewHermezKeeperAddress)
|
assert.Equal(t, auxAddressConst, wdelayerEvents.NewEmergencyCouncil[0].NewEmergencyCouncil)
|
||||||
wdelayerClientAux, err := NewWDelayerClient(ethereumClientAux, wdelayerTestAddressConst)
|
_, err = wdelayerClientAux.WDelayerTransferEmergencyCouncil(emergencyCouncilAddressConst)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
_, err = wdelayerClientAux.WDelayerSetHermezKeeperAddress(hermezKeeperAddressConst)
|
_, err = wdelayerClientEmergencyCouncil.WDelayerClaimEmergencyCouncil()
|
||||||
require.Nil(t, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWDelayerGetWhiteHackGroupAddress(t *testing.T) {
|
|
||||||
whiteHackGroupAddress, err := wdelayerClientTest.WDelayerGetWhiteHackGroupAddress()
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.Equal(t, &whiteHackGroupAddressConst, whiteHackGroupAddress)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWDelayerSetWhiteHackGroupAddress(t *testing.T) {
|
|
||||||
wdelayerClientWhite, err := NewWDelayerClient(ethereumClientWhite, wdelayerTestAddressConst)
|
|
||||||
require.Nil(t, err)
|
|
||||||
_, err = wdelayerClientWhite.WDelayerSetWhiteHackGroupAddress(auxAddressConst)
|
|
||||||
require.Nil(t, err)
|
|
||||||
auxAddress, err := wdelayerClientTest.WDelayerGetWhiteHackGroupAddress()
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.Equal(t, &auxAddressConst, auxAddress)
|
|
||||||
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
|
|
||||||
require.Nil(t, err)
|
|
||||||
wdelayerEvents, _, err := wdelayerClientTest.WDelayerEventsByBlock(currentBlockNum)
|
|
||||||
require.Nil(t, err)
|
|
||||||
assert.Equal(t, auxAddressConst, wdelayerEvents.NewWhiteHackGroupAddress[0].NewWhiteHackGroupAddress)
|
|
||||||
wdelayerClientAux, err := NewWDelayerClient(ethereumClientAux, wdelayerTestAddressConst)
|
|
||||||
require.Nil(t, err)
|
|
||||||
_, err = wdelayerClientAux.WDelayerSetWhiteHackGroupAddress(whiteHackGroupAddressConst)
|
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,9 +94,7 @@ func TestWDelayerGetWithdrawalDelay(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWDelayerChangeWithdrawalDelay(t *testing.T) {
|
func TestWDelayerChangeWithdrawalDelay(t *testing.T) {
|
||||||
wdelayerClientKep, err := NewWDelayerClient(ethereumClientKep, wdelayerTestAddressConst)
|
_, err := wdelayerClientTest.WDelayerChangeWithdrawalDelay(newWithdrawalDelay.Uint64())
|
||||||
require.Nil(t, err)
|
|
||||||
_, err = wdelayerClientKep.WDelayerChangeWithdrawalDelay(newWithdrawalDelay.Uint64())
|
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
withdrawalDelay, err := wdelayerClientTest.WDelayerGetWithdrawalDelay()
|
withdrawalDelay, err := wdelayerClientTest.WDelayerGetWithdrawalDelay()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
@@ -188,9 +165,7 @@ func TestWDelayerSecondDeposit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWDelayerEnableEmergencyMode(t *testing.T) {
|
func TestWDelayerEnableEmergencyMode(t *testing.T) {
|
||||||
wdelayerClientKep, err := NewWDelayerClient(ethereumClientKep, wdelayerTestAddressConst)
|
_, err := wdelayerClientTest.WDelayerEnableEmergencyMode()
|
||||||
require.Nil(t, err)
|
|
||||||
_, err = wdelayerClientKep.WDelayerEnableEmergencyMode()
|
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
emergencyMode, err := wdelayerClientTest.WDelayerIsEmergencyMode()
|
emergencyMode, err := wdelayerClientTest.WDelayerIsEmergencyMode()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
@@ -216,13 +191,13 @@ func TestWDelayerGetEmergencyModeStartingTime(t *testing.T) {
|
|||||||
func TestWDelayerEscapeHatchWithdrawal(t *testing.T) {
|
func TestWDelayerEscapeHatchWithdrawal(t *testing.T) {
|
||||||
amount := new(big.Int)
|
amount := new(big.Int)
|
||||||
amount.SetString("10000000000000000", 10)
|
amount.SetString("10000000000000000", 10)
|
||||||
wdelayerClientWhite, err := NewWDelayerClient(ethereumClientWhite, wdelayerTestAddressConst)
|
wdelayerClientEmergencyCouncil, err := NewWDelayerClient(ethereumClientEmergencyCouncil, wdelayerTestAddressConst)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
_, err = wdelayerClientWhite.WDelayerEscapeHatchWithdrawal(governanceAddressConst, tokenHEZAddressConst, amount)
|
_, err = wdelayerClientEmergencyCouncil.WDelayerEscapeHatchWithdrawal(governanceAddressConst, tokenHEZAddressConst, amount)
|
||||||
require.Contains(t, err.Error(), "NO_MAX_EMERGENCY_MODE_TIME")
|
require.Contains(t, err.Error(), "NO_MAX_EMERGENCY_MODE_TIME")
|
||||||
seconds := maxEmergencyModeTime.Seconds()
|
seconds := maxEmergencyModeTime.Seconds()
|
||||||
addTime(seconds, ethClientDialURL)
|
addTime(seconds, ethClientDialURL)
|
||||||
_, err = wdelayerClientWhite.WDelayerEscapeHatchWithdrawal(governanceAddressConst, tokenHEZAddressConst, amount)
|
_, err = wdelayerClientEmergencyCouncil.WDelayerEscapeHatchWithdrawal(governanceAddressConst, tokenHEZAddressConst, amount)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
|
currentBlockNum, err := wdelayerClientTest.client.EthLastBlock()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
@@ -230,6 +205,6 @@ func TestWDelayerEscapeHatchWithdrawal(t *testing.T) {
|
|||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
assert.Equal(t, tokenHEZAddressConst, wdelayerEvents.EscapeHatchWithdrawal[0].Token)
|
assert.Equal(t, tokenHEZAddressConst, wdelayerEvents.EscapeHatchWithdrawal[0].Token)
|
||||||
assert.Equal(t, governanceAddressConst, wdelayerEvents.EscapeHatchWithdrawal[0].To)
|
assert.Equal(t, governanceAddressConst, wdelayerEvents.EscapeHatchWithdrawal[0].To)
|
||||||
assert.Equal(t, whiteHackGroupAddressConst, wdelayerEvents.EscapeHatchWithdrawal[0].Who)
|
assert.Equal(t, emergencyCouncilAddressConst, wdelayerEvents.EscapeHatchWithdrawal[0].Who)
|
||||||
assert.Equal(t, amount, wdelayerEvents.EscapeHatchWithdrawal[0].Amount)
|
assert.Equal(t, amount, wdelayerEvents.EscapeHatchWithdrawal[0].Amount)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -736,7 +736,8 @@ func (s *Synchronizer) rollupSync(ethBlock *common.Block) (*common.RollupData, e
|
|||||||
position := 0
|
position := 0
|
||||||
|
|
||||||
// Get the input for each Tx
|
// Get the input for each Tx
|
||||||
forgeBatchArgs, sender, err := s.ethClient.RollupForgeBatchArgs(evtForgeBatch.EthTxHash)
|
forgeBatchArgs, sender, err := s.ethClient.RollupForgeBatchArgs(evtForgeBatch.EthTxHash,
|
||||||
|
evtForgeBatch.L1UserTxsLen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, tracerr.Wrap(err)
|
return nil, tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
@@ -1074,16 +1075,12 @@ func (s *Synchronizer) wdelayerSync(ethBlock *common.Block) (*common.WDelayerDat
|
|||||||
s.vars.WDelayer.WithdrawalDelay = evt.WithdrawalDelay
|
s.vars.WDelayer.WithdrawalDelay = evt.WithdrawalDelay
|
||||||
varsUpdate = true
|
varsUpdate = true
|
||||||
}
|
}
|
||||||
for _, evt := range wDelayerEvents.NewHermezKeeperAddress {
|
for _, evt := range wDelayerEvents.NewEmergencyCouncil {
|
||||||
s.vars.WDelayer.HermezKeeperAddress = evt.NewHermezKeeperAddress
|
s.vars.WDelayer.EmergencyCouncilAddress = evt.NewEmergencyCouncil
|
||||||
varsUpdate = true
|
varsUpdate = true
|
||||||
}
|
}
|
||||||
for _, evt := range wDelayerEvents.NewWhiteHackGroupAddress {
|
for _, evt := range wDelayerEvents.NewHermezGovernanceAddress {
|
||||||
s.vars.WDelayer.WhiteHackGroupAddress = evt.NewWhiteHackGroupAddress
|
s.vars.WDelayer.HermezGovernanceAddress = evt.NewHermezGovernanceAddress
|
||||||
varsUpdate = true
|
|
||||||
}
|
|
||||||
for _, evt := range wDelayerEvents.NewHermezGovernanceDAOAddress {
|
|
||||||
s.vars.WDelayer.HermezGovernanceDAOAddress = evt.NewHermezGovernanceDAOAddress
|
|
||||||
varsUpdate = true
|
varsUpdate = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -293,8 +293,7 @@ func NewClientSetupExample() *ClientSetup {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
TokenHEZ: tokenHEZ,
|
TokenHEZ: tokenHEZ,
|
||||||
HermezGovernanceDAOAddress: governanceAddress,
|
HermezGovernanceAddress: governanceAddress,
|
||||||
SafetyAddress: ethCommon.HexToAddress("0x84d8B79E84fe87B14ad61A554e740f6736bF4c20"),
|
|
||||||
HermezAuctionContract: ethCommon.HexToAddress("0x8E442975805fb1908f43050c9C1A522cB0e28D7b"),
|
HermezAuctionContract: ethCommon.HexToAddress("0x8E442975805fb1908f43050c9C1A522cB0e28D7b"),
|
||||||
WithdrawDelayerContract: ethCommon.HexToAddress("0x5CB7979cBdbf65719BEE92e4D15b7b7Ed3D79114"),
|
WithdrawDelayerContract: ethCommon.HexToAddress("0x5CB7979cBdbf65719BEE92e4D15b7b7Ed3D79114"),
|
||||||
}
|
}
|
||||||
@@ -314,6 +313,7 @@ func NewClientSetupExample() *ClientSetup {
|
|||||||
auctionVariables := &common.AuctionVariables{
|
auctionVariables := &common.AuctionVariables{
|
||||||
DonationAddress: ethCommon.HexToAddress("0x61Ed87CF0A1496b49A420DA6D84B58196b98f2e7"),
|
DonationAddress: ethCommon.HexToAddress("0x61Ed87CF0A1496b49A420DA6D84B58196b98f2e7"),
|
||||||
BootCoordinator: ethCommon.HexToAddress("0xE39fEc6224708f0772D2A74fd3f9055A90E0A9f2"),
|
BootCoordinator: ethCommon.HexToAddress("0xE39fEc6224708f0772D2A74fd3f9055A90E0A9f2"),
|
||||||
|
BootCoordinatorURL: "https://boot.coordinator.com",
|
||||||
DefaultSlotSetBid: [6]*big.Int{
|
DefaultSlotSetBid: [6]*big.Int{
|
||||||
big.NewInt(1000), big.NewInt(1100), big.NewInt(1200),
|
big.NewInt(1000), big.NewInt(1100), big.NewInt(1200),
|
||||||
big.NewInt(1300), big.NewInt(1400), big.NewInt(1500)},
|
big.NewInt(1300), big.NewInt(1400), big.NewInt(1500)},
|
||||||
@@ -329,9 +329,8 @@ func NewClientSetupExample() *ClientSetup {
|
|||||||
HermezRollup: auctionConstants.HermezRollup,
|
HermezRollup: auctionConstants.HermezRollup,
|
||||||
}
|
}
|
||||||
wDelayerVariables := &common.WDelayerVariables{
|
wDelayerVariables := &common.WDelayerVariables{
|
||||||
HermezGovernanceDAOAddress: ethCommon.HexToAddress("0xcfD0d163AE6432a72682323E2C3A5a69e6B37D12"),
|
HermezGovernanceAddress: ethCommon.HexToAddress("0xcfD0d163AE6432a72682323E2C3A5a69e6B37D12"),
|
||||||
WhiteHackGroupAddress: ethCommon.HexToAddress("0x2730700932a4FDB97B9268A3Ca29f97Ea5fd7EA0"),
|
EmergencyCouncilAddress: ethCommon.HexToAddress("0x2730700932a4FDB97B9268A3Ca29f97Ea5fd7EA0"),
|
||||||
HermezKeeperAddress: ethCommon.HexToAddress("0x92aAD86176dC0f0046FE85Ed5dA008a828bE3868"),
|
|
||||||
WithdrawalDelay: 60,
|
WithdrawalDelay: 60,
|
||||||
EmergencyModeStartingTime: 0,
|
EmergencyModeStartingTime: 0,
|
||||||
EmergencyMode: false,
|
EmergencyMode: false,
|
||||||
@@ -944,6 +943,7 @@ func (c *Client) addBatch(args *eth.RollupForgeBatchArgs) (*types.Transaction, e
|
|||||||
r.Events.ForgeBatch = append(r.Events.ForgeBatch, eth.RollupEventForgeBatch{
|
r.Events.ForgeBatch = append(r.Events.ForgeBatch, eth.RollupEventForgeBatch{
|
||||||
BatchNum: int64(len(r.State.ExitRoots)) - 1,
|
BatchNum: int64(len(r.State.ExitRoots)) - 1,
|
||||||
EthTxHash: ethTx.Hash(),
|
EthTxHash: ethTx.Hash(),
|
||||||
|
L1UserTxsLen: uint16(len(args.L1UserTxs)),
|
||||||
})
|
})
|
||||||
|
|
||||||
return ethTx, nil
|
return ethTx, nil
|
||||||
@@ -1061,7 +1061,7 @@ func (c *Client) RollupEventsByBlock(blockNum int64) (*eth.RollupEvents, *ethCom
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RollupForgeBatchArgs returns the arguments used in a ForgeBatch call in the Rollup Smart Contract in the given transaction
|
// RollupForgeBatchArgs returns the arguments used in a ForgeBatch call in the Rollup Smart Contract in the given transaction
|
||||||
func (c *Client) RollupForgeBatchArgs(ethTxHash ethCommon.Hash) (*eth.RollupForgeBatchArgs, *ethCommon.Address, error) {
|
func (c *Client) RollupForgeBatchArgs(ethTxHash ethCommon.Hash, l1UserTxsLen uint16) (*eth.RollupForgeBatchArgs, *ethCommon.Address, error) {
|
||||||
c.rw.RLock()
|
c.rw.RLock()
|
||||||
defer c.rw.RUnlock()
|
defer c.rw.RUnlock()
|
||||||
|
|
||||||
@@ -1220,7 +1220,7 @@ func (c *Client) AuctionGetDonationAddress() (*ethCommon.Address, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AuctionSetBootCoordinator is the interface to call the smart contract function
|
// AuctionSetBootCoordinator is the interface to call the smart contract function
|
||||||
func (c *Client) AuctionSetBootCoordinator(newBootCoordinator ethCommon.Address) (tx *types.Transaction, err error) {
|
func (c *Client) AuctionSetBootCoordinator(newBootCoordinator ethCommon.Address, newBootCoordinatorURL string) (tx *types.Transaction, err error) {
|
||||||
c.rw.Lock()
|
c.rw.Lock()
|
||||||
defer c.rw.Unlock()
|
defer c.rw.Unlock()
|
||||||
cpy := c.nextBlock().copy()
|
cpy := c.nextBlock().copy()
|
||||||
@@ -1511,8 +1511,8 @@ func (c *Client) AuctionEventsByBlock(blockNum int64) (*eth.AuctionEvents, *ethC
|
|||||||
// WDelayer
|
// WDelayer
|
||||||
//
|
//
|
||||||
|
|
||||||
// WDelayerGetHermezGovernanceDAOAddress is the interface to call the smart contract function
|
// WDelayerGetHermezGovernanceAddress is the interface to call the smart contract function
|
||||||
func (c *Client) WDelayerGetHermezGovernanceDAOAddress() (*ethCommon.Address, error) {
|
func (c *Client) WDelayerGetHermezGovernanceAddress() (*ethCommon.Address, error) {
|
||||||
c.rw.RLock()
|
c.rw.RLock()
|
||||||
defer c.rw.RUnlock()
|
defer c.rw.RUnlock()
|
||||||
|
|
||||||
@@ -1520,8 +1520,8 @@ func (c *Client) WDelayerGetHermezGovernanceDAOAddress() (*ethCommon.Address, er
|
|||||||
return nil, tracerr.Wrap(errTODO)
|
return nil, tracerr.Wrap(errTODO)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WDelayerSetHermezGovernanceDAOAddress is the interface to call the smart contract function
|
// WDelayerTransferGovernance is the interface to call the smart contract function
|
||||||
func (c *Client) WDelayerSetHermezGovernanceDAOAddress(newAddress ethCommon.Address) (tx *types.Transaction, err error) {
|
func (c *Client) WDelayerTransferGovernance(newAddress ethCommon.Address) (tx *types.Transaction, err error) {
|
||||||
c.rw.Lock()
|
c.rw.Lock()
|
||||||
defer c.rw.Unlock()
|
defer c.rw.Unlock()
|
||||||
cpy := c.nextBlock().copy()
|
cpy := c.nextBlock().copy()
|
||||||
@@ -1534,17 +1534,8 @@ func (c *Client) WDelayerSetHermezGovernanceDAOAddress(newAddress ethCommon.Addr
|
|||||||
return nil, tracerr.Wrap(errTODO)
|
return nil, tracerr.Wrap(errTODO)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WDelayerGetHermezKeeperAddress is the interface to call the smart contract function
|
// WDelayerClaimGovernance is the interface to call the smart contract function
|
||||||
func (c *Client) WDelayerGetHermezKeeperAddress() (*ethCommon.Address, error) {
|
func (c *Client) WDelayerClaimGovernance() (tx *types.Transaction, err error) {
|
||||||
c.rw.RLock()
|
|
||||||
defer c.rw.RUnlock()
|
|
||||||
|
|
||||||
log.Error("TODO")
|
|
||||||
return nil, tracerr.Wrap(errTODO)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WDelayerSetHermezKeeperAddress is the interface to call the smart contract function
|
|
||||||
func (c *Client) WDelayerSetHermezKeeperAddress(newAddress ethCommon.Address) (tx *types.Transaction, err error) {
|
|
||||||
c.rw.Lock()
|
c.rw.Lock()
|
||||||
defer c.rw.Unlock()
|
defer c.rw.Unlock()
|
||||||
cpy := c.nextBlock().copy()
|
cpy := c.nextBlock().copy()
|
||||||
@@ -1557,8 +1548,8 @@ func (c *Client) WDelayerSetHermezKeeperAddress(newAddress ethCommon.Address) (t
|
|||||||
return nil, tracerr.Wrap(errTODO)
|
return nil, tracerr.Wrap(errTODO)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WDelayerGetWhiteHackGroupAddress is the interface to call the smart contract function
|
// WDelayerGetEmergencyCouncil is the interface to call the smart contract function
|
||||||
func (c *Client) WDelayerGetWhiteHackGroupAddress() (*ethCommon.Address, error) {
|
func (c *Client) WDelayerGetEmergencyCouncil() (*ethCommon.Address, error) {
|
||||||
c.rw.RLock()
|
c.rw.RLock()
|
||||||
defer c.rw.RUnlock()
|
defer c.rw.RUnlock()
|
||||||
|
|
||||||
@@ -1566,8 +1557,22 @@ func (c *Client) WDelayerGetWhiteHackGroupAddress() (*ethCommon.Address, error)
|
|||||||
return nil, tracerr.Wrap(errTODO)
|
return nil, tracerr.Wrap(errTODO)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WDelayerSetWhiteHackGroupAddress is the interface to call the smart contract function
|
// WDelayerTransferEmergencyCouncil is the interface to call the smart contract function
|
||||||
func (c *Client) WDelayerSetWhiteHackGroupAddress(newAddress ethCommon.Address) (tx *types.Transaction, err error) {
|
func (c *Client) WDelayerTransferEmergencyCouncil(newAddress ethCommon.Address) (tx *types.Transaction, err error) {
|
||||||
|
c.rw.Lock()
|
||||||
|
defer c.rw.Unlock()
|
||||||
|
cpy := c.nextBlock().copy()
|
||||||
|
defer func() { c.revertIfErr(err, cpy) }()
|
||||||
|
if c.addr == nil {
|
||||||
|
return nil, tracerr.Wrap(eth.ErrAccountNil)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Error("TODO")
|
||||||
|
return nil, tracerr.Wrap(errTODO)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WDelayerClaimEmergencyCouncil is the interface to call the smart contract function
|
||||||
|
func (c *Client) WDelayerClaimEmergencyCouncil() (tx *types.Transaction, err error) {
|
||||||
c.rw.Lock()
|
c.rw.Lock()
|
||||||
defer c.rw.Unlock()
|
defer c.rw.Unlock()
|
||||||
cpy := c.nextBlock().copy()
|
cpy := c.nextBlock().copy()
|
||||||
|
|||||||
@@ -235,7 +235,8 @@ func TestClientRollup(t *testing.T) {
|
|||||||
rollupEvents, _, err = c.RollupEventsByBlock(blockNum)
|
rollupEvents, _, err = c.RollupEventsByBlock(blockNum)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
rollupForgeBatchArgs1, sender, err := c.RollupForgeBatchArgs(rollupEvents.ForgeBatch[0].EthTxHash)
|
rollupForgeBatchArgs1, sender, err := c.RollupForgeBatchArgs(rollupEvents.ForgeBatch[0].EthTxHash,
|
||||||
|
rollupEvents.ForgeBatch[0].L1UserTxsLen)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
assert.Equal(t, *c.addr, *sender)
|
assert.Equal(t, *c.addr, *sender)
|
||||||
assert.Equal(t, rollupForgeBatchArgs0, rollupForgeBatchArgs1)
|
assert.Equal(t, rollupForgeBatchArgs0, rollupForgeBatchArgs1)
|
||||||
|
|||||||
Reference in New Issue
Block a user