Skip to content

Commit 1efbf60

Browse files
committed
Next block delay
1 parent 35ecc0a commit 1efbf60

File tree

21 files changed

+1009
-29
lines changed

21 files changed

+1009
-29
lines changed

indexer/packages/v4-protos/src/codegen/dydxprotocol/blocktime/params.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@ export interface DowntimeParamsSDKType {
1919
*/
2020
durations: DurationSDKType[];
2121
}
22+
/** SynchronyParams defines the parameters for block synchrony. */
23+
24+
export interface SynchronyParams {
25+
/**
26+
* next_block_delay replaces the locally configured timeout_commit in
27+
* CometBFT. It determines the amount of time the CometBFT waits after the If
28+
* the application sends next_block_delay = 0 to the consensus engine, the
29+
* latter defaults back to using timeout_commit.
30+
*/
31+
nextBlockDelay?: Duration;
32+
}
33+
/** SynchronyParams defines the parameters for block synchrony. */
34+
35+
export interface SynchronyParamsSDKType {
36+
/**
37+
* next_block_delay replaces the locally configured timeout_commit in
38+
* CometBFT. It determines the amount of time the CometBFT waits after the If
39+
* the application sends next_block_delay = 0 to the consensus engine, the
40+
* latter defaults back to using timeout_commit.
41+
*/
42+
next_block_delay?: DurationSDKType;
43+
}
2244

