[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:
parent
78ca49dcc3
commit
ac0519b57a
|
@ -56003,7 +56003,7 @@
|
||||||
},
|
},
|
||||||
"price_pusher": {
|
"price_pusher": {
|
||||||
"name": "@pythnetwork/price-pusher",
|
"name": "@pythnetwork/price-pusher",
|
||||||
"version": "5.4.8",
|
"version": "5.4.9",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@injectivelabs/sdk-ts": "1.10.72",
|
"@injectivelabs/sdk-ts": "1.10.72",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@pythnetwork/price-pusher",
|
"name": "@pythnetwork/price-pusher",
|
||||||
"version": "5.4.8",
|
"version": "5.4.9",
|
||||||
"description": "Pyth Price Pusher",
|
"description": "Pyth Price Pusher",
|
||||||
"homepage": "https://pyth.network",
|
"homepage": "https://pyth.network",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
|
|
|
@ -133,37 +133,37 @@ export class InjectivePricePusher implements IPricePusher {
|
||||||
|
|
||||||
const txService = new TxGrpcClient(this.grpcEndpoint);
|
const txService = new TxGrpcClient(this.grpcEndpoint);
|
||||||
// simulation
|
// 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 {
|
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++;
|
this.account.baseAccount.sequence++;
|
||||||
|
|
||||||
/** Append Signatures */
|
/** Append Signatures */
|
||||||
|
|
Loading…
Reference in New Issue