Skip to content

Commit

Permalink
👷 add complete protocol workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
cairoeth committed Mar 25, 2024
1 parent 2373337 commit 4c027ae
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 10 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/protocol.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: All protocol components

on: [push, pull_request]

jobs:
protocol:
name: Protocol
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ^1.20
id: go

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10.11"
id: python

- name: Check out code into the Go module directory
uses: actions/checkout@v3
id: checkout

- name: Install psql
run: |
apt-get update
apt-get install --yes --no-install-recommends postgresql-client
id: psql

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
id: foundry

- name: Install docker-compose
run: |
sudo curl -L https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
id: docker-compose

- name: Install example requirements
run: pip install -r requirements.txt
id: python-requirements

- name: Run all components concurrently
run: make run-ci
id: run-ci
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ run-anvil:

# Run all components concurrently
run-all:
make -j run-anvil run-share run-operator
make -j run-anvil run-share run-operator &

# Run all in background and example (used by CI)
run-ci:
make run-all & && sleep 200 && python test_tx.py && exit 0
make run-all && sleep 200 && python test_tx.py && exit 0

test:
go test ./...
Expand Down
2 changes: 1 addition & 1 deletion preconf-operator/cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func main() {
app.Flags = []cli.Flag{config.ConfigFileFlag}
app.Name = "preconf-operator"
app.Usage = "Preconfirmations Operator"
app.Description = "Service that subcribes to Preconf-Share and sends preconfirmations."
app.Description = "Service that subcribes to preconf-share and sends preconfirmations."

app.Action = operatorMain
err := app.Run(os.Args)
Expand Down
6 changes: 4 additions & 2 deletions preconf-operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,11 @@ func (o *Operator) Start(ctx context.Context) error {

sub, err := client.Subscribe(eventChan)
if err != nil {
o.logger.Error("Cannot subscribe to Preconf-Share endpoint", "err", err)
o.logger.Error("Cannot subscribe to preconf-share endpoint", "err", err)
}

o.logger.Infof("Listening to preconf-share stream..")

for {
select {
case <-ctx.Done():
Expand All @@ -280,7 +282,7 @@ func (o *Operator) Start(ctx context.Context) error {
o.logger.Fatal("Error in metrics server", "err", err)
case event := <-eventChan:
if event.Error != nil {
o.logger.Error("Error occurred from Preconf-Share stream", "err", event.Error)
o.logger.Error("Error occurred from preconf-share stream", "err", event.Error)
sub.Stop()
}

Expand Down
2 changes: 1 addition & 1 deletion preconf-operator/sse/backend.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package sse is the SSE Client for Preconf-Share
// Package sse is the SSE Client for preconf-share
package sse

// SSEClient is the SSE Client abstraction
Expand Down
2 changes: 1 addition & 1 deletion preconf-share/preconshare/mevshare.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package preconshare implements Preconf-Share node
// Package preconshare implements preconf-share node
// Here is a full flow of data through the node:
//
// bundle-relay-api -> API sends:
Expand Down
7 changes: 4 additions & 3 deletions test_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
tx, private_key).rawTransaction.hex()
block = str(hex(web3.eth.block_number + 1))


def request():
r = requests.get('http://localhost:8080', json={
"params": [
Expand All @@ -40,7 +41,7 @@ def request():
json_response = r.json()

if json_response["result"]["preconfSignature"] is None:
raise Exception("No preconfirmation")
raise Exception("No preconfirmation")

print(f"Status Code (request): {r.status_code}, Response: {r.json()}")

Expand All @@ -59,5 +60,5 @@ def request():


# threaded_process_range()
request()

request()

0 comments on commit 4c027ae

Please sign in to comment.