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

[RelayMiner] Allow big transactions simulation #1027

Merged
merged 7 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows-helpers/run-e2e-test-job-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ spec:
- name: POKTROLLD_HOME
value: /root/.poktroll
- name: PATH_URL
value: http://${NAMESPACE}-path:3000/v1
value: http://${NAMESPACE}-path:3069/v1
# PATH relies on subdomains to get the requested service but our DevNet infra is not
# built to expose arbitrary subdomains and supporting it would be a significant effort.
# As a workaround, PATH_HOST_OVERRIDE is used as the host:port to connect to PATH while
# the subdomain is passed as a Host header in the request.
- name: PATH_HOST_OVERRIDE
value: ${NAMESPACE}-path:3000
value: ${NAMESPACE}-path:3069
volumeMounts:
- mountPath: /root/.poktroll/keyring-test/
name: writable-keys-volume
Expand Down
14 changes: 14 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ validators:
instrumentation:
prometheus: true
log_level: "info"
# Increase the rpc and mempool max bytes to support large transactions.
# DEV_NOTE: These values were selected arbitrarily, but chosen to be large,
# as a result of load testing and seeing large proof messages during the
# Claim & Proof lifecycle.
rpc:
# Controls how large any single RPC request accepted by the CometBFT
# server (offchain) can be.
max_body_bytes: "100000000"
red-0ne marked this conversation as resolved.
Show resolved Hide resolved
mempool:
# Control how big any single transaction accepted by the CometBFT server
# (offchain) can be.
# Since multiple messages are bundled into a single transaction,
# max_tx_bytes needs to be increased alongside max_txs_bytes as well.
max_tx_bytes: "100000000"
red-0ne marked this conversation as resolved.
Show resolved Hide resolved
client:
chain-id: poktroll

Expand Down
29 changes: 27 additions & 2 deletions pkg/client/tx/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@ import (
cosmostx "github.com/cosmos/cosmos-sdk/client/tx"
cosmoskeyring "github.com/cosmos/cosmos-sdk/crypto/keyring"
cosmostypes "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
grpc "google.golang.org/grpc"

"github.com/pokt-network/poktroll/pkg/client"
txtypes "github.com/pokt-network/poktroll/pkg/client/tx/types"
)

// maxGRPCMsgSize is the maximum message size the gRPC client can send and receive.
// The current value has been set arbitrarily to a large value after empirically
// observing multiple Proof messages bundled within a single transaction exceeding
// the default 4MB limit.
// TODO_MAINNET: Adjust the max message size to a more sensible value.
// DEV_NOTE: This value should adjusted in concert with the CometBFT's rpc
// max_body_bytes, mempool max_tx_bytes and max_txs_bytes.
const maxGRPCMsgSize = 100 * 1024 * 1024 // 100MB
red-0ne marked this conversation as resolved.
Show resolved Hide resolved

var _ client.TxContext = (*cosmosTxContext)(nil)

// cosmosTxContext is an internal implementation of the client.TxContext interface.
Expand Down Expand Up @@ -134,10 +145,24 @@ func (txCtx cosmosTxContext) GetSimulatedTxGas(
WithFromName(signingKeyName).
WithSequence(seq)

_, gas, err := cosmostx.CalculateGas(txCtx.GetClientCtx(), txf, msgs...)
txBytes, err := txf.BuildSimTx(msgs...)
if err != nil {
return 0, err
}

txSvcClient := tx.NewServiceClient(clientCtx)

simRequest := &tx.SimulateRequest{TxBytes: txBytes}
// Set the maximum message size for the gRPC client to allow large transactions
// (e.g. transactions with multiple proof messages) to be simulated.
gRPCOpts := []grpc.CallOption{
grpc.MaxCallSendMsgSize(maxGRPCMsgSize),
grpc.MaxCallRecvMsgSize(maxGRPCMsgSize),
}
simRes, err := txSvcClient.Simulate(context.Background(), simRequest, gRPCOpts...)
if err != nil {
return 0, err
}

return gas, nil
return uint64(txf.GasAdjustment() * float64(simRes.GasInfo.GasUsed)), nil
}
Loading