From b46f515aef8c4aff0b76ac5cc72a4c6cf32284a1 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Fri, 15 Mar 2024 21:00:30 +0300 Subject: [PATCH] debug --- pkg/innerring/innerring.go | 5 +++- pkg/morph/client/notary.go | 60 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index a75b998515..ea26d9ef31 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -973,6 +973,8 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- } } + emissionHardcoded := 10_0000_0000 + // create alphabet processor alphabetProcessor, err := alphabet.New(&alphabet.Params{ Log: log, @@ -981,7 +983,8 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- NetmapClient: server.netmapClient, MorphClient: server.morphClient, IRList: server, - StorageEmission: cfg.GetUint64("emit.storage.amount"), + // StorageEmission: cfg.GetUint64("emit.storage.amount"), + StorageEmission: uint64(emissionHardcoded), }) if err != nil { return nil, err diff --git a/pkg/morph/client/notary.go b/pkg/morph/client/notary.go index 76ceac5012..fd26ecb4fd 100644 --- a/pkg/morph/client/notary.go +++ b/pkg/morph/client/notary.go @@ -2,6 +2,7 @@ package client import ( "crypto/elliptic" + "encoding/base64" "encoding/binary" "errors" "fmt" @@ -190,15 +191,65 @@ func (c *Client) DepositEndlessNotary(amount fixedn.Fixed8) (res util.Uint256, e return c.depositNotary(amount, math.MaxUint32) } +func hashesToStrings(hh []util.Uint256) []string { + res := make([]string, 0, len(hh)) + + for _, h := range hh { + res = append(res, h.StringLE()) + } + + return res +} + func (c *Client) depositNotary(amount fixedn.Fixed8, till int64) (res util.Uint256, err error) { acc := c.acc.ScriptHash() - txHash, vub, err := c.gasToken.Transfer( + // txHash, vub, err := c.gasToken.Transfer( + // c.accAddr, + // c.notary.notary, + // big.NewInt(int64(amount)), + // ¬ary.OnNEP17PaymentData{Account: &acc, Till: uint32(till)}) + // if err != nil { + // if !errors.Is(err, neorpc.ErrAlreadyExists) { + // return util.Uint256{}, fmt.Errorf("can't make notary deposit: %w", err) + // } + // + // // Transaction is already in mempool waiting to be processed. + // // This is an expected situation if we restart the service. + // c.logger.Debug("notary deposit has already been made", + // zap.Int64("amount", int64(amount)), + // zap.Int64("expire_at", till), + // zap.Uint32("vub", vub), + // zap.Error(err)) + // return util.Uint256{}, nil + // } + + memPoolHashes, err := c.client.GetRawMemPool() + if err != nil { + return util.Uint256{}, fmt.Errorf("mem pool hashes failed: %w", err) + } + + c.logger.Debug("mem pool hashes before notary deposit", + zap.Strings("hashes", hashesToStrings(memPoolHashes)), + ) + + tx, err := c.gasToken.TransferTransaction( c.accAddr, c.notary.notary, big.NewInt(int64(amount)), ¬ary.OnNEP17PaymentData{Account: &acc, Till: uint32(till)}) + if err != nil { + return util.Uint256{}, fmt.Errorf("wtf? %w", err) + } + + h, vub, err := c.rpcActor.Send(tx) if err != nil { if !errors.Is(err, neorpc.ErrAlreadyExists) { + c.logger.Debug("no notary deposit for now", + zap.Int64("sysfee", tx.SystemFee), + zap.Int64("netfee", tx.NetworkFee), + zap.String("script", base64.StdEncoding.EncodeToString(tx.Script)), + ) + return util.Uint256{}, fmt.Errorf("can't make notary deposit: %w", err) } @@ -216,9 +267,12 @@ func (c *Client) depositNotary(amount fixedn.Fixed8, till int64) (res util.Uint2 zap.Int64("amount", int64(amount)), zap.Int64("expire_at", till), zap.Uint32("vub", vub), - zap.Stringer("tx_hash", txHash.Reverse())) + zap.String("tx_hash", h.StringLE()), + zap.Int64("sysfee", tx.SystemFee), + zap.Int64("netfee", tx.NetworkFee), + zap.String("script", base64.StdEncoding.EncodeToString(tx.Script))) - return txHash, nil + return h, nil } // GetNotaryDeposit returns deposit of client's account in notary contract.