Skip to content

Commit

Permalink
Merge pull request #822 from OffchainLabs/consistent-no-ticket-error
Browse files Browse the repository at this point in the history
Consistently use NoTicketWithID() Solidity error in ArbRetryableTx
  • Loading branch information
PlasmaPower authored Jul 22, 2022
2 parents 9fbb20d + cb57b86 commit 5e0fe04
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions precompiles/ArbRetryableTx.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ type ArbRetryableTx struct {
NotCallableError func() error
}

var (
ErrNotFound = errors.New("ticketId not found")
ErrSelfModifyingRetryable = errors.New("retryable cannot modify itself")
)
var ErrSelfModifyingRetryable = errors.New("retryable cannot modify itself")

func (con ArbRetryableTx) oldNotFoundError(c ctx) error {
if c.State.FormatVersion() >= 3 {
return con.NoTicketWithIDError()
} else {
return errors.New("ticketId not found")
}
}

// Schedule an attempt to redeem the retryable, donating all of the call's gas to the redeem attempt
func (con ArbRetryableTx) Redeem(c ctx, evm mech, ticketId bytes32) (bytes32, error) {
Expand All @@ -61,7 +66,7 @@ func (con ArbRetryableTx) Redeem(c ctx, evm mech, ticketId bytes32) (bytes32, er
return hash{}, err
}
if retryable == nil {
return hash{}, ErrNotFound
return hash{}, con.oldNotFoundError(c)
}
nextNonce, err := retryable.IncrementNumTries()
if err != nil {
Expand Down Expand Up @@ -158,7 +163,7 @@ func (con ArbRetryableTx) Keepalive(c ctx, evm mech, ticketId bytes32) (huge, er
return nil, err
}
if nbytes == 0 {
return nil, ErrNotFound
return nil, con.oldNotFoundError(c)
}
updateCost := arbmath.WordsForBytes(nbytes) * params.SstoreSetGas / 100
if err := c.Burn(updateCost); err != nil {
Expand All @@ -184,7 +189,7 @@ func (con ArbRetryableTx) GetBeneficiary(c ctx, evm mech, ticketId bytes32) (add
return addr{}, err
}
if retryable == nil {
return addr{}, ErrNotFound
return addr{}, con.oldNotFoundError(c)
}
return retryable.Beneficiary()
}
Expand All @@ -200,7 +205,7 @@ func (con ArbRetryableTx) Cancel(c ctx, evm mech, ticketId bytes32) error {
return err
}
if retryable == nil {
return ErrNotFound
return con.oldNotFoundError(c)
}
beneficiary, err := retryable.Beneficiary()
if err != nil {
Expand Down

0 comments on commit 5e0fe04

Please sign in to comment.