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

Add L1<>L2 interop. Closes #37 #40

Merged
merged 52 commits into from
Aug 30, 2022
Merged

Add L1<>L2 interop. Closes #37 #40

merged 52 commits into from
Aug 30, 2022

Conversation

juliangruber
Copy link
Contributor

@juliangruber juliangruber commented Aug 9, 2022

Closes #37.

Documentation of approach and current direction: https://gist.github.com/juliangruber/032276dbdd44e056d5f7fc18d8debc3e

TODO

  • Make the L2 fallback configurable
    • Disabled (main net)
    • Fire and forget (test net initially, then main net)
    • Full integration (post l1 launch)
  • Verify L2's car response
  • Extract raw data from car if ?format=raw

Mock client:

import http2 from 'node:http2'
import { CarWriter } from '@ipld/car'
import { Readable } from 'node:stream'
import { CID } from 'multiformats/cid'
import { sha256 } from 'multiformats/hashes/sha2'
import * as raw from 'multiformats/codecs/raw'

const client = http2.connect('https://127.0.0.1')
const req = client.request({
  ':path': `/register/http2?nocache=1`,
})
req.on('data', async d => {
  const line = d.toString().trim()
  if (line === '') return
  const obj = JSON.parse(line)
  console.log(obj)
  if (obj.cid) {
    console.log('-> sending reply')
    const r = client.request({
      ':path': `/data/${obj.cid}`,
      ':method': 'POST'
    })
    const bytes = new TextEncoder().encode('hi')
    const hash = await sha256.digest(raw.encode(bytes))
    const cid = CID.create(1, raw.code, hash)
    const { writer, out } = await CarWriter.create(cid)
    Readable.from(out).pipe(r)
    await writer.put({ cid, bytes })
    await writer.close()
  }
})
req.on('end', () => {
  client.close()
})
req.end()
$ NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_NO_WARNINGS=1 node l2.mjs

@juliangruber juliangruber changed the title Add L1<>L2 interop Add L1<>L2 interop. Closes #37 Aug 9, 2022
@juliangruber juliangruber marked this pull request as ready for review August 17, 2022 13:57
container/shim/src/index.js Outdated Show resolved Hide resolved
Copy link

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

Nice! I left a few comments to consider.

container/shim/src/index.js Show resolved Hide resolved
container/shim/src/index.js Outdated Show resolved Hide resolved
container/shim/src/index.js Outdated Show resolved Hide resolved
container/shim/src/index.js Outdated Show resolved Hide resolved
container/shim/src/index.js Outdated Show resolved Hide resolved
@juliangruber juliangruber marked this pull request as draft August 18, 2022 10:50
@juliangruber juliangruber marked this pull request as ready for review August 22, 2022 11:25
container/shim/src/index.js Outdated Show resolved Hide resolved
@guanzo guanzo mentioned this pull request Aug 25, 2022
1 task
Copy link
Collaborator

@DiegoRBaquero DiegoRBaquero left a comment

Choose a reason for hiding this comment

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

Should be fine to deploy given that it´s FF for test net.

@juliangruber juliangruber merged commit f83a821 into main Aug 30, 2022
@juliangruber juliangruber deleted the add/register branch August 30, 2022 15:30
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.

Add GET /register/:L2_ID
4 participants