signBundle doesn't set correct chainId when passed a FlashbotsBundleTransaction
signBundle() can take a mix of FlashbotsBundleTransactions and FlashbotsBundleRawTransactions. In the case of FlashbotsBundleTransaction, the user provides an (unsigned) TransactionRequest and a Signer. signBundle() populates certain fields of the transaction in case they're missing, like: nonce, gasPrice, gasLimit; however it doesn't include chainId, which ends up being 0 even on Görli.
To be fair, the testnet example does explicitly set chainId to 5, however it could still make sense to automatically populate chainId, either using the Signer's getChainId() method or its populateTransaction(). Notably: when using a Contract's populateTransaction.XXX methods, chainId will be missing from the resulting object.
i am observing the same issue. anybody aware of any workarounds?
i am observing the same issue. anybody aware of any workarounds?
I decided to populate and sign the transaction before passing it to signBundle like this:
const transaction = await this._contract.populateTransaction.someFunc(
/* ... parameters ... */,
{
nonce: this._signer.getTransactionCount("latest") // ignore pending TXs
}
);
const populatedTransaction = await this._signer.populateTransaction(transaction);
const signedTransaction = await this._signer.signTransaction(populatedTransaction);
const signedBundle = await this._bundleProvider.signBundle([{ signedTransaction }]);
Alternatively, you could also just set chainId before passing the TransactionRequest to signBundle:
const transaction = await this._contract.populateTransaction.someFunc(/* ... parameters ... */);
transaction.chainId = await this._signer.getChainId();
const signedBundle = await this._bundleProvider.signBundle([{
transaction,
signer: this._signer
}]);