Skip to content

Improves/sub call check - #35

Open
hundredark wants to merge 4 commits into
mainfrom
improves/sub-call-check
Open

hundredark wants to merge 4 commits into
mainfrom
improves/sub-call-check

Conversation

@hundredark

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Cleanup validation can authorize unintended transfers, burns, or mints, while also rejecting valid SOL-dust cleanups and accepting mismatched token decimals.

4 open issues
What changed in this PR

This PR strengthens Solana subsystem-call validation and simplifies the store lookup used to detect unfinished prepare calls.

Changes:

  • Validates prepare movements by asset, amount, source, and destination, and requires a prepare call when referenced assets exist.
  • Separates transfers from burns during post-process and deposit validation.
  • Replaces the unfinished-sub-call transaction with a single existence query.
File Description
store/​call.go Simplifies the pending prepare-call existence check.
solana/​system_call.go Adds movement-ledger validation for prepare, post-process, and deposit calls.
solana/​mvm.go Enforces required prepare calls and supplies validation context.
apps/​solana/​common.go Adds typed extraction of initial transfers and burns.

Review effort: Max

Comment thread solana/system_call.go
if old.Amount.Cmp(amount) != 0 {
return fmt.Errorf("invalid user balance change: %s %s %s", address, amount.String(), old.Amount.String())
}
actualTransfers, actualBurns := buildInitialAssetMovementMaps(tx, "", node.SolanaPayer().String())
Comment thread solana/system_call.go
Comment on lines +890 to 894
expectedValue := asset.Amount.Mul(decimal.New(1, int32(asset.Decimal))).BigInt()
movement := actual[address]
if movement == nil {
return fmt.Errorf("missing %s user balance change: %s", kind, address)
}
Comment thread solana/system_call.go
Comment on lines +905 to +907
if expected[address] == nil {
return fmt.Errorf("unexpected %s user balance change: %s %s", kind, address, amount.String())
}
Comment thread solana/system_call.go
}
if actual.Cmp(expected) != 0 {
return fmt.Errorf("invalid deposit: %s %s %s %s %s", signature, key, expected.String(), actual.String(), tx.MustToBase64())
if movement.Value.Cmp(expectedValue) != 0 {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants