Skip to content

Commit

Permalink
Add an error for exceeding refundable fee. (#134)
Browse files Browse the repository at this point in the history
* Add errors for exceeding the refundable fee.

These have to be operation errors, as core is hard-wired to only return `txFAILED` on transaction failure and modifying this behavior is risky/slow.

* Remove `contractEventsSizeBytes` from `SorobanResources`.

This field is almost redundant and only helps to avoid apply-time error in the rare cases when the user sets the events resource, but forgets to set high enough refundable fee. It does, on the other hand, introduce another apply-time failure condition if the contracts emits a bit more events than expected (even if the refundable fee is high enough to cover that).

The total size of the events emitted is still governed by the network setting.
  • Loading branch information
dmkozh authored Aug 18, 2023
1 parent 1894f09 commit 1795087
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Stellar-transaction.x
Original file line number Diff line number Diff line change
Expand Up @@ -814,10 +814,6 @@ struct SorobanResources
uint32 readBytes;
// The maximum number of bytes this transaction can write to ledger
uint32 writeBytes;

// Maximum size of the contract events (serialized to XDR) this transaction
// can emit.
uint32 contractEventsSizeBytes;
};

// The transaction extension for Soroban.
Expand Down Expand Up @@ -1793,7 +1789,8 @@ enum InvokeHostFunctionResultCode
INVOKE_HOST_FUNCTION_MALFORMED = -1,
INVOKE_HOST_FUNCTION_TRAPPED = -2,
INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED = -3,
INVOKE_HOST_FUNCTION_ENTRY_EXPIRED = -4
INVOKE_HOST_FUNCTION_ENTRY_EXPIRED = -4,
INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE = -5
};

union InvokeHostFunctionResult switch (InvokeHostFunctionResultCode code)
Expand All @@ -1804,6 +1801,7 @@ case INVOKE_HOST_FUNCTION_MALFORMED:
case INVOKE_HOST_FUNCTION_TRAPPED:
case INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED:
case INVOKE_HOST_FUNCTION_ENTRY_EXPIRED:
case INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE:
void;
};

Expand All @@ -1814,7 +1812,8 @@ enum BumpFootprintExpirationResultCode

// codes considered as "failure" for the operation
BUMP_FOOTPRINT_EXPIRATION_MALFORMED = -1,
BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED = -2
BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED = -2,
BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE = -3
};

union BumpFootprintExpirationResult switch (BumpFootprintExpirationResultCode code)
Expand All @@ -1823,6 +1822,7 @@ case BUMP_FOOTPRINT_EXPIRATION_SUCCESS:
void;
case BUMP_FOOTPRINT_EXPIRATION_MALFORMED:
case BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED:
case BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE:
void;
};

Expand All @@ -1833,7 +1833,8 @@ enum RestoreFootprintResultCode

// codes considered as "failure" for the operation
RESTORE_FOOTPRINT_MALFORMED = -1,
RESTORE_FOOTPRINT_RESOURCE_LIMIT_EXCEEDED = -2
RESTORE_FOOTPRINT_RESOURCE_LIMIT_EXCEEDED = -2,
RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE = -3
};

union RestoreFootprintResult switch (RestoreFootprintResultCode code)
Expand All @@ -1842,6 +1843,7 @@ case RESTORE_FOOTPRINT_SUCCESS:
void;
case RESTORE_FOOTPRINT_MALFORMED:
case RESTORE_FOOTPRINT_RESOURCE_LIMIT_EXCEEDED:
case RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE:
void;
};

Expand Down

0 comments on commit 1795087

Please sign in to comment.