-
Notifications
You must be signed in to change notification settings - Fork 267
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
Configurable Fiat-Based Stable MinGasPrice #2310
Conversation
rskj-core/src/test/java/co/rsk/mine/gas/DefaultMinGasPriceProviderTest.java
Fixed
Show fixed
Hide fixed
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 really liked the approach and the way you tackled the problem. Good job.
Generally, I don't have big changes to recommend. But some small things that IMO could make it even more flexible than the approach you have followed. Let me know your opinion, if you want to discuss it on slack, ping me. 😄
rskj-core/src/main/java/co/rsk/config/mining/HttpGetStableMinGasSystemConfig.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/org/ethereum/config/SystemProperties.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/mine/gas/MinGasPriceProviderType.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/mine/gas/MinGasPriceProvider.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/mine/gas/StableMinGasPriceProvider.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/mine/gas/StableMinGasPriceProviderFactory.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/mine/gas/StableMinGasPriceProviderFactory.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/mine/gas/StableMinGasPriceProviderFactory.java
Outdated
Show resolved
Hide resolved
rskj-core/src/main/java/co/rsk/config/mining/StableMinGasPriceSystemConfig.java
Outdated
Show resolved
Hide resolved
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 seems unnecessarily complicated. Why should a strategy know it's type? Imo there is no need for a factory and all those different abstractions. Also there is no need to change the MinimumGasPriceCalculator. I'd simplify it to the following, given that all the information needed is known on boot-up:
classDiagram
direction RL
class MinimumGasPriceCalculator {
Unchanged - only to illustrate use
+construcor(long)
}
class BlockToMineBuilder {
Unchanged - only to illustrate use
+constuctor(..., MinimumGasPriceCalculator)
}
RskContext --* BlockToMineBuilder
BlockToMineBuilder --o MinimumGasPriceCalculator
RskContext --* MinimumGasPriceCalculator
class RskSystemProperties {
+getMinerMinGasPriceConfig(): MinGasPriceConfig
}
class RskContext {
-getMiningConfig(): MiningConfig
+getBlockToMineBuilder(): BlockToMineBuilder
}
class MinGasPriceConfig {
+providerType: "onchain" | "http" | "default"
+url: URL
+minGasPriceTarget: long
+otherStuffIfAny
+createMinGasPriceProvider(MinGasPriceConfig): MinGasPriceProvider
}
class MiningConfig {
-minGasPriceProvider: MinGasPriceProvider
+constructor(MinGasPriceConfig)
+getMinGasPriceTarget(): long
}
class MinGasPriceProvider {
<<<Interface>>>
+getMinGasPrice()
}
class DefaultMinGasPriceProvider {
+constructor()
}
class OffChainMinGasPriceProvider {
+constructor(OffChainMinGasPriceProviderConfig)
}
class OnChainMinGasPriceProvider {
+constructor(OnChainMinGasPriceProviderConfig)
}
MinGasPriceConfig *-- RskSystemProperties
RskSystemProperties *-- RskContext
MinGasPriceProvider *-- MinGasPriceConfig
MinGasPriceConfig <-- MiningConfig
MinGasPriceProvider o-- MiningConfig
MiningConfig *-- RskContext
MinGasPriceProvider <|-- DefaultMinGasPriceProvider
MinGasPriceProvider <|-- OffChainMinGasPriceProvider
MinGasPriceProvider <|-- OnChainMinGasPriceProvider
rskj-core/src/main/java/co/rsk/mine/gas/provider/onchain/OnChainMinGasPriceProvider.java
Fixed
Show fixed
Hide fixed
rskj-core/src/test/java/co/rsk/mine/gas/FixedMinGasPriceProviderTest.java
Fixed
Show fixed
Hide fixed
rskj-core/src/test/java/co/rsk/config/mining/WebStableMinGasSystemConfigTest.java
Fixed
Show fixed
Hide fixed
rskj-core/src/test/java/co/rsk/mine/gas/provider/MinGasPriceProviderFactoryTest.java
Fixed
Show fixed
Hide fixed
1f27b8a
to
bf975c5
Compare
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.
Good job. I just added some comments with suggestions and thoughts. Let me know if you have some doubt, you can reply here or reach me on slack.
@@ -0,0 +1,92 @@ | |||
package co.rsk.mine.gas.provider.web; | |||
|
|||
public class WebStableMinGasPriceConfig { |
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.
question: why do you need two classes so similar to hold these informations? Why can't you use the one for mapping WebStableMinGasSystemConfig
to receive these parameters on the WebMinGasPriceProvider
?
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.
suggestion: This whole class is unnecessary, it's basically calling the constructor from the OnChainMinGasPriceProvider. If, big if here, we have multiple ways to retrieve the price on-chain we could create such factory. It's the same idea from the other factory, we could just call the constructor directly, we have all the info needed on the other factory.
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.
suggestion: This whole class is unnecessary, it's basically calling the constructor from the WebMinGasPriceProvider
. If, big if here, we have multiple ways to retrieve the price off-chain we could create such factory. But at the moment, I would vouch to keep it simple and write so flexible code if we really need in the future. Having just a simple MinGasPriceProviderFactory
is enough, and we can add the different ways of retrieve here.
logger.warn("Could not find stable min gas price system config, using {} provider", fixedMinGasPriceProvider.getType().name()); | ||
return fixedMinGasPriceProvider; | ||
} | ||
if (!stableMinGasPriceSystemConfig.isEnabled()) { |
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.
thought: maybe would be good to have logged here as well that the feature isn't enabled.
case WEB: | ||
return WebStableMinGasPriceProviderFactory.create(stableMinGasPriceSystemConfig, fixedMinGasPriceProvider); | ||
case ON_CHAIN: | ||
return OnChainMinGasPriceProviderFactory.create(stableMinGasPriceSystemConfig, fixedMinGasPriceProvider); |
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.
suggestion: as commented previously, I would create the MinGasPriceProvider
implementation here directly according the method. You already have all the configurations here, you could have methods to get the config according each type passed to extract the configuration complexity creation.
The concept of a factory is exactly hold these logics necessary to return different implementations, if start to become too complex, we can abstract more and create other classes. But for now, the first level of abstraction is more than enough.
import co.rsk.mine.gas.provider.MinGasPriceProviderType; | ||
import co.rsk.mine.gas.provider.StableMinGasPriceProvider; | ||
|
||
public class OnChainMinGasPriceProvider extends StableMinGasPriceProvider { |
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.
We should be careful with mixing problem domains. I suspect that the RBTC/USD exchange rate != min gas price!
And so all these classes should to be renamed. Furthermore, I don't see anywhere where we make this conversion from XR to min gas price.
What am I missing?
public enum MinGasPriceProviderType { | ||
FIXED, | ||
WEB, | ||
ON_CHAIN |
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 know I suggested this, but that was when I thought that the on chain call would be done directly in the vm rather than through eth module. And so, we should call it ETH_CALL.
…multi_factory feat(smgp): implements eth_call exchange rate provider
Adding new Web Provider
rskj-core/src/test/java/co/rsk/config/mining/OnChainMinGasPriceSystemConfigTest.java
Fixed
Show fixed
Hide fixed
rskj-core/src/test/java/co/rsk/mine/gas/provider/web/WebMinGasPriceProviderTest.java
Fixed
Show fixed
Hide fixed
rskj-core/src/main/java/co/rsk/mine/gas/provider/web/WebMinGasPriceProvider.java
Fixed
Show fixed
Hide fixed
rskj-core/src/test/java/co/rsk/config/mining/EthCallMinGasPriceSystemConfigTest.java
Fixed
Show fixed
Hide fixed
rskj-core/src/test/java/co/rsk/config/mining/HttpGetStableMinGasSystemConfigTest.java
Fixed
Show fixed
Hide fixed
rskj-core/src/test/java/co/rsk/mine/gas/FixedMinGasPriceProviderTest.java
Fixed
Show fixed
Hide fixed
rskj-core/src/test/java/co/rsk/mine/gas/provider/HttpGetMinGasPriceProviderTest.java
Fixed
Show fixed
Hide fixed
Quality Gate passedIssues Measures |
master -> feature/include_stable_minGasPrice_provider merge
Quality Gate passedIssues Measures |
Enhancing Miner Configuration for Stable Transaction Costs
Description
Develop and integrate a feature that allows RSK miners to configure the minimum gas price (MinGasPrice) in fiat currency instead of the current cryptocurrency (WEI) linked to Bitcoin. This feature aims to stabilize the transaction cost in fiat terms, improving predictability and user experience.
Motivation and Context
Currently, RSK miners can set the minimum gas price (MinGasPrice) using the miner.minGasPrice configuration, which is denominated in WEI and inherently linked to the Bitcoin price. This linkage causes transaction costs to fluctuate with Bitcoin's value, potentially leading to increased costs when Bitcoin appreciates, thereby adversely affecting user experience.
To address this issue, the proposed feature aims to empower miners with the ability to specify and configure the minimum gas price in fiat currency. This change would stabilize transaction costs in fiat terms, regardless of cryptocurrency market variations, and is intended to enhance predictability and user satisfaction. Currently, the system supports only one configuration parameter for setting the MinGasPrice.
The goal is to give miners a capability to specify / configure min gas price value denominated in a fiat currency.
How Has This Been Tested?
Types of changes
Checklist: