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

Stateful builder #115

Merged
merged 7 commits into from
Dec 22, 2023
Merged

Stateful builder #115

merged 7 commits into from
Dec 22, 2023

Conversation

ferranbt
Copy link
Collaborator

@ferranbt ferranbt commented Dec 4, 2023

📝 Summary

📚 References


  • I have seen and agree to CONTRIBUTING.md

@@ -34,6 +34,19 @@ library Suave {
bytes body;
}

struct SimulateTransactionResult {
uint64 egp;
Copy link
Member

Choose a reason for hiding this comment

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

So one thing I foresee us needing relatively soon, unless you were to do this with eth_calls, would be the coinbase balance diff before and after simulate transaction for a specific address or array of addresses. I'm not it's worth changing anything about we would handle modifying this struct that we return, but wanted to bring up as a consideration just in case it sparks any ideas.

Copy link
Collaborator Author

@ferranbt ferranbt Dec 19, 2023

Choose a reason for hiding this comment

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

I could see that included as some type of getBalance call to the builder and not enshrined in this struct.

output:
fields:
- name: id
type: string
Copy link
Member

Choose a reason for hiding this comment

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

why is id a string?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The session id is a uuid identifier. It gets rendered as a string.

@@ -196,3 +197,20 @@ func (s *suaveRuntime) doHTTPRequest(request types.HttpRequest) ([]byte, error)
}
return data, nil
}

func (s *suaveRuntime) newBuilder() (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

would be interesting to think about two kettles sharing the same session ID and doing a newBuilder(existingSessionID string) or connectBuilder. We don't need to consider for this work just mentioning if it inspires anything again!

Copy link
Member

Choose a reason for hiding this comment

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

permisisons around this has some caution signs for me, you could mess with someones simulation if you knew their session ID if done naively

}

type Server struct {
sessionMngr sessionManager
Copy link
Member

Choose a reason for hiding this comment

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

should we have a mutex on this? seems possible you could call start a session from another SUAPP before the last new session call has been completed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The locks are on sessionManager.

suave/builder/api/api_server.go Show resolved Hide resolved
context core.ChainContext
}

func newBuilder(config *builderConfig) *builder {
Copy link
Member

Choose a reason for hiding this comment

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

@Ruteri curious your thoughts on if this is the best way to set up builder, I remember something non-obvious about reverts changing in builder recently so double check would be appreciated

Number: new(big.Int).Add(parent.Number, common.Big1),
GasLimit: core.CalcGasLimit(parent.GasLimit, s.config.GasCeil),
Time: 1000, // TODO: fix this
Coinbase: common.Address{}, // TODO: fix this
Copy link
Member

Choose a reason for hiding this comment

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

hmm yeah interesting to think what you would set this to. Two ideas come to mind:

  • set to '0x + keccak256("SUAVE")` so its consistent for users
  • allow for the ability to set it. I think there may be some scenarios where you if your a builder who also has a contract controlled by your address that does something different based on profit in a block, then you would want to be able to set this. Happy to spell this out more but I think it's desirable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree, I think some of these params should be configurable when you start a session like the extra field.

@ferranbt ferranbt marked this pull request as ready for review December 21, 2023 13:35
Copy link
Member

@dmarzzz dmarzzz left a comment

Choose a reason for hiding this comment

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

LSTM

@ferranbt ferranbt merged commit 7c9c147 into main Dec 22, 2023
3 checks passed
@ferranbt ferranbt deleted the stateless-builder branch December 22, 2023 17:42
@ferranbt ferranbt changed the title Stateless builder Stateful builder Jan 18, 2024
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.

3 participants