Andy Johnson
Andy Johnson

Reputation: 309

Commitment Level

I've written a basic rpc client which polls the state of an Solana account to look for a specific condition (i.e. a unique int64 Id being written to it). When the condition arises, I call a smart contract which takes the same account as a mutable argument.

Before doing anything, the program checks for the same condition. However this check fails. I understand we're dealing with a distributed system and that state maybe inconsistent for a period of time, but I can repeatedly call for over 30 secs and it fails each time, before ultimately succeeding.

I've read about the concept of commitment levels but always assumed the account state passed into the smart contract would be the latest state of the world (i.e. processed)? What I appear to be observing is it's more like the finalised state.

Can anyone shed some light on what might be going on here?

I will try and come up with a minimal code example to demonstrate the problem but just wanted to ask the question first, to see if anyone can point me in the right direction.

Thanks

Upvotes: 0

Views: 1472

Answers (2)

Andy Johnson
Andy Johnson

Reputation: 309

In the end my specific problem came down to pre-flight checks using the 'finalized' commitment level when my logic for polling the account was using 'confirmed'. Modifying the preflightCommitment argument on sendTransaction fixed the problem for me.

Upvotes: 0

Jacob Creech
Jacob Creech

Reputation: 2107

So if you look at the docs you linked, processed has a note:

the block may still be skipped by the cluster

This is a very important note if you're only looking for account state changes and don't want some that may be false. There's a number of reasons that a slot can be skipped, or a transaction could be rejected by the cluster.

If any of the above happens, then the account state that is accepted by the cluster as a whole may not be reflected in processed, but finalized.

Upvotes: 1

Related Questions