Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
carpawell committed Mar 18, 2024
1 parent b60675d commit b46f515
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 4 deletions.
5 changes: 4 additions & 1 deletion pkg/innerring/innerring.go
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,8 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<-
}
}

emissionHardcoded := 10_0000_0000

Check warning on line 976 in pkg/innerring/innerring.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/innerring.go#L976

Added line #L976 was not covered by tests

// create alphabet processor
alphabetProcessor, err := alphabet.New(&alphabet.Params{
Log: log,
Expand All @@ -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),

Check warning on line 987 in pkg/innerring/innerring.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/innerring.go#L987

Added line #L987 was not covered by tests
})
if err != nil {
return nil, err
Expand Down
60 changes: 57 additions & 3 deletions pkg/morph/client/notary.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package client

import (
"crypto/elliptic"
"encoding/base64"
"encoding/binary"
"errors"
"fmt"
Expand Down Expand Up @@ -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))

Check warning on line 195 in pkg/morph/client/notary.go

View check run for this annotation

Codecov / codecov/patch

pkg/morph/client/notary.go#L194-L195

Added lines #L194 - L195 were not covered by tests

for _, h := range hh {
res = append(res, h.StringLE())

Check warning on line 198 in pkg/morph/client/notary.go

View check run for this annotation

Codecov / codecov/patch

pkg/morph/client/notary.go#L197-L198

Added lines #L197 - L198 were not covered by tests
}

return res

Check warning on line 201 in pkg/morph/client/notary.go

View check run for this annotation

Codecov / codecov/patch

pkg/morph/client/notary.go#L201

Added line #L201 was not covered by tests
}

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)),
// &notary.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)

Check warning on line 228 in pkg/morph/client/notary.go

View check run for this annotation

Codecov / codecov/patch

pkg/morph/client/notary.go#L226-L228

Added lines #L226 - L228 were not covered by tests
}

c.logger.Debug("mem pool hashes before notary deposit",
zap.Strings("hashes", hashesToStrings(memPoolHashes)),
)

Check warning on line 233 in pkg/morph/client/notary.go

View check run for this annotation

Codecov / codecov/patch

pkg/morph/client/notary.go#L231-L233

Added lines #L231 - L233 were not covered by tests

tx, err := c.gasToken.TransferTransaction(

Check warning on line 235 in pkg/morph/client/notary.go

View check run for this annotation

Codecov / codecov/patch

pkg/morph/client/notary.go#L235

Added line #L235 was not covered by tests
c.accAddr,
c.notary.notary,
big.NewInt(int64(amount)),
&notary.OnNEP17PaymentData{Account: &acc, Till: uint32(till)})
if err != nil {
return util.Uint256{}, fmt.Errorf("wtf? %w", err)

Check warning on line 241 in pkg/morph/client/notary.go

View check run for this annotation

Codecov / codecov/patch

pkg/morph/client/notary.go#L240-L241

Added lines #L240 - L241 were not covered by tests
}

h, vub, err := c.rpcActor.Send(tx)

Check warning on line 244 in pkg/morph/client/notary.go

View check run for this annotation

Codecov / codecov/patch

pkg/morph/client/notary.go#L244

Added line #L244 was not covered by tests
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)),
)

Check warning on line 251 in pkg/morph/client/notary.go

View check run for this annotation

Codecov / codecov/patch

pkg/morph/client/notary.go#L247-L251

Added lines #L247 - L251 were not covered by tests

return util.Uint256{}, fmt.Errorf("can't make notary deposit: %w", err)
}

Expand All @@ -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)))

Check warning on line 273 in pkg/morph/client/notary.go

View check run for this annotation

Codecov / codecov/patch

pkg/morph/client/notary.go#L270-L273

Added lines #L270 - L273 were not covered by tests

return txHash, nil
return h, nil

Check warning on line 275 in pkg/morph/client/notary.go

View check run for this annotation

Codecov / codecov/patch

pkg/morph/client/notary.go#L275

Added line #L275 was not covered by tests
}

// GetNotaryDeposit returns deposit of client's account in notary contract.
Expand Down

0 comments on commit b46f515

Please sign in to comment.