Skip to content

Commit 2bb0ffe

Browse files
authored
Update Espresso Go SDK to 0.2.1 (#176)
* init update to Go SDK 0.2.1 * can pass tests * add go sdk version param * solve multiClientCreation error and circleCI * fix espressoClient creation for caff node and add safeguard log when streamer is nil * adapt to new client to have at least two urls * update docker as well (#178) * add comments on at least 2 urls * fix another single url * fix docker compose single url * fix docker compose caff single url * allow a bit larger variance in the receipt to L1 time of integration test 1 * tweak docker compose file * also tweak caff hotshot urls * fix appendArg of BatcherMod in LaunchBatcherInEnclave() * add sha256sum check to dockerfile * check espresso go crypto helper sha256sum in a more elegant way
1 parent ef4be47 commit 2bb0ffe

25 files changed

+182
-132
lines changed

.circleci/config.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -991,12 +991,12 @@ jobs:
991991
at: "."
992992
if: ${{ uses_artifacts }}
993993
- run:
994-
name: download espresso-network-go
994+
name: download espresso-network go sdk
995995
command: |
996-
ver=$(grep "github.com/EspressoSystems/espresso-network-go" go.mod | awk '{print $2}')
997-
url="https://github.com/EspressoSystems/espresso-network-go/releases/download/${ver}/libespresso_crypto_helper-x86_64-unknown-linux-gnu.a"
996+
ver=$(grep "github.com/EspressoSystems/espresso-network/sdks/go" go.mod | awk '{print $2}')
997+
url="https://github.com/EspressoSystems/espresso-network/releases/download/sdks%2Fgo%2F${ver}/libespresso_crypto_helper-x86_64-unknown-linux-gnu.so"
998998
mkdir -p /home/circleci/local-lib
999-
wget $url -O /home/circleci/local-lib/libespresso_crypto_helper-x86_64-unknown-linux-gnu.a
999+
wget $url -O /home/circleci/local-lib/libespresso_crypto_helper-x86_64-unknown-linux-gnu.so
10001000
- run:
10011001
name: Fuzz
10021002
command: |
@@ -1064,12 +1064,12 @@ jobs:
10641064
name: do mise install (did not work otherwise for unknown reason)
10651065
command: /home/circleci/.local/bin/mise install
10661066
- run:
1067-
name: download espresso-network-go
1067+
name: download espresso-network go sdk
10681068
command: |
1069-
ver=$(grep "github.com/EspressoSystems/espresso-network-go" go.mod | awk '{print $2}')
1070-
url="https://github.com/EspressoSystems/espresso-network-go/releases/download/${ver}/libespresso_crypto_helper-x86_64-unknown-linux-gnu.a"
1069+
ver=$(grep "github.com/EspressoSystems/espresso-network/sdks/go" go.mod | awk '{print $2}')
1070+
url="https://github.com/EspressoSystems/espresso-network/releases/download/sdks%2Fgo%2F${ver}/libespresso_crypto_helper-x86_64-unknown-linux-gnu.so"
10711071
mkdir -p /home/circleci/local-lib
1072-
wget $url -O /home/circleci/local-lib/libespresso_crypto_helper-x86_64-unknown-linux-gnu.a
1072+
wget $url -O /home/circleci/local-lib/libespresso_crypto_helper-x86_64-unknown-linux-gnu.so
10731073
- run:
10741074
name: build op-program-client
10751075
command: make op-program-client

espresso/docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ services:
137137
- --l1.trustrpc=true
138138
- --rpc.enable-admin=true
139139
- --caff.hotshot-urls=http://espresso-dev-node:24000
140+
- --caff.hotshot-urls=http://espresso-dev-node:24000
140141
- --caff.next-hotshot-block-num=1
141142
- --caff.polling-hotshot-polling-interval=500ms
142143
- --log.level=debug
@@ -159,7 +160,8 @@ services:
159160
- --l1-eth-rpc=http://l1:8545
160161
- --l2-eth-rpc=http://op-geth:8551
161162
- --rollup-rpc=http://op-node-sequencer:8545
162-
- --espresso-url=http://espresso-dev-node:24000
163+
- --espresso-url=http://localhost:44889
164+
- --espresso-url=http://localhost:44889
163165
- --espresso-light-client-addr=0x703848f4c85f18e3acd8196c8ec91eb0b7bd0797
164166

165167
op-proposer:

espresso/environment/10_soft_confirmation_integrity_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030
"testing"
3131
"time"
3232

33-
esp_client "github.com/EspressoSystems/espresso-network-go/client"
34-
esp_common "github.com/EspressoSystems/espresso-network-go/types/common"
33+
espressoClient "github.com/EspressoSystems/espresso-network/sdks/go/client"
34+
espressoCommon "github.com/EspressoSystems/espresso-network/sdks/go/types/common"
3535
env "github.com/ethereum-optimism/optimism/espresso/environment"
3636
"github.com/ethereum-optimism/optimism/op-e2e/system/e2esys"
3737
"github.com/ethereum-optimism/optimism/op-node/rollup"
@@ -289,7 +289,7 @@ const SUBMIT_RANDOM_DATA_INTERVAL = 500 * time.Millisecond
289289

290290
// submitRandomDataToSequencerNamespace is a function that submits
291291
// random data to the sequencer namespace at a specified interval.
292-
func submitRandomDataToSequencerNamespace(ctx context.Context, espCli esp_client.EspressoClient, namespace uint64) {
292+
func submitRandomDataToSequencerNamespace(ctx context.Context, espCli espressoClient.EspressoClient, namespace uint64) {
293293
// We only want to submit garbage data to the sequencer so quickly
294294
ticker := time.NewTicker(SUBMIT_RANDOM_DATA_INTERVAL)
295295
buffer := make([]byte, 1024*3)
@@ -304,9 +304,9 @@ func submitRandomDataToSequencerNamespace(ctx context.Context, espCli esp_client
304304
n, _ := crypto_rand.Read(buffer)
305305

306306
// Submit garbage data to the sequencer namespace
307-
_, err := espCli.SubmitTransaction(ctx, esp_common.Transaction{
307+
_, err := espCli.SubmitTransaction(ctx, espressoCommon.Transaction{
308308
Namespace: namespace,
309-
Payload: esp_common.Bytes(buffer[:n]),
309+
Payload: espressoCommon.Bytes(buffer[:n]),
310310
})
311311
if err != nil {
312312
log.Error("Failed to submit random data to sequencer namespace", "namespace", namespace, "error", err)
@@ -395,7 +395,7 @@ const SUBMIT_VALID_DATA_WITH_WRONG_SIGNATURE_INTERVAlL = 500 * time.Millisecond
395395

396396
// Attack Espresso Integrity by Submitting Valid Data with the wrong
397397
// Signature to the Sequencer's namespace.
398-
func submitValidDataWithWrongSignature(ctx context.Context, rollupCfg *rollup.Config, l2Seq *ethclient.Client, espCli esp_client.EspressoClient, namespace uint64) {
398+
func submitValidDataWithWrongSignature(ctx context.Context, rollupCfg *rollup.Config, l2Seq *ethclient.Client, espCli espressoClient.EspressoClient, namespace uint64) {
399399
// We only want to submit garbage data to the sequencer so quickly
400400
ticker := time.NewTicker(SUBMIT_VALID_DATA_WITH_WRONG_SIGNATURE_INTERVAlL)
401401
stackTrie := trie.NewStackTrie(func(path []byte, hash geth_common.Hash, blob []byte) {})
@@ -474,7 +474,7 @@ func submitValidDataWithRandomSignature(
474474
ctx context.Context,
475475
rollupCfg *rollup.Config,
476476
l2Seq *ethclient.Client,
477-
espCli esp_client.EspressoClient,
477+
espCli espressoClient.EspressoClient,
478478
namespace uint64,
479479
) {
480480
// We only want to submit garbage data to the sequencer so quickly
@@ -614,7 +614,7 @@ func TestSequencerFeedConsistencyWithAttackOnEspresso(t *testing.T) {
614614
}
615615

616616
l2Seq := system.NodeClient(e2esys.RoleSeq)
617-
espCli := esp_client.NewClient(espressoSequencerURL.String())
617+
espCli := espressoClient.NewClient(espressoSequencerURL.String())
618618
namespace := system.RollupConfig.L2ChainID.Uint64()
619619

620620
// Attack Espresso Integrity by Submitting Garbage Data to the Same

espresso/environment/12_enforce_majority_rule_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ func runWithMultiClient(t *testing.T, numGoodUrls int, numBadUrls int, expectedE
9292
// If M>N, the chain should make progress, otherwise it should not.
9393
func TestEnforceMajorityRule(t *testing.T) {
9494

95-
runWithMultiClient(t, 1, 0, NO_ERROR_EXPECTED)
95+
// To create a valid multiple nodes client, we need to provide at least 2 URLs.
96+
runWithMultiClient(t, 2, 0, NO_ERROR_EXPECTED)
9697
runWithMultiClient(t, 2, 1, NO_ERROR_EXPECTED)
9798
runWithMultiClient(t, 0, 2, ERROR_EXPECTED)
9899
runWithMultiClient(t, 1, 1, ERROR_EXPECTED)

espresso/environment/1_espresso_benchmark_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func TestE2eDevNetWithEspressoFastConfirmationStability(t *testing.T) {
145145
t.Errorf("expected a small amount of variance in the receipt to caff time:\nhave:\n\t\"%v\"\nwant:\n\t\"%v\"\n", have, want)
146146
}
147147

148-
if have, want := metrics.ReceiptToVerify.StdDev, 2*time.Second; have > want {
148+
if have, want := metrics.ReceiptToVerify.StdDev, 3*time.Second; have > want {
149149
t.Errorf("expected a small amount of variance in the receipt to L1 time:\nhave:\n\t\"%v\"\nwant:\n\t\"%v\"\n", have, want)
150150
}
151151
}

espresso/environment/2_espresso_liveness_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"testing"
1010
"time"
1111

12-
espressoClient "github.com/EspressoSystems/espresso-network-go/client"
13-
lightclient "github.com/EspressoSystems/espresso-network-go/light-client"
12+
espressoClient "github.com/EspressoSystems/espresso-network/sdks/go/client"
13+
espressoLightClient "github.com/EspressoSystems/espresso-network/sdks/go/light-client"
1414
"github.com/ethereum-optimism/optimism/espresso"
1515
env "github.com/ethereum-optimism/optimism/espresso/environment"
1616
"github.com/ethereum-optimism/optimism/op-batcher/batcher"
@@ -258,7 +258,7 @@ func TestE2eDevNetWithEspressoEspressoDegradedLivenessViaCaffNode(t *testing.T)
258258
{
259259
// Streamer Setup and Configuration
260260
l := log.NewLogger(slog.Default().Handler())
261-
lightClient, err := lightclient.NewLightclientCaller(common.HexToAddress(env.ESPRESSO_LIGHT_CLIENT_ADDRESS), l1Client)
261+
lightClient, err := espressoLightClient.NewLightclientCaller(common.HexToAddress(env.ESPRESSO_LIGHT_CLIENT_ADDRESS), l1Client)
262262
require.NoError(t, err, "light client creation failed")
263263
streamer := espresso.NewEspressoStreamer(
264264
system.RollupConfig.L2ChainID.Uint64(),

espresso/environment/3_2_espresso_deterministic_state_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"github.com/ethereum/go-ethereum/rpc"
1414
"github.com/stretchr/testify/require"
1515

16-
espressoClient "github.com/EspressoSystems/espresso-network-go/client"
17-
espressoCommon "github.com/EspressoSystems/espresso-network-go/types"
16+
espressoClient "github.com/EspressoSystems/espresso-network/sdks/go/client"
17+
espressoCommon "github.com/EspressoSystems/espresso-network/sdks/go/types"
1818
env "github.com/ethereum-optimism/optimism/espresso/environment"
1919
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
2020
"github.com/ethereum-optimism/optimism/op-e2e/system/e2esys"
@@ -73,7 +73,10 @@ func TestDeterministicDerivationExecutionStateWithInvalidTransaction(t *testing.
7373

7474
// We want to setup our test
7575
addressAlice := system.Cfg.Secrets.Addresses().Alice
76-
espressoClient := espressoClient.NewMultipleNodesClient(espressoDevNode.EspressoUrls())
76+
espressoClient, err := espressoClient.NewMultipleNodesClient(espressoDevNode.EspressoUrls())
77+
if have, want := err, error(nil); have != want {
78+
t.Fatalf("failed to create Espresso client:\nhave:\n\t\"%v\"\nwant:\n\t\"%v\"\n", have, want)
79+
}
7780
l1Client := system.NodeClient(e2esys.RoleL1)
7881
l2Verif := system.NodeClient(e2esys.RoleVerif)
7982
l2Seq := system.NodeClient(e2esys.RoleSeq)
@@ -282,7 +285,10 @@ func TestValidEspressoTransactionCreation(t *testing.T) {
282285
defer env.Stop(t, caffNode)
283286

284287
// We want to setup our test
285-
espressoClient := espressoClient.NewMultipleNodesClient(espressoDevNode.EspressoUrls())
288+
espressoClient, err := espressoClient.NewMultipleNodesClient(espressoDevNode.EspressoUrls())
289+
if have, want := err, error(nil); have != want {
290+
t.Fatalf("failed to create Espresso client:\nhave:\n\t\"%v\"\nwant:\n\t\"%v\"\n", have, want)
291+
}
286292
l2Verif := system.NodeClient(e2esys.RoleVerif)
287293
caffVerif := system.NodeClient(env.RoleCaffNode)
288294
// create a real Espresso transaction and make sure it can go through

espresso/environment/enclave_helpers.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ func LaunchBatcherInEnclave() DevNetLauncherOption {
120120
appendArg(&args, flags.ThrottleThresholdFlag.Name, c.ThrottleThreshold)
121121
appendArg(&args, flags.ThrottleTxSizeFlag.Name, c.ThrottleTxSize)
122122
appendArg(&args, flags.WaitNodeSyncFlag.Name, c.WaitNodeSync)
123-
appendArg(&args, flags.EspressoUrlsFlag.Name, c.EspressoUrls)
123+
for _, url := range c.EspressoUrls {
124+
appendArg(&args, flags.EspressoUrlsFlag.Name, url)
125+
}
124126
appendArg(&args, flags.EspressoLCAddrFlag.Name, c.EspressoLightClientAddr)
125127
appendArg(&args, flags.TestingEspressoBatcherPrivateKeyFlag.Name, c.TestingEspressoBatcherPrivateKey)
126128

espresso/environment/espresso_caff_node.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,10 @@ func LaunchCaffNode(t *testing.T, system *e2esys.System, espressoDevNode Espress
114114
caffNodeConfig.Rollup.CaffNodeConfig = rollup.CaffNodeConfig{
115115
IsCaffNode: true,
116116
PollingHotShotPollingInterval: 30 * time.Millisecond,
117-
HotShotUrls: []string{u.String()},
118-
L1EthRpc: system.L1.UserRPC().RPC(),
119-
EspressoLightClientAddr: ESPRESSO_LIGHT_CLIENT_ADDRESS,
117+
// To create a valid multiple nodes client, we need to provide at least 2 URLs.
118+
HotShotUrls: []string{u.String(), u.String()},
119+
L1EthRpc: system.L1.UserRPC().RPC(),
120+
EspressoLightClientAddr: ESPRESSO_LIGHT_CLIENT_ADDRESS,
120121
}
121122

122123
// Configure

espresso/environment/optitmism_espresso_test_helpers.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import (
1919
"testing"
2020
"time"
2121

22-
espressoClient "github.com/EspressoSystems/espresso-network-go/client"
23-
espressoCommon "github.com/EspressoSystems/espresso-network-go/types"
22+
espressoClient "github.com/EspressoSystems/espresso-network/sdks/go/client"
23+
espressoCommon "github.com/EspressoSystems/espresso-network/sdks/go/types"
2424
"github.com/ethereum-optimism/optimism/op-batcher/batcher"
2525
"github.com/ethereum-optimism/optimism/op-batcher/flags"
2626
"github.com/ethereum-optimism/optimism/op-e2e/config"
@@ -772,7 +772,8 @@ func launchEspressoDevNodeDocker() DevNetLauncherOption {
772772

773773
espressoDevNode := &EspressoDevNodeDockerContainerInfo{
774774
DockerContainerInfo: espressoDevNodeContainerInfo,
775-
espressoUrls: []string{"http://" + hostPort},
775+
// To create a valid multiple nodes client, we need to provide at least 2 URLs.
776+
espressoUrls: []string{"http://" + hostPort, "http://" + hostPort},
776777
}
777778
ct.EspressoDevNode = espressoDevNode
778779
c.EspressoUrls = espressoDevNode.espressoUrls

0 commit comments

Comments
 (0)