-
Notifications
You must be signed in to change notification settings - Fork 35
New API #297
New API #297
Conversation
564ac24
to
3f8b98c
Compare
b6aeec5
to
01b97cf
Compare
018b1c2
to
39e5f76
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.
Solid work! The new API is well organised and clean.
I only managed to review about 1/3 of it. Will find another time to continue with the remaining.
|
||
</details> | ||
|
||
## New Organization of APIs |
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.
The new organisation looks much better!!!
@Override | ||
public void configureRoutes(final RoutingHandler handler) { | ||
handler.get("/health", this::handleHealthRequest); | ||
handler.get("/health/", this::handleHealthRequest); |
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.
Minor: don't think we need both; it only causes confusion rather than does anything good.
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 makes both paths accepted by server. Such a minor thing as trailing slash should not cause issues to client
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 understand your intention but not totally agree.
We should encourage clients to use the correct endpoint (less flexible), rather than to correct their mistakes.
handler.post("/rpc", this::handleRpc); | ||
handler.post("/rpc/", this::handleRpc); | ||
handler.get("/universe.json", this::handleUniverseRequest); | ||
handler.get("/universe.json/", this::handleUniverseRequest); |
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.
Similarly
radixdlt-core/radixdlt/src/main/java/com/radixdlt/api/data/BalanceEntry.java
Show resolved
Hide resolved
radixdlt-core/radixdlt/src/main/java/com/radixdlt/api/data/TransactionAction.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.
A few more comments
radixdlt-core/radixdlt/src/main/java/com/radixdlt/api/handler/ArchiveTransactionsHandler.java
Show resolved
Hide resolved
RuntimeProperties properties | ||
) { | ||
this.port = properties.get("node_api.port", DEFAULT_PORT); | ||
this.port = properties.get("api.node.port", DEFAULT_PORT); |
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 might also consider making the binding network interface configurable, as suggested by #321
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 a good idea, but for other PR
private JSONObject constructBalanceEntry(REAddr rri, UInt384 amount) { | ||
return clientApiStore.getTokenDefinition(rri) | ||
.fold( | ||
__ -> jsonObject().put("rri", "<unknown>").put("amount", amount), |
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.
Is it possible to have RRI with no definition?
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 a safety guard in case if there are any issues with DB which may prevent retrieving token definition
radixdlt-core/docker/Dockerfile.core
Outdated
RADIXDLT_VALIDATION_API_ENABLE=true \ | ||
RADIXDLT_UNIVERSE_API_ENABLE=true \ | ||
RADIXDLT_VERSION_API_ENABLE=true \ | ||
RADIXDLT_ARCHIVE_API_PORT=8080 |
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.
These shouldn't all be enabled by default?
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.
Fixed
radixdlt-core/docs/api-info.md
Outdated
- `/validation` - read-only methods which provide same information as available today via all `/node/*` endpoints | ||
- `/system` - read-only methods which provide same information as available today via all `/system/*` endpoints | ||
|
||
- The `/system`, `/account` and `/validator` endpoints are expected to be protected by firewall and/or require authentication/etc. |
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.
Should be /validation
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.
fixed
radixdlt-core/docs/api-info.md
Outdated
- The `/system`, `/account` and `/validator` endpoints are expected to be protected by firewall and/or require authentication/etc. | ||
(similar requirements/setup as we have today) | ||
|
||
### REST APIs |
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 we should stop calling these REST endpoints as its not really RESTful: https://en.wikipedia.org/wiki/Representational_state_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.
Fixed
|
||
private UniverseType universeType(UniverseModule universeModule) { | ||
try { | ||
return universeModule.universe(properties, DefaultSerialization.getInstance()).type(); |
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 shouldn't have getters in Modules as this is the purpose of dependency injection.
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 a workaround for the situation when I need to make configuration decision using already configured in "Guice map" information. Unfortunately, this information is not easily available via other means.
Perhaps we should consider configuring Guice in "layered" fashion, when initially we configure "startup" injector with core things (like runtime properties and universe) and then assemble a working injector using "startup" injector to inject core dependencies.
var nodeEndpoints = enabledNodeEndpoints(properties, universeType); | ||
|
||
bind(new TypeLiteral<List<EndpointConfig>>() {}).annotatedWith(AtNode.class).toInstance(nodeEndpoints); | ||
bind(new TypeLiteral<List<EndpointConfig>>() {}).annotatedWith(AtArchive.class).toInstance(archiveEndpoints); |
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 broken to me, we should not have bindings to objects which contain Modules. All information should be communicated via dependency injection.
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.
Fixed
private final String symbol; | ||
private final String iconUrl; | ||
private final String tokenUrl; | ||
private final String description; |
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 feels like its starting to become unweildy
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.
Refactored.
import static com.radixdlt.api.JsonRpcUtil.jsonObject; | ||
import static com.radixdlt.api.JsonRpcUtil.response; | ||
|
||
@Singleton |
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 decided early on not to use @singleton so that this can be managed only by Modules themselves.
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.
Sorry, I was not involved in that decision. Anyway, fixed.
@Qualifier | ||
@Target({ FIELD, PARAMETER, METHOD }) | ||
@Retention(RUNTIME) | ||
public @interface Account { |
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.
Account name is too generic and should be changed to something more specific to the API
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.
Fixed
@@ -33,6 +35,7 @@ | |||
/** | |||
* High level JSON RPC client API store. | |||
*/ | |||
@ImplementedBy(BerkeleyClientApiStore.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.
This should be managed by Modules and not the class itself.
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.
Fixed
public AccountService( | ||
RadixEngine<LedgerAndBFTProof> radixEngine, | ||
@Self ECPublicKey bftKey, | ||
ClientApiStore clientApiStore |
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.
AccountService should not be dependent on ClientApiStore as we don't want all nodes to run another database
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.
Fixed
33bc496
to
c4b8efc
Compare
1c34379
to
72ec61b
Compare
6ec3b96
to
a43fe68
Compare
…; Implement single step submission from client
SonarCloud Quality Gate failed. |
X-Radixdlt-Method
andX-Radixdlt-Correlation-Id
)