spacemeshos / pm

Project management. Meta-tasks related to research, dev, and specs for the Spacemesh protocol and infrastructure.
http://spacemesh.io/
Creative Commons Zero v1.0 Universal
2 stars 0 forks source link

Implement Eth JSON-RPC #277

Open lrettig opened 1 year ago

lrettig commented 1 year ago

There are two fundamental issues with the current node API: 1. it's not complete and not terribly well designed (see summary here: https://github.com/spacemeshos/pm/issues/269#issue-1914316367), and 2. it's not compliant with any existing blockchain API spec, which makes integration work quite difficult. Note that we have "competing" proposals on the table to rewrite/improve the existing API (#270), and to build an entirely new API (#269); we also have a related proposal to support even broader EVM compatibility (#189).

We can kill two birds with one stone by adding support for an existing, standard API, and the most obvious choice is Eth-flavored JSON-RPC. Skimming the JSON-RPC spec, I don't see any major issues or major incompatibilities, though this will require some additional work. If we do implement it, it's likely we'll need to drop certain endpoints and modify the behavior of others, but there's precedent for doing this and other projects have done this quite successfully.

Benefits:

Downsides:

Lots of other chains that aren't natively EVM compatible have done this, so we're in good company. Here are examples:

See also: #223

dshulyak commented 1 year ago

how wallets will work if txs are not compatible? beside objects that can be coerced into eth, there are many that can't. providing only eth api is not sufficient

with l1 rollup design such API does make sense, but there is no reason to implement it before doing vm work.

dshulyak commented 1 year ago

also before starting this work, we need to research that we can do compliant api. we should take reference spec for chosen API (i was looking at startknet rpc) and add notes what every method means and should do in spacemesh terms . and also account for some expected behavior which is not a part of the spec, but might be problematic for integration such as handling reorgs

lrettig commented 1 year ago

@dshulyak thanks for taking a look.

beside objects that can be coerced into eth, there are many that can't. providing only eth api is not sufficient

such as? ATXs I guess? I don't know that it's critical that this API expose all data. we'll have multiple APIs. and things like ATXs, ballots, proposals, etc. are not relevant from the perspective of the wallet or the user submitting transactions.

account for some expected behavior which is not a part of the spec, but might be problematic for integration such as handling reorgs

eth has reorgs too. I don't see an issue here.

we should take reference spec for chosen API and add notes what every method means and should do in spacemesh terms

agree, this is the next step.

dshulyak commented 1 year ago

such as? ATXs I guess? I don't know that it's critical that this API expose all data. we'll have multiple APIs. and things like ATXs, ballots, proposals, etc. are not relevant from the perspective of the wallet or the user submitting transactions.

this is what i said. eth api is not sufficient. submitting txs is not the only use case for data api.

also because txs are not compatible there is no reason to rush implementing it, before execution / vm engine is implemented

there are also rewards that represented as separate object in spacemesh, so somehow they will need to be represented. i proposed to save/execute them as implicit (generated after executing block) transactions, but maybe there is a simpler approach.