-
Notifications
You must be signed in to change notification settings - Fork 5k
Conversation
@garious WDYT? This deviates slightly from the current Budget DSL |
I just added another commit proposing what a wallet cli for this could look like. For 0.8 we could also just punt on defining a yaml/json/whatever external representation and instead encode budget transactions as:
Uses all the same stuff under the hook but you just don't get the experience of: $ vim budget-transfer.yml
... edit edit...
$ solana-wallet compile budget-transfer.yml -o transaction.bin
$ solana-wallet send transaction.bin until 0.10. Advantage of this approach too is that it forces Budget to remain very simple. If we define an external representation then it's a short slide down to adding conditionals and loops. But we really ought to be using the generalized contract infra for that in 0.10 and beyond |
I've been thinking of keys as the interpreter's stack, not a heap. So the high-level data structure wouldn't ever reference |
Yeah I think of keys as the same (in addition to the transaction userdata). |
The existing low-level, expression-oriented Budget AST seems more elegant to me. The only thing I was expecting to see change is less keys in the low-level AST, and more keys in the high-level one. Specifically, the low-level AST does not contain |
I think you can ignore #1189 for now, since it is running multiple experiments at once and offers no new tests in all that I/O-free code. It doesn't look like that'll get merged any time soon. Instead, consider pulling the useful bits out of there, write some tests, and let's get that part merged. |
Hmm, there is only one to key. That’s key[1]. This can’t be encoded in Account userdata because that’s where the tokens actually live while the Transfer is pending. I feel like we aren’t talking the same language yet. What does high and low-level AST mean to you exactly? |
To me, the low-level AST is exactly what's serialized in |
Also, I'm having trouble seeing why we'd add the |
I see var budget = BudgetExpr(from, tokens)
.afterDate(dt)
.pay(tokens, to); Or perhaps hide the smart contracts from the user and write something like: var tx = Transaction(from, tokens)
.afterDate(dt)
.pay(tokens, to)
.sign(secretKey); |
Low-level AST (Account userdata): the With v0.2 I arrived at the conclusion that the high-level AST should just be wallet cli extensions and a JS object. No YAML/JSON/etc representation as the language is so small it felt like overkill.
Yeah that works too. I kept it separate during this discussion in an attempt at clarity. I certainly see rewriting |
Are we talking about the same thing when I said:
If so, this is the part I'm referring to when I say we gotta get those Pubkeys out of the low-level AST and turn A second possibility is to go ahead and leave the keys in the AST and boot the My preference is the latter, but maybe it's not feasible. @aeyakovenko, thoughts? |
@mvines, I spoke with @aeyakovenko about this. We're basically on the same page now. We're not going to add a |
|
||
### Transfer (aka, Budget v2) Transaction Format | ||
```rust | ||
pub enum TransferCondition { |
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.
This was called Condition in budget.rs, which seems like a better name, because it doesn't assume the consequence of satisfying that condition would be to make a payment. Note that Budget
is an enum with After(Condition, Payment)
. The only reason that's not After(Condition, Box<Budget>)
is because we didn't write the static analysis code to ensure that's not a really big, expensive expression.
Witness(Pubkey), | ||
} | ||
|
||
pub struct Transfer { |
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.
This is called Payment
in payment_plan.rs, but includes a to
pubkey. In the current code, a Budget expression wraps and guards the Payment
instead of including those guards in the struct. In this proposed form, you'd need to add cancellable
and conditions
fields to every type of action, not just payment. Also, if a transaction was not cancellable and had no conditions, you'd have to pay 9 bytes to tell the system its the base case instead of just 1, Budget::Pay
.
/// Cancel the `Transfer` identified by `key[1]`. Fails if `key[0]` is not in `Transfer` | ||
/// `cancellable`, or if the `Transfer` is already unlocked. The `tokens` will be returned to | ||
/// `key[0]`. | ||
Cancel, |
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.
In the current code, what you call Witness
below aims to handle this case.
/// Declare and instantiate a new `Transfer` into `key[1]` using tokens from `key[0]`. | ||
/// | ||
/// `key[1]` must be unallocated before calling `Create` | ||
Create(Transfer), |
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.
This is something like NewContract(Contract(Instruction(Budget)))
in current code. I like the idea of moving all Budget-specific constructors out of Instruction
.
|
||
#### Cancel Transfer | ||
```sh | ||
$ solana-wallet transfer cancel TransferPubKey |
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.
Strange to see this and witness under the transfer
command. How about solana-wallet cancel $sig
?
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.
I guess this comes down to the question of, do we want solana-wallet
to be Budget DSL specific? Doesn't seem like a bad idea necessarily, I just didn't want to jump right to there without discussion first. But sounds like you're already there?
|
||
#### Indicate Elapsed Time. | ||
```sh | ||
$ solana-wallet transfer timestamp TransferPubKey 2018-12-24T23:59 |
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.
How about: solana-wallet timestamp
and have it submit the system time by default? I wonder if that should also optionally include a the contract signature. Ideally it wouldn't, but it's a pretty expensive operation for the server to go look up every contract that might be waiting on a timestamp instead of just the one you're targeting.
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.
Submitting the system time by default sounds good.
There's no need to include a contact signature. The contact is the public key (denoted by TransferPubKey) that the timestamp instruction is directed at.
Ok so we want to reduce all the @CriesofCarrots, with that do you have enough info to start moving the cli design forward using the current contents of this PR as a guide? Internally we'll need to tweak a couple things in Budget DSL/bank.rs to some of the commands actually work, I can work on that in parallel and/or you can help too if I'm too slow. |
Excellent. Yes, I do, thanks! |
302 #1258 |
This RFC defines the external Budget DSL-like language.