Skip to content

Possible bug/enhancement for Hyperblock mode #15

@alexberce

Description

@alexberce

Hi there,
We are using this library to process the transactions sent to some of our smart contracts.

When using the BlastApi gateway we get a lot of errors (error code 500) and from the discussion that I've had with the BwareLabs team, this usually means that we requested a block from the future (not finalized yet).

After a quick look at the library code, I noticed that it uses erd_nonce for the current nonce, and not erd_highest_final_nonce. Shouldn't erd_highest_final_nonce give us the last final block?

private async getCurrentNonce(shardId: number): Promise<number> {
    const shardInfo = await this.gatewayGet(`network/status/${shardId}`);
    return shardInfo.status.erd_nonce;
}

I'm proposing the following non-breaking changes to the library:

  1. Add a new optional property that allows us to specify which nonce to use
export enum TransactionProcessorNonceStrategy {
  CurrentNonce = 'erd_nonce',
  HighestFinalNonce = 'erd_highest_final_nonce',
}

export class TransactionProcessorOptions {
  ...
  nonceStrategy?: TransactionProcessorNonceStrategy = TransactionProcessorNonceStrategy.CurrentNonce
}
  1. Update the getCurrentNonce code to use the the new property
private async getCurrentNonce(shardId: number): Promise<number> {
    const shardInfo = await this.gatewayGet(`network/status/${shardId}`);
    return shardInfo.status[this.options.nonceStrategy];
}

I can create a PR if you are willing to include it in this library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions