centrifuge / go-substrate-rpc-client

Substrate RPC client for go aka GSRPC
Apache License 2.0
203 stars 178 forks source link

Unable to pull block based off old MultiSignature in V3 #149

Closed zadmarbella closed 10 months ago

zadmarbella commented 3 years ago

Testing on westend Westend is using MultiAddress https://github.com/paritytech/polkadot/blob/master/runtime/westend/src/lib.rs#L815

Not seeing the issue in v2 but it's there in v3.

snippet used to test:

    api := NewSubstrateAPI()
    metadata := GetMetadataLatest(api)

    types.SetSerDeOptions(types.SerDeOptions{NoPalletIndices: true})
    fmt.Println("BXL: SetSerDeOptions: ")

    key, err := types.CreateStorageKey(metadata, "System", "Events", nil, nil)
    if err != nil {
        panic(err)
    }

    // blockNumber 3443522  westend testing 
    blockNumber := uint64(3443522)
    blockHash, err := api.RPC.Chain.GetBlockHash(blockNumber)
    // blockHash, err := api.RPC.Chain.GetBlockHashLatest()
    if err != nil {
        return err
    }

    raw, err := api.RPC.State.GetStorageRaw(key, blockHash)
    if err != nil {
        panic(err)
    }

    //fmt.Printf("%x\n", *raw)

    events := types.EventRecords{}
    err = types.EventRecordsRaw(*raw).DecodeEventRecords(metadata, &events)
    if err != nil {
        panic(err)
    }

    // fmt.Println("BXL: readBlockUsingCentrifuge: blockHash: ", blockHash.Hex())
    // Get the block
    block, err := api.RPC.Chain.GetBlock(blockHash)
    if err != nil {
        panic(err)
    }
vedhavyas commented 3 years ago

This is happening because the block requested above was added pre-multiaddress. Since v3 doesn't have backward compatibility with v2, its fails on v3 but goes through on v2

cdamian commented 10 months ago

Closing this for now, please let us know if this is still something that you need help with.