Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
jayy04 committed Sep 25, 2024
1 parent 43c09ff commit a260fd6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 5 additions & 5 deletions protocol/x/accountplus/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,16 @@ func (ad AuthenticatorDecorator) AnteHandle(
)
}

a11r := selectedAuthenticator.Authenticator
authenticator := selectedAuthenticator.Authenticator
stringId := strconv.FormatUint(selectedAuthenticator.Id, 10)
authenticationRequest.AuthenticatorId = stringId

// Consume the authenticator's static gas
ctx.GasMeter().ConsumeGas(a11r.StaticGas(), "authenticator static gas")
ctx.GasMeter().ConsumeGas(authenticator.StaticGas(), "authenticator static gas")

// Authenticate should never modify state. That's what track is for
neverWriteCtx, _ := ctx.CacheContext()
authErr := a11r.Authenticate(neverWriteCtx, authenticationRequest)
authErr := authenticator.Authenticate(neverWriteCtx, authenticationRequest)

// If authentication is successful, continue
if authErr == nil {
Expand All @@ -178,7 +178,7 @@ func (ad AuthenticatorDecorator) AnteHandle(
// loop variable inside the closure.
currentMsgTypeURL := sdk.MsgTypeURL(msg)
tracks = append(tracks, func() error {
err := a11r.Track(ctx, authenticationRequest)
err := authenticator.Track(ctx, authenticationRequest)
if err != nil {
// track should not fail in normal circumstances,
// since it is intended to update track state before execution.
Expand All @@ -198,7 +198,7 @@ func (ad AuthenticatorDecorator) AnteHandle(
"track failed (account = %s, authenticator id = %s, authenticator type, %s, msg index = %d)",
account,
stringId,
a11r.Type(),
authenticator.Type(),
msgIndex,
)
}
Expand Down
6 changes: 6 additions & 0 deletions protocol/x/accountplus/ante/circuit_breaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ func NewCircuitBreakerDecorator(
}

// AnteHandle checks if a tx is a smart account tx and routes it through the correct series of ante handlers.
//
// Note that whether or not to use the new authenticator flow is determined by the presence of the `TxExtension`.
// This is different from the Osmosis's implementation, which falls back to the original flow if
// smart account is disabled.
// The reason for this is because only minimal validation is done on resting maker orders when they get matched
// and this approach mitigates an issue for maker orders when smart account gets disabled through governance.
func (ad CircuitBreakerDecorator) AnteHandle(
ctx sdk.Context,
tx sdk.Tx,
Expand Down

0 comments on commit a260fd6

Please sign in to comment.