Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into verify_curve
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Jan 2, 2025
2 parents 9bb6daf + 5a9b265 commit 8c5f74e
Show file tree
Hide file tree
Showing 39 changed files with 433 additions and 1,925 deletions.
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/qa.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ v without deliberation
* [ ] Audit x/bank/v2
* [ ] Audit x/circuit
* [ ] Audit x/consensus
* [ ] Audit x/crisis
* [ ] Audit x/distribution
* [ ] Audit x/evidence
* [ ] Audit x/epochs
Expand Down
2 changes: 0 additions & 2 deletions .github/pr_labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
- x/circuit/**/*
"C:x/consensus":
- x/consensus/**/*
"C:x/crisis":
- x/crisis/**/*
"C:x/distribution":
- x/distribution/**/*
"C:x/evidence":
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
check-latest: false
cache: true
cache-dependency-path: depinject/go.sum
Expand Down Expand Up @@ -312,7 +312,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true
cache: true
cache-dependency-path: errors/go.sum
Expand Down Expand Up @@ -343,7 +343,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true
cache: true
cache-dependency-path: math/go.sum
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i

### Bug Fixes

* (query) [23002](https://github.com/cosmos/cosmos-sdk/pull/23002) Fix collection filtered pagination.

### API Breaking Changes

* (x/params) [#22995](https://github.com/cosmos/cosmos-sdk/pull/22995) Remove `x/params`. Migrate to the new params system introduced in `v0.47` as demonstrated [here](https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md#xparams).
Expand Down
2 changes: 1 addition & 1 deletion collections/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Since a module can have multiple collections, the following is expected:
We don't want a collection to write over the state of the other collection so we pass it a prefix, which defines a storage
partition owned by the collection.

If you already built modules, the prefix translates to the items you were creating in your ``types/keys.go`` file, example: https://github.com/cosmos/cosmos-sdk/blob/main/x/feegrant/key.go#L27
If you already built modules, the prefix translates to the items you were creating in your ``types/keys.go`` file, example: https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-rc.1/x/feegrant/key.go#L16~L22

your old:

Expand Down
2 changes: 1 addition & 1 deletion depinject/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module cosmossdk.io/depinject

go 1.21
go 1.22

require (
github.com/cosmos/cosmos-proto v1.0.0-beta.5
Expand Down
4 changes: 2 additions & 2 deletions docs/architecture/adr-069-gov-improvements.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ Voter can only vote NO on the proposal. If the NO threshold is reached, the opti
Two governance parameters will be in added [`v1.Params`][5] to support optimistic proposals:

```protobuf
// optimistic_authorized_addreses is an optional governance parameter that limits the authorized accounts that can submit optimistic proposals
repeated string optimistic_authorized_addreses = 17 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// optimistic_authorized_addresses is an optional governance parameter that limits the authorized accounts that can submit optimistic proposals
repeated string optimistic_authorized_addresses = 17 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Optimistic rejected threshold defines at which percentage of NO votes, the optimistic proposal should fail and be converted to a standard proposal.
string optimistic_rejected_threshold = 18 [(cosmos_proto.scalar) = "cosmos.Dec"];
Expand Down
2 changes: 1 addition & 1 deletion errors/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module cosmossdk.io/errors/v2

// NOTE: this go.mod should have zero dependencies.

go 1.20
go 1.22
3 changes: 0 additions & 3 deletions log/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func BenchmarkLoggers(b *testing.B) {
// so that real write time is negligible.
b.Run("zerolog", func(b *testing.B) {
for _, bc := range benchCases {
bc := bc
b.Run(bc.name, func(b *testing.B) {
zl := zerolog.New(io.Discard)
logger := log.NewCustomLogger(zl)
Expand All @@ -99,7 +98,6 @@ func BenchmarkLoggers(b *testing.B) {
// also useful as a reference for how expensive zerolog is.
b.Run("specialized nop logger", func(b *testing.B) {
for _, bc := range nopCases {
bc := bc
b.Run(bc.name, func(b *testing.B) {
logger := log.NewNopLogger()

Expand All @@ -115,7 +113,6 @@ func BenchmarkLoggers(b *testing.B) {
// so we offer the specialized version in the exported API.
b.Run("zerolog nop logger", func(b *testing.B) {
for _, bc := range nopCases {
bc := bc
b.Run(bc.name, func(b *testing.B) {
logger := log.NewCustomLogger(zerolog.Nop())

Expand Down
2 changes: 1 addition & 1 deletion log/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module cosmossdk.io/log

go 1.21
go 1.22

require (
github.com/bytedance/sonic v1.12.6
Expand Down
2 changes: 1 addition & 1 deletion math/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module cosmossdk.io/math

go 1.20
go 1.22

require (
github.com/cockroachdb/apd/v3 v3.2.1
Expand Down
4 changes: 4 additions & 0 deletions math/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand All @@ -29,6 +31,7 @@ golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 h1:SbSDUWW1PAO24TNpLdeheoYPd7kllICcLU52x6eD4kQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA=
Expand All @@ -37,6 +40,7 @@ google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6h
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw=
Expand Down
1 change: 0 additions & 1 deletion math/legacy_dec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,6 @@ func TestFormatDecNonDigits(t *testing.T) {
}

for _, value := range badCases {
value := value
t.Run(value, func(t *testing.T) {
s, err := math.FormatDec(value)
if err == nil {
Expand Down
4 changes: 2 additions & 2 deletions scripts/build/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ MOCKS_DIR = $(CURDIR)/tests/mocks
HTTPS_GIT := https://github.com/cosmos/cosmos-sdk.git
DOCKER := $(shell which docker)
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)
COSMOS_BUILD_OPTIONS := v2
COSMOS_BUILD_OPTIONS += ' v2'

rocksdb_version=v9.6.1
rocksdb_version=v9.7.3

ifeq ($(findstring .,$(VERSION)),)
VERSION := 0.0.0
Expand Down
158 changes: 138 additions & 20 deletions server/v2/stf/README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,152 @@
# State Transition Function (STF)
# STF (State Transition Function) Documentation

STF is a function that takes a state and an action as input and returns the next state. It does not assume the execution model of the application nor consensus.
This document outlines the main external calls in the STF package, their execution flows, and dependencies.

The state transition function receives a read only instance of state. It does not directly write to disk, instead it will return the state changes which has undergone within the application. The state transition function is deterministic, meaning that given the same input, it will always produce the same output.
## Table of Contents
- [DeliverBlock](#deliverblock)
- [Simulate](#simulate)
- [ValidateTx](#validatetx)
- [Query](#query)

## BranchDB
## DeliverBlock

BranchDB is a cache of all the reads done within a block, simulation or transaction validation. It takes a read-only instance of state and creates its own write instance using a btree. After all state transitions are done, the new change sets are returned to the caller.
DeliverBlock is the main state transition function that processes an entire block of transactions.

The BranchDB can be replaced and optimized for specific use cases. The implementation is as follows
```mermaid
sequenceDiagram
participant Caller
participant STF
participant State
participant PreBlock
participant BeginBlock
participant TxProcessor
participant EndBlock
Caller->>STF: DeliverBlock(ctx, block, state)
STF->>State: Branch(state)
STF->>State: SetHeaderInfo
STF->>PreBlock: doPreBlock(ctx, txs)
STF->>BeginBlock: doBeginBlock(ctx)
loop For each transaction
STF->>TxProcessor: deliverTx(ctx, state, tx)
TxProcessor->>TxProcessor: validateTx()
TxProcessor->>TxProcessor: execTx()
TxProcessor-->>STF: TxResult
end
STF->>EndBlock: doEndBlock(ctx)
STF->>EndBlock: validatorUpdates(ctx)
STF-->>Caller: BlockResponse, newState, error
```

### Dependencies
- Required Input:
- Context
- BlockRequest containing transactions
- ReadOnly state
- Required Components:
- PreBlock handler
- BeginBlock handler
- EndBlock handler
- Transaction validator
- Message router
- Gas meter

## Simulate

Simulate executes a transaction without committing changes to the actual state.

```go
type branchdb func(state store.ReaderMap) store.WriterMap
```mermaid
sequenceDiagram
participant Caller
participant STF
participant State
participant TxProcessor
Caller->>STF: Simulate(ctx, state, gasLimit, tx)
STF->>State: Branch(state)
STF->>State: GetHeaderInfo()
STF->>TxProcessor: deliverTx(ctx, state, tx, SimulateMode)
TxProcessor-->>Caller: TxResult, simulationState
```

## GasMeter
### Dependencies
- Required Input:
- Context
- ReadOnly state
- Gas limit
- Transaction
- Required Components:
- Transaction processor
- Gas meter
- Message router

GasMeter is a utility that keeps track of the gas consumed by the state transition function. It is used to limit the amount of computation that can be done within a block.
## ValidateTx

ValidateTx performs transaction validation without execution.

```mermaid
sequenceDiagram
participant Caller
participant STF
participant State
participant Validator
Caller->>STF: ValidateTx(ctx, state, gasLimit, tx)
STF->>State: Branch(state)
STF->>Validator: validateTx(ctx, state, gasLimit, tx)
Validator-->>Caller: TxResult
```

The GasMeter can be replaced and optimized for specific use cases. The implementation is as follows:
### Dependencies
- Required Input:
- Context
- ReadOnly state
- Gas limit
- Transaction
- Required Components:
- Transaction validator
- Gas meter

```go
type (
// gasMeter is a function type that takes a gas limit as input and returns a gas.Meter.
// It is used to measure and limit the amount of gas consumed during the execution of a function.
gasMeter func(gasLimit uint64) gas.Meter
## Query

// wrapGasMeter is a function type that wraps a gas meter and a store writer map.
wrapGasMeter func(meter gas.Meter, store store.WriterMap) store.WriterMap
)
Query executes a read-only query against the application state.

```mermaid
sequenceDiagram
participant Caller
participant STF
participant State
participant QueryRouter
Caller->>STF: Query(ctx, state, gasLimit, req)
STF->>State: Branch(state)
STF->>State: GetHeaderInfo()
STF->>QueryRouter: Invoke(ctx, req)
QueryRouter-->>Caller: Response, error
```

THe wrapGasMeter is used in order to consume gas. Application developers can seamlsessly replace the gas meter with their own implementation in order to customize consumption of gas.
### Dependencies
- Required Input:
- Context
- ReadOnly state
- Gas limit
- Query request message
- Required Components:
- Query router
- Gas meter
- Message handlers

## Error Handling

All operations include error handling for:
- Context cancellation
- Gas limit exceeded
- Invalid transactions
- State operation failures
- Panic recovery (in transaction execution)

## Gas Management

Gas is tracked and limited for:
- Transaction validation
- Message execution
- State operations
- Query execution

Each operation that consumes gas uses a gas meter to track usage and ensure limits are not exceeded.
2 changes: 1 addition & 1 deletion store/snapshots/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const (
snapshotMaxItemSize = int(64e6) // SDK has no key/value size limit, so we set an arbitrary limit
)

var ErrOptsZeroSnapshotInterval = errors.New("snaphot-interval must not be 0")
var ErrOptsZeroSnapshotInterval = errors.New("snapshot-interval must not be 0")

// NewManager creates a new manager.
func NewManager(store *Store, opts types.SnapshotOptions, multistore types.Snapshotter, extensions map[string]types.ExtensionSnapshotter, logger storetypes.Logger) *Manager {
Expand Down
2 changes: 1 addition & 1 deletion systemtests/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ At the end is a tail from the server log printed. This can sometimes be handy wh
When we have a json response, the [gjson](https://github.com/tidwall/gjson) lib can shine. It comes with jquery like
syntax that makes it easy to navigation within the document.

For example `gjson.Get(raw, "supply").Array()` gives us all the childs to `supply` as an array.
For example `gjson.Get(raw, "supply").Array()` gives us all the children to `supply` as an array.
Or `gjson.Get("supply.#(denom==stake).amount").Int()` for the amount of the stake token as int64 type.

In order to test our assumptions in the system test, we modify the code to use `gjson` to fetch the data:
Expand Down
Loading

0 comments on commit 8c5f74e

Please sign in to comment.