Giter Club home page Giter Club logo

go-muxrpc's People

Contributors

andyleap avatar cryptix avatar decentral1se avatar dominictarr avatar keks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

go-muxrpc's Issues

luigi-less interfaces

This is a tracking issue, looking for ideas to solve some of ssbc/go-ssb#48, mainly removing the hidden marshaling that's happening in the luigi Source and Sink interfaces.

Currently I have something like this in mind but am totally open to better ideas:

// inspired by sql.Rows but without the scan
type Source interface {
	Next(context.Context) bool // blocks until there are new muxrpc frames for this stream

	// instead of returning an (un)marshaled object
	// we just give access to the received []byte contained in the muxrpc body
	io.Reader

        // when processing fails or the context was canceled
	Err() error 

       // sometimes we want to close a query early before it is drained
       // (this sends a EndErr packet back )
       Cancel(error)
}

Removing the extra Err() error method and changing next to Next(context.Context) error could also work but i feel like the previous might result in easier to read code.

I feel like Sink could just be an io.WriteCloser that takes a single body and wraps it in the correct request id and flags. Maybe we need an additional CloseWithError(error) on it to signal failed requests and such.

stream processing blocking

This is really annoying.... The creator of rpc streams has to take care that they don't deadlock each other. This means: a caller needs to drain the whole stream and not start new rpc calls while reading that stream and block for that new answer before reading more of the other stream... Sounds convoluted but imagine this:

src, err:= client.Source(/* call with lot's of replies*/)


for {
  v, err := src.Next(ctx)
  if eof { break }

  // process v

  // if the backlog of objects in the pipe for src is too big, the reply for this call does not arrive.
  resp, _ := client.Async()

}

A work around for this can be to read all messages from source into ram and then process them as a next step, like this:

var msgs []interface{}
snk := luigi.NewSliceSink(msgs)

src, err:= client.Source(/* call with lot's of replies*/)
// check(err)

err = luigi.Pump(ctx, snk, src)
// check(err)

for _, v:= range msgs {
  // process v
  

  resp, _ := client.Async()
}

Build error: math.MaxUint32 overflows int

Go version:

go version go1.19.2 linux/arm

Build architecture:

armv7l

Problem:

I'm attempting to build go-sbot which relies on go-muxrpc (see ssbc/go-ssb#180 for details). The build fails with the following error message:

../go/pkg/mod/github.com/ssbc/go-muxrpc/[email protected]/codec/writer.go:27:15: math.MaxUint32 (untyped int constant 4294967295) overflows int

Possible fix:

I believe this can be solved with the following change to codec/writer.go:27:15:

// cast `bodyLen` to uint
if uint(bodyLen) > math.MaxUint32 {

I tried this fix on a fork and it passes the tests. I wanted to retry the build of go-sbot with this change but I am utterly failing (no Go experience; don't know how to change the module dependency to pull from my fork).

maxBufferSize redeclared / overflows int

Follows ssbc/go-ssb-room#355 (comment), #16 was not a good fix after all 🤦‍♀️

GOARCH=arm GOOS=linux go build ./...
# github.com/ssbc/go-muxrpc/v2/codec
codec/buffer_32bit.go:10:7: maxBufferSize redeclared in this block
	codec/buffer.go:14:7: other declaration of maxBufferSize
codec/writer.go:26:15: maxBufferSize (untyped int constant 4294967295) overflows int
go vet ./codec
# github.com/ssbc/go-muxrpc/v2/codec
vet: codec/buffer_32bit.go:10:7: maxBufferSize redeclared in this block

Malformed request sent when connecting to peers

On connection go-muxrpc sends the following request to peers:

{
    "name": "manifest",
    "args": [],
    "type": "async"
}

This request is malformed as per the protocol guide request name is a list of strings:

The name is a list of strings. For a top-level procedure like createHistoryStream the list only has one element: ["createHistoryStream"].

https://ssbc.github.io/scuttlebutt-protocol-guide/#request-format

This means that the request should instead have the following form:

{
    "name": ["manifest"],
    "args": [],
    "type": "async"
}

Therefore it is possible that clients which reject connections from peers which send malformed requests will not be able to communicate with projects which use go-muxrpc.

Reduce goroutine storm

Right now there is no bound on incoming requests. Each new call starts a goroutine.

Especially for legacy ssb replication this means ~9k once the connection is established. Depending on the load of the remote party this happens in a couple of seconds but I‘ve also Seen strained Systems where this built-up takes nearly 15minutes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.