topshot-sales icon indicating copy to clipboard operation
topshot-sales copied to clipboard

rpc error: code = Internal desc = failed to execute the script on the execution node execution-

Open robksawyer opened this issue 3 years ago • 8 comments

Getting the following when running.

😷 (topshot-sales) go run main.go
current height:  12211408
moment purchased: momentid: 1833038, price: 73.000000, seller: d5942108a5060ba2
panic: error fetching sale moment from flow: client: rpc error: code = Unknown desc = 3 errors occurred:
	* rpc error: code = Internal desc = failed to execute the script on the execution node execution-4ab025ab974e7ad7f344fbd16e5fbcb17fb8769fc8849b9d241ae518787695bd@execution-003.mainnet5.nodes.onflow.org:3569=1000: rpc error: code = Internal desc = failed to execute script: failed to execute script (internal error): ledger returns unsuccessful: error getting register (account_address_state) value at 3cde740aa01c073f84583152674cdefa7535bab85800b228ce3bcb70149d4062: trie with the given rootHash [3cde740aa01c073f84583152674cdefa7535bab85800b228ce3bcb70149d4062] not found
	* rpc error: code = Internal desc = failed to execute the script on the execution node execution-0ca407c1da940952ebcc02283b60cd97c9a008e111a48ea6cf1ce8f36f1e0153@execution-004.mainnet5.nodes.onflow.org:3569=1000: rpc error: code = Internal desc = failed to execute script: failed to execute script (internal error): ledger returns unsuccessful: error getting register (account_address_state) value at 3cde740aa01c073f84583152674cdefa7535bab85800b228ce3bcb70149d4062: trie with the given rootHash [3cde740aa01c073f84583152674cdefa7535bab85800b228ce3bcb70149d4062] not found
	* rpc error: code = Internal desc = failed to execute the script on the execution node execution-160241f88cbfaa0f361cf64adb0a1c9fc19dec1daf4b96550cd67b7a9fb26cd9@execution-002.mainnet5.nodes.onflow.org:3569=1000: rpc error: code = Internal desc = failed to execute script: failed to execute script (internal error): ledger returns unsuccessful: error getting register (account_address_state) value at 3cde740aa01c073f84583152674cdefa7535bab85800b228ce3bcb70149d4062: trie with the given rootHash [3cde740aa01c073f84583152674cdefa7535bab85800b228ce3bcb70149d4062] not found



goroutine 1 [running]:
main.handleErr(...)
	/Users/robksawyer/Sites/topshot/topshot-sales/main.go:14
main.main()
	/Users/robksawyer/Sites/topshot/topshot-sales/main.go:44 +0x7db
exit status 2

robksawyer avatar Feb 24 '21 09:02 robksawyer

same error. similar comments on medium page.

nickkz avatar Feb 25 '21 04:02 nickkz

Hi @robksawyer and @nickkz Same thing here. Any updates on it? Thanks!

bigoper avatar Mar 02 '21 16:03 bigoper

@robksawyer @bigoper after some experimentation I found the solution. func GetSaleMomentFromOwnerAtBlock has an extra comma line 43. blocksize should be reduced from 500 to around 100. works; I am extracting sales and listing data to a local db now.

nickkz avatar Mar 02 '21 23:03 nickkz

Yeah the error you are experiencing is caused by volume of top shot moments sold, when this medium article was written the value of 500 was working. However since volume is much higher 50 - 100 are more reliable values. I have externalized the configuration of this in PR #4 to make this easier to adjust on the fly. Long-term the code itself should probably do some error handling / exponential back off

jamiesonio avatar Mar 02 '21 23:03 jamiesonio

@nickkz , where is the extra comma on that line? Sorry if it's something obvious as I'm not too familiar with golang.

Assuming that doesn't fix my issue, I'm having problems with iteratively fetching block data to download the entire transaction history. For example, I assume we can do something like this:

Iteration 1:

StartHeight: latestBlock.Height - 50,
EndHeight:   latestBlock.Height

Iteration 2:

StartHeight: latestBlock.Height - 100,
EndHeight:   latestBlock.Height - 50

and so on. I'm only able to get through 2-3 iterations before running into OP's errors, even when using a smaller block size. Any thoughts?

lambertchu avatar Mar 04 '21 02:03 lambertchu

@lambertchu

the errant comma has been bolded below. I also found similar issues; I took the approach of reducing the blocksize to 50, then putting the program in a repeating loop, kicking it off every 5 minutes to download latest sales to a local db. This won't catch every sale, but it is good enough for my purposes. If you want we can chat; I have sent you a linkedin invite.

res, err := flowClient.ExecuteScriptAtBlockHeight(context.Background(), blockHeight, []byte(getSaleMomentScript), []cadence.Value{ cadence.BytesToAddress(ownerAddress.Bytes()), cadence.UInt64(momentFlowID) , (<-------) })

nickkz avatar Mar 04 '21 18:03 nickkz

@lambertchu

errant comma

The errant comma is not really an issue (valid syntax wise).

res, err := flowClient.ExecuteScriptAtBlockHeight(context.Background(), blockHeight, []byte(getSaleMomentScript), []cadence.Value{
cadence.BytesToAddress(ownerAddress.Bytes()),
cadence.UInt64(momentFlowID), (<-------)
})

If removed, then you'l have to shift the round/curly brackets.

res, err := flowClient.ExecuteScriptAtBlockHeight(context.Background(), blockHeight, []byte(getSaleMomentScript), []cadence.Value{
cadence.BytesToAddress(ownerAddress.Bytes()),
cadence.UInt64(momentFlowID)})

Iterations

Reducing the step size won't help :) In general, you won't be able to go more than ~120 (block height) back in time. The data (address) is not there anymore.

hence the failure.

I hope it helps.

bigoper avatar Mar 04 '21 19:03 bigoper

Hi @bigoper, thanks a lot for the comment. That helps a lot.

Can you point me to some documentation that describes how many blocks are available back in time?

Also, does this mean that I have to fetch recent data every few minutes to eventually get historic data, or is there a more clever way to obtain historic data?

Thanks, Fabian

fhadiji avatar Mar 20 '21 14:03 fhadiji