Skip to content

Commit

Permalink
chore(server): bump cosmossdk.io/core and correct comment naming (#22245
Browse files Browse the repository at this point in the history
)

(cherry picked from commit ee3d320)

# Conflicts:
#	server/v2/appmanager/go.mod
#	server/v2/appmanager/go.sum
#	server/v2/stf/core_router_service.go
#	server/v2/stf/gas/defaults.go
  • Loading branch information
hoank101 authored and mergify[bot] committed Oct 15, 2024
1 parent 5f534c9 commit 6622fc2
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 2 deletions.
7 changes: 7 additions & 0 deletions server/v2/appmanager/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module cosmossdk.io/server/v2/appmanager

go 1.23

require cosmossdk.io/core v1.0.0-alpha.4

require cosmossdk.io/schema v0.3.0 // indirect
4 changes: 4 additions & 0 deletions server/v2/appmanager/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
cosmossdk.io/core v1.0.0-alpha.4/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
cosmossdk.io/schema v0.3.0 h1:01lcaM4trhzZ1HQTfTV8z6Ma1GziOZ/YmdzBN3F720c=
cosmossdk.io/schema v0.3.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
2 changes: 1 addition & 1 deletion server/v2/cometbft/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (c *Consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) (
}

func (c *Consensus[T]) maybeRunGRPCQuery(ctx context.Context, req *abci.QueryRequest) (resp *abciproto.QueryResponse, isGRPC bool, err error) {
// if this fails then we cannot serve queries anymore
// if this fails then we cannot serve queries anymore
registry, err := c.getProtoRegistry()
if err != nil {
return nil, false, err
Expand Down
2 changes: 1 addition & 1 deletion server/v2/cometbft/internal/mock/mock_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (roa *ReaderMap) GetReader(actor []byte) (corestore.Reader, error) {
return NewMockReader(roa.version, roa.store, actor), nil
}

// Reader represents a read-only adapter for accessing data from the root store.
// MockReader represents a read-only adapter for accessing data from the root store.
type MockReader struct {
version uint64 // The version of the data.
store *MockStore // The root store to read data from.
Expand Down
74 changes: 74 additions & 0 deletions server/v2/stf/core_router_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package stf

import (
"context"

"cosmossdk.io/core/router"
"cosmossdk.io/core/transaction"
)

// NewMsgRouterService implements router.Service.
func NewMsgRouterService(identity transaction.Identity) router.Service {
return msgRouterService{identity: identity}
}

var _ router.Service = (*msgRouterService)(nil)

type msgRouterService struct {
// TODO(tip): the identity sits here for the purpose of disallowing modules to impersonate others (sudo).
// right now this is not used, but it serves the reminder of something that we should be eventually
// looking into.
identity []byte
}

// CanInvoke returns an error if the given message cannot be invoked.
func (m msgRouterService) CanInvoke(ctx context.Context, typeURL string) error {
exCtx, err := getExecutionCtxFromContext(ctx)

Check failure on line 26 in server/v2/stf/core_router_service.go

View workflow job for this annotation

GitHub Actions / dependency-review

undefined: getExecutionCtxFromContext

Check failure on line 26 in server/v2/stf/core_router_service.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: getExecutionCtxFromContext

Check failure on line 26 in server/v2/stf/core_router_service.go

View workflow job for this annotation

GitHub Actions / tests (01)

undefined: getExecutionCtxFromContext
if err != nil {
return err
}

return exCtx.msgRouter.CanInvoke(ctx, typeURL)
}

// Invoke execute a message and returns a response.
func (m msgRouterService) Invoke(ctx context.Context, msg transaction.Msg) (transaction.Msg, error) {
exCtx, err := getExecutionCtxFromContext(ctx)

Check failure on line 36 in server/v2/stf/core_router_service.go

View workflow job for this annotation

GitHub Actions / dependency-review

undefined: getExecutionCtxFromContext

Check failure on line 36 in server/v2/stf/core_router_service.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: getExecutionCtxFromContext

Check failure on line 36 in server/v2/stf/core_router_service.go

View workflow job for this annotation

GitHub Actions / tests (01)

undefined: getExecutionCtxFromContext
if err != nil {
return nil, err
}

return exCtx.msgRouter.Invoke(ctx, msg)
}

// NewQueryRouterService implements router.Service.
func NewQueryRouterService() router.Service {
return queryRouterService{}
}

var _ router.Service = (*queryRouterService)(nil)

type queryRouterService struct{}

// CanInvoke returns an error if the given request cannot be invoked.
func (m queryRouterService) CanInvoke(ctx context.Context, typeURL string) error {
exCtx, err := getExecutionCtxFromContext(ctx)

Check failure on line 55 in server/v2/stf/core_router_service.go

View workflow job for this annotation

GitHub Actions / dependency-review

undefined: getExecutionCtxFromContext

Check failure on line 55 in server/v2/stf/core_router_service.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: getExecutionCtxFromContext

Check failure on line 55 in server/v2/stf/core_router_service.go

View workflow job for this annotation

GitHub Actions / tests (01)

undefined: getExecutionCtxFromContext
if err != nil {
return err
}

return exCtx.queryRouter.CanInvoke(ctx, typeURL)
}

// Invoke execute a message and returns a response.
func (m queryRouterService) Invoke(
ctx context.Context,
req transaction.Msg,
) (transaction.Msg, error) {
exCtx, err := getExecutionCtxFromContext(ctx)

Check failure on line 68 in server/v2/stf/core_router_service.go

View workflow job for this annotation

GitHub Actions / dependency-review

undefined: getExecutionCtxFromContext

Check failure on line 68 in server/v2/stf/core_router_service.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: getExecutionCtxFromContext (typecheck)

Check failure on line 68 in server/v2/stf/core_router_service.go

View workflow job for this annotation

GitHub Actions / tests (01)

undefined: getExecutionCtxFromContext
if err != nil {
return nil, err
}

return exCtx.queryRouter.Invoke(ctx, req)
}
48 changes: 48 additions & 0 deletions server/v2/stf/gas/defaults.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package gas

import (
coregas "cosmossdk.io/core/gas"
"cosmossdk.io/core/store"
)

// DefaultWrapWithGasMeter defines the default wrap with gas meter function in stf. In case
// the meter sets as limit stf.NoGasLimit, then a fast path is taken and the store.WriterMap
// is returned.
func DefaultWrapWithGasMeter(meter coregas.Meter, state store.WriterMap) store.WriterMap {
if meter.Limit() == coregas.NoGasLimit {
return state
}
return NewMeteredWriterMap(DefaultConfig, meter, state)

Check failure on line 15 in server/v2/stf/gas/defaults.go

View workflow job for this annotation

GitHub Actions / dependency-review

undefined: NewMeteredWriterMap

Check failure on line 15 in server/v2/stf/gas/defaults.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: NewMeteredWriterMap

Check failure on line 15 in server/v2/stf/gas/defaults.go

View workflow job for this annotation

GitHub Actions / tests (01)

undefined: NewMeteredWriterMap
}

// DefaultGasMeter returns the default gas meter. In case it is coregas.NoGasLimit a NoOpMeter is returned.
func DefaultGasMeter(gasLimit uint64) coregas.Meter {
if gasLimit == coregas.NoGasLimit {
return NoOpMeter{}
}
return NewMeter(gasLimit)

Check failure on line 23 in server/v2/stf/gas/defaults.go

View workflow job for this annotation

GitHub Actions / dependency-review

undefined: NewMeter

Check failure on line 23 in server/v2/stf/gas/defaults.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: NewMeter (typecheck)

Check failure on line 23 in server/v2/stf/gas/defaults.go

View workflow job for this annotation

GitHub Actions / tests (01)

undefined: NewMeter
}

// DefaultConfig returns the default gas config.
// Unless overridden, the default gas costs are:
var DefaultConfig = coregas.GasConfig{
HasCost: 1000,
DeleteCost: 1000,
ReadCostFlat: 1000,
ReadCostPerByte: 3,
WriteCostFlat: 2000,
WriteCostPerByte: 30,
IterNextCostFlat: 30,
}

type NoOpMeter struct{}

func (n NoOpMeter) Consumed() coregas.Gas { return 0 }

func (n NoOpMeter) Limit() coregas.Gas { return coregas.NoGasLimit }

func (n NoOpMeter) Consume(_ coregas.Gas, _ string) error { return nil }

func (n NoOpMeter) Refund(_ coregas.Gas, _ string) error { return nil }

func (n NoOpMeter) Remaining() coregas.Gas { return coregas.NoGasLimit }

0 comments on commit 6622fc2

Please sign in to comment.