Skip to content

Commit

Permalink
Merge branch 'master' into add-float64-to-int
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 authored May 26, 2021
2 parents abd6514 + 151d6c5 commit 5da5c75
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ if input key is empty, or input data contains empty key.

### Improvements

* (baseapp, types) [#\9390](https://github.com/cosmos/cosmos-sdk/pull/9390) Add current block header hash to `Context`
* (x/bank) [\#8614](https://github.com/cosmos/cosmos-sdk/issues/8614) Add `Name` and `Symbol` fields to denom metadata
* (x/auth) [\#8522](https://github.com/cosmos/cosmos-sdk/pull/8522) Allow to query all stored accounts
* (crypto/types) [\#8600](https://github.com/cosmos/cosmos-sdk/pull/8600) `CompactBitArray`: optimize the `NumTrueBitsBefore` method and add an `Equal` method.
Expand Down
12 changes: 7 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ If you open a PR on the Cosmos SDK, it is mandatory to update the relevant docum
- If your changes relate to the core of the CLI or Light-client (not specifically to module's CLI/Rest), please modify the `docs/interfaces/` folder.
- If your changes relate to a module, please update the module's spec in `x/moduleName/docs/spec/`.

When writing documentation, follow the [Documentation Writing Guidelines](./docs/DOC_WRITING_GUIDELINES.md).

## Forking

Please note that Go requires code to live under absolute paths, which complicates forking.
Expand Down Expand Up @@ -166,7 +168,7 @@ For example, in vscode your `.vscode/settings.json` should look like:

## Testing

Tests can be ran by running `make test` at the top level of the SDK repository.
Tests can be ran by running `make test` at the top level of the SDK repository.

We expect tests to use `require` or `assert` rather than `t.Skip` or `t.Fail`,
unless there is a reason to do otherwise.
Expand Down Expand Up @@ -204,7 +206,7 @@ The SDK utilizes [semantic versioning](https://semver.org/).
Ensure that you base and target your PR on the `master` branch.
All feature additions should be targeted against `master`. Bug fixes for an outstanding release candidate
should be targeted against the release candidate branch.
should be targeted against the release candidate branch.
### Development Procedure
Expand Down Expand Up @@ -324,7 +326,7 @@ the community of this project.
## Concept & Release Approval Process
The process for how Cosmos SDK maintainers take features and ADRs from concept to release
is broken up into three distinct stages: **Strategy Discovery**, **Concept Approval**, and
is broken up into three distinct stages: **Strategy Discovery**, **Concept Approval**, and
**Implementation & Release Approval**
Expand Down Expand Up @@ -352,7 +354,7 @@ If an individual Pull Request for an ADR needs more time than 2 weeks to reach r
in current state (`Draft` or `Proposed`), with its contents updated to summarize
the current state of its discussion.
If an ADR is taking longer than 4 weeks to reach a final conclusion, the **Concept Approval Committee**
If an ADR is taking longer than 4 weeks to reach a final conclusion, the **Concept Approval Committee**
should convene to rectify the situation by either:
- unanimously setting a new time bound period for this ADR
- making changes to the Concept Approval Process (as outlined here)
Expand Down Expand Up @@ -396,7 +398,7 @@ well as for PRs made as part of a release process:
* Code reviewers should ensure the PR does exactly what the ADR said it should
* Code reviewers should have more senior engineering capability
* 1/2 approval is required from the **primary repo maintainers** in `CODEOWNERS`
*Note: For any major or minor release series denoted as a "Stable Release" (e.g. v0.39 "Launchpad"), a separate release
committee is often established. Stable Releases, and their corresponding release committees are documented
separately in [STABLE_RELEASES.md](./STABLE_RELEASES.md)*
3 changes: 2 additions & 1 deletion baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg
// by InitChain. Context is now updated with Header information.
app.deliverState.ctx = app.deliverState.ctx.
WithBlockHeader(req.Header).
WithBlockHeight(req.Header.Height)
WithBlockHeight(req.Header.Height).
WithHeaderHash(req.Hash)
}

// add block gas meter
Expand Down
16 changes: 16 additions & 0 deletions docs/DOC_WRITING_GUIDELINES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Documentation Writing Guidelines

## Best Practices

+ Check the spelling and grammar, even if you have to copy and paste from an external source.
+ Use simple sentences. Easy-to-read sentences mean the reader can quickly use the guidance you share.
+ Try to express your thoughts in a concise and clean way.
+ Don't abuse `code` format when writing in plain English.
+ Follow Google developer documentation [style guide](https://developers.google.com/style).
+ Check the meaning of words in Microsoft's [A-Z word list and term collections](https://docs.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/term-collections/accessibility-terms) (use the search input!).



## Technical Writing Course

Google provides a free [course](https://developers.google.com/tech-writing/overview) for technical writing.
27 changes: 17 additions & 10 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/gogo/protobuf/proto"
abci "github.com/tendermint/tendermint/abci/types"
tmbytes "github.com/tendermint/tendermint/libs/bytes"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

Expand All @@ -25,6 +26,7 @@ type Context struct {
ctx context.Context
ms MultiStore
header tmproto.Header
headerHash tmbytes.HexBytes
chainID string
txBytes []byte
logger log.Logger
Expand Down Expand Up @@ -63,6 +65,13 @@ func (c Context) BlockHeader() tmproto.Header {
return *msg
}

// HeaderHash returns a copy of the header hash obtained during abci.RequestBeginBlock
func (c Context) HeaderHash() tmbytes.HexBytes {
hash := make([]byte, len(c.headerHash))
copy(hash, c.headerHash)
return hash
}

func (c Context) ConsensusParams() *abci.ConsensusParams {
return proto.Clone(c.consParams).(*abci.ConsensusParams)
}
Expand Down Expand Up @@ -104,6 +113,15 @@ func (c Context) WithBlockHeader(header tmproto.Header) Context {
return c
}

// WithHeaderHash returns a Context with an updated tendermint block header hash.
func (c Context) WithHeaderHash(hash []byte) Context {
temp := make([]byte, len(hash))
copy(temp, hash)

c.headerHash = temp
return c
}

// WithBlockTime returns a Context with an updated tendermint block header time in UTC time
func (c Context) WithBlockTime(newTime time.Time) Context {
newHeader := c.BlockHeader()
Expand Down
5 changes: 4 additions & 1 deletion types/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func (s *contextTestSuite) TestContextWithCustom() {
meter := types.NewGasMeter(10000)
blockGasMeter := types.NewGasMeter(20000)
minGasPrices := types.DecCoins{types.NewInt64DecCoin("feetoken", 1)}
headerHash := []byte("headerHash")

ctx = types.NewContext(nil, header, ischeck, logger)
s.Require().Equal(header, ctx.BlockHeader())
Expand All @@ -103,7 +104,8 @@ func (s *contextTestSuite) TestContextWithCustom() {
WithVoteInfos(voteinfos).
WithGasMeter(meter).
WithMinGasPrices(minGasPrices).
WithBlockGasMeter(blockGasMeter)
WithBlockGasMeter(blockGasMeter).
WithHeaderHash(headerHash)
s.Require().Equal(height, ctx.BlockHeight())
s.Require().Equal(chainid, ctx.ChainID())
s.Require().Equal(ischeck, ctx.IsCheckTx())
Expand All @@ -113,6 +115,7 @@ func (s *contextTestSuite) TestContextWithCustom() {
s.Require().Equal(meter, ctx.GasMeter())
s.Require().Equal(minGasPrices, ctx.MinGasPrices())
s.Require().Equal(blockGasMeter, ctx.BlockGasMeter())
s.Require().Equal(headerHash, ctx.HeaderHash().Bytes())
s.Require().False(ctx.WithIsCheckTx(false).IsCheckTx())

// test IsReCheckTx
Expand Down

0 comments on commit 5da5c75

Please sign in to comment.