mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 11:26:44 +01:00
Compare commits
13 Commits
master
...
refactore/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4462fd9c53 | ||
|
|
49280afc1a | ||
|
|
5d06bfc4e4 | ||
|
|
bc9d7fdc90 | ||
|
|
dde99d6178 | ||
|
|
2841b4e22c | ||
|
|
ad4e6e8dcb | ||
|
|
aa1f0a2618 | ||
|
|
0f4be6a946 | ||
|
|
602e1e7634 | ||
|
|
6aac050858 | ||
|
|
cd7cdef339 | ||
|
|
379ca78b4e |
@@ -499,12 +499,14 @@ func TestMain(m *testing.M) {
|
|||||||
// Slot 7
|
// Slot 7
|
||||||
nextForgers[6].Coordinator = nonBootForger
|
nextForgers[6].Coordinator = nonBootForger
|
||||||
|
|
||||||
var buckets [common.RollupConstNumBuckets]common.BucketParams
|
buckets := make([]common.BucketParams, 5)
|
||||||
for i := range buckets {
|
for i := range buckets {
|
||||||
buckets[i].CeilUSD = big.NewInt(int64(i) * 10)
|
buckets[i].CeilUSD = big.NewInt(int64(i) * 10)
|
||||||
buckets[i].Withdrawals = big.NewInt(int64(i) * 100)
|
buckets[i].BlockStamp = big.NewInt(int64(i) * 100)
|
||||||
buckets[i].BlockWithdrawalRate = big.NewInt(int64(i) * 1000)
|
buckets[i].Withdrawals = big.NewInt(int64(i) * 1000)
|
||||||
buckets[i].MaxWithdrawals = big.NewInt(int64(i) * 10000)
|
buckets[i].RateBlocks = big.NewInt(int64(i) * 10000)
|
||||||
|
buckets[i].RateWithdrawals = big.NewInt(int64(i) * 100000)
|
||||||
|
buckets[i].MaxWithdrawals = big.NewInt(int64(i) * 1000000)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate SC vars and add them to HistoryDB (if needed)
|
// Generate SC vars and add them to HistoryDB (if needed)
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ func newRollupConstants(publicConstants common.RollupConstants) *rollupConstants
|
|||||||
MaxL1UserTx: common.RollupConstMaxL1UserTx,
|
MaxL1UserTx: common.RollupConstMaxL1UserTx,
|
||||||
MaxL1Tx: common.RollupConstMaxL1Tx,
|
MaxL1Tx: common.RollupConstMaxL1Tx,
|
||||||
InputSHAConstantBytes: common.RollupConstInputSHAConstantBytes,
|
InputSHAConstantBytes: common.RollupConstInputSHAConstantBytes,
|
||||||
NumBuckets: common.RollupConstNumBuckets,
|
|
||||||
MaxWithdrawalDelay: common.RollupConstMaxWithdrawalDelay,
|
MaxWithdrawalDelay: common.RollupConstMaxWithdrawalDelay,
|
||||||
ExchangeMultiplier: common.RollupConstExchangeMultiplier,
|
ExchangeMultiplier: common.RollupConstExchangeMultiplier,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,9 @@ func assertEqualRollupVariables(t *testing.T, rollupVariables common.RollupVaria
|
|||||||
assert.Equal(t, rollupVariables.SafeMode, apiVariables.SafeMode)
|
assert.Equal(t, rollupVariables.SafeMode, apiVariables.SafeMode)
|
||||||
if checkBuckets {
|
if checkBuckets {
|
||||||
for i, bucket := range rollupVariables.Buckets {
|
for i, bucket := range rollupVariables.Buckets {
|
||||||
assert.Equal(t, apitypes.NewBigIntStr(bucket.BlockWithdrawalRate), apiVariables.Buckets[i].BlockWithdrawalRate)
|
assert.Equal(t, apitypes.NewBigIntStr(bucket.BlockStamp), apiVariables.Buckets[i].BlockStamp)
|
||||||
|
assert.Equal(t, apitypes.NewBigIntStr(bucket.RateBlocks), apiVariables.Buckets[i].RateBlocks)
|
||||||
|
assert.Equal(t, apitypes.NewBigIntStr(bucket.RateWithdrawals), apiVariables.Buckets[i].RateWithdrawals)
|
||||||
assert.Equal(t, apitypes.NewBigIntStr(bucket.CeilUSD), apiVariables.Buckets[i].CeilUSD)
|
assert.Equal(t, apitypes.NewBigIntStr(bucket.CeilUSD), apiVariables.Buckets[i].CeilUSD)
|
||||||
assert.Equal(t, apitypes.NewBigIntStr(bucket.MaxWithdrawals), apiVariables.Buckets[i].MaxWithdrawals)
|
assert.Equal(t, apitypes.NewBigIntStr(bucket.MaxWithdrawals), apiVariables.Buckets[i].MaxWithdrawals)
|
||||||
assert.Equal(t, apitypes.NewBigIntStr(bucket.Withdrawals), apiVariables.Buckets[i].Withdrawals)
|
assert.Equal(t, apitypes.NewBigIntStr(bucket.Withdrawals), apiVariables.Buckets[i].Withdrawals)
|
||||||
|
|||||||
@@ -2729,16 +2729,24 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
ceilUSD:
|
ceilUSD:
|
||||||
type: string
|
type: string
|
||||||
description: Max USD value
|
description: Max USD value that bucket holds
|
||||||
example: "1000"
|
example: "1000"
|
||||||
|
blockStamp:
|
||||||
|
type: string
|
||||||
|
description: Block number of the last bucket update
|
||||||
|
example: "1"
|
||||||
withdrawals:
|
withdrawals:
|
||||||
type: string
|
type: string
|
||||||
description: Available withdrawals of the bucket
|
description: Available withdrawals of the bucket
|
||||||
example: "4"
|
example: "4"
|
||||||
blockWithdrawalRate:
|
rateBlocks:
|
||||||
type: string
|
type: string
|
||||||
description: Every `blockWithdrawalRate` blocks add 1 withdrawal
|
description: rateBlocks every `rateBlocks` blocks add `rateWithdrawals` withdrawal
|
||||||
example: "8"
|
example: "2"
|
||||||
|
rateWithdrawals:
|
||||||
|
type: string
|
||||||
|
description: add `rateWithdrawals` every `rateBlocks`
|
||||||
|
example: "3"
|
||||||
maxWithdrawals:
|
maxWithdrawals:
|
||||||
type: string
|
type: string
|
||||||
description: Max withdrawals the bucket can hold
|
description: Max withdrawals the bucket can hold
|
||||||
@@ -2746,8 +2754,10 @@ components:
|
|||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
- ceilUSD
|
- ceilUSD
|
||||||
|
- blockStamp
|
||||||
- withdrawals
|
- withdrawals
|
||||||
- blockWithdrawalRate
|
- rateBlocks
|
||||||
|
- rateWithdrawals
|
||||||
- maxWithdrawals
|
- maxWithdrawals
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
required:
|
required:
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ const (
|
|||||||
// _L1_USER_TOTALBYTES bytes] l1TxsData + totalL2TxsDataLength + feeIdxCoordinatorLength +
|
// _L1_USER_TOTALBYTES bytes] l1TxsData + totalL2TxsDataLength + feeIdxCoordinatorLength +
|
||||||
// [2 bytes] chainID = 18542 bytes + totalL2TxsDataLength + feeIdxCoordinatorLength
|
// [2 bytes] chainID = 18542 bytes + totalL2TxsDataLength + feeIdxCoordinatorLength
|
||||||
RollupConstInputSHAConstantBytes = 18546
|
RollupConstInputSHAConstantBytes = 18546
|
||||||
// RollupConstNumBuckets Number of buckets
|
|
||||||
RollupConstNumBuckets = 5
|
|
||||||
// RollupConstMaxWithdrawalDelay max withdrawal delay in seconds
|
// RollupConstMaxWithdrawalDelay max withdrawal delay in seconds
|
||||||
RollupConstMaxWithdrawalDelay = 2 * 7 * 24 * 60 * 60
|
RollupConstMaxWithdrawalDelay = 2 * 7 * 24 * 60 * 60
|
||||||
// RollupConstExchangeMultiplier exchange multiplier
|
// RollupConstExchangeMultiplier exchange multiplier
|
||||||
@@ -133,8 +131,10 @@ func (c *RollupConstants) FindVerifierIdx(MaxTx, NLevels int64) (int, error) {
|
|||||||
// Contract
|
// Contract
|
||||||
type BucketParams struct {
|
type BucketParams struct {
|
||||||
CeilUSD *big.Int
|
CeilUSD *big.Int
|
||||||
|
BlockStamp *big.Int
|
||||||
Withdrawals *big.Int
|
Withdrawals *big.Int
|
||||||
BlockWithdrawalRate *big.Int
|
RateBlocks *big.Int
|
||||||
|
RateWithdrawals *big.Int
|
||||||
MaxWithdrawals *big.Int
|
MaxWithdrawals *big.Int
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ type RollupVariables struct {
|
|||||||
FeeAddToken *big.Int `meddler:"fee_add_token,bigint" validate:"required"`
|
FeeAddToken *big.Int `meddler:"fee_add_token,bigint" validate:"required"`
|
||||||
ForgeL1L2BatchTimeout int64 `meddler:"forge_l1_timeout" validate:"required"`
|
ForgeL1L2BatchTimeout int64 `meddler:"forge_l1_timeout" validate:"required"`
|
||||||
WithdrawalDelay uint64 `meddler:"withdrawal_delay" validate:"required"`
|
WithdrawalDelay uint64 `meddler:"withdrawal_delay" validate:"required"`
|
||||||
Buckets [RollupConstNumBuckets]BucketParams `meddler:"buckets,json"`
|
Buckets []BucketParams `meddler:"buckets,json"`
|
||||||
SafeMode bool `meddler:"safe_mode"`
|
SafeMode bool `meddler:"safe_mode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -738,7 +738,7 @@ func exampleInitSCVars() (*common.RollupVariables, *common.AuctionVariables, *co
|
|||||||
big.NewInt(10),
|
big.NewInt(10),
|
||||||
12,
|
12,
|
||||||
13,
|
13,
|
||||||
[5]common.BucketParams{},
|
[]common.BucketParams{},
|
||||||
false,
|
false,
|
||||||
}
|
}
|
||||||
//nolint:govet
|
//nolint:govet
|
||||||
|
|||||||
@@ -355,8 +355,10 @@ type BucketUpdateAPI struct {
|
|||||||
// Contract
|
// Contract
|
||||||
type BucketParamsAPI struct {
|
type BucketParamsAPI struct {
|
||||||
CeilUSD *apitypes.BigIntStr `json:"ceilUSD"`
|
CeilUSD *apitypes.BigIntStr `json:"ceilUSD"`
|
||||||
|
BlockStamp *apitypes.BigIntStr `json:"blockStamp"`
|
||||||
Withdrawals *apitypes.BigIntStr `json:"withdrawals"`
|
Withdrawals *apitypes.BigIntStr `json:"withdrawals"`
|
||||||
BlockWithdrawalRate *apitypes.BigIntStr `json:"blockWithdrawalRate"`
|
RateBlocks *apitypes.BigIntStr `json:"rateBlocks"`
|
||||||
|
RateWithdrawals *apitypes.BigIntStr `json:"rateWithdrawals"`
|
||||||
MaxWithdrawals *apitypes.BigIntStr `json:"maxWithdrawals"`
|
MaxWithdrawals *apitypes.BigIntStr `json:"maxWithdrawals"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,25 +368,28 @@ type RollupVariablesAPI struct {
|
|||||||
FeeAddToken *apitypes.BigIntStr `json:"feeAddToken" meddler:"fee_add_token" validate:"required"`
|
FeeAddToken *apitypes.BigIntStr `json:"feeAddToken" meddler:"fee_add_token" validate:"required"`
|
||||||
ForgeL1L2BatchTimeout int64 `json:"forgeL1L2BatchTimeout" meddler:"forge_l1_timeout" validate:"required"`
|
ForgeL1L2BatchTimeout int64 `json:"forgeL1L2BatchTimeout" meddler:"forge_l1_timeout" validate:"required"`
|
||||||
WithdrawalDelay uint64 `json:"withdrawalDelay" meddler:"withdrawal_delay" validate:"required"`
|
WithdrawalDelay uint64 `json:"withdrawalDelay" meddler:"withdrawal_delay" validate:"required"`
|
||||||
Buckets [common.RollupConstNumBuckets]BucketParamsAPI `json:"buckets" meddler:"buckets,json"`
|
Buckets []BucketParamsAPI `json:"buckets" meddler:"buckets,json"`
|
||||||
SafeMode bool `json:"safeMode" meddler:"safe_mode"`
|
SafeMode bool `json:"safeMode" meddler:"safe_mode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRollupVariablesAPI creates a RollupVariablesAPI from common.RollupVariables
|
// NewRollupVariablesAPI creates a RollupVariablesAPI from common.RollupVariables
|
||||||
func NewRollupVariablesAPI(rollupVariables *common.RollupVariables) *RollupVariablesAPI {
|
func NewRollupVariablesAPI(rollupVariables *common.RollupVariables) *RollupVariablesAPI {
|
||||||
|
buckets := make([]BucketParamsAPI, len(rollupVariables.Buckets))
|
||||||
rollupVars := RollupVariablesAPI{
|
rollupVars := RollupVariablesAPI{
|
||||||
EthBlockNum: rollupVariables.EthBlockNum,
|
EthBlockNum: rollupVariables.EthBlockNum,
|
||||||
FeeAddToken: apitypes.NewBigIntStr(rollupVariables.FeeAddToken),
|
FeeAddToken: apitypes.NewBigIntStr(rollupVariables.FeeAddToken),
|
||||||
ForgeL1L2BatchTimeout: rollupVariables.ForgeL1L2BatchTimeout,
|
ForgeL1L2BatchTimeout: rollupVariables.ForgeL1L2BatchTimeout,
|
||||||
WithdrawalDelay: rollupVariables.WithdrawalDelay,
|
WithdrawalDelay: rollupVariables.WithdrawalDelay,
|
||||||
SafeMode: rollupVariables.SafeMode,
|
SafeMode: rollupVariables.SafeMode,
|
||||||
|
Buckets: buckets,
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, bucket := range rollupVariables.Buckets {
|
for i, bucket := range rollupVariables.Buckets {
|
||||||
rollupVars.Buckets[i] = BucketParamsAPI{
|
rollupVars.Buckets[i] = BucketParamsAPI{
|
||||||
CeilUSD: apitypes.NewBigIntStr(bucket.CeilUSD),
|
CeilUSD: apitypes.NewBigIntStr(bucket.CeilUSD),
|
||||||
|
BlockStamp: apitypes.NewBigIntStr(bucket.BlockStamp),
|
||||||
Withdrawals: apitypes.NewBigIntStr(bucket.Withdrawals),
|
Withdrawals: apitypes.NewBigIntStr(bucket.Withdrawals),
|
||||||
BlockWithdrawalRate: apitypes.NewBigIntStr(bucket.BlockWithdrawalRate),
|
RateBlocks: apitypes.NewBigIntStr(bucket.RateBlocks),
|
||||||
|
RateWithdrawals: apitypes.NewBigIntStr(bucket.RateWithdrawals),
|
||||||
MaxWithdrawals: apitypes.NewBigIntStr(bucket.MaxWithdrawals),
|
MaxWithdrawals: apitypes.NewBigIntStr(bucket.MaxWithdrawals),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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-eth-edu` (tested with commit `e6c5b7db8da2de1b9cc55e281c8d1dfa524b06f0`)
|
`git checkout feature/newDeploymentScript-eth-mik` (tested with commit `0eccd237dda102a4ad788a6e11f98361d39d0d9c`)
|
||||||
|
|
||||||
Now, install the dependencies:
|
Now, install the dependencies:
|
||||||
|
|
||||||
|
|||||||
@@ -309,9 +309,12 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) Coordinators(opts *bi
|
|||||||
Forger common.Address
|
Forger common.Address
|
||||||
CoordinatorURL string
|
CoordinatorURL string
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
return *outstruct, err
|
||||||
|
}
|
||||||
|
|
||||||
outstruct.Forger = out[0].(common.Address)
|
outstruct.Forger = *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
|
||||||
outstruct.CoordinatorURL = out[1].(string)
|
outstruct.CoordinatorURL = *abi.ConvertType(out[1], new(string)).(*string)
|
||||||
|
|
||||||
return *outstruct, err
|
return *outstruct, err
|
||||||
|
|
||||||
@@ -884,12 +887,15 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) Slots(opts *bind.Call
|
|||||||
BidAmount *big.Int
|
BidAmount *big.Int
|
||||||
ClosedMinBid *big.Int
|
ClosedMinBid *big.Int
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
return *outstruct, err
|
||||||
|
}
|
||||||
|
|
||||||
outstruct.Bidder = out[0].(common.Address)
|
outstruct.Bidder = *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
|
||||||
outstruct.Fulfilled = out[1].(bool)
|
outstruct.Fulfilled = *abi.ConvertType(out[1], new(bool)).(*bool)
|
||||||
outstruct.ForgerCommitment = out[2].(bool)
|
outstruct.ForgerCommitment = *abi.ConvertType(out[2], new(bool)).(*bool)
|
||||||
outstruct.BidAmount = out[3].(*big.Int)
|
outstruct.BidAmount = *abi.ConvertType(out[3], new(*big.Int)).(**big.Int)
|
||||||
outstruct.ClosedMinBid = out[4].(*big.Int)
|
outstruct.ClosedMinBid = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int)
|
||||||
|
|
||||||
return *outstruct, err
|
return *outstruct, err
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum"
|
"github.com/ethereum/go-ethereum"
|
||||||
@@ -61,21 +60,12 @@ type RollupEventInitialize struct {
|
|||||||
|
|
||||||
// RollupVariables returns the RollupVariables from the initialize event
|
// RollupVariables returns the RollupVariables from the initialize event
|
||||||
func (ei *RollupEventInitialize) RollupVariables() *common.RollupVariables {
|
func (ei *RollupEventInitialize) RollupVariables() *common.RollupVariables {
|
||||||
var buckets [common.RollupConstNumBuckets]common.BucketParams
|
|
||||||
for i := range buckets {
|
|
||||||
buckets[i] = common.BucketParams{
|
|
||||||
CeilUSD: big.NewInt(0),
|
|
||||||
Withdrawals: big.NewInt(0),
|
|
||||||
BlockWithdrawalRate: big.NewInt(0),
|
|
||||||
MaxWithdrawals: big.NewInt(0),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return &common.RollupVariables{
|
return &common.RollupVariables{
|
||||||
EthBlockNum: 0,
|
EthBlockNum: 0,
|
||||||
FeeAddToken: ei.FeeAddToken,
|
FeeAddToken: ei.FeeAddToken,
|
||||||
ForgeL1L2BatchTimeout: int64(ei.ForgeL1L2BatchTimeout),
|
ForgeL1L2BatchTimeout: int64(ei.ForgeL1L2BatchTimeout),
|
||||||
WithdrawalDelay: ei.WithdrawalDelay,
|
WithdrawalDelay: ei.WithdrawalDelay,
|
||||||
Buckets: buckets,
|
Buckets: []common.BucketParams{},
|
||||||
SafeMode: false,
|
SafeMode: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,19 +137,20 @@ type RollupEventUpdateWithdrawalDelay struct {
|
|||||||
// RollupUpdateBucketsParameters are the bucket parameters used in an update
|
// RollupUpdateBucketsParameters are the bucket parameters used in an update
|
||||||
type RollupUpdateBucketsParameters struct {
|
type RollupUpdateBucketsParameters struct {
|
||||||
CeilUSD *big.Int
|
CeilUSD *big.Int
|
||||||
|
BlockStamp *big.Int
|
||||||
Withdrawals *big.Int
|
Withdrawals *big.Int
|
||||||
BlockWithdrawalRate *big.Int
|
RateBlocks *big.Int
|
||||||
|
RateWithdrawals *big.Int
|
||||||
MaxWithdrawals *big.Int
|
MaxWithdrawals *big.Int
|
||||||
}
|
}
|
||||||
|
|
||||||
type rollupEventUpdateBucketsParametersAux struct {
|
type rollupEventUpdateBucketsParametersAux struct {
|
||||||
ArrayBuckets [common.RollupConstNumBuckets][4]*big.Int
|
ArrayBuckets []*big.Int
|
||||||
}
|
}
|
||||||
|
|
||||||
// RollupEventUpdateBucketsParameters is an event of the Rollup Smart Contract
|
// RollupEventUpdateBucketsParameters is an event of the Rollup Smart Contract
|
||||||
type RollupEventUpdateBucketsParameters struct {
|
type RollupEventUpdateBucketsParameters struct {
|
||||||
// ArrayBuckets [common.RollupConstNumBuckets][4]*big.Int
|
ArrayBuckets []RollupUpdateBucketsParameters
|
||||||
ArrayBuckets [common.RollupConstNumBuckets]RollupUpdateBucketsParameters
|
|
||||||
SafeMode bool
|
SafeMode bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,8 +484,8 @@ func (c *RollupClient) RollupL1UserTxERC20ETH(fromBJJ babyjub.PublicKeyComp, fro
|
|||||||
auth.Value = depositAmount
|
auth.Value = depositAmount
|
||||||
}
|
}
|
||||||
var permit []byte
|
var permit []byte
|
||||||
return c.hermez.AddL1Transaction(auth, babyPubKey, fromIdxBig, uint16(depositAmountF),
|
return c.hermez.AddL1Transaction(auth, babyPubKey, fromIdxBig, big.NewInt(int64(depositAmountF)),
|
||||||
uint16(amountF), tokenID, toIdxBig, permit)
|
big.NewInt(int64(amountF)), tokenID, toIdxBig, permit)
|
||||||
},
|
},
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, tracerr.Wrap(fmt.Errorf("Failed add L1 Tx ERC20/ETH: %w", err))
|
return nil, tracerr.Wrap(fmt.Errorf("Failed add L1 Tx ERC20/ETH: %w", err))
|
||||||
@@ -542,7 +533,7 @@ func (c *RollupClient) RollupL1UserTxERC20Permit(fromBJJ babyjub.PublicKeyComp,
|
|||||||
signature, _ := c.client.ks.SignHash(*c.client.account, digest)
|
signature, _ := c.client.ks.SignHash(*c.client.account, digest)
|
||||||
permit := createPermit(owner, spender, amount, deadline, digest, signature)
|
permit := createPermit(owner, spender, amount, deadline, digest, signature)
|
||||||
return c.hermez.AddL1Transaction(auth, babyPubKey, fromIdxBig,
|
return c.hermez.AddL1Transaction(auth, babyPubKey, fromIdxBig,
|
||||||
uint16(depositAmountF), uint16(amountF), tokenID, toIdxBig, permit)
|
big.NewInt(int64(depositAmountF)), big.NewInt(int64(amountF)), tokenID, toIdxBig, permit)
|
||||||
},
|
},
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, tracerr.Wrap(fmt.Errorf("Failed add L1 Tx ERC20Permit: %w", err))
|
return nil, tracerr.Wrap(fmt.Errorf("Failed add L1 Tx ERC20Permit: %w", err))
|
||||||
@@ -604,18 +595,20 @@ func (c *RollupClient) RollupUpdateFeeAddToken(newFeeAddToken *big.Int) (tx *typ
|
|||||||
|
|
||||||
// RollupUpdateBucketsParameters is the interface to call the smart contract function
|
// RollupUpdateBucketsParameters is the interface to call the smart contract function
|
||||||
func (c *RollupClient) RollupUpdateBucketsParameters(
|
func (c *RollupClient) RollupUpdateBucketsParameters(
|
||||||
arrayBuckets [common.RollupConstNumBuckets]RollupUpdateBucketsParameters,
|
arrayBuckets []RollupUpdateBucketsParameters,
|
||||||
) (tx *types.Transaction, err error) {
|
) (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(
|
if tx, err = c.client.CallAuth(
|
||||||
12500000, //nolint:gomnd
|
12500000, //nolint:gomnd
|
||||||
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
|
||||||
|
params := make([]*big.Int, len(arrayBuckets))
|
||||||
|
for i, bucket := range arrayBuckets {
|
||||||
|
params[i], err = c.hermez.PackBucket(c.opts,
|
||||||
|
bucket.CeilUSD, bucket.BlockStamp, bucket.Withdrawals,
|
||||||
|
bucket.RateBlocks, bucket.RateWithdrawals, bucket.MaxWithdrawals)
|
||||||
|
if err != nil {
|
||||||
|
return nil, tracerr.Wrap(fmt.Errorf("failed to pack bucket: %w", err))
|
||||||
|
}
|
||||||
|
}
|
||||||
return c.hermez.UpdateBucketsParameters(auth, params)
|
return c.hermez.UpdateBucketsParameters(auth, params)
|
||||||
},
|
},
|
||||||
); err != nil {
|
); err != nil {
|
||||||
@@ -739,7 +732,7 @@ var (
|
|||||||
logHermezUpdateWithdrawalDelay = crypto.Keccak256Hash([]byte(
|
logHermezUpdateWithdrawalDelay = crypto.Keccak256Hash([]byte(
|
||||||
"UpdateWithdrawalDelay(uint64)"))
|
"UpdateWithdrawalDelay(uint64)"))
|
||||||
logHermezUpdateBucketsParameters = crypto.Keccak256Hash([]byte(
|
logHermezUpdateBucketsParameters = crypto.Keccak256Hash([]byte(
|
||||||
"UpdateBucketsParameters(uint256[4][" + strconv.Itoa(common.RollupConstNumBuckets) + "])"))
|
"UpdateBucketsParameters(uint256[])"))
|
||||||
logHermezUpdateTokenExchange = crypto.Keccak256Hash([]byte(
|
logHermezUpdateTokenExchange = crypto.Keccak256Hash([]byte(
|
||||||
"UpdateTokenExchange(address[],uint64[])"))
|
"UpdateTokenExchange(address[],uint64[])"))
|
||||||
logHermezSafeMode = crypto.Keccak256Hash([]byte(
|
logHermezSafeMode = crypto.Keccak256Hash([]byte(
|
||||||
@@ -906,11 +899,18 @@ func (c *RollupClient) RollupEventsByBlock(blockNum int64,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, tracerr.Wrap(err)
|
return nil, tracerr.Wrap(err)
|
||||||
}
|
}
|
||||||
|
bucketsParameters.ArrayBuckets = make([]RollupUpdateBucketsParameters, len(bucketsParametersAux.ArrayBuckets))
|
||||||
for i, bucket := range bucketsParametersAux.ArrayBuckets {
|
for i, bucket := range bucketsParametersAux.ArrayBuckets {
|
||||||
bucketsParameters.ArrayBuckets[i].CeilUSD = bucket[0]
|
bucket, err := c.hermez.UnpackBucket(c.opts, bucket)
|
||||||
bucketsParameters.ArrayBuckets[i].Withdrawals = bucket[1]
|
if err != nil {
|
||||||
bucketsParameters.ArrayBuckets[i].BlockWithdrawalRate = bucket[2]
|
return nil, tracerr.Wrap(err)
|
||||||
bucketsParameters.ArrayBuckets[i].MaxWithdrawals = bucket[3]
|
}
|
||||||
|
bucketsParameters.ArrayBuckets[i].CeilUSD = bucket.CeilUSD
|
||||||
|
bucketsParameters.ArrayBuckets[i].BlockStamp = bucket.BlockStamp
|
||||||
|
bucketsParameters.ArrayBuckets[i].Withdrawals = bucket.Withdrawals
|
||||||
|
bucketsParameters.ArrayBuckets[i].RateBlocks = bucket.RateBlocks
|
||||||
|
bucketsParameters.ArrayBuckets[i].RateWithdrawals = bucket.RateWithdrawals
|
||||||
|
bucketsParameters.ArrayBuckets[i].MaxWithdrawals = bucket.MaxWithdrawals
|
||||||
}
|
}
|
||||||
rollupEvents.UpdateBucketsParameters =
|
rollupEvents.UpdateBucketsParameters =
|
||||||
append(rollupEvents.UpdateBucketsParameters, bucketsParameters)
|
append(rollupEvents.UpdateBucketsParameters, bucketsParameters)
|
||||||
@@ -932,8 +932,10 @@ func (c *RollupClient) RollupEventsByBlock(blockNum int64,
|
|||||||
}
|
}
|
||||||
for i := range bucketsParameters.ArrayBuckets {
|
for i := range bucketsParameters.ArrayBuckets {
|
||||||
bucketsParameters.ArrayBuckets[i].CeilUSD = big.NewInt(0)
|
bucketsParameters.ArrayBuckets[i].CeilUSD = big.NewInt(0)
|
||||||
|
bucketsParameters.ArrayBuckets[i].BlockStamp = big.NewInt(0)
|
||||||
bucketsParameters.ArrayBuckets[i].Withdrawals = big.NewInt(0)
|
bucketsParameters.ArrayBuckets[i].Withdrawals = big.NewInt(0)
|
||||||
bucketsParameters.ArrayBuckets[i].BlockWithdrawalRate = big.NewInt(0)
|
bucketsParameters.ArrayBuckets[i].RateBlocks = big.NewInt(0)
|
||||||
|
bucketsParameters.ArrayBuckets[i].RateWithdrawals = big.NewInt(0)
|
||||||
bucketsParameters.ArrayBuckets[i].MaxWithdrawals = big.NewInt(0)
|
bucketsParameters.ArrayBuckets[i].MaxWithdrawals = big.NewInt(0)
|
||||||
}
|
}
|
||||||
rollupEvents.UpdateBucketsParameters = append(rollupEvents.UpdateBucketsParameters,
|
rollupEvents.UpdateBucketsParameters = append(rollupEvents.UpdateBucketsParameters,
|
||||||
|
|||||||
@@ -234,12 +234,15 @@ func TestRollupUpdateFeeAddToken(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRollupUpdateBucketsParameters(t *testing.T) {
|
func TestRollupUpdateBucketsParameters(t *testing.T) {
|
||||||
var bucketsParameters [common.RollupConstNumBuckets]RollupUpdateBucketsParameters
|
bucketsParameters := make([]RollupUpdateBucketsParameters, 5)
|
||||||
|
ceilUSD, _ := new(big.Int).SetString("10000000", 10)
|
||||||
for i := range bucketsParameters {
|
for i := range bucketsParameters {
|
||||||
bucketsParameters[i].CeilUSD = big.NewInt(int64((i + 1) * 100))
|
bucketsParameters[i].CeilUSD = big.NewInt(0).Mul(ceilUSD, big.NewInt(int64(i+1)))
|
||||||
|
bucketsParameters[i].BlockStamp = big.NewInt(int64(0))
|
||||||
bucketsParameters[i].Withdrawals = big.NewInt(int64(i + 1))
|
bucketsParameters[i].Withdrawals = big.NewInt(int64(i + 1))
|
||||||
bucketsParameters[i].BlockWithdrawalRate = big.NewInt(int64(i+1) * 100)
|
bucketsParameters[i].RateBlocks = big.NewInt(int64(i+1) * 4)
|
||||||
bucketsParameters[i].MaxWithdrawals = big.NewInt(int64(100000000000))
|
bucketsParameters[i].RateWithdrawals = big.NewInt(int64(3))
|
||||||
|
bucketsParameters[i].MaxWithdrawals = big.NewInt(int64(1215752192))
|
||||||
}
|
}
|
||||||
_, err := rollupClient.RollupUpdateBucketsParameters(bucketsParameters)
|
_, err := rollupClient.RollupUpdateBucketsParameters(bucketsParameters)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -248,7 +251,14 @@ func TestRollupUpdateBucketsParameters(t *testing.T) {
|
|||||||
blockStampBucket = currentBlockNum
|
blockStampBucket = currentBlockNum
|
||||||
rollupEvents, err := rollupClient.RollupEventsByBlock(currentBlockNum, nil)
|
rollupEvents, err := rollupClient.RollupEventsByBlock(currentBlockNum, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, bucketsParameters, rollupEvents.UpdateBucketsParameters[0].ArrayBuckets)
|
for i := range bucketsParameters {
|
||||||
|
assert.Equal(t, 0, bucketsParameters[i].CeilUSD.Cmp(rollupEvents.UpdateBucketsParameters[0].ArrayBuckets[i].CeilUSD))
|
||||||
|
assert.Equal(t, 0, bucketsParameters[i].BlockStamp.Cmp(rollupEvents.UpdateBucketsParameters[0].ArrayBuckets[i].BlockStamp))
|
||||||
|
assert.Equal(t, 0, bucketsParameters[i].Withdrawals.Cmp(rollupEvents.UpdateBucketsParameters[0].ArrayBuckets[i].Withdrawals))
|
||||||
|
assert.Equal(t, 0, bucketsParameters[i].RateBlocks.Cmp(rollupEvents.UpdateBucketsParameters[0].ArrayBuckets[i].RateBlocks))
|
||||||
|
assert.Equal(t, 0, bucketsParameters[i].RateWithdrawals.Cmp(rollupEvents.UpdateBucketsParameters[0].ArrayBuckets[i].RateWithdrawals))
|
||||||
|
assert.Equal(t, 0, bucketsParameters[i].MaxWithdrawals.Cmp(rollupEvents.UpdateBucketsParameters[0].ArrayBuckets[i].MaxWithdrawals))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRollupUpdateWithdrawalDelay(t *testing.T) {
|
func TestRollupUpdateWithdrawalDelay(t *testing.T) {
|
||||||
@@ -1016,9 +1026,9 @@ func TestRollupWithdrawMerkleProof(t *testing.T) {
|
|||||||
// Bucket 1
|
// Bucket 1
|
||||||
// Bucket[0].withdrawals = 1, Bucket[1].withdrawals = 2, ...
|
// Bucket[0].withdrawals = 1, Bucket[1].withdrawals = 2, ...
|
||||||
// Bucket[1].withdrawals - 1 = 1
|
// Bucket[1].withdrawals - 1 = 1
|
||||||
assert.Equal(t, 1, rollupEvents.UpdateBucketWithdraw[0].NumBucket)
|
assert.Equal(t, 0, rollupEvents.UpdateBucketWithdraw[0].NumBucket)
|
||||||
assert.Equal(t, blockStampBucket, rollupEvents.UpdateBucketWithdraw[0].BlockStamp)
|
assert.Equal(t, int64(442), rollupEvents.UpdateBucketWithdraw[0].BlockStamp)
|
||||||
assert.Equal(t, big.NewInt(1), rollupEvents.UpdateBucketWithdraw[0].Withdrawals)
|
assert.Equal(t, big.NewInt(15), rollupEvents.UpdateBucketWithdraw[0].Withdrawals)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRollupSafeMode(t *testing.T) {
|
func TestRollupSafeMode(t *testing.T) {
|
||||||
|
|||||||
@@ -1126,8 +1126,10 @@ func (s *Synchronizer) rollupSync(ethBlock *common.Block) (*common.RollupData, e
|
|||||||
for i, bucket := range evt.ArrayBuckets {
|
for i, bucket := range evt.ArrayBuckets {
|
||||||
s.vars.Rollup.Buckets[i] = common.BucketParams{
|
s.vars.Rollup.Buckets[i] = common.BucketParams{
|
||||||
CeilUSD: bucket.CeilUSD,
|
CeilUSD: bucket.CeilUSD,
|
||||||
|
BlockStamp: bucket.BlockStamp,
|
||||||
Withdrawals: bucket.Withdrawals,
|
Withdrawals: bucket.Withdrawals,
|
||||||
BlockWithdrawalRate: bucket.BlockWithdrawalRate,
|
RateBlocks: bucket.RateBlocks,
|
||||||
|
RateWithdrawals: bucket.RateWithdrawals,
|
||||||
MaxWithdrawals: bucket.MaxWithdrawals,
|
MaxWithdrawals: bucket.MaxWithdrawals,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -301,20 +301,11 @@ func NewClientSetupExample() *ClientSetup {
|
|||||||
HermezAuctionContract: ethCommon.HexToAddress("0x8E442975805fb1908f43050c9C1A522cB0e28D7b"),
|
HermezAuctionContract: ethCommon.HexToAddress("0x8E442975805fb1908f43050c9C1A522cB0e28D7b"),
|
||||||
WithdrawDelayerContract: ethCommon.HexToAddress("0x5CB7979cBdbf65719BEE92e4D15b7b7Ed3D79114"),
|
WithdrawDelayerContract: ethCommon.HexToAddress("0x5CB7979cBdbf65719BEE92e4D15b7b7Ed3D79114"),
|
||||||
}
|
}
|
||||||
var buckets [common.RollupConstNumBuckets]common.BucketParams
|
|
||||||
for i := range buckets {
|
|
||||||
buckets[i] = common.BucketParams{
|
|
||||||
CeilUSD: big.NewInt(0),
|
|
||||||
Withdrawals: big.NewInt(0),
|
|
||||||
BlockWithdrawalRate: big.NewInt(0),
|
|
||||||
MaxWithdrawals: big.NewInt(0),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rollupVariables := &common.RollupVariables{
|
rollupVariables := &common.RollupVariables{
|
||||||
FeeAddToken: big.NewInt(11),
|
FeeAddToken: big.NewInt(11),
|
||||||
ForgeL1L2BatchTimeout: 10,
|
ForgeL1L2BatchTimeout: 10,
|
||||||
WithdrawalDelay: 80,
|
WithdrawalDelay: 80,
|
||||||
Buckets: buckets,
|
Buckets: []common.BucketParams{},
|
||||||
}
|
}
|
||||||
auctionConstants := &common.AuctionConstants{
|
auctionConstants := &common.AuctionConstants{
|
||||||
BlocksPerSlot: 40,
|
BlocksPerSlot: 40,
|
||||||
|
|||||||
Reference in New Issue
Block a user