Comments (2)
Yeah, understand. If the types can be arbitrarily complex then objects are going to be required, it's just a pain to map JSON to an internal struct when the value can have different types (string or object).
Although it would be possible to build a full JSON representation of a CLType that was well-defined and had a single defined structure, I very much doubt that it is worth your time to do so. I'll patch something up in my parser instead.
Thanks for the detailed response.
from casper-node.
That's an interesting point! I agree it's possible, and might make the ergonomics slightly better for users consuming the JSON. However, there are a couple of factors at play here.
While it's true that many of the other variants of the CLType
can be represented as a single JSON string field (the simple variants), it's not true that they all can. The complex variants can be comprised of nested CLTypes
(except for ByteArray
which contains the length of the array rather than a nested CLType
). In JSON form, these complex variants need to be represented as JSON objects rather than strings, so ByteArray
isn't unique in that regard.
A more practical problem with adopting the approach you suggest is that we currently just derive the Serialize
and Deserialize
traits for CLType
. This gives us the ability to serialize to a binary format or to JSON or TOML for free.
In its binary format, the nested length of the ByteArray
needs to be included so that the bytes comprising the data can be distinguished from possible other data. Normally the length is encoded as a prefix, followed by the number of bytes specified by that prefix, followed by any other encoded data.
So, on the one hand we need the Serialize
and Deserialize
implementations to use the nested length in ByteArray
, but on the other (for JSON encoding), we want to skip it. This is possible: we could hand-write custom implementations for these traits rather than deriving them. However, the risk vs reward doesn't seem worthwhile to me in this case, given the complexity of not deriving the traits, and considering that this is only useful for single variant of the CLType
.
I'll not close this issue for now so we can discuss further, but my current inclination is to not change from the status quo.
Thanks anyway for raising the issue. It's a point I hadn't considered up until now :)
from casper-node.
Related Issues (20)
- Tune Juliet networking settings
- Evaluate difficulty of threading through request/response pattern from networking to rest of the system [ Timeboxed ] HOT 1
- Remove stale metrics
- Remove P dependency of networking component
- Ensure that networking Tickets are threaded through the node as well as possible
- The DeployConfig chainspec setting for max dependencies should be removed along with all mentions of same.
- Cleanup RPC status and peers endpoints
- Add a test validating a block without any deploys, but with a signature that cannot be fetched HOT 1
- Error encountered while running a freshly compiled NCTL network from feat-2.0.
- Rust toolchain failure observed with CEP18 contract.
- Fix Juliet test HOT 1
- Add a flag for enabling speculative exec into the binary port and disable it by default
- Add a dictionary item request to the binary port
- Move ReactorState from casper-types to the node and replace it with a String in NodeStatus
- Rename Transform types
- Review max_request_size_bytes and max_response_size_bytes binary port config
- Send custom error message payloads in the binary port
- Investigate potentially flaky Highway Zug rewards tests
- Joiner issue for 1.6 HOT 1
- Wrong documentation for enable_contract_version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from casper-node.