Repository navigation
feat(sdk-coin-stx): accept a configured PoX-5 staking contract address #10058
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -209,6 +209,16 @@ export interface StacksNetwork extends AccountNetwork { | |
| readonly chainId?: number; | ||
| /** Transaction version byte. Omitted for the stock Stacks mainnet/testnet deployments. */ | ||
| readonly transactionVersion?: number; | ||
| /** | ||
| * Additional staking contract deployer addresses this network accepts, in addition to the | ||
| * canonical `stakingContractAddress`. Deployment-specific and temporary: used to allow a | ||
| * non-canonical pox-5 deployment (e.g. the Stacks Foundation test contract) without the caller | ||
| * passing an allowlist. Empty/omitted by default, so behaviour is unchanged unless configured. | ||
| * | ||
| * @obligation remove once the test deployment is retired — an address listed here is trusted for | ||
| * every Stacks transaction on this network | ||
| */ | ||
| readonly allowedStakingContractAddresses?: ReadonlyArray<string>; | ||
| } | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
|
|
@@ -1362,6 +1372,10 @@ class Stx extends Mainnet implements StacksNetwork { | |
| sendmanymemoContractAddress = 'SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE'; | ||
| stakingContractAddress = 'SP000000000000000000002Q6VF78'; | ||
| sbtcWithdrawalContractAddress = 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4'; | ||
| // Temporary: the Stacks Foundation pox-5 test contract (standard name `pox-5`, non-canonical boot | ||
| // address). Allows transactions targeting it to parse/build without a caller-supplied allowlist. | ||
| // Remove with the test. | ||
| allowedStakingContractAddresses = ['SP3JVSE4ZB5GMDJP5XBPX7ZB1BG3QDFW7RCEQJDMY']; | ||
|
Comment on lines
+1375
to
+1378
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Every mainnet Stx consumer will build, parse and route real-fund Why this was flaggedThe mainnet Verification: Trigger: any mainnet consumer of @ bitgo/statics builds or parses a contract call whose deployer is SP3JVSE4ZB5GMDJP5XBPX7ZB1BG3QDFW7RCEQJDMY. networks.ts:1378 puts the address on the shared mainnet |
||
| } | ||
|
|
||
| class StxTestnet extends Testnet implements StacksNetwork { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Every mainnet consumer will now build and parse
pox-4andsend-many-memocalls to the third-party test deployer, not just itspox-5.isValidContractAddresstrusts the configured address on its own.ContractBuilder.isContractPairValidthen accepts any canonical name at any address that passes. Fix: scope the trust to the (pox-5, configured address) pair, checking it inisContractPairValidandPox5Builder.isValidContractCall, and leaveisValidContractAddressaddress-only for the canonical contracts.Why this was flagged
The new clause at utils.ts:295 adds
SP3JVSE4ZB5GMDJP5XBPX7ZB1BG3QDFW7RCEQJDMYto every check done throughisValidContractAddress.ContractBuilder.contractAddress(contractBuilder.ts:108) therefore accepts it.isContractPairValid(contractBuilder.ts:66-73) returns true whenisCanonicalName && isCanonicalAddress, and canonical names includepox-4andsend-many-memo. So asend-many-memoorpox-4call to that deployer builds, and throughfactory.from(hex)it is rehydrated and explained like a trusted BitGo contract. On base it was rejected with 'Invalid contract address'. That deployer is an outside Stacks Foundation test key and can deploy a contract under any name, such as asend-many-memothat sends funds elsewhere. Explain/sign paths would show such a call as a normal send-many or stacking call. The doc comment's own @ obligation note says the address is trusted for every Stacks transaction. The PR describes the change as pox-5 only, and the test edit in contractBuilder.ts (swapping in a new dummy address) shows that cross-name pairing now happens.Verification: On mainnet, a build or
factory.from(hex)parse of a contract call whose deployer is SP3JVSE4ZB5GMDJP5XBPX7ZB1BG3QDFW7RCEQJDMY and whose name ispox-4orsend-many-memopasses. contractBuilder.ts:66-73isContractPairValidreturns true wheneverisCanonicalName && isCanonicalAddress. On the base commit, line 110 throws "Invalid contract address" for this deployer.