-
Notifications
You must be signed in to change notification settings - Fork 135
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
[CT-723] add block number + stage to grpc updates #1252
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1683,6 +1683,8 @@ func (app *App) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk. | |
|
||
// BeginBlocker application updates every begin block | ||
func (app *App) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { | ||
ctx = ctx.WithExecMode(lib.ExecModeBeginBlock) | ||
|
||
// Update the proposer address in the logger for the panic logging middleware. | ||
proposerAddr := sdk.ConsAddress(ctx.BlockHeader().ProposerAddress) | ||
middleware.Logger = ctx.Logger().With("proposer_cons_addr", proposerAddr.String()) | ||
Comment on lines
1683
to
1690
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The gRPC server is initialized without specifying credentials, which could potentially expose the server to unencrypted connections. It's recommended to secure the gRPC server by using SSL/TLS credentials. - app.Server = daemonserver.NewServer(logger, grpc.NewServer(), &daemontypes.FileHandlerImpl{}, daemonFlags.Shared.SocketAddress)
+ creds, err := credentials.NewServerTLSFromFile("cert.pem", "cert.key")
+ if err != nil {
+ log.Fatalf("Failed to generate credentials %v", err)
+ }
+ app.Server = daemonserver.NewServer(logger, grpc.NewServer(grpc.Creds(creds)), &daemontypes.FileHandlerImpl{}, daemonFlags.Shared.SocketAddress) |
||
|
@@ -1693,6 +1695,8 @@ func (app *App) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { | |
|
||
// EndBlocker application updates every end block | ||
func (app *App) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) { | ||
ctx = ctx.WithExecMode(lib.ExecModeEndBlock) | ||
|
||
// Reset the logger for middleware. | ||
// Note that the middleware is only used by `CheckTx` and `DeliverTx`, and not `EndBlocker`. | ||
// Panics from `EndBlocker` will not be logged by the middleware and will lead to consensus failures. | ||
|
@@ -1716,6 +1720,8 @@ func (app *App) Precommitter(ctx sdk.Context) { | |
|
||
// PrepareCheckStater application updates after commit and before any check state is invoked. | ||
func (app *App) PrepareCheckStater(ctx sdk.Context) { | ||
ctx = ctx.WithExecMode(lib.ExecModePrepareCheckState) | ||
|
||
if err := app.ModuleManager.PrepareCheckState(ctx); err != nil { | ||
panic(err) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,13 @@ import ( | |
"github.com/dydxprotocol/v4-chain/protocol/lib/log" | ||
) | ||
|
||
// Custom exec modes | ||
const ( | ||
ExecModeBeginBlock = 100 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using ints for these values? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are meant to augment these |
||
ExecModeEndBlock = 101 | ||
ExecModePrepareCheckState = 102 | ||
) | ||
|
||
type TxHash string | ||
|
||
func GetTxHash(tx []byte) TxHash { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,17 +233,23 @@ func (k Keeper) InitializeNewGrpcStreams(ctx sdk.Context) { | |
allUpdates.Append(update) | ||
} | ||
|
||
k.SendOrderbookUpdates(allUpdates, true) | ||
k.SendOrderbookUpdates(ctx, allUpdates, true) | ||
} | ||
|
||
// SendOrderbookUpdates sends the offchain updates to the gRPC streaming manager. | ||
func (k Keeper) SendOrderbookUpdates( | ||
ctx sdk.Context, | ||
offchainUpdates *types.OffchainUpdates, | ||
snapshot bool, | ||
) { | ||
if len(offchainUpdates.Messages) == 0 { | ||
return | ||
} | ||
|
||
k.GetGrpcStreamingManager().SendOrderbookUpdates(offchainUpdates, snapshot) | ||
k.GetGrpcStreamingManager().SendOrderbookUpdates( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't really feel strongly at all but why don't we pass in the ctx instead of the blockheight and exec mode There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can abstract away the context from the streaming manager. logic to get block height/exec mode doesn't really belong there. let me know if you have a preference |
||
offchainUpdates, | ||
snapshot, | ||
lib.MustConvertIntegerToUint32(ctx.BlockHeight()), | ||
ctx.ExecMode(), | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wanna do
while you are at it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the strings not the ints though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean to move this from
x/clob
's begin blocker to here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can just add some tags to the app-level app.go file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
going to punt on this for now so that I can merge. let's do this in a separate PR