-
Notifications
You must be signed in to change notification settings - Fork 0
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
[WIP] Covenant fees #8
Conversation
TODOs:
|
Good work! Looking over this, it looks like you are going in the right direction. Definitely some style nits (we try to keep as close to the hsd style as possible) but you can really have whatever style you want if you aren't planning on opening it as a PR against the other |
I plan to merge it into the other repo, so I'll follow hsd style guidelines. Are they written down somewhere? I think I just need to change my editor to grab the write config. |
I cloned I will leave comments regarding style, I do not think that the linter will catch all of them. Reading through the codebase a few times will help. Things are generally minimal and there is a focus on performance. For example, short variable names, |
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.
Please give feedback on the comments. Ultimately, the final decision to merge code doesn't just come down to me but also Zippy and Boyma. These are based on my interpretation of our style so if you disagree, feel free to have them review as well/read through the codebase more to get your own feel for the style.
*/ | ||
const updateLimitedTypes = new Set(types.OPEN, types.UPDATE, types.TRANSFER, types.REVOKE); | ||
|
||
rules.isUpdateLimited = function isUpdateLimited(typeStr) { |
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 think this should take a Number
instead of a string
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.
And we should be very sure that this function doesn't already exist in the codebase someplace
@@ -528,6 +528,16 @@ rules.countOpens = function countOpens(tx) { | |||
return total; | |||
}; | |||
|
|||
/** |
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.
You could simplify this by making it a bit more abstract and declaring each "Bucket" and either:
- Storing the bucket in an power-of-two enum and declaring a mapping from each type to its bucket(s)
- Directly declaring the types included in each bucket and having a single method check for membership in each bucket. (i.e. exporting the "Sets" in a lookup-only wrapper class)
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 actually think this bucketing maybe fits best in the fee estimator, not the rules.
* @returns {Rate} | ||
*/ | ||
|
||
estimateFee(target, smart, covenantType) { |
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.
It's not clear that none of these buckets will ever intersect. I think it's simplest just to estimate fees in all applicable ways and take their max at the end.
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.
You mean something like this?
estimateFee(target, smart, covenantType) {
const estimates = [];
if (rules.isOpenLimited(covenantType)) {
estimates.push(this.openFees.estimateFee(target, smart));
}
if (rules.isUpdateLimited(covenantType)) {
estimates.push(this.updateFees.estimateFee(target, smart));
}
if (rules.isRenewalLimited(covenantType)) {
estimates.push(this.renewalFees.estimateFee(target, smart));
}
estimates.push(this.blockspaceFees.estimateFee(target, smart));
return Math.max(...estimates);
}
You may find this relevant bcoin-org/bcoin#518 |
Thanks for all your feedback @tynes. I made your suggested changes and reopened the PR against the main repo: handshake-org#282 |
Here's a proof-of-concept of my covenant fees proposal. It's not connected to anything, so it doesn't work yet. My goal is to show the scope of the intended changes and get feedback about them.
There are two parts:
ComposedEstimator
class, which keeps track of four estimators, one for each fee limit. Its job is to pass through arguments to the appropriatePolicyEstimator
.rpc
to show the type of changes required changes to fee estimation. This change is just an example. Ultimately, I'd have to change all of the places where something callsestimateFee
andestimatePriority
.Does this approach make sense?