updated rollup buckets to the current state

This commit is contained in:
Mikelle
2021-03-19 12:36:34 +03:00
parent 4ebe285912
commit 379ca78b4e
10 changed files with 116 additions and 75 deletions

File diff suppressed because one or more lines are too long

View File

@@ -64,10 +64,12 @@ 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),
CeilUSD: big.NewInt(0),
BlockStamp: big.NewInt(0),
Withdrawals: big.NewInt(0),
RateBlocks: big.NewInt(0),
RateWithdrawals: big.NewInt(0),
MaxWithdrawals: big.NewInt(0),
}
}
return &common.RollupVariables{
@@ -146,14 +148,16 @@ type RollupEventUpdateWithdrawalDelay struct {
// RollupUpdateBucketsParameters are the bucket parameters used in an update
type RollupUpdateBucketsParameters struct {
CeilUSD *big.Int
Withdrawals *big.Int
BlockWithdrawalRate *big.Int
MaxWithdrawals *big.Int
CeilUSD *big.Int
BlockStamp *big.Int
Withdrawals *big.Int
RateBlocks *big.Int
RateWithdrawals *big.Int
MaxWithdrawals *big.Int
}
type rollupEventUpdateBucketsParametersAux struct {
ArrayBuckets [common.RollupConstNumBuckets][4]*big.Int
ArrayBuckets [common.RollupConstNumBuckets][6]*big.Int
}
// RollupEventUpdateBucketsParameters is an event of the Rollup Smart Contract
@@ -606,12 +610,14 @@ func (c *RollupClient) RollupUpdateFeeAddToken(newFeeAddToken *big.Int) (tx *typ
func (c *RollupClient) RollupUpdateBucketsParameters(
arrayBuckets [common.RollupConstNumBuckets]RollupUpdateBucketsParameters,
) (tx *types.Transaction, err error) {
params := [common.RollupConstNumBuckets][4]*big.Int{}
params := [common.RollupConstNumBuckets][6]*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
params[i][1] = bucket.BlockStamp
params[i][2] = bucket.Withdrawals
params[i][3] = bucket.RateBlocks
params[i][4] = bucket.RateWithdrawals
params[i][5] = bucket.MaxWithdrawals
}
if tx, err = c.client.CallAuth(
12500000, //nolint:gomnd
@@ -908,9 +914,11 @@ func (c *RollupClient) RollupEventsByBlock(blockNum int64,
}
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]
bucketsParameters.ArrayBuckets[i].BlockStamp = bucket[1]
bucketsParameters.ArrayBuckets[i].Withdrawals = bucket[2]
bucketsParameters.ArrayBuckets[i].RateBlocks = bucket[3]
bucketsParameters.ArrayBuckets[i].RateWithdrawals = bucket[4]
bucketsParameters.ArrayBuckets[i].MaxWithdrawals = bucket[5]
}
rollupEvents.UpdateBucketsParameters =
append(rollupEvents.UpdateBucketsParameters, bucketsParameters)
@@ -932,8 +940,10 @@ func (c *RollupClient) RollupEventsByBlock(blockNum int64,
}
for i := range bucketsParameters.ArrayBuckets {
bucketsParameters.ArrayBuckets[i].CeilUSD = big.NewInt(0)
bucketsParameters.ArrayBuckets[i].BlockStamp = 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)
}
rollupEvents.UpdateBucketsParameters = append(rollupEvents.UpdateBucketsParameters,

View File

@@ -237,8 +237,10 @@ func TestRollupUpdateBucketsParameters(t *testing.T) {
var bucketsParameters [common.RollupConstNumBuckets]RollupUpdateBucketsParameters
for i := range bucketsParameters {
bucketsParameters[i].CeilUSD = big.NewInt(int64((i + 1) * 100))
bucketsParameters[i].BlockStamp = big.NewInt(int64(0))
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].RateWithdrawals = big.NewInt(int64(3))
bucketsParameters[i].MaxWithdrawals = big.NewInt(int64(100000000000))
}
_, err := rollupClient.RollupUpdateBucketsParameters(bucketsParameters)