[price-pusher] Bugfix in handling account sequence mismatch (#1028)

account sequence mismatch error could happen in the simulation but the
try catch did not cover that part
Verified the fix by manually incrementing the sequence number twice after
each transaction so a refetch was necessary
This commit is contained in:
Mohammad Amin Khashkhashi Moghaddam 2023-08-24 11:57:30 +02:00 committed by GitHub
parent 78ca49dcc3
commit ac0519b57a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 32 deletions

2
package-lock.json generated
View File

@ -56003,7 +56003,7 @@
},
"price_pusher": {
"name": "@pythnetwork/price-pusher",
"version": "5.4.8",
"version": "5.4.9",
"license": "Apache-2.0",
"dependencies": {
"@injectivelabs/sdk-ts": "1.10.72",

View File

@ -1,6 +1,6 @@
{
"name": "@pythnetwork/price-pusher",
"version": "5.4.8",
"version": "5.4.9",
"description": "Pyth Price Pusher",
"homepage": "https://pyth.network",
"main": "lib/index.js",

View File

@ -133,37 +133,37 @@ export class InjectivePricePusher implements IPricePusher {
const txService = new TxGrpcClient(this.grpcEndpoint);
// simulation
const {
gasInfo: { gasUsed },
} = await txService.simulate(simulateTxRaw);
// simulation returns us the approximate gas used
// gas passed with the transaction should be more than that
// in order for it to be successfully executed
// this multiplier takes care of that
const gas = (gasUsed * this.chainConfig.gasMultiplier).toFixed();
const fee = {
amount: [
{
denom: "inj",
amount: (Number(gas) * this.chainConfig.gasPrice).toFixed(),
},
],
gas,
};
const { signBytes, txRaw } = createTransactionFromMsg({
sequence: this.account.baseAccount.sequence,
accountNumber: this.account.baseAccount.accountNumber,
message: msg,
chainId: this.chainConfig.chainId,
fee,
pubKey: this.wallet.toPublicKey().toBase64(),
});
const sig = await this.wallet.sign(Buffer.from(signBytes));
try {
const {
gasInfo: { gasUsed },
} = await txService.simulate(simulateTxRaw);
// simulation returns us the approximate gas used
// gas passed with the transaction should be more than that
// in order for it to be successfully executed
// this multiplier takes care of that
const gas = (gasUsed * this.chainConfig.gasMultiplier).toFixed();
const fee = {
amount: [
{
denom: "inj",
amount: (Number(gas) * this.chainConfig.gasPrice).toFixed(),
},
],
gas,
};
const { signBytes, txRaw } = createTransactionFromMsg({
sequence: this.account.baseAccount.sequence,
accountNumber: this.account.baseAccount.accountNumber,
message: msg,
chainId: this.chainConfig.chainId,
fee,
pubKey: this.wallet.toPublicKey().toBase64(),
});
const sig = await this.wallet.sign(Buffer.from(signBytes));
this.account.baseAccount.sequence++;
/** Append Signatures */