Skip to content

Commit c613ced

Browse files
committed
wrap submitBlockSignatures call
1 parent 539bd03 commit c613ced

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

go-cosmwasm/api/lib.go

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,31 @@ func HealthCheck() ([]byte, error) {
4848
}
4949

5050
func SubmitBlockSignatures(header []byte, commit []byte, txs []byte, encRandom []byte /* valSet []byte, nextValSet []byte */) ([]byte, []byte, error) {
51+
recorder := GetRecorder()
52+
53+
// Create combined input for recording/replay
54+
input := make([]byte, 0, len(header)+len(commit)+len(txs)+len(encRandom))
55+
input = append(input, header...)
56+
input = append(input, commit...)
57+
input = append(input, txs...)
58+
input = append(input, encRandom...)
59+
60+
// In replay mode, return recorded data
61+
if recorder.IsReplayMode() {
62+
if output, err, found := recorder.Replay("SubmitBlockSignatures", input); found {
63+
if err != nil {
64+
return nil, nil, err
65+
}
66+
// Output is 64 bytes: [32 bytes random][32 bytes validator_set_evidence]
67+
if len(output) == 64 {
68+
return output[:32], output[32:], nil
69+
}
70+
return nil, nil, fmt.Errorf("SubmitBlockSignatures: invalid recorded data (expected 64 bytes, got %d)", len(output))
71+
}
72+
return nil, nil, fmt.Errorf("SubmitBlockSignatures: no recorded data found (replay mode)")
73+
}
74+
75+
// SGX mode: call the actual enclave
5176
errmsg := C.Buffer{}
5277
spidSlice := sendSlice(header)
5378
defer freeAfterSend(spidSlice)
@@ -62,7 +87,19 @@ func SubmitBlockSignatures(header []byte, commit []byte, txs []byte, encRandom [
6287
if err != nil {
6388
return nil, nil, errorWithMessage(err, errmsg)
6489
}
65-
return receiveVector(res.buf1), receiveVector(res.buf2), nil
90+
91+
buf1 := receiveVector(res.buf1)
92+
buf2 := receiveVector(res.buf2)
93+
94+
// Record the result - 64 bytes: [32 bytes buf1][32 bytes buf2]
95+
output := make([]byte, 64)
96+
copy(output[:32], buf1)
97+
copy(output[32:], buf2)
98+
if recordErr := recorder.Record("SubmitBlockSignatures", input, output, nil); recordErr != nil {
99+
fmt.Printf("[SubmitBlockSignatures] Warning: failed to record: %v\n", recordErr)
100+
}
101+
102+
return buf1, buf2, nil
66103
}
67104

68105
func SubmitValidatorSetEvidence(evidence []byte) error {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ replace (
88
cosmossdk.io/api => github.com/scrtlabs/cosmos-sdk-api v0.7.6-secret.0
99
cosmossdk.io/store => github.com/scrtlabs/cosmos-sdk-store v1.1.1-secret.1
1010
cosmossdk.io/x/tx => github.com/scrtlabs/cosmos-sdk-x-tx v0.13.7-secret.0
11-
github.com/cometbft/cometbft => github.com/scrtlabs/tendermint v0.38.19-secret.1-non-sgx.1
11+
github.com/cometbft/cometbft => github.com/scrtlabs/tendermint v0.38.19-secret.1-non-sgx.2
1212
github.com/cosmos/cosmos-sdk => github.com/scrtlabs/cosmos-sdk v0.50.14-secret.7
1313
github.com/cosmos/iavl => github.com/scrtlabs/iavl v1.2.2-secret.0
1414
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,8 +1619,8 @@ github.com/scrtlabs/cosmos-sdk-x-tx v0.13.7-secret.0 h1:i3k5706sDHKhaCvzokB+n33/
16191619
github.com/scrtlabs/cosmos-sdk-x-tx v0.13.7-secret.0/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
16201620
github.com/scrtlabs/iavl v1.2.2-secret.0 h1:P96PL1Lf8OBSW9pMrlaRxhceZ4z9Hc7jk12g9ShWeHw=
16211621
github.com/scrtlabs/iavl v1.2.2-secret.0/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw=
1622-
github.com/scrtlabs/tendermint v0.38.19-secret.1-non-sgx.1 h1:l4kcsJdGq20NctF4VMYq2mQkV8k31Vcy7/U4Ud2TuqI=
1623-
github.com/scrtlabs/tendermint v0.38.19-secret.1-non-sgx.1/go.mod h1:I8kyAQPjMco6jjCshUSMYFoY6TybsbADGBmGcjWrgKM=
1622+
github.com/scrtlabs/tendermint v0.38.19-secret.1-non-sgx.2 h1:StYLcnDnqE9GB0LxHyh1UIMcy0XuJiFUNV2W5MG/cRQ=
1623+
github.com/scrtlabs/tendermint v0.38.19-secret.1-non-sgx.2/go.mod h1:I8kyAQPjMco6jjCshUSMYFoY6TybsbADGBmGcjWrgKM=
16241624
github.com/scrtlabs/tm-secret-enclave v1.13.1 h1:0mXcBdoWyqEGhQEdbXMjSuTi9LKKMld2BqEj0eNpoxU=
16251625
github.com/scrtlabs/tm-secret-enclave v1.13.1/go.mod h1:nxZQtzzAqBNBLOEXSv4cKlUnVA4vRmHOn6ujr3kxVME=
16261626
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=

x/compute/module.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
157157

158158
// BeginBlock returns the begin blocker for the compute module.
159159
func (am AppModule) BeginBlock(c context.Context) error {
160-
if api.GetRecorder().IsReplayMode() {
161-
return nil
162-
}
163-
164160
// Note: as of tendermint v0.38.0 block begin request info is no longer available
165161
ctx := c.(sdk.Context)
166162
block_header := ctx.BlockHeader()

0 commit comments

Comments
 (0)