Skip to content

Commit

Permalink
reset unwanted commits
Browse files Browse the repository at this point in the history
  • Loading branch information
likhita-809 committed Jan 31, 2024
1 parent 47d1ebe commit 4712842
Show file tree
Hide file tree
Showing 64 changed files with 1,090 additions and 471 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i

### Features

* (types) [#19164](https://github.com/cosmos/cosmos-sdk/pull/19164) Add a ValueCodec for the math.Uint type that can be used in collections maps.
* (types) [#19281](https://github.com/cosmos/cosmos-sdk/pull/19281) Added a new method, `IsGT`, for `types.Coin`. This method is used to check if a `types.Coin` is greater than another `types.Coin`.
* (client) [#18557](https://github.com/cosmos/cosmos-sdk/pull/18557) Add `--qrcode` flag to `keys show` command to support displaying keys address QR code.
* (client) [#18101](https://github.com/cosmos/cosmos-sdk/pull/18101) Add a `keyring-default-keyname` in `client.toml` for specifying a default key name, and skip the need to use the `--from` flag when signing transactions.
* (tests) [#17868](https://github.com/cosmos/cosmos-sdk/pull/17868) Added helper method `SubmitTestTx` in testutil to broadcast test txns to test e2e tests.
Expand Down Expand Up @@ -90,7 +92,8 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (simulation) [#18196](https://github.com/cosmos/cosmos-sdk/pull/18196) Fix the problem of `validator set is empty after InitGenesis` in simulation test.
* (baseapp) [#18551](https://github.com/cosmos/cosmos-sdk/pull/18551) Fix SelectTxForProposal the calculation method of tx bytes size is inconsistent with CometBFT
* (abci): [#19200](https://github.com/cosmos/cosmos-sdk/pull/19200) Ensure that sdk side ve math matches cometbft

* (server) [#18994](https://github.com/cosmos/cosmos-sdk/pull/18994) Update server context directly rather than a reference to a sub-object

### API Breaking Changes

* (server) [#18303](https://github.com/cosmos/cosmos-sdk/pull/18303) `x/genutil` now handles the application export. `server.AddCommands` does not take an `AppExporter` but instead `genutilcli.Commands` does.
Expand Down
10 changes: 10 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ Refer to SimApp `root_v2.go` and `root.go` for an example with an app v2 and a l

<!-- explain app_config.go changes -->

### Core

`appmodule.Environment` interface was introduced to fetch different services from the application. This can be used as an alternative to using `sdk.UnwrapContext(ctx)` to fetch the services. It needs to be passed into a module at instantiation.

Circuit Breaker is used as an example.

```go
app.CircuitKeeper = circuitkeeper.NewKeeper(runtime.NewEnvironment((keys[circuittypes.StoreKey]), nil), appCodec, authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AuthKeeper.AddressCodec())
```

### Modules

#### `**all**`
Expand Down
294 changes: 226 additions & 68 deletions api/cosmos/gov/v1/gov.pulsar.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion baseapp/abci_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_PriorityNonceMempoolTxSe
expectedTxs: []int{9},
},
"no txs added": {
// Becasuse the first tx was deemed valid but too big, the next expected valid sequence is tx[0].seq (3), so
// Because the first tx was deemed valid but too big, the next expected valid sequence is tx[0].seq (3), so
// the rest of the txs fail because they have a seq of 4.
ctx: s.ctx,
txInputs: []testTx{testTxs[12], testTxs[13], testTxs[14]},
Expand Down
10 changes: 9 additions & 1 deletion client/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,14 @@ func GetClientContextFromCmd(cmd *cobra.Command) Context {
// SetCmdClientContext sets a command's Context value to the provided argument.
// If the context has not been set, set the given context as the default.
func SetCmdClientContext(cmd *cobra.Command, clientCtx Context) error {
cmd.SetContext(context.WithValue(cmd.Context(), ClientContextKey, &clientCtx))
var cmdCtx context.Context

if cmd.Context() == nil {
cmdCtx = context.Background()
} else {
cmdCtx = cmd.Context()
}

cmd.SetContext(context.WithValue(cmdCtx, ClientContextKey, &clientCtx))
return nil
}
3 changes: 1 addition & 2 deletions client/v2/internal/offchain/msgSignArbitraryData.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "amino/amino.proto";

// MsgSignArbitraryData defines an arbitrary, general-purpose, off-chain message
message MsgSignArbitraryData {
option (amino.name) = "offchain/MsgSignArbitraryData";
option (amino.name) = "offchain/MsgSignArbitraryData";
option (cosmos.msg.v1.signer) = "signer";
// AppDomain is the application requesting off-chain message signing
string app_domain = 1;
Expand All @@ -17,4 +17,3 @@ message MsgSignArbitraryData {
// Data represents the raw bytes of the content that is signed (text, json, etc)
string data = 3;
}

3 changes: 2 additions & 1 deletion collections/lookup_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package collections_test
import (
"testing"

"github.com/stretchr/testify/require"

"cosmossdk.io/collections"
"cosmossdk.io/collections/colltest"
"github.com/stretchr/testify/require"
)

func TestLookupMap(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ Ref: https://keepachangelog.com/en/1.0.0/

* [#18379](https://github.com/cosmos/cosmos-sdk/pull/18379) Add branch service.
* [#18457](https://github.com/cosmos/cosmos-sdk/pull/18457) Add branch.ExecuteWithGasLimit.
* [#19041](https://github.com/cosmos/cosmos-sdk/pull/19041) Add `appmodule.Environment` interface to fetch different services

### API Breaking

* [#18857](https://github.com/cosmos/cosmos-sdk/pull/18857) Moved `FormatCoins` to `x/tx`.
* [#18861](httpes://github.com/cosmos/cosmos-sdk/pull/18861) Moved `coin.ParseCoin` to `client/v2/internal`.
* [#18866](https://github.com/cosmos/cosmos-sdk/pull/18866) All items related to depinject have been moved to `cosmossdk.io/depinject` (`Provide`, `Invoke`, `Register`)
* [#19041](https://github.com/cosmos/cosmos-sdk/pull/19041) `HasEventListeners` was removed from appmodule due to the fact that it was not used anywhere in the SDK nor implemented

## [v0.12.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.12.0)

Expand Down
19 changes: 19 additions & 0 deletions core/appmodule/environment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package appmodule

import (
"cosmossdk.io/core/branch"
"cosmossdk.io/core/event"
"cosmossdk.io/core/gas"
"cosmossdk.io/core/header"
"cosmossdk.io/core/store"
)

// Environment is used to get all services to their respective module
type Environment struct {
BranchService branch.Service
EventService event.Service
GasService gas.Service
HeaderService header.Service
KVStoreService store.KVStoreService
MemStoreService store.MemoryStoreService
}
32 changes: 0 additions & 32 deletions core/appmodule/event.go

This file was deleted.

17 changes: 0 additions & 17 deletions core/appmodule/event_test.go

This file was deleted.

10 changes: 7 additions & 3 deletions core/event/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,27 @@ type Manager interface {
// Callers SHOULD assume that these events may be included in consensus. These events
// MUST be emitted deterministically and adding, removing or changing these events SHOULD
// be considered state-machine breaking.
Emit(ctx context.Context, event protoiface.MessageV1) error
Emit(event protoiface.MessageV1) error

// EmitKV emits an event based on an event and kv-pair attributes.
//
// These events will not be part of consensus and adding, removing or changing these events is
// not a state-machine breaking change.
EmitKV(ctx context.Context, eventType string, attrs ...Attribute) error
EmitKV(eventType string, attrs ...Attribute) error

// EmitNonConsensus emits events represented as a protobuf message (as described in ADR 032), without
// including it in blockchain consensus.
//
// These events will not be part of consensus and adding, removing or changing events is
// not a state-machine breaking change.
EmitNonConsensus(ctx context.Context, event protoiface.MessageV1) error
EmitNonConsensus(event protoiface.MessageV1) error
}

// KVEventAttribute is a kv-pair event attribute.
type Attribute struct {
Key, Value string
}

func NewAttribute(key, value string) Attribute {
return Attribute{Key: key, Value: value}
}
13 changes: 4 additions & 9 deletions core/gas/meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,10 @@ type Service interface {
WithBlockGasMeter(ctx context.Context, meter Meter) context.Context
}

// Meter represents a gas meter.
// Meter represents a gas meter for modules consumption
type Meter interface {
GasConsumed() Gas
GasConsumedToLimit() Gas
GasRemaining() Gas
Consume(amount Gas, descriptor string)
Refund(amount Gas, descriptor string)
Remaining() Gas
Limit() Gas
ConsumeGas(amount Gas, descriptor string)
RefundGas(amount Gas, descriptor string)
IsPastLimit() bool
IsOutOfGas() bool
String() string
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# ADR 070: Un-Ordered Transaction Inclusion
# ADR 070: Unordered Transactions

## Changelog

* Dec 4, 2023: Initial Draft (@yihuang, @tac0turtle, @alexanderbez)
* Jan 30, 2024: Include section on deterministic transaction encoding

## Status

Expand Down Expand Up @@ -49,15 +50,15 @@ and limit the size of the dictionary.
message TxBody {
...
bool unordered = 4;
bool unordered = 4;
}
```

### Replay Protection

In order to provide replay protection, a user should ensure that the transaction's
TTL value is relatively short-lived but long enough to provide enough time to be
included in a block, e.g. ~H+50.
included in a block, e.g. ~H+50.

We facilitate this by storing the transaction's hash in a durable map, `UnorderedTxManager`,
to prevent duplicates, i.e. replay attacks. Upon transaction ingress during `CheckTx`,
Expand Down Expand Up @@ -107,7 +108,7 @@ func NewUnorderedTxManager() *UnorderedTxManager {
blockCh: make(chan uint64, 16),
txHashes: make(map[TxHash]uint64),
}

return m
}

Expand Down Expand Up @@ -182,13 +183,13 @@ func (m *UnorderedTxManager) purgeLoop() error {
// channel closed
break
}

latest := *blocks[len(blocks)-1]
hashes := m.expired(latest)
if len(hashes) > 0 {
m.purge(hashes)
}

// avoid burning cpu in catching up phase
time.Sleep(PurgeLoopSleepMS * time.Millisecond)
}
Expand Down Expand Up @@ -274,9 +275,17 @@ func (d *DedupTxDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool,
}
```

### `OnNewBlock`
### Transaction Hashes

It is absolutely vital that transaction hashes are deterministic, i.e. transaction
encoding is not malleable. If a given transaction, which is otherwise valid, can
be encoded to produce different hashes, which reflect the same valid transaction,
then a duplicate unordered transaction can be submitted and included in a block.

Wire the `OnNewBlock` method of `UnorderedTxManager` into the BaseApp's ABCI `Commit` event.
In order to prevent this, transactions should be encoded in a deterministic manner.
[ADR-027](./adr-027-deterministic-protobuf-serialization.md) provides such a mechanism.
However, it is important to note that the way a transaction is signed should ensure
ADR-027 is followed. E.g. we want to avoid Amino signing.

### State Management

Expand All @@ -303,7 +312,8 @@ Alternatively, we can write all the transactions to consensus state.

### Negative

* Start up overhead to scan historical blocks.
* Requires additional storage overhead and management of processed unordered
transactions that exist outside of consensus state.

## References

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipus
github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/bufbuild/protocompile v0.7.1 h1:Kd8fb6EshOHXNNRtYAmLAwy/PotlyFoN0iMbuwGNh0M=
github.com/bufbuild/protocompile v0.7.1/go.mod h1:+Etjg4guZoAqzVk2czwEQP12yaxLJ8DxuqCJ9qHdH94=
github.com/bufbuild/protocompile v0.8.0 h1:9Kp1q6OkS9L4nM3FYbr8vlJnEwtbpDPQlQOVXfR+78s=
github.com/bufbuild/protocompile v0.8.0/go.mod h1:+Etjg4guZoAqzVk2czwEQP12yaxLJ8DxuqCJ9qHdH94=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s=
github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
Expand Down Expand Up @@ -395,8 +395,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/jhump/protoreflect v1.15.4 h1:mrwJhfQGGljwvR/jPEocli8KA6G9afbQpH8NY2wORcI=
github.com/jhump/protoreflect v1.15.4/go.mod h1:2B+zwrnMY3TTIqEK01OG/d3pyUycQBfDf+bx8fE2DNg=
github.com/jhump/protoreflect v1.15.5 h1:Y9eEjV3vwdX57VV3uuxtknBRxA2vQ3LOifKOOC2n5ec=
github.com/jhump/protoreflect v1.15.5/go.mod h1:jCHoyYQIJnaabEYnbGwyo9hUqfyUMTbJw/tAut5t97E=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U=
github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ=
Expand Down
18 changes: 13 additions & 5 deletions proto/cosmos/gov/v1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,12 @@ message Params {
//
// Since: x/gov v1.0.0
string optimistic_rejected_threshold = 19 [(cosmos_proto.scalar) = "cosmos.Dec"];

// yes_quorum defines the minimum percentage of Yes votes in quroum for proposal to pass.
// Default value: 0 (disabled).
//
// Since: x/gov v1.0.0
string yes_quorum = 20 [(cosmos_proto.scalar) = "cosmos.Dec"];
}

// MessageBasedParams defines the parameters of specific messages in a proposal.
Expand All @@ -361,14 +367,16 @@ message MessageBasedParams {
// Duration of the voting period.
google.protobuf.Duration voting_period = 1 [(gogoproto.stdduration) = true];

// Minimum percentage of total stake needed to vote for a result to be
// considered valid.
// Minimum percentage of total stake needed to vote for a result to be considered valid.
string quorum = 2 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum proportion of Yes votes for proposal to pass.
// yes_quorum defines the minimum percentage of Yes votes in quroum for proposal to pass.
// If zero then the yes_quorum is disabled.
string yes_quorum = 20 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum proportion of Yes votes for proposal to pass.
string threshold = 3 [(cosmos_proto.scalar) = "cosmos.Dec"];

// Minimum value of Veto votes to Total votes ratio for proposal to be
// vetoed.
// Minimum value of Veto votes to Total votes ratio for proposal to be vetoed.
string veto_threshold = 4 [(cosmos_proto.scalar) = "cosmos.Dec"];
}
18 changes: 18 additions & 0 deletions runtime/environment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package runtime

import (
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/store"
)

// NewEnvironment creates a new environment for the application
// if memstoreservice is needed, it can be added to the environment: environment.MemStoreService = memstoreservice
func NewEnvironment(kvService store.KVStoreService) appmodule.Environment {
return appmodule.Environment{
EventService: EventService{},
HeaderService: HeaderService{},
BranchService: BranchService{},
GasService: GasService{},
KVStoreService: kvService,
}
}
Loading

0 comments on commit 4712842

Please sign in to comment.