Skip to content

fix(precompiles): bind system_transfer_from to msg.sender#3786

Draft
legion2002 wants to merge 1 commit intomainfrom
fix/system-transfer-from-caller-context
Draft

fix(precompiles): bind system_transfer_from to msg.sender#3786
legion2002 wants to merge 1 commit intomainfrom
fix/system-transfer-from-caller-context

Conversation

@legion2002
Copy link
Copy Markdown
Contributor

@legion2002 legion2002 commented Apr 30, 2026

Addresses the review feedback on PR #3219 by removing the caller-supplied source address from system_transfer_from and binding it to the external msg.sender captured at the precompile boundary.

This threads msg.sender through StorageCtx, updates the TIP-20 helper and AMM call sites, and adds regression coverage for the scoped sender context.

Validation: cargo nextest run -p tempo-precompiles

Linear: https://linear.app/tempoxyz/issue/CHAIN-1144/tip-1035-implicit-approvals-list

@legion2002 legion2002 marked this pull request as draft April 30, 2026 21:30
@github-actions
Copy link
Copy Markdown
Contributor

📊 Tempo Precompiles Coverage

precompiles

Coverage: 5640/7677 lines (73.47%)

File details
File Lines Coverage
src/account_keychain/dispatch.rs 30/68 44.12%
src/account_keychain/mod.rs 274/724 37.85%
src/address_registry/dispatch.rs 31/33 93.94%
src/address_registry/mod.rs 50/56 89.29%
src/error.rs 39/114 34.21%
src/ip_validation.rs 10/10 100.00%
src/lib.rs 191/217 88.02%
src/nonce/dispatch.rs 9/10 90.00%
src/nonce/mod.rs 46/61 75.41%
src/signature_verifier/dispatch.rs 19/20 95.00%
src/signature_verifier/mod.rs 13/17 76.47%
src/stablecoin_dex/dispatch.rs 92/93 98.92%
src/stablecoin_dex/mod.rs 874/918 95.21%
src/stablecoin_dex/order.rs 110/161 68.32%
src/stablecoin_dex/orderbook.rs 157/216 72.69%
src/storage/evm.rs 173/194 89.18%
src/storage/hashmap.rs 0/150 0.00%
src/storage/mod.rs 27/27 100.00%
src/storage/packing.rs 68/93 73.12%
src/storage/thread_local.rs 188/246 76.42%
src/storage/types/array.rs 0/72 0.00%
src/storage/types/bytes_like.rs 79/162 48.77%
src/storage/types/mapping.rs 27/48 56.25%
src/storage/types/mod.rs 67/91 73.63%
src/storage/types/primitives.rs 21/24 87.50%
src/storage/types/set.rs 28/192 14.58%
src/storage/types/slot.rs 55/81 67.90%
src/storage/types/vec.rs 101/246 41.06%
src/tip20/dispatch.rs 149/165 90.30%
src/tip20/mod.rs 586/689 85.05%
src/tip20/rewards.rs 238/252 94.44%
src/tip20/roles.rs 107/110 97.27%
src/tip20_factory/dispatch.rs 17/18 94.44%
src/tip20_factory/mod.rs 105/125 84.00%
src/tip403_registry/dispatch.rs 55/56 98.21%
src/tip403_registry/mod.rs 334/371 90.03%
src/tip_fee_manager/amm.rs 286/365 78.36%
src/tip_fee_manager/dispatch.rs 81/83 97.59%
src/tip_fee_manager/mod.rs 71/136 52.21%
src/validator_config/dispatch.rs 38/52 73.08%
src/validator_config/mod.rs 171/227 75.33%
src/validator_config_v2/dispatch.rs 71/73 97.26%
src/validator_config_v2/mod.rs 552/611 90.34%

contracts

Coverage: 1/226 lines (0.44%)

File details
File Lines Coverage
src/lib.rs 1/1 100.00%
src/precompiles/account_keychain.rs 0/37 0.00%
src/precompiles/address_registry.rs 0/9 0.00%
src/precompiles/nonce.rs 0/18 0.00%
src/precompiles/signature_verifier.rs 0/3 0.00%
src/precompiles/stablecoin_dex.rs 0/21 0.00%
src/precompiles/tip20.rs 0/49 0.00%
src/precompiles/tip20_factory.rs 0/9 0.00%
src/precompiles/tip403_registry.rs 0/15 0.00%
src/precompiles/tip_fee_manager.rs 0/15 0.00%
src/precompiles/validator_config.rs 0/13 0.00%
src/precompiles/validator_config_v2.rs 0/36 0.00%

Total: 5641/7903 lines (71.38%)

📦 Download full HTML report

};

scoped_thread_local!(static STORAGE: RefCell<&mut dyn PrecompileStorageProvider>);
scoped_thread_local!(static MSG_SENDER: Address);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hmm not sure i understand the idea here. all precompiles propagate msg_sender manually now so adding this introduces a bit of an inconsistency to how it's handled

also i don't think we need to keep it as a thread local variable, it could just be a part of PrecompileStorageProvider context i believe

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah we want to remove manually propogating msg_sender to system transfer from, so we can have better guarantees about TIP 1035.

We want system_transfer_from to receive a trusted msg_sender, instead of trusting whatever the precompile passes to it.

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