@@ -85,7 +85,8 @@ import (
8585 tmlog "github.com/tendermint/tendermint/libs/log"
8686 tmos "github.com/tendermint/tendermint/libs/os"
8787 dbm "github.com/tendermint/tm-db"
88-
88+ authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
89+ sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
8990 // unnamed import of statik for swagger UI support
9091 _ "github.com/scrtlabs/SecretNetwork/client/docs/statik"
9192)
@@ -180,10 +181,52 @@ func (app *SecretNetworkApp) RegisterTendermintService(clientCtx client.Context)
180181
181182func (app * SecretNetworkApp ) DeliverTx (req abci.RequestDeliverTx ) (res abci.ResponseDeliverTx ) {
182183 fmt .Printf ("nerla app/app.go DeliverTx tx %x\n " , req .Tx )
183- if compute .GetFakeDeliver () {
184- fmt .Printf ("nerla app/app.go DeliverTx FAKE_DELIVER is true\n " , )
185- return abci.ResponseDeliverTx {Code : abci .CodeTypeOK }
184+ dTx , err := app .GetTxConfig ().TxDecoder ()(req .Tx )
185+ if err != nil {
186+ fmt .Println ( "nerla app/app.go error TxDecoder" )
187+ panic (err )
186188 }
189+ msgs := dTx .GetMsgs ()
190+ for _ , m := range msgs {
191+ mSecret := m .(compute.SecretNetworkMsg )
192+ if mSecret .Type () == "call_delivertx" || mSecret .Type () == "snapshot" {
193+ fmt .Printf ("nerla app/app.go m.Type() %s calling Simulate\n " , mSecret .Type ())
194+ ctx := app .BaseApp .GetContextForDeliverTx (req .Tx )
195+ sigTx , ok := dTx .(authsigning.SigVerifiableTx )
196+ if ! ok {
197+ fmt .Println ("nerla app/app.go invalid transaction type" )
198+ panic (sdkerrors .ErrTxDecode )
199+ }
200+
201+ sigs , err := sigTx .GetSignaturesV2 ()
202+ if err != nil {
203+ fmt .Println ("nerla app/app.go GetSignaturesV2 err" )
204+ panic (err )
205+ }
206+ signerAddrs := sigTx .GetSigners ()
207+
208+ for i , sig := range sigs {
209+ addr := signerAddrs [i ]
210+ acc := app .AppKeepers .AccountKeeper .GetAccount (ctx , addr )
211+ fmt .Printf ("nerla app/app.go before addr %s acc.seq %d sig.seq %d\n " , addr .String (), acc .GetSequence (), sig .Sequence + 1 )
212+ if err := acc .SetSequence (sig .Sequence + 1 ); err != nil {
213+ panic (err )
214+ }
215+ app .AppKeepers .AccountKeeper .SetAccount (ctx , acc )
216+ acc2 := app .AppKeepers .AccountKeeper .GetAccount (ctx , addr )
217+ fmt .Printf ("nerla app/app.go after addr %s acc.seq %d\n " , addr .String (), acc2 .GetSequence ())
218+ }
219+
220+ gasInfo , resp , err := app .BaseApp .Simulate (req .Tx )
221+ fmt .Printf ("nerla app/app.go Simulate gasInfo %d res %v err %v\n " , gasInfo , resp , err )
222+ return abci.ResponseDeliverTx {Code : abci .CodeTypeOK }
223+ }
224+ }
225+
226+ // if compute.GetFakeDeliver() {
227+ // fmt.Printf("nerla app/app.go DeliverTx FAKE_DELIVER is true\n", )
228+ // return abci.ResponseDeliverTx{Code: abci.CodeTypeOK}
229+ // }
187230 resp := app .BaseApp .DeliverTx (req )
188231 fmt .Printf ("nerla app/app.go DeliverTx res %v\n " , resp )
189232 return resp
0 commit comments