Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Pitasi committed Jun 21, 2024
1 parent 71a0573 commit 600bc9a
Show file tree
Hide file tree
Showing 21 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ localnet bin="wardend":
{{bin}} config set app minimum-gas-prices 0uward
{{bin}} config set app api.enable true
{{bin}} config set app api.enabled-unsafe-cors true
{{bin}} config set app telemetry.enabled true
{{bin}} config set config consensus.timeout_commit 1s -s
replace 's/cors_allowed_origins = \[\]/cors_allowed_origins = ["*"]/' ~/.warden/config/config.toml
{{bin}} keys add val > /dev/null
Expand Down
5 changes: 5 additions & 0 deletions warden/x/act/keeper/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/baseapp"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/warden-protocol/wardenprotocol/shield"
"github.com/warden-protocol/wardenprotocol/shield/object"
Expand Down Expand Up @@ -61,6 +62,8 @@ func (k Keeper) executeAction(ctx context.Context, act *types.Action) error {
return fmt.Errorf("unpacking Action.Msg: %w", err)
}

defer telemetry.MeasureSince(telemetry.Now(), sdk.MsgTypeURL(msg))

handler := k.router.Handler(msg)
if handler == nil {
return fmt.Errorf("no handler registered for %s", sdk.MsgTypeURL(msg))
Expand Down Expand Up @@ -183,6 +186,8 @@ func (k Keeper) AddAction(ctx context.Context, creator string, msg sdk.Msg, time
return nil, err
}

telemetry.IncrCounter(1, "action", "count")

// try executing the action immediately
if err := k.TryExecuteAction(ctx, act); err != nil {
return nil, err
Expand Down
3 changes: 3 additions & 0 deletions warden/x/act/keeper/msg_server_approve_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/act/types/v1beta1"
)
Expand Down Expand Up @@ -40,5 +41,7 @@ func (k msgServer) ApproveAction(goCtx context.Context, msg *types.MsgApproveAct
return nil, err
}

telemetry.IncrCounter(1, "approve_action", "msg", "count")

return &types.MsgApproveActionResponse{Status: act.Status.String()}, nil
}
3 changes: 3 additions & 0 deletions warden/x/act/keeper/msg_server_new_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/act/types/v1beta1"
)
Expand All @@ -27,6 +28,8 @@ func (k msgServer) NewAction(ctx context.Context, msg *types.MsgNewAction) (*typ
}); err != nil {
return nil, err
}
telemetry.IncrCounter(1, "action", "count")

return &types.MsgNewActionResponse{
Id: act.Id,
}, nil
Expand Down
3 changes: 3 additions & 0 deletions warden/x/act/keeper/msg_server_new_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/warden-protocol/wardenprotocol/shield"
types "github.com/warden-protocol/wardenprotocol/warden/x/act/types/v1beta1"
Expand Down Expand Up @@ -34,6 +35,8 @@ func (k msgServer) NewRule(goCtx context.Context, msg *types.MsgNewRule) (*types
return nil, err
}

telemetry.IncrCounter(1, "new_rule", "msg", "count")

return &types.MsgNewRuleResponse{
Id: id,
}, nil
Expand Down
3 changes: 3 additions & 0 deletions warden/x/act/keeper/msg_server_revoke_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/act/types/v1beta1"
)
Expand Down Expand Up @@ -32,5 +33,7 @@ func (k msgServer) RevokeAction(goCtx context.Context, msg *types.MsgRevokeActio
return nil, err
}

telemetry.IncrCounter(1, "revoke_action", "msg", "count")

return &types.MsgRevokeActionResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/act/keeper/msg_server_update_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"github.com/cosmos/cosmos-sdk/telemetry"

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -19,5 +20,7 @@ func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam
return nil, err
}

telemetry.IncrCounter(1, "intent", "update_params", "msg", "count")

return &types.MsgUpdateParamsResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/act/keeper/msg_server_update_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/warden-protocol/wardenprotocol/shield"
Expand Down Expand Up @@ -39,5 +40,7 @@ func (k msgServer) UpdateRule(ctx context.Context, msg *types.MsgUpdateRule) (*t
return nil, err
}

telemetry.IncrCounter(1, "update_rule", "msg", "count")

return &types.MsgUpdateRuleResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_add_keychain_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -43,5 +44,7 @@ func (k msgServer) AddKeychainWriter(goCtx context.Context, msg *types.MsgAddKey
return nil, err
}

telemetry.IncrCounter(1, "add_keychain_writer", "msg", "count")

return &types.MsgAddKeychainWriterResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_add_space_owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -35,5 +36,7 @@ func (k msgServer) AddSpaceOwner(ctx context.Context, msg *types.MsgAddSpaceOwne
return nil, err
}

telemetry.IncrCounter(1, "add_space_owner", "msg", "count")

return &types.MsgAddSpaceOwnerResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_fulfil_signature_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/ed25519"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -69,6 +70,7 @@ func (k msgServer) FulfilSignatureRequest(goCtx context.Context, msg *types.MsgF
return nil, err
}

telemetry.IncrCounter(1, "fulfill_signature_request", "msg", "count")
case types.SignRequestStatus_SIGN_REQUEST_STATUS_REJECTED:
req.Status = types.SignRequestStatus_SIGN_REQUEST_STATUS_REJECTED
req.Result = &types.SignRequest_RejectReason{
Expand All @@ -84,6 +86,7 @@ func (k msgServer) FulfilSignatureRequest(goCtx context.Context, msg *types.MsgF
return nil, err
}

telemetry.IncrCounter(1, "reject_signature_request", "msg", "count")
default:
return nil, fmt.Errorf("invalid status field, should be either fulfilled/rejected")
}
Expand Down
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_new_key_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -61,6 +62,8 @@ func (k msgServer) NewKeyRequest(ctx context.Context, msg *types.MsgNewKeyReques
return nil, err
}

telemetry.IncrCounter(1, "new_key_request", "msg", "count")

return &types.MsgNewKeyRequestResponse{
Id: id,
}, nil
Expand Down
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_new_keychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -30,6 +31,8 @@ func (k msgServer) NewKeychain(goCtx context.Context, msg *types.MsgNewKeychain)
return nil, err
}

telemetry.IncrCounter(1, "new_keychain", "msg", "count")

return &types.MsgNewKeychainResponse{
Id: id,
}, nil
Expand Down
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_new_signature_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"

types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
Expand Down Expand Up @@ -80,5 +81,7 @@ func (k msgServer) NewSignatureRequest(ctx context.Context, msg *types.MsgNewSig
return nil, err
}

telemetry.IncrCounter(1, "new_signature_request", "msg", "count")

return &types.MsgNewSignatureRequestResponse{Id: id}, nil
}
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_new_space.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -40,6 +41,8 @@ func (k msgServer) NewSpace(goCtx context.Context, msg *types.MsgNewSpace) (*typ
return nil, err
}

telemetry.IncrCounter(1, "new_space", "msg", "count")

return &types.MsgNewSpaceResponse{
Id: id,
}, nil
Expand Down
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_remove_space_owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -37,5 +38,7 @@ func (k msgServer) RemoveSpaceOwner(ctx context.Context, msg *types.MsgRemoveSpa
return nil, err
}

telemetry.IncrCounter(1, "remove_space_owner", "msg", "count")

return &types.MsgRemoveSpaceOwnerResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_update_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -31,5 +32,7 @@ func (k msgServer) UpdateKey(ctx context.Context, msg *types.MsgUpdateKey) (*typ
return nil, err
}

telemetry.IncrCounter(1, "update_key", "msg", "count")

return &types.MsgUpdateKeyResponse{}, nil
}
4 changes: 4 additions & 0 deletions warden/x/warden/keeper/msg_server_update_key_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/ed25519"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"

types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
Expand Down Expand Up @@ -79,6 +80,7 @@ func (k msgServer) UpdateKeyRequest(goCtx context.Context, msg *types.MsgUpdateK
}); err != nil {
return nil, err
}
telemetry.IncrCounter(1, "update_key_request", "msg", "count")

case types.KeyRequestStatus_KEY_REQUEST_STATUS_REJECTED:
req.Status = types.KeyRequestStatus_KEY_REQUEST_STATUS_REJECTED
Expand All @@ -94,6 +96,8 @@ func (k msgServer) UpdateKeyRequest(goCtx context.Context, msg *types.MsgUpdateK
return nil, err
}

telemetry.IncrCounter(1, "update_key_request", "msg", "count")

default:
return nil, fmt.Errorf("invalid status field, should be either fulfilled/rejected")
}
Expand Down
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_update_keychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -37,5 +38,7 @@ func (k msgServer) UpdateKeychain(goCtx context.Context, msg *types.MsgUpdateKey
return nil, err
}

telemetry.IncrCounter(1, "update_keychain", "msg", "count")

return &types.MsgUpdateKeychainResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_update_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"github.com/cosmos/cosmos-sdk/telemetry"

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -19,5 +20,7 @@ func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam
return nil, err
}

telemetry.IncrCounter(1, "warden", "update_params", "msg", "count")

return &types.MsgUpdateParamsResponse{}, nil
}
3 changes: 3 additions & 0 deletions warden/x/warden/keeper/msg_server_update_space.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/warden-protocol/wardenprotocol/warden/x/warden/types/v1beta2"
)
Expand Down Expand Up @@ -44,6 +45,8 @@ func (k msgServer) UpdateSpace(ctx context.Context, msg *types.MsgUpdateSpace) (
return nil, err
}

telemetry.IncrCounter(1, "update_space", "msg", "count")

return &types.MsgUpdateSpaceResponse{}, nil
}

Expand Down

0 comments on commit 600bc9a

Please sign in to comment.