centrifuge / go-substrate-rpc-client

Substrate RPC client for go aka GSRPC
Apache License 2.0
204 stars 179 forks source link

when getting events from block 2535089, retriever.GetEvents() got error #361

Open ryuuyq opened 1 year ago

ryuuyq commented 1 year ago

when getting events from block 2535089, retriever.GetEvents() got error :

event parsing: error 0: exec function error: event topics decoding: event #1: expected more bytes, but could not decode any more

    testURL := "wss://rpc.polkadot.io"
    api, err := gsrpc.NewSubstrateAPI(testURL)
    if err != nil {
        log.Printf("Couldn't connect to '%s': %s\n", testURL, err)
        return
    }
    retriever, err := retriever.NewDefaultEventRetriever(state.NewEventProvider(api.RPC.State), api.RPC.State)
    if err != nil {
        log.Printf("Couldn't create event retriever: %s", err)
        return
    }

    blockHash, err := api.RPC.Chain.GetBlockHash(uint64(2535089))
    if err != nil {
        log.Printf("Couldn't retrieve blockHash for '%s', block number %d: %s\n", testURL, header.Number, err)
        return
    }

    events, err := retriever.GetEvents(blockHash)
    if err != nil {
        log.Printf("Couldn't retrieve events for '%s', block number %d: %s\n", testURL, header.Number, err)
        return
    }

    log.Printf("Found %d events for '%s', at block number %d.\n", len(events), testURL, header.Number)
cdamian commented 11 months ago

@ryuuyq - please refer to - https://github.com/centrifuge/go-substrate-rpc-client/issues/357#issuecomment-1840748032