-
Notifications
You must be signed in to change notification settings - Fork 116
Generic Boxes #23
Comments
Could you provide some example? If it is about "access restrictions", so I assume restricting access to the block itself, then probably String field should be a part of a proposition? |
As we are developing smart contract templates, we have chosen to store a contract shared amongst members as a box with a value type that can hold the state data for that contract (sealed by a 1-of-n proposition). It's different than the above, but it is a case where the default value of I understand that one could add additional data to the boxes, but given especially the way that boxes are handled in wallet, it seems a bit silly to do so just to end up with an extraneous So far, we've ended up building a set of generic type structures that sit parallel to a lot of the existing pieces (e.g. Box, MinimalState, BoxTransaction, etc) all the way up to the NodeViewHolder and Application level, largely duplicating existing logic because of how tightly coupled they all are. |
As far as a |
Any further thoughts on this @kushti ? |
@mpk2 Sorry for the long reply Matt! I imagine, a contract(a box) has some number of tokens associated with it? Then value is needed. State could be made a part of Proposition, if transaction applicability depends on it (proposition could be e.g. a tuple of <state, set of possible transitions> then). I never thought about token-less applications actually. I'll revise whether it it possible to do painless generalization regarding value field (another code review is coming, final before next Release Candidate version). |
Thanks! Really enjoy the work that has been put into this project. We're building out our sections as it goes along. I think that since we're running contract templates ourselves, the contract state is sufficient to determine valid transitions itself (it's not a sandboxed Turing-complete sort of setup). Instead, the contract can locally check the validity of an executed internal transaction. What you've just written seems generally applicable, though! We've already decided to generalise some of the structures for our project. Would it be worth submitting a pull request if you decide to revise? |
Thanks for the great words. would be extremely happy to get pull requests. So a contract is enough to validate transactions associated with it(no anything external is needed)? and no tokens associated with it? |
To be more specific, contract templates as we're currently developing them have a limited lifespan. There are 3 types of transactions for this lifespan: The purpose here is for a contract to internally keep track of and modify its state of affairs as they pertain to a group of accounts. Depending on the final state of affairs at the end of lifespan, balances of cryptocurrencies within the minimal state do change. However, you wouldn't call these tokens as they are not maintained or modified during contract execution. It would be more similar to the idea that contracts in Ethereum could return ether to a user depending on their internal state. The system can probably be envisioned in Ethereum as something like some master contract that maintains user token balances and spawns sub-contracts. It's probably a strange use-case, but it currently matches our needs. |
In case I wasn't clear (I sometimes write a little too much) each type of contract transaction does rely at least partially on minimal state to validate. For |
That sounds like a proposition is a state of a (finite?) state machine . so Proposition is the machine description. Is it a good model? |
That's probably not a bad way to think about it. I separated this out from the proposition itself. As it's currently implemented, the signature on the tx is checked against a list of valid parties that can interact with the contract, so the proposition right now on the contract box is a (very naive version of) 1-of-n multisig proposition like |
I think the only reason I didn't include it in the Proposition is that it also needs to be part of the generation for the new box (i.e. new contract state) |
Pull request submitted #25 |
@kushti Any thoughts on the PR? |
@zihehuang Sory, we were a bit overbusy last week, will regard pull request in few days |
Currently, boxes are parameterized only by proposition, with a value type of
Long
. It seems that a lot of the code is intertwined with this assumption, but there's no particular reason why box values should be limited toLong
.One example is using
String
as the value type for a box in order to define access restrictions to a blockchain resource.The text was updated successfully, but these errors were encountered: