Skip to content
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

feat: refactor Delia #10

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

feat: refactor Delia #10

wants to merge 2 commits into from

Conversation

jmg-duarte
Copy link
Collaborator

@jmg-duarte jmg-duarte commented Mar 11, 2025

This refactor introduces a bunch of new features, while temporarily removing others.

Added:

  • TS support
  • Biome support
  • SCALE encoding support
  • Libp2p support
  • FE is now "detached" - doesn't need to be served by the SP

Removed:

  • Time/block conversion
  • Upload to get the Piece CID & size

Closes #7

Running instructions:
In 3 shells:

  • pnpm run dev
  • just testnet
  • examples/start_sp.sh

This refactor introduces a bunch of new features, while temporarily removing others.

Added:
* TS support
* Biome support
* SCALE encoding support
* Libp2p support
* FE is now "detached" - doesn't need to be served by the SP

Removed:
* Time/block conversion
* Upload to get the Piece CID & size
@jmg-duarte jmg-duarte self-assigned this Mar 11, 2025
@jmg-duarte jmg-duarte added this to the Phase 3 milestone Mar 11, 2025
Copy link

@aidan46 aidan46 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to get it running and propose a deal succesfully. However, there are some docs missing. It would be nice the have some docs on how the flow works, prerequisites for running delia (run testnet, register storage provider, add market account balance for sp and client), getting the piece cid/size (ik this will be upgraded soon), etc.
I think you were using a dev account for testing, I used a user generated wallet and had to add the market balance too

Copy link

@th7nder th7nder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some other notes:

  1. When you select your Polkadot extension wallet, it doesn't rellow the webpage automatically and shows you the error. You need to hit F5.
  2. When you don't start the testnet, there is an infinite loading bar.
  3. Would be useful to have a *nix flake for this one.
  4. Eslint is not configured for production like it should.
  5. The instructions on how to run it should be in the README.md
  6. delia needs to detect network issues and raise errors accordingly

DealPreparation = 1,
}

function setupTypeRegistry(): TypeRegistry {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be hardcoded or in the future come from the metadata.scale?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually how it's done. Parity doesn't really offer a translation from the SCALE file

import { type Ctx, GlobalCtx } from "./GlobalCtx";

export function GlobalCtxProvider(props: React.PropsWithChildren<Ctx>) {
const value = useMemo(() => ({ registry: props.registry }), [props.registry]);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this memo is necessary here, GlobalCtxProvider never ever changes as of now. I might be rusty with React though...

},
"ignore": [
"tsconfig*.json",
"TimeBlockConverter.tsx"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If TimeBlockConverter.tsx it's not used, why is it here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So Biome doesn't complain

Comment on lines +44 to +55
const timeOptions = useMemo(() => generateTimeOptions(), []);

useEffect(() => {
let mounted = true;

const connectWebSocket = () => {
if (wsRef.current?.readyState === WebSocket.OPEN) return;

wsRef.current = new WebSocket("ws://127.0.0.1:42069");

wsRef.current.onopen = () => {
console.log("Connected to chain for block number");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid of the complexity of this entire component, if it's not used, should we just delete it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not used right now, I was keeping it to add it but I can remove and fetch it from the git history

Comment on lines +68 to +71
if (proposeDealResponse instanceof Error) {
toast.error(proposeDealResponse.message);
return;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not Rust, we don't do instanceof, we catch Errors.

const signedRpc = await validDealProposal.toSignedRpc(p, ctx.registry, account);
const publishDealResponse = await callPublishDeal(
signedRpc,
{ ...address, port: 8000 }, // We can't hardcode this but we can't do anything about it *right now*
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ ...address, port: 8000 }, // We can't hardcode this but we can't do anything about it *right now*
{ ...address, port: DEFAULT_RPC_PORT }, // We can't hardcode this but we can't do anything about it *right now*

for some reason sometimes it's 8000, sometimes it's 8001?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, one is the HTTP upload server and the other is the JSON RPC


// TODO: type this
const providerPeerId = provider.peerId;
// TODO: catch the error?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do

const [loading, setLoading] = useState(false);

const updateProviderSelection = useCallback((newProvider: string) => {
selectProviders((oldState) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's going on here? This callback works like a toggle? Should it just accept the 'list of selected providers'?

account: InjectedAccountWithMeta;
}) {
const [dealProposal, setDealProposal] = useState(
DealProposal.default().copyUpdate("client", account.address),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rusty rust

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Client-side JS to SCALE conversion
4 participants