2345
function createBaseDowntimeParams(): DowntimeParams {
2446
return {
@@ -63,4 +85,49 @@ export const DowntimeParams = {
6385
return message;
6486
}
6587

88+
};
89+
90+
function createBaseSynchronyParams(): SynchronyParams {
91+
return {
92+
nextBlockDelay: undefined
93+
};
94+
}
95+
96+
export const SynchronyParams = {
97+
encode(message: SynchronyParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
98+
if (message.nextBlockDelay !== undefined) {
99+
Duration.encode(message.nextBlockDelay, writer.uint32(10).fork()).ldelim();
100+
}
101+
102+
return writer;
103+
},
104+
105+
decode(input: _m0.Reader | Uint8Array, length?: number): SynchronyParams {
106+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
107+
let end = length === undefined ? reader.len : reader.pos + length;
108+
const message = createBaseSynchronyParams();
109+
110+
while (reader.pos < end) {
111+
const tag = reader.uint32();
112+
113+
switch (tag >>> 3) {
114+
case 1:
115+
message.nextBlockDelay = Duration.decode(reader, reader.uint32());
116+
break;
117+
118+
default:
119+
reader.skipType(tag & 7);
120+
break;
121+
}
122+
}
123+
124+
return message;
125+
},
126+
127+
fromPartial(object: DeepPartial<SynchronyParams>): SynchronyParams {
128+
const message = createBaseSynchronyParams();
129+
message.nextBlockDelay = object.nextBlockDelay !== undefined && object.nextBlockDelay !== null ? Duration.fromPartial(object.nextBlockDelay) : undefined;
130+
return message;
131+
}
132+
66133
};
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import { Rpc } from "../../helpers";
22
import * as _m0 from "protobufjs/minimal";
3-
import { MsgUpdateDowntimeParams, MsgUpdateDowntimeParamsResponse } from "./tx";
3+
import { MsgUpdateDowntimeParams, MsgUpdateDowntimeParamsResponse, MsgUpdateSynchronyParams, MsgUpdateSynchronyParamsResponse } from "./tx";
44
/** Msg defines the Msg service. */
55

66
export interface Msg {
77
/** UpdateDowntimeParams updates the DowntimeParams in state. */
88
updateDowntimeParams(request: MsgUpdateDowntimeParams): Promise<MsgUpdateDowntimeParamsResponse>;
9+
/** UpdateSynchronyParams updates the SynchronyParams in state. */
10+
11+
updateSynchronyParams(request: MsgUpdateSynchronyParams): Promise<MsgUpdateSynchronyParamsResponse>;
912
}
1013
export class MsgClientImpl implements Msg {
1114
private readonly rpc: Rpc;
1215

1316
constructor(rpc: Rpc) {
1417
this.rpc = rpc;
1518
this.updateDowntimeParams = this.updateDowntimeParams.bind(this);
19+
this.updateSynchronyParams = this.updateSynchronyParams.bind(this);
1620
}
1721

1822
updateDowntimeParams(request: MsgUpdateDowntimeParams): Promise<MsgUpdateDowntimeParamsResponse> {
@@ -21,4 +25,10 @@ export class MsgClientImpl implements Msg {
2125
return promise.then(data => MsgUpdateDowntimeParamsResponse.decode(new _m0.Reader(data)));
2226
}
2327

28+
updateSynchronyParams(request: MsgUpdateSynchronyParams): Promise<MsgUpdateSynchronyParamsResponse> {
29+
const data = MsgUpdateSynchronyParams.encode(request).finish();
30+
const promise = this.rpc.request("dydxprotocol.blocktime.Msg", "UpdateSynchronyParams", data);
31+
return promise.then(data => MsgUpdateSynchronyParamsResponse.decode(new _m0.Reader(data)));
32+
}
33+
2434
}

indexer/packages/v4-protos/src/codegen/dydxprotocol/blocktime/tx.ts

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DowntimeParams, DowntimeParamsSDKType } from "./params";
1+
import { DowntimeParams, DowntimeParamsSDKType, SynchronyParams, SynchronyParamsSDKType } from "./params";
22
import * as _m0 from "protobufjs/minimal";
33
import { DeepPartial } from "../../helpers";
44
/** MsgUpdateDowntimeParams is the Msg/UpdateDowntimeParams request type. */
@@ -29,6 +29,34 @@ export interface MsgUpdateDowntimeParamsResponse {}
2929
*/
3030

3131
export interface MsgUpdateDowntimeParamsResponseSDKType {}
32+
/** MsgUpdateSynchronyParams is the Msg/UpdateSynchronyParams request type. */
33+
34+
export interface MsgUpdateSynchronyParams {
35+
authority: string;
36+
/** Defines the parameters to update. All parameters must be supplied. */
37+
38+
params?: SynchronyParams;
39+
}
40+
/** MsgUpdateSynchronyParams is the Msg/UpdateSynchronyParams request type. */
41+
42+
export interface MsgUpdateSynchronyParamsSDKType {
43+
authority: string;
44+
/** Defines the parameters to update. All parameters must be supplied. */
45+
46+
params?: SynchronyParamsSDKType;
47+
}
48+
/**
49+
* MsgUpdateSynchronyParamsResponse is the Msg/UpdateSynchronyParams response
50+
* type.
51+
*/
52+
53+
export interface MsgUpdateSynchronyParamsResponse {}
54+
/**
55+
* MsgUpdateSynchronyParamsResponse is the Msg/UpdateSynchronyParams response
56+
* type.
57+
*/
58+
59+
export interface MsgUpdateSynchronyParamsResponseSDKType {}
3260

3361
function createBaseMsgUpdateDowntimeParams(): MsgUpdateDowntimeParams {
3462
return {
@@ -117,4 +145,93 @@ export const MsgUpdateDowntimeParamsResponse = {
117145
return message;
118146
}
119147

148+
};
149+
150+
function createBaseMsgUpdateSynchronyParams(): MsgUpdateSynchronyParams {
151+
return {
152+
authority: "",
153+
params: undefined
154+
};
155+
}
156+
157+
export const MsgUpdateSynchronyParams = {
158+
encode(message: MsgUpdateSynchronyParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
159+
if (message.authority !== "") {
160+
writer.uint32(10).string(message.authority);
161+
}
162+
163+
if (message.params !== undefined) {
164+
SynchronyParams.encode(message.params, writer.uint32(18).fork()).ldelim();
165+
}
166+
167+
return writer;
168+
},
169+
170+
decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateSynchronyParams {
171+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
172+
let end = length === undefined ? reader.len : reader.pos + length;
173+
const message = createBaseMsgUpdateSynchronyParams();
174+
175+
while (reader.pos < end) {
176+
const tag = reader.uint32();
177+
178+
switch (tag >>> 3) {
179+
case 1:
180+
message.authority = reader.string();
181+
break;
182+
183+
case 2:
184+
message.params = SynchronyParams.decode(reader, reader.uint32());
185+
break;
186+
187+
default:
188+
reader.skipType(tag & 7);
189+
break;
190+
}
191+
}
192+
193+
return message;
194+
},
195+
196+
fromPartial(object: DeepPartial<MsgUpdateSynchronyParams>): MsgUpdateSynchronyParams {
197+
const message = createBaseMsgUpdateSynchronyParams();
198+
message.authority = object.authority ?? "";
199+
message.params = object.params !== undefined && object.params !== null ? SynchronyParams.fromPartial(object.params) : undefined;
200+
return message;
201+
}
202+
203+
};
204+
205+
function createBaseMsgUpdateSynchronyParamsResponse(): MsgUpdateSynchronyParamsResponse {
206+
return {};
207+
}
208+
209+
export const MsgUpdateSynchronyParamsResponse = {
210+
encode(_: MsgUpdateSynchronyParamsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
211+
return writer;
212+
},
213+
214+
decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateSynchronyParamsResponse {
215+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
216+
let end = length === undefined ? reader.len : reader.pos + length;
217+
const message = createBaseMsgUpdateSynchronyParamsResponse();
218+
219+
while (reader.pos < end) {
220+
const tag = reader.uint32();
221+
222+
switch (tag >>> 3) {
223+
default:
224+
reader.skipType(tag & 7);
225+
break;
226+
}
227+
}
228+
229+
return message;
230+
},
231+
232+
fromPartial(_: DeepPartial<MsgUpdateSynchronyParamsResponse>): MsgUpdateSynchronyParamsResponse {
233+
const message = createBaseMsgUpdateSynchronyParamsResponse();
234+
return message;
235+
}
236+
120237
};

proto/dydxprotocol/blocktime/params.proto

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@ message DowntimeParams {
1313
repeated google.protobuf.Duration durations = 1
1414
[ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ];
1515
}
16+
17+
// SynchronyParams defines the parameters for block synchrony.
18+
message SynchronyParams {
19+
// next_block_delay replaces the locally configured timeout_commit in
20+
// CometBFT. It determines the amount of time the CometBFT waits after the
21+
// `CommitTime` (subjective time when +2/3 precommits were received), before
22+
// moving to next height.
23+
// If the application sends next_block_delay = 0 to the consensus engine, the
24+
// latter defaults back to using timeout_commit.
25+
google.protobuf.Duration next_block_delay = 1
26+
[ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ];
27+
}

proto/dydxprotocol/blocktime/tx.proto

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ service Msg {
1313
// UpdateDowntimeParams updates the DowntimeParams in state.
1414
rpc UpdateDowntimeParams(MsgUpdateDowntimeParams)
1515
returns (MsgUpdateDowntimeParamsResponse);
16+
// UpdateSynchronyParams updates the SynchronyParams in state.
17+
rpc UpdateSynchronyParams(MsgUpdateSynchronyParams)
18+
returns (MsgUpdateSynchronyParamsResponse);
1619
}
1720

1821
// MsgUpdateDowntimeParams is the Msg/UpdateDowntimeParams request type.
@@ -28,3 +31,17 @@ message MsgUpdateDowntimeParams {
2831
// MsgUpdateDowntimeParamsResponse is the Msg/UpdateDowntimeParams response
2932
// type.
3033
message MsgUpdateDowntimeParamsResponse {}
34+
35+
// MsgUpdateSynchronyParams is the Msg/UpdateSynchronyParams request type.
36+
message MsgUpdateSynchronyParams {
37+
// The address that controls the module.
38+
option (cosmos.msg.v1.signer) = "authority";
39+
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
40+
41+
// Defines the parameters to update. All parameters must be supplied.
42+
SynchronyParams params = 2 [ (gogoproto.nullable) = false ];
43+
}
44+
45+
// MsgUpdateSynchronyParamsResponse is the Msg/UpdateSynchronyParams response
46+
// type.
47+
message MsgUpdateSynchronyParamsResponse {}

protocol/app/app.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,8 @@ func New(
15711571
app.SetPrepareProposal(prepareProposalHandler)
15721572
app.SetProcessProposal(processProposalHandler)
15731573

1574+
app.SetBlockDelayGetter(app.BlockTimeKeeper.GetBlockDelay)
1575+
15741576
// Note that panics from out of gas errors won't get logged, since the `OutOfGasMiddleware` is added in front of this,
15751577
// so error will get handled by that middleware and subsequent middlewares won't get executed.
15761578
// Also note that `AddRunTxRecoveryHandler` adds the handler in reverse order, meaning that handlers that appear

protocol/app/msgs/all_msgs.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ var (
180180
"/dydxprotocol.accountplus.TxExtension": {},
181181

182182
// blocktime
183-
"/dydxprotocol.blocktime.MsgUpdateDowntimeParams": {},
184-
"/dydxprotocol.blocktime.MsgUpdateDowntimeParamsResponse": {},
183+
"/dydxprotocol.blocktime.MsgUpdateDowntimeParams": {},
184+
"/dydxprotocol.blocktime.MsgUpdateDowntimeParamsResponse": {},
185+
"/dydxprotocol.blocktime.MsgUpdateSynchronyParams": {},
186+
"/dydxprotocol.blocktime.MsgUpdateSynchronyParamsResponse": {},
185187

186188
// bridge
187189
"/dydxprotocol.bridge.MsgAcknowledgeBridges": {},

protocol/app/msgs/internal_msgs.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,10 @@ var (
118118
"/dydxprotocol.accountplus.MsgSetActiveStateResponse": nil,
119119

120120
// blocktime
121-
"/dydxprotocol.blocktime.MsgUpdateDowntimeParams": &blocktime.MsgUpdateDowntimeParams{},
122-
"/dydxprotocol.blocktime.MsgUpdateDowntimeParamsResponse": nil,
121+
"/dydxprotocol.blocktime.MsgUpdateDowntimeParams": &blocktime.MsgUpdateDowntimeParams{},
122+
"/dydxprotocol.blocktime.MsgUpdateDowntimeParamsResponse": nil,
123+
"/dydxprotocol.blocktime.MsgUpdateSynchronyParams": &blocktime.MsgUpdateSynchronyParams{},
124+
"/dydxprotocol.blocktime.MsgUpdateSynchronyParamsResponse": nil,
123125

124126
// bridge
125127
"/dydxprotocol.bridge.MsgCompleteBridge": &bridge.MsgCompleteBridge{},

protocol/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,9 @@ replace (
470470
// Use dYdX fork of Cosmos SDK/store
471471
cosmossdk.io/store => github.com/dydxprotocol/cosmos-sdk/store v1.0.3-0.20240326192503-dd116391188d
472472
// Use dYdX fork of CometBFT
473-
github.com/cometbft/cometbft => github.com/dydxprotocol/cometbft v0.38.6-0.20241120221529-56316dc17261
473+
github.com/cometbft/cometbft => github.com/dydxprotocol/cometbft v0.38.6-0.20241126215519-69cdde955fd0
474474
// Use dYdX fork of Cosmos SDK
475-
github.com/cosmos/cosmos-sdk => github.com/dydxprotocol/cosmos-sdk v0.50.6-0.20241120185835-38650041ec4d
475+
github.com/cosmos/cosmos-sdk => github.com/dydxprotocol/cosmos-sdk v0.50.6-0.20241127172510-4ee58434cdea
476476
github.com/cosmos/iavl => github.com/dydxprotocol/iavl v1.1.1-0.20240509161911-1c8b8e787e85
477477
)
478478

protocol/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -958,10 +958,10 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
958958
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
959959
github.com/dvsekhvalnov/jose2go v1.6.0 h1:Y9gnSnP4qEI0+/uQkHvFXeD2PLPJeXEL+ySMEA2EjTY=
960960
github.com/dvsekhvalnov/jose2go v1.6.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
961-
github.com/dydxprotocol/cometbft v0.38.6-0.20241120221529-56316dc17261 h1:uspjqDKBvC5I98gKBdZxqX3q0M2UOE/UlGgg+1CLNyI=
962-
github.com/dydxprotocol/cometbft v0.38.6-0.20241120221529-56316dc17261/go.mod h1:XSQX1hQbr54qaJb4/5YNNZGXkAQHHa6bi/KMcN1SQ7w=
963-
github.com/dydxprotocol/cosmos-sdk v0.50.6-0.20241120185835-38650041ec4d h1:6Qzg4IuX6LNdciU55jzpGuKxEVgD09rbU2cQaoJFo9Q=
964-
github.com/dydxprotocol/cosmos-sdk v0.50.6-0.20241120185835-38650041ec4d/go.mod h1:8EZnLstapHjZ2iGa9nGIhctJ3gU1yCqmRUPN8WI7jD0=
961+
github.com/dydxprotocol/cometbft v0.38.6-0.20241126215519-69cdde955fd0 h1:KBMuBNAE91SVeULnq2XBnmSDGeimI6aM1+YxlLb0yOI=
962+
github.com/dydxprotocol/cometbft v0.38.6-0.20241126215519-69cdde955fd0/go.mod h1:XSQX1hQbr54qaJb4/5YNNZGXkAQHHa6bi/KMcN1SQ7w=
963+
github.com/dydxprotocol/cosmos-sdk v0.50.6-0.20241127172510-4ee58434cdea h1:5jsj2e6zqnx7Q7SiNTYC7UGEW0ymgKFTbLxzp27/2Fg=
964+
github.com/dydxprotocol/cosmos-sdk v0.50.6-0.20241127172510-4ee58434cdea/go.mod h1:z/5+LD4MJzLqbe+fBCWI2pZLnQbOlzSM82snAw2zceg=
965965
github.com/dydxprotocol/cosmos-sdk/store v1.0.3-0.20240326192503-dd116391188d h1:HgLu1FD2oDFzlKW6/+SFXlH5Os8cwNTbplQIrQOWx8w=
966966
github.com/dydxprotocol/cosmos-sdk/store v1.0.3-0.20240326192503-dd116391188d/go.mod h1:zMcD3hfNwd0WMTpdRUhS3QxoCoEtBXWeoKsu3iaLBbQ=
967967
github.com/dydxprotocol/iavl v1.1.1-0.20240509161911-1c8b8e787e85 h1:5B/yGZyTBX/OZASQQMnk6Ms/TZja56MYd8OBaVc0Mho=

protocol/lib/ante/internal_msg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func IsInternalMsg(msg sdk.Msg) bool {
7777

7878
// blocktime
7979
*blocktime.MsgUpdateDowntimeParams,
80-
80+
*blocktime.MsgUpdateSynchronyParams,
8181
// bridge
8282
*bridge.MsgCompleteBridge,
8383
*bridge.MsgUpdateEventParams,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package keeper
2+
3+
import (
4+
"time"
5+
6+
sdk "github.com/cosmos/cosmos-sdk/types"
7+
8+
"github.com/dydxprotocol/v4-chain/protocol/x/blocktime/types"
9+
)
10+
11+
func (k Keeper) GetSynchronyParams(ctx sdk.Context) types.SynchronyParams {
12+
store := ctx.KVStore(k.storeKey)
13+
bytes := store.Get([]byte(types.SynchronyParamsKey))
14+
15+
if bytes == nil {
16+
return types.DefaultSynchronyParams()
17+
}
18+
19+
var params types.SynchronyParams
20+
k.cdc.MustUnmarshal(bytes, &params)
21+
return params
22+
}
23+
24+
func (k Keeper) SetSynchronyParams(ctx sdk.Context, params types.SynchronyParams) {
25+
store := ctx.KVStore(k.storeKey)
26+
store.Set([]byte(types.SynchronyParamsKey), k.cdc.MustMarshal(&params))
27+
}
28+
29+
func (k Keeper) GetBlockDelay(ctx sdk.Context) time.Duration {
30+
return k.GetSynchronyParams(ctx).NextBlockDelay
31+
}

0 commit comments

Comments
 (0)