-
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
A simple mockup of L2 logic without proofs or signatures. #6
Conversation
Deposit is a big unanswered question
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.
Obviously some things are missing like a token-id for all the transactions, but we didn't iron them out yet. Code is clear and easy to follow, important edge-cases have proper handling or have an according todo,.
pub balances: HashMap<PublicKey, u64>, | ||
pub batch_epoch: u64, | ||
/// The set of transfers that will be batched in the next epoch. | ||
pub batched_transfers: HashSet<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.
What if we introduced
pub enum Transaction {
Deposit { .... },
Transfer { .... },
Withdraw { ... }
}
Then we could have a batch HashSet<Transaction>
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.
Oh I just saw transfers are in a HashSet, and the others in a vector.
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.
My thinking here is Deposit
and Withdraw
need separate handling.
Although perhaps Withdraw
should also be a HashSet
to check for duplication.
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.
Sure, but we could just match and dispatch accordingly. But let's move that to a later point, seems premature. Also, I think adding a timestamp to each of those types would make sense and put all of them in a hashset actually
As a next step I would also move most code out of the main.rs and put it into a |
kairos-server/Cargo.toml
Outdated
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 types that flow in/out of server to/from an sdk could be factored out to a dedicated crate ... I began this process in my paradox implementation.
https://github.com/cspr-rad/paradox-4/tree/main/node/types/src/external
kairos-server/src/routes/transfer.rs
Outdated
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.
General comment in respect of the handlers. Typically they should be a thin layer, the business logic should be handled by an inner layer that can be tested outside of the network context. But it's early days.
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.
Another general comment in respect of the handlers. The input/output request/response types could be wrapped in generic ServerRequest & ServerResponse types. These types would provide a contextual envelope.
For an example of what I mean, check out the core external types exposed in my paradox implementation.
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.
Another general comment in respect of the handlers. The input/output request/response types could be wrapped in generic ServerRequest & ServerResponse types. These types would provide a contextual envelope.
I'd suggest using a middle layer there.
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.
Finished my review. Most of my comments relate to code structure and are nit-picky ... but there again I am very nit-picky ! Also most of my comments should be taken with a pinch of salt as I know that you guys are just getting things up and running.
I would ask you to be cognizant of the fact that a successful L1/L2 will result in the development of several SDKs, e.g. rust, typescript, python ... etc. Therefore it is useful to structure the code in such a way that makes it as easy as possible for an SDK to be built. This typically means factoring out the over the wire types to a dedicated crate ... sometimes even with some meta-programming tricks so as to forward engineer the over the wire typeset in other programming language bindings. Also on this note, the cli program should be as thin as possible and depend upon the sdk ... you quite often see cli/sdk entanglements that make it difficult to use the sdk in standalone mode (e.g. from a trading bot).
My thinking here is we are going to call into a native Rust or WASM lib for sigs anyway, those SDKs can be thin wrappers around a Rust lib. If we try and make over the wire types multi lang compatible we can not use things like |
I switched to typed routes, and added logging and two tests. |
pub balances: HashMap<PublicKey, u64>, | ||
pub batch_epoch: u64, | ||
/// The set of transfers that will be batched in the next epoch. | ||
pub batched_transfers: HashSet<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.
Sure, but we could just match and dispatch accordingly. But let's move that to a later point, seems premature. Also, I think adding a timestamp to each of those types would make sense and put all of them in a hashset actually
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.
Nice. Will be running tests and going deeper into business logic but am approving.
Co-authored-by: Marijan Petričević <[email protected]>
So I am thinking we currently don't care about CI failing. |
can you
if that builds, you are good to merge I would say. |
Follow up tasks:
thiserror
so we can consume typed JSON errors in the CLI.