diff --git a/chainio/clients/avsregistry/reader.go b/chainio/clients/avsregistry/reader.go index bf90c443..3d2fc769 100644 --- a/chainio/clients/avsregistry/reader.go +++ b/chainio/clients/avsregistry/reader.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "errors" + "fmt" "math" "math/big" @@ -212,7 +213,8 @@ func (r *AvsRegistryChainReader) GetOperatorAddrsInQuorumsAtCurrentBlock( uint32(curBlock), ) if err != nil { - return nil, types.WrapError(errors.New("Failed to get operators state"), err) + return nil, types.WrapError(fmt.Errorf("Failed to get operators state at block %d, quorums %v and registryCoordinatorAddr %v", + curBlock, quorumNumbers, r.registryCoordinatorAddr), err) } var quorumOperatorAddrs [][]common.Address for _, quorum := range operatorStakes { diff --git a/chainio/clients/wallet/fireblocks_wallet.go b/chainio/clients/wallet/fireblocks_wallet.go index d2a8ca77..153ac25a 100644 --- a/chainio/clients/wallet/fireblocks_wallet.go +++ b/chainio/clients/wallet/fireblocks_wallet.go @@ -29,11 +29,12 @@ type fireblocksWallet struct { // accessed concurrently by SendTransaction and GetTransactionReceipt mu sync.Mutex - fireblocksClient fireblocks.Client - ethClient eth.Client - vaultAccountName string - logger logging.Logger - chainID *big.Int + fireblocksClient fireblocks.Client + ethClient eth.Client + vaultAccountName string + logger logging.Logger + chainID *big.Int + gasLimitMultiplier float64 // nonceToTx keeps track of the transaction ID for each nonce // this is used to retrieve the transaction hash for a given nonce @@ -53,11 +54,12 @@ func NewFireblocksWallet(fireblocksClient fireblocks.Client, ethClient eth.Clien } logger.Debug("Creating new Fireblocks wallet for chain", "chainID", chainID) return &fireblocksWallet{ - fireblocksClient: fireblocksClient, - ethClient: ethClient, - vaultAccountName: vaultAccountName, - logger: logger, - chainID: chainID, + fireblocksClient: fireblocksClient, + ethClient: ethClient, + vaultAccountName: vaultAccountName, + logger: logger, + chainID: chainID, + gasLimitMultiplier: FallbackGasLimitMultiplier, nonceToTxID: make(map[uint64]TxID), txIDToNonce: make(map[TxID]uint64), @@ -68,6 +70,11 @@ func NewFireblocksWallet(fireblocksClient fireblocks.Client, ethClient eth.Clien }, nil } +func (t *fireblocksWallet) WithGasLimitMultiplier(multiplier float64) *fireblocksWallet { + t.gasLimitMultiplier = multiplier + return t +} + func (t *fireblocksWallet) getAccount(ctx context.Context) (*fireblocks.VaultAccount, error) { if t.account == nil { accounts, err := t.fireblocksClient.ListVaultAccounts(ctx) @@ -158,7 +165,7 @@ func (t *fireblocksWallet) SendTransaction(ctx context.Context, tx *types.Transa gasLimit := "" if tx.Gas() > 0 { - gasLimit = strconv.FormatUint(tx.Gas(), 10) + gasLimit = strconv.FormatUint(uint64(float64(tx.Gas())*t.gasLimitMultiplier), 10) } // if the gas fees are specified in the transaction, use them. diff --git a/chainio/clients/wallet/privatekey_wallet.go b/chainio/clients/wallet/privatekey_wallet.go index ecc14409..32214a4a 100644 --- a/chainio/clients/wallet/privatekey_wallet.go +++ b/chainio/clients/wallet/privatekey_wallet.go @@ -17,16 +17,18 @@ import ( ) var ( - FallbackGasTipCap = big.NewInt(15_000_000_000) + FallbackGasTipCap = big.NewInt(15_000_000_000) + FallbackGasLimitMultiplier = 1.1 ) var _ Wallet = (*privateKeyWallet)(nil) type privateKeyWallet struct { - ethClient eth.Client - address common.Address - signerFn signerv2.SignerFn - logger logging.Logger + ethClient eth.Client + address common.Address + signerFn signerv2.SignerFn + logger logging.Logger + gasLimitMultiplier float64 // cache contracts map[common.Address]*bind.BoundContract @@ -34,14 +36,20 @@ type privateKeyWallet struct { func NewPrivateKeyWallet(ethClient eth.Client, signer signerv2.SignerFn, signerAddress common.Address, logger logging.Logger) (Wallet, error) { return &privateKeyWallet{ - ethClient: ethClient, - address: signerAddress, - signerFn: signer, - logger: logger, - contracts: make(map[common.Address]*bind.BoundContract, 0), + ethClient: ethClient, + address: signerAddress, + signerFn: signer, + logger: logger, + gasLimitMultiplier: FallbackGasLimitMultiplier, + contracts: make(map[common.Address]*bind.BoundContract, 0), }, nil } +func (t *privateKeyWallet) WithGasLimitMultiplier(multiplier float64) *privateKeyWallet { + t.gasLimitMultiplier = multiplier + return t +} + func (t *privateKeyWallet) SendTransaction(ctx context.Context, tx *types.Transaction) (TxID, error) { // Estimate gas and nonce // can't print tx hash in logs because the tx changes below when we complete and sign it @@ -134,7 +142,7 @@ func (t *privateKeyWallet) estimateGasAndNonce(ctx context.Context, tx *types.Tr GasFeeCap: gasFeeCap, Data: tx.Data(), Value: tx.Value(), - Gas: gasLimit, // TODO(add buffer) + Gas: uint64(float64(gasLimit) * t.gasLimitMultiplier), Nonce: tx.Nonce(), // We are not doing any nonce management for now but we probably should later for more robustness }