Repository navigation
[RFC] Example-driven proposal for Move-based programmability - #4
Conversation
870cfb3 to
a13ed34
Compare
gdanezis
left a comment
There was a problem hiding this comment.
Wow. Mind blowing stuff.
| // logic for their structs that cannot be subverted by other modules | ||
| public native fun transfer<T: key>(obj: T, recipient: Authenticator); | ||
|
|
||
| /// Transfer ownership of `obj` to another object `id`. Afterward, `obj` |
There was a problem hiding this comment.
Nice one: also I think the constraint is a little stronger than it may be used only when another object is in the Tx. The 'owner' object smart contact needs to invoke the operation that uses the owned object?
There was a problem hiding this comment.
I don't think I understood this. Here's what I was thinking in more detail; let me know which part is too strong.
- Every transaction has to be signed by one end-user Bob
- A transaction can include objects directly owned by Bob (e.g.,
obj1.authenticator = Bob) - Under the George proposal, objects can own other objects, and a the transaction can also include objects transitively owned by Bob (e.g.,
ParentObj.authenticator = GranparentObj, ChildObj.Authenticator=ParentObj, GrandparentObj.authenticator = Bob) - If a transaction wants to use ChildObj, it must also include ParentObj and GrandparentObj + be signed by Bob. Otherwise, we can't verify which end-user's signature grants permission to include ChildObj.
There was a problem hiding this comment.
Thanks for these examples, they're great!
In several cases, I've noticed portions of examples that angle towards ACLs: we have a list of subjects with special permissions:
const ADMINinHero.move,const OWNERinTrustedCoin.move
I've indicated other "roles" that may arise, for instance on the EscrowSwap contract.
Sidenote:
Just so we're on the same page re: vocabulary in the context of this discussion:
- we're dealing with resources (e.g. a boar, a sword, a
TreasuryCap),- and we're dealing with subjects (e.g. the owner of the passed resources, the admin account, the coin
OWNERaccount),ACLs are what guarantees safety when you "classify" what can happen depending on the resource at hand (e.g. for the
Herocontract, the normal callers have ambient permissions toslay,heal, ..., whereas the admin also has permissions tocreate_{potion, boar}). And, as you know, capabilities are what happen when you "sort" permissions on the subject at hand (e.g. Bob has aSword, and aBoar, so he cancreatea Hero, and maybeslay, but notheal).
Overall, I would like some details on the management of the contract ACL list, if you will.
- if it is, as demonstrated, limited to constants —requiring a full-fleged contract update to change— do we plan to manage those updates more loosely in FastX? If not, is this manageable? How do we address the proliferation of contracts who want a "fork" of the
HeroesOfBC&Magicgame? - Will we materialize explicit ACLs? What would that look like? Maybe a
Permissionstype, pointers from smart contracts to a specific handful of coarsePermissionsinstances, and a global namespace tyingPermissionsto users ? - How do we delegate and revoke permissions?
| sword: Sword, | ||
| } | ||
|
|
||
| /// The hero's trusty sword |
There was a problem hiding this comment.
I think the later. What I haven't seen is the Sword creation though.
| ) { | ||
| let v = read_field(to_read); | ||
| write_field(to_write, v + int_input); | ||
| transfer(to_consume, Authenticator::new(bytes_input)); |
There was a problem hiding this comment.
I think the idea here I think is to represent object ownership (in the pecuniary sense) by object ownership (in the Rust capability sense).
Even If a &mut foo sufficed at runtime to transfer foo (by, say a —hypothetical— mutation of an owner field in foo), then any smart contract you'd give this &mut foo to could either give your foo a new sword, or transfer it away, at its discretion.
One language trick to reconcile your expectation of drop and your read of "taking a value" is to call it "consuming" a value.
| public fun create<T: key + store, ExchangeForT: key + store>( | ||
| recipient: Authenticator, | ||
| third_party: Authenticator, | ||
| exchange_for: IDBytes, | ||
| escrowed: T, | ||
| ctx: &mut TxContext | ||
| ) { |
There was a problem hiding this comment.
IIUC, nothing prevents e.g. me from escrowing the object to myself, and then scamming others into participating in an exchange with me.
Without a return_to_sender call automatically issued by a timekeeper I do not control (as discussed later), this allows me to block another person's object (as well as my own), trolling them, or alternatively, holding this as a perpetual American option.
In other terms, we need to make sure the 3d party is not only not the sender (symmetrically receiver), but also not otherwise controlled by the sender (resp. receiver).
There was a problem hiding this comment.
Ah, interesting point. I don't think there's much we can do about this--at the very least, we can assert that sender and recipient are not the same as third_party. But of course in general, third_party can be recipient with a different authenticator, and there's no good way to prevent that.
I think this attack is a special case of "if the trusted third party is not trustworthy, your objects will get locked up", but makes the important point that the trusted third party might have more motivation to lock up your object than you might think (i.e., trolling is not rational, holding a free American option is...)
If you want to use objects defined by HeroesOfBC&Magic in a different game, that should be possible by simply defining a new module that adds new logic around those objects. However, if the user wants to mutate the objects in ways that aren't allowed by the original module, or change the game logic, they'll need to fork the contract. If it's well-engineered, HeroesOfBC&Magic will be split across multiple modules that isolate the more generic bits from the game-specific ones + allows lots of customization of the generic bits.
TBD. I think there are interesting decisions between simplicity (it doesn't get any easier than asserting that the sender authenticator is equal to a constant) and more complex, but possibly harder-to-use access control functionality. My inclination is to start with the simplest methods, then add more as there are needs/clear value props (using capabilities, which are more complex but enable delegation is a great example).
See #4 (comment) |
ced417d to
c0c0fa5
Compare
c0c0fa5 to
c1ed7cc
Compare
[Object Ownership #4] Prevent circular ownership
fixed type stack length bug
…ct.rs Addresses review comments #4 and #7: - Move enable_gcp_attestation feature flag and gas cost params from protocol version 115 to 121 (the current max). Version 115 was far too early and would retroactively enable the feature. - Revert sui_object.rs TryInto<Object> to use get_for_min_version() as on main. The get_for_max_version_UNSAFE workaround was added for MovePackageTooBig during earlier broken-snapshot iterations and is no longer needed now that v118/v120 snapshots are correct. - Update protocol config snapshots for versions 115-120.
## Summary Automated documentation fixes based on the weekly docs audit report. ### Fixed issues - 🔴 **#1** [HIGH]: CLI: `send-funds` command missing from docs snippet - 🔴 **#2** [HIGH]: Move CLI: `sui move new` generated `Move.toml` is completely outdated - 🔴 **#3** [HIGH]: Move CLI: Directory listing shows `Sources` (capital S) instead of `sources` - 🟡 **#20** [MEDIUM]: Move build output mentions `UPDATING GIT DEPENDENCY` - 🟡 **#21** [MEDIUM]: Move coverage: Claims debug build is required - 🔴 **#4** [HIGH]: Exchange Integration: `sui_getEvents` API used with wrong signature - 🔴 **#5** [HIGH]: Exchange Integration: Variable name bug in curl example - 🔴 **#6** [HIGH]: Exchange Integration: Uses devnet URLs for production guidance - 🔴 **#9** [HIGH]: Duplicate exchange integration docs - 🔴 **#10** [HIGH]: Exchange Integration: Rust SDK examples use deprecated `SuiClientBuilder` with JSON-RPC - 🟡 **#22** [MEDIUM]: Exchange Integration: `read_api().get_balance()` pattern - 🔴 **#7** [HIGH]: Validator CLI: Missing commands in docs - 🔴 **#8** [HIGH]: Research Papers: Outdated consensus description - 🟡 **#11** [MEDIUM]: GraphQL: Hardcoded version number `1.56.1` - 🟡 **#12** [MEDIUM]: External Signers: Hardcoded minimum version - 🟡 **#13** [MEDIUM]: Package Management: Hardcoded `toolchain-version = "1.64.0"` - 🟡 **#14** [MEDIUM]: Full Node Config: `enable-event-processing` in template but not in NodeConfig - 🟡 **#15** [MEDIUM]: Full Node Config: `rpc.enable-indexing` not prominently documented - 🟢 **#28** [LOW]: Full node setup: Genesis blob URLs use `curl -fLJO` - 🟡 **#16** [MEDIUM]: Consensus: Performance numbers may be stale - 🟡 **#17** [MEDIUM]: `client.mdx`: Dynamic field example shows `SuiSystemStateInnerV2` - 🟡 **#18** [MEDIUM]: Release Notes: Broken external URL - 🟡 **#19** [MEDIUM]: DeepBook Margin SDK: Hardcoded fullnode URLs - 🟢 **#25** [LOW]: Observability doc is marked as draft - 🟢 **#26** [LOW]: Tokenized Asset docs reference `UPDATING GIT DEPENDENCY` - 🟢 **#27** [LOW]: Install from source: `--features tracing` documentation ### Files changed - `docs/content/snippets/console-output/sui-client-help.mdx` - `docs/content/references/cli/move.mdx` - `docs/content/operators/exchange-integration.mdx` - `docs/content/references/exchange-integration-guide.mdx` - `docs/content/references/cli/validator.mdx` - `docs/content/references/research-papers.mdx` - `docs/content/develop/accessing-data/using-events.mdx` - `docs/content/develop/accessing-data/graphql/query-with-graphql.mdx` - `docs/content/references/cli/external-signers.mdx` - `docs/content/develop/manage-packages/move-package-management.mdx` - `docs/content/operators/full-node/sui-full-node.mdx` - `docs/content/develop/sui-architecture/consensus.mdx` - `docs/content/references/cli/client.mdx` - `docs/content/references/release-notes.mdx` - `docs/content/onchain-finance/deepbook-margin-sdk/deepbook-margin-sdk.mdx` - `docs/content/operators/observability.mdx` - `docs/content/onchain-finance/tokenized-assets/deploy-tokenized-asset.mdx` - `docs/content/getting-started/onboarding/install-source.mdx` ### Skipped (manual action needed) - 🟢 **#23** [LOW]: `completion` subcommand not independently documented - 🟢 **#24** [LOW]: `fire-drill` subcommand not documented --- *This PR was automatically generated by the Docs Audit Fixer. Please review the changes carefully before merging.*
## Summary Automated documentation fixes based on the weekly docs audit report. ### Fixed issues - 🔴 **#1** [HIGH]: zkLogin Integration: Devnet hardcoded as the example RPC URL - 🟡 **#2** [MEDIUM]: Gasless Stablecoin Transfers: Eligible stablecoins linked to a merged PR, not stable docs - 🟡 **#3** [MEDIUM]: `references/cli.mdx`: Wrong capitalization in suiup GitHub URL - 🟡 **#4** [MEDIUM]: `references/cli.mdx`: `external-keys` command not listed in CLI overview - 🟡 **#5** [MEDIUM]: DeepBook Predict docs: pinned to feature branch `predict-testnet-4-16` — will go stale - 🟡 **#6** [MEDIUM]: Client CLI: Several newer commands have no examples in `client.mdx` - 🟡 **#7** [MEDIUM]: zkLogin demo: VITE_NETWORK=devnet in .env example - 🟢 **#10** [LOW]: indexer `build.mdx`: "Recommended" pattern still starts with 30-day-retention HTTPS endpoint - 🟢 **#11** [LOW]: DeepBook Predict server URL not in main contract information page - 🟢 **#12** [LOW]: `references/sui-move.mdx` links to `move-summary` snippet that may need updating ### Files changed - `docs/content/sui-stack/zklogin-integration/index.mdx` - `docs/content/develop/transaction-payment/gasless-stablecoin-transfers.mdx` - `docs/content/references/cli.mdx` - `docs/content/onchain-finance/deepbook-predict/deepbook-predict.mdx` - `docs/content/references/cli/client.mdx` - `docs/content/sui-stack/zklogin-integration/zklogin-demo.mdx` - `docs/content/develop/accessing-data/custom-indexer/build.mdx` - `docs/content/onchain-finance/deepbook-predict/contract-information.mdx` - `docs/content/references/sui-move.mdx` ### Skipped (manual action needed) - 🟢 **#8** [LOW]: `completion` subcommand still not documented - 🟢 **#9** [LOW]: `fire-drill` subcommand still not documented --- *This PR was automatically generated by the Docs Audit Fixer. Please review the changes carefully before merging.* --------- Co-authored-by: wlmyng <[email protected]>
## Summary Automated documentation fixes based on the weekly docs audit report. ### Fixed issues - 🟡 **#4** [MEDIUM]: Custom indexer docs still make the 30-day HTTPS checkpoint endpoint part of the canonical “recommended” startup command ### Files changed - `docs/content/develop/accessing-data/custom-indexer/build.mdx` ### Skipped (manual action needed) - 🟡 **#1** [MEDIUM]: Full node docs still point to the YAML template for the “complete list” of `rpc` options, but the template does not contain that list - 🟡 **#2** [MEDIUM]: `client.mdx` still omits examples for several commands that ship in `sui client --help` - 🟡 **#3** [MEDIUM]: zkLogin demo still defaults to Devnet even though the main zkLogin guide was corrected to Testnet - 🟡 **#5** [MEDIUM]: DeepBook Predict docs still carry a stale freshness marker and remain pinned to a dated Testnet branch - 🟡 **#6** [MEDIUM]: New v2alpha ledger-history list APIs and their required full-node knobs are effectively undocumented - 🟢 **#7** [LOW]: `completion` still has no dedicated docs page - 🟢 **#8** [LOW]: `fire-drill` still has no docs page or “internal-only” note - 🟢 **#9** [LOW]: `MystenLabs` GitHub URL casing is still inconsistent in multiple docs --- *This PR was automatically generated by the Docs Audit Fixer. Please review the changes carefully before merging.*
See included README