Skip to content

Commit b85671d

Browse files
authored
Merge pull request #465 from scrtlabs/secret-0.50.x-add-implicit-hash
draft: cron-module, added implicit hash to the header
2 parents ca38989 + 07f1be1 commit b85671d

File tree

3 files changed

+159
-133
lines changed

3 files changed

+159
-133
lines changed

baseapp/abci.go

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package baseapp
22

33
import (
44
"context"
5+
"crypto/sha256"
6+
"encoding/hex"
57
"fmt"
68
"sort"
79
"strings"
@@ -45,8 +47,10 @@ func (app *BaseApp) InitChain(req *abci.RequestInitChain) (*abci.ResponseInitCha
4547

4648
// On a new chain, we consider the init chain block height as 0, even though
4749
// req.InitialHeight is 1 by default.
48-
initHeader := cmtproto.Header{ChainID: req.ChainId, Time: req.Time}
49-
app.logger.Info("InitChain", "initialHeight", req.InitialHeight, "chainID", req.ChainId)
50+
emptyHash := sha256.Sum256([]byte{})
51+
52+
initHeader := cmtproto.Header{ChainID: req.ChainId, Time: req.Time, ImplicitHash: emptyHash[:]}
53+
app.logger.Info("InitChain", "initialHeight", req.InitialHeight, "chainID", req.ChainId, "emptyHash", hex.EncodeToString(emptyHash[:]))
5054

5155
// Set the initial height, which will be used to determine if we are proposing
5256
// or processing the first block or not.
@@ -384,12 +388,22 @@ func (app *BaseApp) PrepareProposal(req *abci.RequestPrepareProposal) (resp *abc
384388
// Always reset state given that PrepareProposal can timeout and be called
385389
// again in a subsequent round.
386390
header := cmtproto.Header{
391+
Version: req.Version,
387392
ChainID: app.chainID,
388393
Height: req.Height,
389394
Time: req.Time,
390-
ProposerAddress: req.ProposerAddress,
395+
LastBlockId: req.LastBlockId,
396+
LastCommitHash: req.LastCommitHash,
397+
DataHash: req.DataHash,
398+
ValidatorsHash: req.ValidatorsHash,
391399
NextValidatorsHash: req.NextValidatorsHash,
400+
ConsensusHash: req.ConsensusHash,
392401
AppHash: app.LastCommitID().Hash,
402+
LastResultsHash: req.LastResultsHash,
403+
EvidenceHash: req.EvidenceHash,
404+
ProposerAddress: req.ProposerAddress,
405+
EncryptedRandom: req.EncryptedRandom,
406+
ImplicitHash: req.ImplicitHash,
393407
}
394408
app.setState(execModePrepareProposal, header)
395409

@@ -468,12 +482,22 @@ func (app *BaseApp) ProcessProposal(req *abci.RequestProcessProposal) (resp *abc
468482
// Always reset state given that ProcessProposal can timeout and be called
469483
// again in a subsequent round.
470484
header := cmtproto.Header{
485+
Version: req.Version,
471486
ChainID: app.chainID,
472487
Height: req.Height,
473488
Time: req.Time,
474-
ProposerAddress: req.ProposerAddress,
489+
LastBlockId: req.LastBlockId,
490+
LastCommitHash: req.LastCommitHash,
491+
DataHash: req.DataHash,
492+
ValidatorsHash: req.ValidatorsHash,
475493
NextValidatorsHash: req.NextValidatorsHash,
494+
ConsensusHash: req.ConsensusHash,
476495
AppHash: app.LastCommitID().Hash,
496+
LastResultsHash: req.LastResultsHash,
497+
EvidenceHash: req.EvidenceHash,
498+
ProposerAddress: req.ProposerAddress,
499+
EncryptedRandom: req.EncryptedRandom,
500+
ImplicitHash: req.ImplicitHash,
477501
}
478502
app.setState(execModeProcessProposal, header)
479503

@@ -561,7 +585,7 @@ func (app *BaseApp) ExtendVote(_ context.Context, req *abci.RequestExtendVote) (
561585
if req.Height == app.initialHeight {
562586
ctx, _ = app.finalizeBlockState.Context().CacheContext()
563587
} else {
564-
emptyHeader := cmtproto.Header{ChainID: app.chainID, Height: req.Height}
588+
emptyHeader := cmtproto.Header{ChainID: app.chainID, Height: req.Height, ImplicitHash: req.ImplicitHash}
565589
ms := app.cms.CacheMultiStore()
566590
ctx = sdk.NewContext(ms, emptyHeader, false, app.logger).WithStreamingManager(app.streamingManager)
567591
}
@@ -714,14 +738,22 @@ func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.Request
714738
}
715739

716740
header := cmtproto.Header{
741+
Version: req.Version,
717742
ChainID: app.chainID,
718743
Height: req.Height,
719744
Time: req.Time,
720-
ProposerAddress: req.ProposerAddress,
745+
LastBlockId: req.LastBlockId,
746+
LastCommitHash: req.LastCommitHash,
747+
DataHash: req.DataHash,
748+
ValidatorsHash: req.ValidatorsHash,
721749
NextValidatorsHash: req.NextValidatorsHash,
750+
ConsensusHash: req.ConsensusHash,
722751
AppHash: app.LastCommitID().Hash,
723-
DataHash: txs.Hash(),
752+
LastResultsHash: req.LastResultsHash,
753+
EvidenceHash: req.EvidenceHash,
754+
ProposerAddress: req.ProposerAddress,
724755
EncryptedRandom: req.EncryptedRandom,
756+
ImplicitHash: req.ImplicitHash,
725757
}
726758

727759
// finalizeBlockState should be set on InitChain or ProcessProposal. If it is

go.mod

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
go 1.21
1+
go 1.22.11
2+
3+
toolchain go1.24.0
24

35
module github.com/cosmos/cosmos-sdk
46

5-
replace github.com/cometbft/cometbft => github.com/scrtlabs/tendermint v0.38.9-secret.3
7+
replace github.com/cometbft/cometbft => github.com/scrtlabs/tendermint v0.38.17-secret-5
68

79
require (
810
cosmossdk.io/api v0.7.6
@@ -28,7 +30,7 @@ require (
2830
github.com/cosmos/gogogateway v1.2.0
2931
github.com/cosmos/gogoproto v1.7.0
3032
github.com/cosmos/ledger-cosmos-go v0.14.0
31-
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
33+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
3234
github.com/golang/mock v1.6.0
3335
github.com/golang/protobuf v1.5.4
3436
github.com/google/go-cmp v0.6.0
@@ -46,21 +48,21 @@ require (
4648
github.com/magiconair/properties v1.8.7
4749
github.com/manifoldco/promptui v0.9.0
4850
github.com/mattn/go-isatty v0.0.20
49-
github.com/prometheus/client_golang v1.20.1
50-
github.com/prometheus/common v0.55.0
51+
github.com/prometheus/client_golang v1.20.5
52+
github.com/prometheus/common v0.62.0
5153
github.com/rs/zerolog v1.33.0
5254
github.com/spf13/cast v1.7.1
5355
github.com/spf13/cobra v1.8.1
5456
github.com/spf13/pflag v1.0.5
5557
github.com/spf13/viper v1.19.0
5658
github.com/stretchr/testify v1.10.0
5759
github.com/tendermint/go-amino v0.16.0
58-
golang.org/x/crypto v0.27.0
59-
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0
60-
golang.org/x/sync v0.8.0
61-
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
62-
google.golang.org/grpc v1.67.1
63-
google.golang.org/protobuf v1.35.1
60+
golang.org/x/crypto v0.32.0
61+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
62+
golang.org/x/sync v0.10.0
63+
google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a
64+
google.golang.org/grpc v1.70.0
65+
google.golang.org/protobuf v1.36.4
6466
gotest.tools/v3 v3.5.1
6567
pgregory.net/rapid v1.1.0
6668
sigs.k8s.io/yaml v1.4.0
@@ -72,23 +74,21 @@ require (
7274
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
7375
github.com/DataDog/zstd v1.5.5 // indirect
7476
github.com/beorn7/perks v1.0.1 // indirect
75-
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
7677
github.com/bufbuild/protocompile v0.6.0 // indirect
7778
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
78-
github.com/cespare/xxhash v1.1.0 // indirect
7979
github.com/cespare/xxhash/v2 v2.3.0 // indirect
8080
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
8181
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
8282
github.com/cockroachdb/pebble v1.1.2 // indirect
8383
github.com/cockroachdb/redact v1.1.5 // indirect
8484
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
85-
github.com/cometbft/cometbft-db v0.11.0 // indirect
85+
github.com/cometbft/cometbft-db v0.14.1 // indirect
8686
github.com/cosmos/iavl v1.2.2 // indirect
8787
github.com/cosmos/ics23/go v0.11.0 // indirect
8888
github.com/danieljoos/wincred v1.1.2 // indirect
8989
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
9090
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
91-
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
91+
github.com/dgraph-io/badger/v4 v4.2.0 // indirect
9292
github.com/dgraph-io/ristretto v0.1.1 // indirect
9393
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
9494
github.com/dustin/go-humanize v1.0.1 // indirect
@@ -98,15 +98,17 @@ require (
9898
github.com/felixge/httpsnoop v1.0.4 // indirect
9999
github.com/fsnotify/fsnotify v1.7.0 // indirect
100100
github.com/getsentry/sentry-go v0.27.0 // indirect
101-
github.com/go-kit/kit v0.12.0 // indirect
101+
github.com/go-kit/kit v0.13.0 // indirect
102102
github.com/go-kit/log v0.2.1 // indirect
103103
github.com/go-logfmt/logfmt v0.6.0 // indirect
104104
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
105105
github.com/gogo/googleapis v1.4.1 // indirect
106106
github.com/gogo/protobuf v1.3.2 // indirect
107-
github.com/golang/glog v1.2.2 // indirect
107+
github.com/golang/glog v1.2.3 // indirect
108+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
108109
github.com/golang/snappy v0.0.4 // indirect
109110
github.com/google/btree v1.1.3 // indirect
111+
github.com/google/flatbuffers v1.12.1 // indirect
110112
github.com/google/orderedcode v0.0.1 // indirect
111113
github.com/gorilla/websocket v1.5.3 // indirect
112114
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
@@ -122,11 +124,10 @@ require (
122124
github.com/klauspost/compress v1.17.9 // indirect
123125
github.com/kr/pretty v0.3.1 // indirect
124126
github.com/kr/text v0.2.0 // indirect
125-
github.com/lib/pq v1.10.7 // indirect
126-
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
127+
github.com/lib/pq v1.10.9 // indirect
127128
github.com/linxGnu/grocksdb v1.8.14 // indirect
128129
github.com/mattn/go-colorable v0.1.13 // indirect
129-
github.com/minio/highwayhash v1.0.2 // indirect
130+
github.com/minio/highwayhash v1.0.3 // indirect
130131
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
131132
github.com/mitchellh/mapstructure v1.5.0 // indirect
132133
github.com/mtibben/percent v0.2.1 // indirect
@@ -135,7 +136,7 @@ require (
135136
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
136137
github.com/oklog/run v1.1.0 // indirect
137138
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
138-
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect
139+
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
139140
github.com/pkg/errors v0.9.1 // indirect
140141
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
141142
github.com/prometheus/client_model v0.6.1 // indirect
@@ -145,23 +146,24 @@ require (
145146
github.com/rs/cors v1.11.1 // indirect
146147
github.com/sagikazarmark/locafero v0.4.0 // indirect
147148
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
148-
github.com/sasha-s/go-deadlock v0.3.1 // indirect
149-
github.com/scrtlabs/tm-secret-enclave v1.11.8 // indirect
149+
github.com/sasha-s/go-deadlock v0.3.5 // indirect
150+
github.com/scrtlabs/tm-secret-enclave v1.13.0 // indirect
150151
github.com/sourcegraph/conc v0.3.0 // indirect
151152
github.com/spf13/afero v1.11.0 // indirect
152153
github.com/subosito/gotenv v1.6.0 // indirect
153154
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
154155
github.com/tidwall/btree v1.7.0 // indirect
155156
github.com/zondax/hid v0.9.2 // indirect
156157
github.com/zondax/ledger-go v0.14.3 // indirect
157-
go.etcd.io/bbolt v1.3.10 // indirect
158+
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
159+
go.opencensus.io v0.24.0 // indirect
158160
go.uber.org/multierr v1.10.0 // indirect
159-
golang.org/x/net v0.29.0 // indirect
160-
golang.org/x/sys v0.25.0 // indirect
161-
golang.org/x/term v0.24.0 // indirect
162-
golang.org/x/text v0.18.0 // indirect
161+
golang.org/x/net v0.34.0 // indirect
162+
golang.org/x/sys v0.29.0 // indirect
163+
golang.org/x/term v0.28.0 // indirect
164+
golang.org/x/text v0.21.0 // indirect
163165
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
164-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
166+
google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect
165167
gopkg.in/ini.v1 v1.67.0 // indirect
166168
gopkg.in/yaml.v3 v3.0.1 // indirect
167169
nhooyr.io/websocket v1.8.6 // indirect

0 commit comments

Comments
 (0)