Skip to content

Commit

Permalink
feat: configure wait for ST result timeout (#2045)
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov authored Aug 13, 2024
1 parent c4b4e02 commit 38fa81b
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 10 deletions.
2 changes: 2 additions & 0 deletions packages/dapi/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ DRIVE_RPC_PORT=26670
NODE_ENV=production

LOG_LEVEL=trace

WAIT_FOR_ST_RESULT_TIMEOUT=80000
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function platformHandlersFactory(
blockchainListener,
dpp,
createGrpcErrorFromDriveResponse,
parseInt(process.env.WAIT_FOR_ST_RESULT_TIMEOUT, 10),
);

const wrappedWaitForStateTransitionResult = jsonToProtobufHandlerWrapper(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function waitForStateTransitionResultHandlerFactory(
blockchainListener,
dpp,
createGrpcErrorFromDriveResponse,
stateTransitionWaitTimeout = 80000,
stateTransitionWaitTimeout,
) {
/**
* @param {Object} txDeliverResult
Expand Down
2 changes: 2 additions & 0 deletions packages/dashmate/configs/defaults/getBaseConfigFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export default function getBaseConfigFactory(homeDir) {
http2: {
maxConcurrentStreams: 10,
},
waitForStResultTimeout: '125s',
host: '0.0.0.0',
port: 443,
},
Expand Down Expand Up @@ -235,6 +236,7 @@ export default function getBaseConfigFactory(homeDir) {
target: 'dapi',
},
},
waitForStResultTimeout: 120000,
},
},
drive: {
Expand Down
2 changes: 2 additions & 0 deletions packages/dashmate/configs/getConfigFileMigrationsFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,8 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs)
'1.1.0-dev.1': (configFile) => {
Object.entries(configFile.configs)
.forEach(([, options]) => {
options.platform.gateway.listeners.dapiAndDrive.waitForStResultTimeout = '125s';
options.platform.dapi.api.waitForStResultTimeout = 120000;

options.platform.drive.tenderdash.p2p.maxConnections = 64;
options.platform.drive.tenderdash.p2p.maxOutgoingConnections = 30;
Expand Down
1 change: 1 addition & 0 deletions packages/dashmate/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ services:
- NODE_ENV=${ENVIRONMENT:?err}
- DRIVE_RPC_HOST=drive_abci
- DRIVE_RPC_PORT=26670
- WAIT_FOR_ST_RESULT_TIMEOUT=${PLATFORM_DAPI_API_WAIT_FOR_ST_RESULT_TIMEOUT:?err}
command: yarn run api
stop_grace_period: 10s
expose:
Expand Down
12 changes: 10 additions & 2 deletions packages/dashmate/src/config/configJsonSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ export default {
additionalProperties: false,
required: ['maxConcurrentStreams'],
},
waitForStResultTimeout: {
$ref: '#/definitions/durationInSeconds',
},
host: {
type: 'string',
minLength: 1,
Expand All @@ -528,7 +531,7 @@ export default {
$ref: '#/definitions/port',
},
},
required: ['http2', 'host', 'port'],
required: ['http2', 'host', 'port', 'waitForStResultTimeout'],
additionalProperties: false,
},
},
Expand Down Expand Up @@ -777,8 +780,13 @@ export default {
required: ['image', 'build', 'deploy'],
additionalProperties: false,
},
waitForStResultTimeout: {
type: 'integer',
minimum: 1,
description: 'How many millis to wait for state transition result before timeout',
},
},
required: ['docker'],
required: ['docker', 'waitForStResultTimeout'],
additionalProperties: false,
},
},
Expand Down
8 changes: 4 additions & 4 deletions packages/dashmate/templates/platform/gateway/envoy.yaml.dot
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@
path: "/org.dash.platform.dapi.v0.Platform/waitForStateTransitionResult"
route:
cluster: dapi_api
idle_timeout: 85s
idle_timeout: {{= it.platform.gateway.listeners.dapiAndDrive.waitForStResultTimeout }}
# Upstream response timeout
timeout: 85s
timeout: {{= it.platform.gateway.listeners.dapiAndDrive.waitForStResultTimeout }}
max_stream_duration:
# Entire stream/request timeout
max_stream_duration: 85s
grpc_timeout_header_max: 85s
max_stream_duration: {{= it.platform.gateway.listeners.dapiAndDrive.waitForStResultTimeout }}
grpc_timeout_header_max: {{= it.platform.gateway.listeners.dapiAndDrive.waitForStResultTimeout }}
# DAPI getConsensusParams endpoint
- match:
path: "/org.dash.platform.dapi.v0.Platform/getConsensusParams"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function waitForStateTransitionResultFactory(grpcTransport) {
// eslint-disable-next-line no-param-reassign
options = {
// Set default timeout
timeout: 80000,
timeout: 120000,
prove: false,
retry: 0,
throwDeadlineExceeded: true,
Expand Down
3 changes: 1 addition & 2 deletions packages/rs-dapi-client/src/transport/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ impl_transport_request_grpc!(
platform_proto::WaitForStateTransitionResultResponse,
PlatformGrpcClient,
RequestSettings {
timeout: Some(Duration::from_secs(80)),
retries: Some(0),
timeout: Some(Duration::from_secs(120)),
..RequestSettings::default()
},
wait_for_state_transition_result
Expand Down

0 comments on commit 38fa81b

Please sign in to comment.