Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TaggedTransactionQueue_validate_transaction #410

Open
maratkanov-a opened this issue Dec 18, 2024 · 1 comment
Open

TaggedTransactionQueue_validate_transaction #410

maratkanov-a opened this issue Dec 18, 2024 · 1 comment

Comments

@maratkanov-a
Copy link

hi trying to work with rpc client and got this error

Verification Error: Runtime error: Execution failed: Other("Wasm execution trapped: wasm trap: unreachable\nwasm backtrace:\n    0: 0x2238 - <unknown>!rust_begin_unwind\n    1: 0x1f85 - <unknown>!core::panicking::panic_fmt::h125c8438143be5c3\n    2: 0x12b5af - <unknown>!TaggedTransactionQueue_validate_transaction\nnote: run with `WASMTIME_BACKTRACE_DETAILS=1` environment variable to display more information\n")

trying to communicate with wss://rpc.crust.network

tried 4.2.1 and latest commit

      package main

import (
	"fmt"
	gsclient "github.com/centrifuge/go-substrate-rpc-client/v4"
	"github.com/centrifuge/go-substrate-rpc-client/v4/signature"
	"github.com/centrifuge/go-substrate-rpc-client/v4/types"
	"github.com/centrifuge/go-substrate-rpc-client/v4/types/codec"
	"github.com/centrifuge/go-substrate-rpc-client/v4/types/extrinsic"
	"log"
)

func main() {
	api, err := gsclient.NewSubstrateAPI("wss://rpc.crust.network")
	if err != nil {
		log.Fatalf("failed to create substrate client: %s", err)
	}

	// Waiting for API to be ready
	meta, err := api.RPC.State.GetMetadataLatest()
	if err != nil {
		log.Fatalf("failed to retrieve metadata: %s", err)
	}

	// Restoring account from seed phrase
	keyringPair, err := signature.KeyringPairFromSecret("", 0)
	if err != nil {
		log.Fatalf("failed to create keyring_pair from secret: %s", err)
	}

	// Getting the state key for AccountInfo
	accountKey, err := types.CreateStorageKey(meta, "System", "Account", keyringPair.PublicKey)
	if err != nil {
		log.Fatalf("failed to create account key: %s", err)
	}

	// Retrieving account state information (AccountInfo)
	var accountInfo struct {
		Nonce types.U32
	}
	ok, err := api.RPC.State.GetStorageLatest(accountKey, &accountInfo)
	if err != nil {
		log.Fatalf("failed to decode account info: %s", err)
	}
	if !ok {
		log.Fatalf("failed to get account info")
	}

	rv, err := api.RPC.State.GetRuntimeVersionLatest()
	if err != nil {
		log.Fatalf("failed to get runtime version: %s", err)
	}

	genesisHash, err := api.RPC.Chain.GetBlockHash(0)
	if err != nil {
		log.Fatalf("failed to get genesis hash: %s", err)
	}

	// Transaction parameters
	fileCid := types.NewBytes([]byte("QmY4qAeFhAtytvjEi8wdb5fccxWHpmGDyy23A2LtyKHxez"))
	size := types.NewU64(91)
	tips := types.NewUCompactFromUInt(0)
	memo := types.NewBytes([]byte("")) // Memo for the order, empty byte array

	// Creating the transaction
	call, err := types.NewCall(meta, "Market.place_storage_order", fileCid, size, tips, memo)
	if err != nil {
		log.Fatalf("failed to create place_storage_order call: %s", err)
	}

	ext := extrinsic.NewExtrinsic(call)
	if err := ext.Sign(
		keyringPair,
		meta,
		extrinsic.WithEra(types.ExtrinsicEra{IsImmortalEra: true}, genesisHash),
		extrinsic.WithNonce(types.NewUCompactFromUInt(uint64(accountInfo.Nonce))),
		extrinsic.WithTip(types.NewUCompactFromUInt(0)),
		extrinsic.WithSpecVersion(rv.SpecVersion),
		extrinsic.WithTransactionVersion(rv.TransactionVersion),
		extrinsic.WithGenesisHash(genesisHash),
	); err != nil {
		log.Fatalf("failed to sign extrinsic: %s", err)
	}

	// Debug output for extrinsic
	h, _ := codec.EncodeToHex(ext)
	fmt.Println("Extrinsic Hex:", h)

	// Sending the transaction
	hash, err := api.RPC.Author.SubmitExtrinsic(ext)
	if err != nil {
		log.Fatalf("failed to submit extrinsic: %s", err)
	}

	fmt.Println("Extrinsic Hash:", hash.Hex())
}

also checked generated transaction at crust page - got response:

createType(Extrinsic):: createType(ExtrinsicV4):: createType(ExtrinsicSignatureV4):: Unable to create Enum via index 25, in Ed25519, Sr25519, Ecdsa
@AstaFrode
Copy link

@maratkanov-a Check whether the parameter type after NewCall matches the interface on the chain

call, err := types.NewCall(meta, "Market.place_storage_order", fileCid, size, tips, memo)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants