Skip to content

Commit 5da5c75

Browse files
authored
Merge branch 'master' into add-float64-to-int
2 parents abd6514 + 151d6c5 commit 5da5c75

File tree

7 files changed

+65
-17
lines changed

7 files changed

+65
-17
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ if input key is empty, or input data contains empty key.
127127

128128
### Improvements
129129

130+
* (baseapp, types) [#\9390](https://github.com/cosmos/cosmos-sdk/pull/9390) Add current block header hash to `Context`
130131
* (x/bank) [\#8614](https://github.com/cosmos/cosmos-sdk/issues/8614) Add `Name` and `Symbol` fields to denom metadata
131132
* (x/auth) [\#8522](https://github.com/cosmos/cosmos-sdk/pull/8522) Allow to query all stored accounts
132133
* (crypto/types) [\#8600](https://github.com/cosmos/cosmos-sdk/pull/8600) `CompactBitArray`: optimize the `NumTrueBitsBefore` method and add an `Equal` method.

CONTRIBUTING.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ If you open a PR on the Cosmos SDK, it is mandatory to update the relevant docum
9797
- 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.
9898
- If your changes relate to a module, please update the module's spec in `x/moduleName/docs/spec/`.
9999

100+
When writing documentation, follow the [Documentation Writing Guidelines](./docs/DOC_WRITING_GUIDELINES.md).
101+
100102
## Forking
101103

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

167169
## Testing
168170

169-
Tests can be ran by running `make test` at the top level of the SDK repository.
171+
Tests can be ran by running `make test` at the top level of the SDK repository.
170172

171173
We expect tests to use `require` or `assert` rather than `t.Skip` or `t.Fail`,
172174
unless there is a reason to do otherwise.
@@ -204,7 +206,7 @@ The SDK utilizes [semantic versioning](https://semver.org/).
204206
Ensure that you base and target your PR on the `master` branch.
205207
206208
All feature additions should be targeted against `master`. Bug fixes for an outstanding release candidate
207-
should be targeted against the release candidate branch.
209+
should be targeted against the release candidate branch.
208210
209211
### Development Procedure
210212
@@ -324,7 +326,7 @@ the community of this project.
324326
## Concept & Release Approval Process
325327
326328
The process for how Cosmos SDK maintainers take features and ADRs from concept to release
327-
is broken up into three distinct stages: **Strategy Discovery**, **Concept Approval**, and
329+
is broken up into three distinct stages: **Strategy Discovery**, **Concept Approval**, and
328330
**Implementation & Release Approval**
329331
330332
@@ -352,7 +354,7 @@ If an individual Pull Request for an ADR needs more time than 2 weeks to reach r
352354
in current state (`Draft` or `Proposed`), with its contents updated to summarize
353355
the current state of its discussion.
354356
355-
If an ADR is taking longer than 4 weeks to reach a final conclusion, the **Concept Approval Committee**
357+
If an ADR is taking longer than 4 weeks to reach a final conclusion, the **Concept Approval Committee**
356358
should convene to rectify the situation by either:
357359
- unanimously setting a new time bound period for this ADR
358360
- making changes to the Concept Approval Process (as outlined here)
@@ -396,7 +398,7 @@ well as for PRs made as part of a release process:
396398
* Code reviewers should ensure the PR does exactly what the ADR said it should
397399
* Code reviewers should have more senior engineering capability
398400
* 1/2 approval is required from the **primary repo maintainers** in `CODEOWNERS`
399-
401+
400402
*Note: For any major or minor release series denoted as a "Stable Release" (e.g. v0.39 "Launchpad"), a separate release
401403
committee is often established. Stable Releases, and their corresponding release committees are documented
402404
separately in [STABLE_RELEASES.md](./STABLE_RELEASES.md)*

baseapp/abci.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg
164164
// by InitChain. Context is now updated with Header information.
165165
app.deliverState.ctx = app.deliverState.ctx.
166166
WithBlockHeader(req.Header).
167-
WithBlockHeight(req.Header.Height)
167+
WithBlockHeight(req.Header.Height).
168+
WithHeaderHash(req.Hash)
168169
}
169170

170171
// add block gas meter

docs/DOC_WRITING_GUIDELINES.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Documentation Writing Guidelines
2+
3+
## Best Practices
4+
5+
+ Check the spelling and grammar, even if you have to copy and paste from an external source.
6+
+ Use simple sentences. Easy-to-read sentences mean the reader can quickly use the guidance you share.
7+
+ Try to express your thoughts in a concise and clean way.
8+
+ Don't abuse `code` format when writing in plain English.
9+
+ Follow Google developer documentation [style guide](https://developers.google.com/style).
10+
+ 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!).
11+
12+
13+
14+
## Technical Writing Course
15+
16+
Google provides a free [course](https://developers.google.com/tech-writing/overview) for technical writing.

docs/package-lock.json

+17-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/context.go

+18
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/gogo/protobuf/proto"
88
abci "github.com/tendermint/tendermint/abci/types"
9+
tmbytes "github.com/tendermint/tendermint/libs/bytes"
910
"github.com/tendermint/tendermint/libs/log"
1011
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
1112

@@ -25,6 +26,7 @@ type Context struct {
2526
ctx context.Context
2627
ms MultiStore
2728
header tmproto.Header
29+
headerHash tmbytes.HexBytes
2830
chainID string
2931
txBytes []byte
3032
logger log.Logger
@@ -63,6 +65,13 @@ func (c Context) BlockHeader() tmproto.Header {
6365
return *msg
6466
}
6567

68+
// HeaderHash returns a copy of the header hash obtained during abci.RequestBeginBlock
69+
func (c Context) HeaderHash() tmbytes.HexBytes {
70+
hash := make([]byte, len(c.headerHash))
71+
copy(hash, c.headerHash)
72+
return hash
73+
}
74+
6675
func (c Context) ConsensusParams() *abci.ConsensusParams {
6776
return proto.Clone(c.consParams).(*abci.ConsensusParams)
6877
}
@@ -104,6 +113,15 @@ func (c Context) WithBlockHeader(header tmproto.Header) Context {
104113
return c
105114
}
106115

116+
// WithHeaderHash returns a Context with an updated tendermint block header hash.
117+
func (c Context) WithHeaderHash(hash []byte) Context {
118+
temp := make([]byte, len(hash))
119+
copy(temp, hash)
120+
121+
c.headerHash = temp
122+
return c
123+
}
124+
107125
// WithBlockTime returns a Context with an updated tendermint block header time in UTC time
108126
func (c Context) WithBlockTime(newTime time.Time) Context {
109127
newHeader := c.BlockHeader()

types/context_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ func (s *contextTestSuite) TestContextWithCustom() {
9292
meter := types.NewGasMeter(10000)
9393
blockGasMeter := types.NewGasMeter(20000)
9494
minGasPrices := types.DecCoins{types.NewInt64DecCoin("feetoken", 1)}
95+
headerHash := []byte("headerHash")
9596

9697
ctx = types.NewContext(nil, header, ischeck, logger)
9798
s.Require().Equal(header, ctx.BlockHeader())
@@ -103,7 +104,8 @@ func (s *contextTestSuite) TestContextWithCustom() {
103104
WithVoteInfos(voteinfos).
104105
WithGasMeter(meter).
105106
WithMinGasPrices(minGasPrices).
106-
WithBlockGasMeter(blockGasMeter)
107+
WithBlockGasMeter(blockGasMeter).
108+
WithHeaderHash(headerHash)
107109
s.Require().Equal(height, ctx.BlockHeight())
108110
s.Require().Equal(chainid, ctx.ChainID())
109111
s.Require().Equal(ischeck, ctx.IsCheckTx())
@@ -113,6 +115,7 @@ func (s *contextTestSuite) TestContextWithCustom() {
113115
s.Require().Equal(meter, ctx.GasMeter())
114116
s.Require().Equal(minGasPrices, ctx.MinGasPrices())
115117
s.Require().Equal(blockGasMeter, ctx.BlockGasMeter())
118+
s.Require().Equal(headerHash, ctx.HeaderHash().Bytes())
116119
s.Require().False(ctx.WithIsCheckTx(false).IsCheckTx())
117120

118121
// test IsReCheckTx

0 commit comments

Comments
 (0)