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

Timeout while listening for bundle results #54

Open
captainyugi00 opened this issue Jul 20, 2024 · 0 comments
Open

Timeout while listening for bundle results #54

captainyugi00 opened this issue Jul 20, 2024 · 0 comments

Comments

@captainyugi00
Copy link

First of all I am sorry if I'm reporting Go code here, but I'm building a client for it.

I am currently receiving timeouts when listening for a bundle result in Go and was wondering if there could be something wrong with these protoc versions

// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.4.0
// - protoc             v5.27.2

After creating and sending the bundle successfully, I want to listen for bundle updates but on .Recv() it times out. Anyone managed to solve this before?

func SubmitBundle() (string, error) {
	ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
	defer cancel()

	searcherClient, err := block_engine.CreateSearcherClient(
		BlockEngineFrankfurtAddress,
		nil,
	)
	if err != nil {
		return "", fmt.Errorf("could not create searcher client: %w", err)
	}

	subBundleResults, err := searcherClient.Client.SubscribeBundleResults(ctx, &searcherpb.SubscribeBundleResultsRequest{})
	if err != nil {
		return "", fmt.Errorf("could not subscribe to bundle results: %w", err)
	}

	tipAccounts, err := getTipAccounts(ctx, searcherClient)
	if err != nil {
		return "", err
	}

	// Seed the random number generator
	rand.Seed(time.Now().UnixNano())

	// Generate a random index
	randomIndex := rand.Intn(len(tipAccounts))

	// Select the string at the random index
	randomTipAccount := tipAccounts[randomIndex]
	tipAccount := solana.MustPublicKeyFromBase58(randomTipAccount)

	err = waitForScheduledLeader(ctx, searcherClient)
	if err != nil {
		return "", err
	}

	rpcClient := rpc.New(*RpcAddress)

	bundle, err := createBundle(
		ctx,
		rpcClient,
		*NumTxs,
		*TxLamports,
		*TipLamports,
		"sending hella fast transaction with jitooo",
		&SenderPrivateKey,
		&ReceiverPublicKey,
		&tipAccount,
	)
	if err != nil {
		return "", err
	}

	bundleUuid, err := searcherClient.SendBundle(
		ctx,
		bundle,
	)
	if err != nil {
		return "", fmt.Errorf("could not send bundle: %w", err)
	}

	log.Println(bundleUuid)

	for {
		time.Sleep(1 * time.Second)

		var bundleResult *bundlepb.BundleResult
		bundleResult, err = subBundleResults.Recv()
		if err != nil {
			fmt.Println("error reading bundle results:", err.Error())
			continue
		}

		switch bundleResult.Result.(type) {
		case *bundlepb.BundleResult_Accepted:
			fmt.Println("Accepted")
			break
		case *bundlepb.BundleResult_Rejected:
			rejected := bundleResult.Result.(*bundlepb.BundleResult_Rejected)
			switch rejected.Rejected.Reason.(type) {
			case *bundlepb.Rejected_SimulationFailure:
				rejection := rejected.Rejected.GetSimulationFailure()
				fmt.Println(rejection.TxSignature, rejection.GetMsg())
			case *bundlepb.Rejected_StateAuctionBidRejected:
				rejection := rejected.Rejected.GetStateAuctionBidRejected()
				fmt.Println(rejection.AuctionId, rejection.SimulatedBidLamports)
			case *bundlepb.Rejected_WinningBatchBidRejected:
				rejection := rejected.Rejected.GetWinningBatchBidRejected()
				fmt.Println(rejection.AuctionId, rejection.SimulatedBidLamports)
			case *bundlepb.Rejected_InternalError:
				rejection := rejected.Rejected.GetInternalError()
				fmt.Println(rejection.Msg)
			case *bundlepb.Rejected_DroppedBundle:
				rejection := rejected.Rejected.GetDroppedBundle()
				fmt.Println(rejection.Msg)
			default:
				fmt.Println("No case")
			}
		}
	}

	return bundleUuid, nil
}
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

1 participant