Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up⚗️ Actions returned from HTTP should be self-descriptive #494
Comments
This comment has been minimized.
This comment has been minimized.
Maybe better:
|
This comment has been minimized.
This comment has been minimized.
We should also consider the possibility to use the So instead of |
LLFourn
added
the
open source
label
Dec 8, 2018
This comment has been minimized.
This comment has been minimized.
Note: I'm adding open source to this because it would make the json snippets in blog post nicer to read but team feels it's more of a "nice to have" so consider it to be done last. |
bonomat
removed
the
open source
label
Dec 12, 2018
D4nte
changed the title
Actions returned from HTTP should be self-descriptive
⚗️ Actions returned from HTTP should be self-descriptive
Jan 16, 2019
D4nte
added
groomed
sprint-backlog
and removed
groomed
labels
Jan 16, 2019
D4nte
added this to the Sprint 6 🔄📖 milestone
Jan 16, 2019
thomaseizinger
added
work-in-progress
and removed
sprint-backlog
labels
Jan 16, 2019
thomaseizinger
self-assigned this
Jan 16, 2019
This comment has been minimized.
This comment has been minimized.
Mediatype vs "inline"-typingFor simplicity reasons, I would say we go with "inline"-typing for now and ditch the mediatype approach. DesignWe currently have four different actions, I've outlined what they could look like below: Send-to-bitcoin address action(amount will be in sat) {
"type": "send-amount-to-bitcoin-address",
"payload": {
"to": "...",
"amount": "5000000"
}
} broadcast signed bitcoin transaction action{
"type": "broadcast-signed-bitcoin-transaction",
"payload": {
"hex": "..."
}
} deploy ethereum contract(amount will be in wei) {
"type": "deploy-ethereum-contract",
"payload": {
"data": "...",
"amount": "...",
"gas_limit": "..."
}
} invoke ethereum contract{
"type": "invoke-ethereum-contract",
"payload": {
"to": "...",
"data": "...",
"gas_limit": "..."
}
} Design rationale
|
This comment has been minimized.
This comment has been minimized.
We had the idea while you were away to be on the side of providing more information rather than less. For example:
Obviously this kind of information isn't needed to execute the action but could be useful in some kind of orthogonal decision making and debugging. It would be very useful for application developers to gain an understanding of what is actually happening.
|
This comment has been minimized.
This comment has been minimized.
Good to me. Agree with starting action name with associated ledger. ie |
This comment has been minimized.
This comment has been minimized.
One more thought on that: while some actions do not exist on all blockchains, we can try to generalize others. They are mostly similar and reduce the amount of different action types we need to hold in some enum, etc.. The question is what do you want to express with the For example, Deploy Ethereum smart contract
The same action could be used for The same action can also be used for Bitcoin, just leave out the Ethereum related fields, e.g. for Funding Bitcoin HTLC:
|
This comment has been minimized.
This comment has been minimized.
I can see how this might be useful, however, I'd also consider it to be a separate feature. Let's keep the scope small and build things like that as we need them.
Good point, I will incorporate that.
I went back and forth between something very similar to your solution and what I ended up presenting. The reason I didn't go for that one is because if you take the generalization all the way to the end, you end up with {
"type": "send-transaction",
"ledger": "ethereum",
"payload": {
"...": "..."
}
} The main reason I didn't want to go for that is because I think there is value in being unambiguous here about what should be done and to reduce runtime errors. This mainly boils down to not having optional fields: An optional field always leads to runtime decisions that need to be made by clients. Although in the end, all these actions result in transactions being made, I think there is value in allowing client developers to have assurance of what is done by a certain code path. My feeling would be that relying on the In the end, I would prefer clients to be as dumb as possible because it reduces the risk of using the API in a wrong way. If they are a fan of generalizing all these actions, they can always write a function themselves that normalizes all these parameters into a single function call which eventually sends a transaction. However, more specific
I had the same thought. However, in the end, there is not really much cost associated with it. Plus it allows us to specify all possible values at compile-time, which results in less runtime errors (compared to a combinatorial solution). Here is the updated proposal: Send-to-bitcoin address action{
"type": "bitcoin-send-amount-to-address",
"payload": {
"to": "...",
"amount": "5000000"
}
} broadcast signed bitcoin transaction action{
"type": "bitcoin-broadcast-signed-transaction",
"payload": {
"hex": "..."
}
} deploy ethereum contract{
"type": "ethereum-deploy-contract",
"payload": {
"data": "...",
"amount": "...",
"gas_limit": "..."
}
} invoke ethereum contract{
"type": "ethereum-invoke-contract",
"payload": {
"contract_address": "...",
"data": "...",
"gas_limit": "..."
}
} |
This comment has been minimized.
This comment has been minimized.
Yap, makes sense. Just one thing on
I would be careful with this as it is not generally true. If the target is a contract even the default function could have some logic in it making the transaction more expensive. In regards of the proposal:
|
This comment has been minimized.
This comment has been minimized.
Hmmm. I thought about the situation where this might bite us. The only one I could think of is that a user supplies a contract address as their redeem/refund address thinking it will just work. Then when they reveal the secret or whatever they find that it's impossible to get their funds out. I googled around and found out that this actually can't happen in our case because we use selfdestruct which transfers eth but doesn't do a call.
For completeness sake I agree. There are contracts that have functions that require the user to transfer eth in the call so we should handle this case. [EDIT] Also we may want to include the |
This comment has been minimized.
This comment has been minimized.
Network may be a good idea for all actions. Will add it!
Good point! Will add it! |
thomaseizinger
referenced this issue
Jan 17, 2019
Closed
Make actions returned from HTTP API self-descriptive #673
This comment has been minimized.
This comment has been minimized.
I'll consider this spike to be done with the creation of #673. |
thomaseizinger
closed this
Jan 17, 2019
wafflebot
bot
removed
the
work-in-progress
label
Jan 17, 2019
This comment has been minimized.
This comment has been minimized.
Do you have a link to that? I would be interesting to see what will happen when you |
LLFourn commentedNov 27, 2018
•
edited by luckysori
Decide how to implement this.
DoD:
When deserialization the bitcoin htlc funding action we currently get:
This should include a field saying what you're meant to do: