[#465] processor/neofs: Don't modify tx details

Mint, Burn and Cheque details should contain hash of
main net tx of Deposit and Withdraw invocation. They will
be formatted inside the contracts so alphabet nodes must
not modify them.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-04-08 10:56:35 +03:00 committed by Alex Vanin
parent 3e9c578e62
commit 0f01a69fd3

View file

@ -8,9 +8,6 @@ import (
) )
const ( const (
// txLogPrefix used for balance transfer comments in balance contract.
txLogPrefix = "mainnet:"
// lockAccountLifeTime defines amount of epochs when lock account is valid. // lockAccountLifeTime defines amount of epochs when lock account is valid.
lockAccountLifetime uint64 = 20 lockAccountLifetime uint64 = 20
) )
@ -28,7 +25,7 @@ func (np *Processor) processDeposit(deposit *neofsEvent.Deposit) {
&invoke.MintBurnParams{ &invoke.MintBurnParams{
ScriptHash: deposit.To().BytesBE(), ScriptHash: deposit.To().BytesBE(),
Amount: np.converter.ToBalancePrecision(deposit.Amount()), Amount: np.converter.ToBalancePrecision(deposit.Amount()),
Comment: append([]byte(txLogPrefix), deposit.ID()...), Comment: deposit.ID(),
}) })
if err != nil { if err != nil {
np.log.Error("can't transfer assets to balance contract", zap.Error(err)) np.log.Error("can't transfer assets to balance contract", zap.Error(err))
@ -87,11 +84,6 @@ func (np *Processor) processWithdraw(withdraw *neofsEvent.Withdraw) {
return return
} }
if len(withdraw.ID()) < util.Uint160Size {
np.log.Error("tx id size is less than script hash size")
return
}
// create lock account // create lock account
// fixme: check collision there, consider reversed script hash // fixme: check collision there, consider reversed script hash
lock, err := util.Uint160DecodeBytesBE(withdraw.ID()[:util.Uint160Size]) lock, err := util.Uint160DecodeBytesBE(withdraw.ID()[:util.Uint160Size])
@ -127,7 +119,7 @@ func (np *Processor) processCheque(cheque *neofsEvent.Cheque) {
&invoke.MintBurnParams{ &invoke.MintBurnParams{
ScriptHash: cheque.LockAccount().BytesBE(), ScriptHash: cheque.LockAccount().BytesBE(),
Amount: np.converter.ToBalancePrecision(cheque.Amount()), Amount: np.converter.ToBalancePrecision(cheque.Amount()),
Comment: append([]byte(txLogPrefix), cheque.ID()...), Comment: cheque.ID(),
}) })
if err != nil { if err != nil {
np.log.Error("can't transfer assets to fed contract", zap.Error(err)) np.log.Error("can't transfer assets to fed contract", zap.Error(err))