For ink contracts with weight v2 it requires refTime and proofSize. For this we are first querying(dry run) the transaction method, getting gasRequired from query result and sending it to transaction. For weights v2 query also required gas values which we are getting from api.consts.system.blockWeights['perClass'].operational.maxExtrinsic
This process is failing sometimes with outofgas exception. api.consts.system.blockWeights
return plethora of results and it is not clear which value to use.
{
baseBlock: {
refTime: 358,523,000
proofSize: 0
}
maxBlock: {
refTime: 500,000,000,000
proofSize: 5,242,880
}
perClass: {
normal: {
baseExtrinsic: {
refTime: 98,974,000
proofSize: 0
}
maxExtrinsic: {
refTime: 324,901,026,000
proofSize: 3,407,872
}
maxTotal: {
refTime: 375,000,000,000
proofSize: 3,932,160
}
reserved: {
refTime: 0
proofSize: 0
}
}
operational: {
baseExtrinsic: {
refTime: 98,974,000
proofSize: 0
}
maxExtrinsic: {
refTime: 449,901,026,000
proofSize: 4,718,592
}
maxTotal: {
refTime: 500,000,000,000
proofSize: 5,242,880
}
reserved: {
refTime: 125,000,000,000
proofSize: 1,310,720
}
}
mandatory: {
baseExtrinsic: {
refTime: 98,974,000
proofSize: 0
}
maxExtrinsic: null
maxTotal: null
reserved: null
}
}
}
For us what worked is doubling the gasRequired coming from dry run but this is not a efficient solution.
Is there an official documentation for estimating gas for Weights v2.