Closed zsystm closed 1 year ago
Analyze gas consumptions by running simulation testing
GetNetAmountStateEssentials (not msg, but heavy gas consumer) | paired chunks | unbonding chunks | rest chunks | consumed |
---|---|---|---|---|
265 | 65 | 0 | 7128932 | |
229 | 101 | 0 | 6615871 |
LiquidStake | method(or logic) | consumed | notes |
---|---|---|---|
GetNetAmountStateEssentials | 8293 | pairedchunks=0, unbondingchunks=0, restchunks=0 | |
GetPairingInsurances | 669548 | pairinginsurances=76 | |
Escrow canto and mint lscanto | 132411 |
LiquidUnstake | method(or logic) | consumed | notes |
---|---|---|---|
IterateAllChunks | 591277 | pairedchunks=100, unbondingchunks=82, restchunks=0 | |
GetNetAmountStateEssentials | 2971939 | pairedchunks=100, unbondingchunks=82, restchunks=0 | |
Queue liquid unstake including escrow lscanto | 18662 |
ClaimDiscountedReward | method(or logic) | consumed | notes |
---|---|---|---|
GetNetAmountStateEssentials | 2507286 | pairedchunks=84, unbondingchunks=82, restchunks=0 | |
Rest of logics | 37176 |
msg | consumed |
---|---|
ProvideInsurance | 37780 |
WithdrawInsurance | 3732 |
WithdrawInsuranceCommission | 22383 |
DepositInsurance | 14926 |
CancelProvideInsurance | 16500 |
LiquidStake (Total Gas Usage at SoftCap: 3,677,506
| at HardCap: 9,584,748
)
99,043
(iterate 215
insurances, 2
pairing insurances)577,585
(iterate 824
insurances, 110
pairing insurances)3,448,895
(SoftCap, u: 0.050359255514767015
)8,877,595
(HardCap, u: 0.099419919986008629
)129,568
(if liquid stake n
chunks, then should multiply n
)LiquidUnstake (Total Gas Usage at SoftCap: 4,300,690
| at HardCap: 10,971,065
)
729,389
(SoftCap, u: 0.051311339313346141
)2,036,620
(HardCap, u: 0.099896375855056327
)3,552,699
(SoftCap, u: 0.051311339313346141
)8,915,843
(HardCap, u: 0.099896375855056327
)18,602
ClaimDiscountedReward (Total Gas Usage at SoftCap: 3,486,035
| at HardCap: 8,830,348
)
3,448,895
(SoftCap, u: 0.050380883554559393
)8,793,208
(HardCap, u: 0.098482544159051878
)37,140
Msg | Total Gas Usage |
---|---|
ProvideInsurance | 37,624 |
WithdrawInsurance | 3,768 |
WithdrawInsuranceCommission | 22,431 |
DepositInsurance | 14,899 |
CancelProvideInsurance | 34,497 |
This function is most gas-guzzling function in lsm. It iterates all chunks to create NetAmountStateEssentials.
For each paired chunks, it consumes about 22,850
2,963
16,044
3,843
For each unbonding chunks, it consumes about 2,047
2047
@dongsam I analyzed gas consumption for all msgs in lsm at above comment.
As we can said earlier, I'll try optimize gas consumption for
LiquidUnstake
@dongsam Optimization - LiquidUnstake
commit: https://github.com/b-harvest/Canto/commit/28a62769d64c00f236239d1d1ae5bb147481fe00
Effects: gas consumption reduced
0.099896375855056327
) --> 7,617,535 (u: 0.100624023240769217
) @zsystm good,
GetNetAmountStateEssentials
also, let's find the final gas consumption one more time as did in this comment@dongsam Optimization - GetNetAmountStateEssentials
Effects: a huge decrease of gas consumption
0.100624023240769217
) 0.100462988764324908
)0.099419919986008629
) 0.099681660514577146
)0.098482544159051878
)0.098412449172946314
)commit: https://github.com/b-harvest/Canto/commit/6ec0f107a752a83d4183256d2bb74807c191324c
While fuzzing tests liquidstaking module, it often exceeded 20,000,000.
Need to optimize gas consumption.