Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent recursive transfers (internal #133) #2659

Merged
merged 6 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions runtime/interpreter/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -975,3 +975,16 @@ func (AccountLinkingForbiddenError) IsUserError() {}
func (e AccountLinkingForbiddenError) Error() string {
return "account linking is not allowed"
}

// RecursiveTransferError
type RecursiveTransferError struct {
LocationRange
}

var _ errors.UserError = RecursiveTransferError{}

func (RecursiveTransferError) IsUserError() {}

func (RecursiveTransferError) Error() string {
return "recursive transfer of value"
}
3 changes: 3 additions & 0 deletions runtime/interpreter/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,7 @@ func (interpreter *Interpreter) transferAndConvert(
atree.Address{},
false,
nil,
nil,
)

result := interpreter.ConvertAndBox(
Expand Down Expand Up @@ -3865,6 +3866,7 @@ func (interpreter *Interpreter) authAccountSaveFunction(addressValue AddressValu
atree.Address(address),
true,
nil,
nil,
)

// Write new value
Expand Down Expand Up @@ -3988,6 +3990,7 @@ func (interpreter *Interpreter) authAccountReadFunction(addressValue AddressValu
atree.Address{},
false,
nil,
nil,
)

// Remove the value from storage,
Expand Down
1 change: 1 addition & 0 deletions runtime/interpreter/interpreter_expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,7 @@ func (interpreter *Interpreter) VisitAttachExpression(attachExpression *ast.Atta
atree.Address{},
false,
nil,
nil,
).(*CompositeValue)

// we enforce this in the checker
Expand Down
1 change: 1 addition & 0 deletions runtime/interpreter/interpreter_invocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func (interpreter *Interpreter) invokeFunctionValue(
atree.Address{},
false,
nil,
nil,
)
}
}
Expand Down
1 change: 1 addition & 0 deletions runtime/interpreter/interpreter_statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ func (interpreter *Interpreter) VisitForStatement(statement *ast.ForStatement) S
atree.Address{},
false,
nil,
nil,
)

iterable, ok := transferredValue.(IterableValue)
Expand Down
1 change: 1 addition & 0 deletions runtime/interpreter/simplecompositevalue.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ func (v *SimpleCompositeValue) Transfer(
_ atree.Address,
remove bool,
storable atree.Storable,
_ map[atree.StorageID]struct{},
) Value {
// TODO: actually not needed, value is not storable
if remove {
Expand Down
Loading