diff --git a/pkg/api/emulation.go b/pkg/api/emulation.go index 5a2b67c0..f3b422e6 100644 --- a/pkg/api/emulation.go +++ b/pkg/api/emulation.go @@ -142,11 +142,7 @@ func (h *Handler) addToMempool(ctx context.Context, bytesBoc []byte, shardAccoun core.Visit(trace, func(node *core.Trace) { accounts[node.Account] = struct{}{} }) - hash, err := msgCell[0].Hash256() - if err != nil { - return shardAccount, err - } - h.mempoolEmulate.traces.Set(hash, trace, cache.WithExpiration(time.Second*time.Duration(ttl))) + h.mempoolEmulate.traces.Set(ton.Bits256(message.Hash()), trace, cache.WithExpiration(time.Second*time.Duration(ttl))) var localMessageHashCache = make(map[ton.Bits256]bool) for account := range accounts { if _, ok := h.mempoolEmulateIgnoreAccounts[account]; ok { // the map is filled only once at the start @@ -166,7 +162,7 @@ func (h *Handler) addToMempool(ctx context.Context, bytesBoc []byte, shardAccoun newMemHashes = append(newMemHashes, mHash) } } - newMemHashes = append(newMemHashes, hash) // it's important to make it last + newMemHashes = append(newMemHashes, ton.Bits256(message.Hash())) // it's important to make it last h.mempoolEmulate.accountsTraces.Set(account, newMemHashes, cache.WithExpiration(time.Second*time.Duration(ttl))) } emulationCh <- blockchain.ExtInMsgCopy{ diff --git a/pkg/api/event_handlers.go b/pkg/api/event_handlers.go index 6c7bb6fe..a9fadb32 100644 --- a/pkg/api/event_handlers.go +++ b/pkg/api/event_handlers.go @@ -392,16 +392,12 @@ func (h *Handler) EmulateMessageToEvent(ctx context.Context, request *oas.Emulat if err != nil { return nil, toError(http.StatusBadRequest, err) } - hash, err := c.Hash256() - if err != nil { + var message tlb.Message + if err = tlb.Unmarshal(c, &message); err != nil { return nil, toError(http.StatusBadRequest, err) } - trace, prs := h.mempoolEmulate.traces.Get(hash) + trace, prs := h.mempoolEmulate.traces.Get(ton.Bits256(message.Hash())) if !prs { - var m tlb.Message - if err := tlb.Unmarshal(c, &m); err != nil { - return nil, toError(http.StatusBadRequest, err) - } configBase64, err := h.storage.TrimmedConfigBase64() if err != nil { return nil, toError(http.StatusInternalServerError, err) @@ -418,7 +414,7 @@ func (h *Handler) EmulateMessageToEvent(ctx context.Context, request *oas.Emulat if err != nil { return nil, toError(http.StatusInternalServerError, err) } - tree, err := emulator.Run(ctx, m) + tree, err := emulator.Run(ctx, message) if err != nil { return nil, toProperEmulationError(err) } @@ -444,17 +440,12 @@ func (h *Handler) EmulateMessageToTrace(ctx context.Context, request *oas.Emulat if err != nil { return nil, toError(http.StatusBadRequest, err) } - hash, err := c.Hash256() - if err != nil { + var message tlb.Message + if err = tlb.Unmarshal(c, &message); err != nil { return nil, toError(http.StatusBadRequest, err) } - trace, prs := h.mempoolEmulate.traces.Get(hash) + trace, prs := h.mempoolEmulate.traces.Get(ton.Bits256(message.Hash())) if !prs { - var m tlb.Message - err = tlb.Unmarshal(c, &m) - if err != nil { - return nil, toError(http.StatusBadRequest, err) - } configBase64, err := h.storage.TrimmedConfigBase64() if err != nil { return nil, toError(http.StatusInternalServerError, err) @@ -466,12 +457,11 @@ func (h *Handler) EmulateMessageToTrace(ctx context.Context, request *oas.Emulat if !params.IgnoreSignatureCheck.Value { options = append(options, txemulator.WithSignatureCheck()) } - emulator, err := txemulator.NewTraceBuilder(options...) if err != nil { return nil, toError(http.StatusInternalServerError, err) } - tree, err := emulator.Run(ctx, m) + tree, err := emulator.Run(ctx, message) if err != nil { return nil, toProperEmulationError(err) }