forked from TrueCloudLab/frostfs-node
[#787] morph: Return VUB from Invoke
method
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
5466e88444
commit
518f3baf41
25 changed files with 69 additions and 48 deletions
|
@ -355,13 +355,15 @@ func (c *Client) UpdateNeoFSAlphabetList(prm UpdateAlphabetListPrm) error {
|
|||
// blockchain. Fallback tx is a `RET`. If Notary support is not enabled
|
||||
// it fallbacks to a simple `Invoke()`.
|
||||
//
|
||||
// Returns valid until block value.
|
||||
//
|
||||
// `nonce` and `vub` are used only if notary is enabled.
|
||||
func (c *Client) NotaryInvoke(contract util.Uint160, fee fixedn.Fixed8, nonce uint32, vub *uint32, method string, args ...any) error {
|
||||
func (c *Client) NotaryInvoke(contract util.Uint160, fee fixedn.Fixed8, nonce uint32, vub *uint32, method string, args ...any) (uint32, error) {
|
||||
c.switchLock.RLock()
|
||||
defer c.switchLock.RUnlock()
|
||||
|
||||
if c.inactive {
|
||||
return ErrConnectionLost
|
||||
return 0, ErrConnectionLost
|
||||
}
|
||||
|
||||
if c.notary == nil {
|
||||
|
@ -376,12 +378,12 @@ func (c *Client) NotaryInvoke(contract util.Uint160, fee fixedn.Fixed8, nonce ui
|
|||
// not expected to be signed by the current node.
|
||||
//
|
||||
// Considered to be used by non-IR nodes.
|
||||
func (c *Client) NotaryInvokeNotAlpha(contract util.Uint160, fee fixedn.Fixed8, method string, args ...any) error {
|
||||
func (c *Client) NotaryInvokeNotAlpha(contract util.Uint160, fee fixedn.Fixed8, method string, args ...any) (uint32, error) {
|
||||
c.switchLock.RLock()
|
||||
defer c.switchLock.RUnlock()
|
||||
|
||||
if c.inactive {
|
||||
return ErrConnectionLost
|
||||
return 0, ErrConnectionLost
|
||||
}
|
||||
|
||||
if c.notary == nil {
|
||||
|
@ -440,10 +442,11 @@ func (c *Client) NotarySignAndInvokeTX(mainTx *transaction.Transaction) error {
|
|||
|
||||
func (c *Client) notaryInvokeAsCommittee(method string, nonce, vub uint32, args ...any) error {
|
||||
designate := c.GetDesignateHash()
|
||||
return c.notaryInvoke(true, true, designate, nonce, &vub, method, args...)
|
||||
_, err := c.notaryInvoke(true, true, designate, nonce, &vub, method, args...)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) notaryInvoke(committee, invokedByAlpha bool, contract util.Uint160, nonce uint32, vub *uint32, method string, args ...any) error {
|
||||
func (c *Client) notaryInvoke(committee, invokedByAlpha bool, contract util.Uint160, nonce uint32, vub *uint32, method string, args ...any) (uint32, error) {
|
||||
start := time.Now()
|
||||
success := false
|
||||
defer func() {
|
||||
|
@ -452,22 +455,22 @@ func (c *Client) notaryInvoke(committee, invokedByAlpha bool, contract util.Uint
|
|||
|
||||
alphabetList, err := c.notary.alphabetSource()
|
||||
if err != nil {
|
||||
return err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
until, err := c.getUntilValue(vub)
|
||||
if err != nil {
|
||||
return err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
cosigners, err := c.notaryCosigners(invokedByAlpha, alphabetList, committee)
|
||||
if err != nil {
|
||||
return err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
nAct, err := notary.NewActor(c.client, cosigners, c.acc)
|
||||
if err != nil {
|
||||
return err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
mainH, fbH, untilActual, err := nAct.Notarize(nAct.MakeTunedCall(contract, method, nil, func(r *result.Invoke, t *transaction.Transaction) error {
|
||||
|
@ -482,7 +485,7 @@ func (c *Client) notaryInvoke(committee, invokedByAlpha bool, contract util.Uint
|
|||
}, args...))
|
||||
|
||||
if err != nil && !alreadyOnChainError(err) {
|
||||
return err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
c.logger.Debug(logs.ClientNotaryRequestInvoked,
|
||||
|
@ -492,7 +495,7 @@ func (c *Client) notaryInvoke(committee, invokedByAlpha bool, contract util.Uint
|
|||
zap.String("fallback_hash", fbH.StringLE()))
|
||||
|
||||
success = true
|
||||
return nil
|
||||
return until, nil
|
||||
}
|
||||
|
||||
func (c *Client) notaryCosignersFromTx(mainTx *transaction.Transaction, alphabetList keys.PublicKeys) ([]actor.SignerAccount, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue