From bfcd53f2e2fd3d5b184b579e7bcaeacdd2ab73e1 Mon Sep 17 00:00:00 2001 From: Ravi Patel <82118011+rpatel-figure@users.noreply.github.com> Date: Thu, 12 Feb 2026 11:38:38 -0600 Subject: [PATCH 1/2] fix: Override gas estimate to double the limit --- .../com/figure/p8e/plugin/Bootstrapper.kt | 3 +-- .../com/figure/p8e/plugin/ProvenanceClient.kt | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/figure/p8e/plugin/Bootstrapper.kt b/src/main/kotlin/com/figure/p8e/plugin/Bootstrapper.kt index b1de11e..92ef94d 100644 --- a/src/main/kotlin/com/figure/p8e/plugin/Bootstrapper.kt +++ b/src/main/kotlin/com/figure/p8e/plugin/Bootstrapper.kt @@ -2,7 +2,6 @@ package com.figure.p8e.plugin import com.google.protobuf.ByteString import com.google.protobuf.Message -import io.grpc.ManagedChannelBuilder import io.provenance.client.grpc.BaseReqSigner import io.provenance.client.grpc.ChannelOpts import io.provenance.client.grpc.createChannel @@ -127,7 +126,7 @@ internal class Bootstrapper( var errored = false - extension.locations.forEach { name, location -> + extension.locations.forEach { (name, location) -> project.logger.info("Publishing contracts - location: $name object-store url: ${location.osUrl} provenance url: ${location.provenanceUrl}") val config = ClientConfig( diff --git a/src/main/kotlin/com/figure/p8e/plugin/ProvenanceClient.kt b/src/main/kotlin/com/figure/p8e/plugin/ProvenanceClient.kt index 7dc197a..e90d809 100644 --- a/src/main/kotlin/com/figure/p8e/plugin/ProvenanceClient.kt +++ b/src/main/kotlin/com/figure/p8e/plugin/ProvenanceClient.kt @@ -3,15 +3,18 @@ package com.figure.p8e.plugin import com.google.protobuf.Any import com.google.protobuf.Message import cosmos.tx.v1beta1.ServiceOuterClass.BroadcastMode +import cosmos.tx.v1beta1.TxOuterClass import cosmos.tx.v1beta1.TxOuterClass.TxBody import io.grpc.ManagedChannel +import io.provenance.client.common.gas.GasEstimate import io.provenance.client.grpc.BaseReqSigner -import io.provenance.client.grpc.GasEstimationMethod +import io.provenance.client.grpc.GasEstimator import io.provenance.client.grpc.PbClient import io.provenance.metadata.v1.ContractSpecificationRequest import io.provenance.metadata.v1.ContractSpecificationResponse import io.provenance.metadata.v1.ScopeSpecificationRequest import io.provenance.metadata.v1.ScopeSpecificationResponse +import io.provenance.msgfees.v1.CalculateTxFeesRequest import org.slf4j.Logger import java.net.URI import java.util.concurrent.TimeUnit @@ -21,11 +24,22 @@ fun Collection.toTxBody(): TxBody = TxBody.newBuilder() .build() fun Message.toAny(typeUrlPrefix: String = "") = Any.pack(this, typeUrlPrefix) +val doubledTransactionGasEstimator: GasEstimator = + { tx: TxOuterClass.Tx, adjustment: Double -> + val estimate = msgFeeClient.calculateTxFees( + CalculateTxFeesRequest.newBuilder() + .setTxBytes(tx.toByteString()) + .setGasAdjustment(adjustment.toFloat()) + .build() + ) + GasEstimate(2 * estimate.estimatedGas, estimate.totalFeesList, estimate.additionalFeesList) + } + class ProvenanceClient(channel: ManagedChannel, val logger: Logger, val location: P8eLocationExtension) { private val inner = PbClient( location.chainId!!, URI(location.provenanceUrl!!), - GasEstimationMethod.MSG_FEE_CALCULATION, + doubledTransactionGasEstimator, channel = channel ) private val queryTimeoutSeconds = location.provenanceQueryTimeoutSeconds.toLong() From 2427cc914bc061e0aa71a484ddd03ece1dc70ef1 Mon Sep 17 00:00:00 2001 From: Ravi Patel <82118011+rpatel-figure@users.noreply.github.com> Date: Thu, 12 Feb 2026 14:50:52 -0600 Subject: [PATCH 2/2] Try allowing hardcoded gas limit --- README.md | 1 + src/main/kotlin/com/figure/p8e/plugin/Dsl.kt | 1 + .../com/figure/p8e/plugin/ProvenanceClient.kt | 14 +++++++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a30c197..8b251db 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,7 @@ p8e { chainId = "pio-mainnet-1" mainNet = true txFeeAdjustment = "2.0" + fixedGasLimit = 60_000_000 txBatchSize = "5" provenanceQueryTimeoutSeconds = "20" osHeaders = mapOf( diff --git a/src/main/kotlin/com/figure/p8e/plugin/Dsl.kt b/src/main/kotlin/com/figure/p8e/plugin/Dsl.kt index a0ecb1f..b2af5b7 100644 --- a/src/main/kotlin/com/figure/p8e/plugin/Dsl.kt +++ b/src/main/kotlin/com/figure/p8e/plugin/Dsl.kt @@ -17,6 +17,7 @@ open class P8eLocationExtension { var mainNet: Boolean = chainId == "pio-mainnet-1" var txBatchSize: String = "10" var txFeeAdjustment: String = "1.25" + var fixedGasLimit: Long = 0 var osHeaders: Map = emptyMap() } diff --git a/src/main/kotlin/com/figure/p8e/plugin/ProvenanceClient.kt b/src/main/kotlin/com/figure/p8e/plugin/ProvenanceClient.kt index e90d809..2bd2af1 100644 --- a/src/main/kotlin/com/figure/p8e/plugin/ProvenanceClient.kt +++ b/src/main/kotlin/com/figure/p8e/plugin/ProvenanceClient.kt @@ -24,7 +24,7 @@ fun Collection.toTxBody(): TxBody = TxBody.newBuilder() .build() fun Message.toAny(typeUrlPrefix: String = "") = Any.pack(this, typeUrlPrefix) -val doubledTransactionGasEstimator: GasEstimator = +fun fixedLimitTransactionGasEstimator(location: P8eLocationExtension): GasEstimator = { tx: TxOuterClass.Tx, adjustment: Double -> val estimate = msgFeeClient.calculateTxFees( CalculateTxFeesRequest.newBuilder() @@ -32,14 +32,22 @@ val doubledTransactionGasEstimator: GasEstimator = .setGasAdjustment(adjustment.toFloat()) .build() ) - GasEstimate(2 * estimate.estimatedGas, estimate.totalFeesList, estimate.additionalFeesList) + GasEstimate( + limit = if (location.fixedGasLimit > 0) { + location.fixedGasLimit + } else { + estimate.estimatedGas + }, + feesCalculated = estimate.totalFeesList, + msgFees = estimate.additionalFeesList + ) } class ProvenanceClient(channel: ManagedChannel, val logger: Logger, val location: P8eLocationExtension) { private val inner = PbClient( location.chainId!!, URI(location.provenanceUrl!!), - doubledTransactionGasEstimator, + fixedLimitTransactionGasEstimator(location), channel = channel ) private val queryTimeoutSeconds = location.provenanceQueryTimeoutSeconds.toLong()