Skip to content

Commit 98084c0

Browse files
committed
retrieve implicit txs from the tm-secret-enclave
1 parent ec621a7 commit 98084c0

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ require (
3434
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475
3535
github.com/rs/cors v1.11.1
3636
github.com/sasha-s/go-deadlock v0.3.5
37-
github.com/scrtlabs/tm-secret-enclave v1.13.0
37+
github.com/scrtlabs/tm-secret-enclave v1.13.0-beta
3838
github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa
3939
github.com/spf13/cobra v1.9.1
4040
github.com/spf13/viper v1.19.0
@@ -45,9 +45,10 @@ require (
4545
golang.org/x/sync v0.11.0
4646
gonum.org/v1/gonum v0.15.1
4747
google.golang.org/grpc v1.70.0
48-
google.golang.org/protobuf v1.36.5
4948
)
5049

50+
require google.golang.org/protobuf v1.36.4
51+
5152
require (
5253
dario.cat/mergo v1.0.0 // indirect
5354
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb
329329
github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U=
330330
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
331331
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
332-
github.com/scrtlabs/tm-secret-enclave v1.12.2 h1:fl1rOFYB4+9orTzjAnp6r5EmIm5/6c78EERrWcgEWHA=
333-
github.com/scrtlabs/tm-secret-enclave v1.12.2/go.mod h1:nxZQtzzAqBNBLOEXSv4cKlUnVA4vRmHOn6ujr3kxVME=
332+
github.com/scrtlabs/tm-secret-enclave v1.13.0-beta h1:9IqEHQ/GSaRzcgqrFkxoLd/5ejOgLSezduz75VKCsZg=
333+
github.com/scrtlabs/tm-secret-enclave v1.13.0-beta/go.mod h1:nxZQtzzAqBNBLOEXSv4cKlUnVA4vRmHOn6ujr3kxVME=
334334
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
335335
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
336336
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
@@ -508,8 +508,8 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
508508
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
509509
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
510510
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
511-
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
512-
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
511+
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
512+
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
513513
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
514514
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
515515
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=

state/execution.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
157157
return nil, err
158158
}
159159

160+
// ScrtLabs changes ->
161+
tmenclave.SetScheduledTxs([]byte{}) // clear scheduled txs before setting new ones
162+
// ScrtLabs changes <-
163+
160164
return state.MakeBlock(height, txl, commit, evidence, proposerAddr), nil
161165
}
162166

state/state.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@ package state
22

33
import (
44
"bytes"
5+
"encoding/hex"
56
"errors"
67
"fmt"
78
"os"
89
"time"
9-
"encoding/hex"
10+
1011
"github.com/cosmos/gogoproto/proto"
1112

12-
tmenclave "github.com/scrtlabs/tm-secret-enclave"
1313
cmtstate "github.com/cometbft/cometbft/proto/tendermint/state"
14+
tm_type "github.com/cometbft/cometbft/proto/tendermint/types"
1415
cmtversion "github.com/cometbft/cometbft/proto/tendermint/version"
1516
"github.com/cometbft/cometbft/types"
1617
cmttime "github.com/cometbft/cometbft/types/time"
1718
"github.com/cometbft/cometbft/version"
19+
tmenclave "github.com/scrtlabs/tm-secret-enclave"
1820
)
1921

2022
// database keys
@@ -241,6 +243,27 @@ func (state State) MakeBlock(
241243
) *types.Block {
242244

243245
// Build base block with block data.
246+
// ScrtLabs changes in ->
247+
marshalledTxs, err := tmenclave.GetScheduledTxs()
248+
if err != nil {
249+
panic("Failed to get scheduled txs from tm-secret-enclave")
250+
}
251+
// implicitTxs = types.Txs(implicitTxs)
252+
implicitTxs := &tm_type.Data{}
253+
err = implicitTxs.Unmarshal(marshalledTxs)
254+
if err != nil {
255+
panic("Failed to unmarshal scheduled txs")
256+
}
257+
258+
scheduledTxs := make([]types.Tx, len(implicitTxs.Txs), len(implicitTxs.Txs)+len(txs))
259+
for i, tx := range implicitTxs.Txs {
260+
scheduledTxs[i] = types.Tx(tx)
261+
}
262+
263+
// Append original txs after scheduled ones
264+
txs = append(scheduledTxs, txs...)
265+
266+
// ScrtLabs changes out <-
244267
block := types.MakeBlock(height, txs, lastCommit, evidence)
245268

246269
// Set time.

0 commit comments

Comments
 (0)