mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-11 15:08:09 -05:00
Compare commits
1 Commits
develop
...
feat-use-a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7f2b88100 |
2
Makefile
2
Makefile
@@ -44,7 +44,7 @@ fmt: ## format the code
|
||||
|
||||
dev_docker: ## build docker images for development/testing usages
|
||||
docker pull postgres
|
||||
docker build -t scroll_l1geth ./common/testcontainers/docker/l1geth/
|
||||
docker build -t scroll_l1anvil ./common/testcontainers/docker/l1anvil/
|
||||
docker build -t scroll_l2geth ./common/testcontainers/docker/l2geth/
|
||||
|
||||
clean: ## Empty out the bin folder
|
||||
|
||||
7
common/testcontainers/.gitignore
vendored
7
common/testcontainers/.gitignore
vendored
@@ -1,7 +0,0 @@
|
||||
consensus/beacondata*
|
||||
consensus/genesis.ssz
|
||||
consensus/validatordata*
|
||||
consensus/data*
|
||||
execution/geth
|
||||
execution/geth.ipc
|
||||
execution/data*
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Loop until no Docker containers matching 'posl1' are found
|
||||
while : ; do
|
||||
containers=$(docker ps -a --format '{{.Names}}' | grep posl1)
|
||||
if [[ -z "$containers" ]]; then
|
||||
break
|
||||
fi
|
||||
echo "find the following containers, removing..."
|
||||
echo "$containers"
|
||||
echo "$containers" | xargs -r docker stop
|
||||
echo "$containers" | xargs -r docker rm -f || echo "Warning: Failed to remove some containers."
|
||||
done
|
||||
|
||||
# Loop until no Docker networks matching 'posl1' are found
|
||||
while : ; do
|
||||
networks=$(docker network ls --format '{{.ID}} {{.Name}}' | grep posl1 | awk '{print $1}')
|
||||
if [[ -z "$networks" ]]; then
|
||||
break
|
||||
fi
|
||||
echo "find the following networks, removing..."
|
||||
echo "$networks"
|
||||
echo "$networks" | xargs -r docker network rm || echo "Warning: Failed to remove some networks."
|
||||
done
|
||||
@@ -1,127 +0,0 @@
|
||||
version: "3.9"
|
||||
services:
|
||||
initialize-env:
|
||||
image: "alpine:3.19.0"
|
||||
command:
|
||||
/bin/sh -c "mkdir -p /data/consensus &&
|
||||
cp -a /consensus/* /data/consensus/ &&
|
||||
mkdir -p /data/execution &&
|
||||
cp -a /execution/* /data/execution/"
|
||||
volumes:
|
||||
- ../../common/testcontainers/consensus:/consensus
|
||||
- ../../common/testcontainers/execution:/execution
|
||||
- data:/data
|
||||
|
||||
# Creates a genesis state for the beacon chain using a YAML configuration file and
|
||||
# a deterministic set of 64 validators.
|
||||
create-beacon-chain-genesis:
|
||||
image: "gcr.io/prysmaticlabs/prysm/cmd/prysmctl:HEAD-263557"
|
||||
command:
|
||||
- testnet
|
||||
- generate-genesis
|
||||
- --fork=deneb
|
||||
- --num-validators=64
|
||||
- --genesis-time-delay=3
|
||||
- --output-ssz=/data/consensus/genesis.ssz
|
||||
- --chain-config-file=/data/consensus/config.yml
|
||||
- --geth-genesis-json-in=/data/execution/genesis.json
|
||||
- --geth-genesis-json-out=/data/execution/genesis.json
|
||||
volumes:
|
||||
- data:/data
|
||||
depends_on:
|
||||
initialize-env:
|
||||
condition: service_completed_successfully
|
||||
|
||||
# Sets up the genesis configuration for the go-ethereum client from a JSON file.
|
||||
geth-genesis:
|
||||
image: "ethereum/client-go:v1.13.14"
|
||||
command: --datadir=/data/execution init /data/execution/genesis.json
|
||||
volumes:
|
||||
- data:/data
|
||||
depends_on:
|
||||
create-beacon-chain-genesis:
|
||||
condition: service_completed_successfully
|
||||
initialize-env:
|
||||
condition: service_completed_successfully
|
||||
|
||||
# Runs a Prysm beacon chain from a specified genesis state created in the previous step
|
||||
# and connects to go-ethereum in the same network as the execution client.
|
||||
# The account used in go-ethereum is set as the suggested fee recipient for transactions
|
||||
# proposed via the validators attached to the beacon node.
|
||||
beacon-chain:
|
||||
image: "gcr.io/prysmaticlabs/prysm/beacon-chain:v5.0.0"
|
||||
command:
|
||||
- --datadir=/data/consensus/beacondata
|
||||
# No peers to sync with in this testnet, so setting to 0
|
||||
- --min-sync-peers=0
|
||||
- --genesis-state=/data/consensus/genesis.ssz
|
||||
- --bootstrap-node=
|
||||
- --interop-eth1data-votes
|
||||
# The chain configuration file used for setting up Prysm
|
||||
- --chain-config-file=/data/consensus/config.yml
|
||||
# We specify the chain id used by our execution client
|
||||
- --contract-deployment-block=0
|
||||
- --chain-id=${CHAIN_ID:-32382}
|
||||
- --rpc-host=0.0.0.0
|
||||
- --grpc-gateway-host=0.0.0.0
|
||||
- --execution-endpoint=http://geth:8551
|
||||
- --accept-terms-of-use
|
||||
- --jwt-secret=/data/execution/jwtsecret
|
||||
- --suggested-fee-recipient=0x123463a4b065722e99115d6c222f267d9cabb524
|
||||
- --minimum-peers-per-subnet=0
|
||||
- --enable-debug-rpc-endpoints
|
||||
- --force-clear-db
|
||||
depends_on:
|
||||
create-beacon-chain-genesis:
|
||||
condition: service_completed_successfully
|
||||
volumes:
|
||||
- data:/data
|
||||
|
||||
# Runs the go-ethereum execution client with the specified, unlocked account and necessary
|
||||
# APIs to allow for proof-of-stake consensus via Prysm.
|
||||
geth:
|
||||
image: "ethereum/client-go:v1.13.14"
|
||||
command:
|
||||
- --http
|
||||
- --http.api=eth,net,web3
|
||||
- --http.addr=0.0.0.0
|
||||
- --http.corsdomain=*
|
||||
- --authrpc.vhosts=*
|
||||
- --authrpc.addr=0.0.0.0
|
||||
- --authrpc.jwtsecret=/data/execution/jwtsecret
|
||||
- --datadir=/data/execution
|
||||
- --allow-insecure-unlock
|
||||
- --unlock=0x123463a4b065722e99115d6c222f267d9cabb524
|
||||
- --password=/data/execution/geth_password.txt
|
||||
- --nodiscover
|
||||
- --syncmode=full
|
||||
ports:
|
||||
- 8545
|
||||
depends_on:
|
||||
geth-genesis:
|
||||
condition: service_completed_successfully
|
||||
beacon-chain:
|
||||
condition: service_started
|
||||
volumes:
|
||||
- data:/data
|
||||
|
||||
# We run a validator client with 64, deterministically-generated keys that match
|
||||
# The validator keys present in the beacon chain genesis state generated a few steps above.
|
||||
validator:
|
||||
image: "gcr.io/prysmaticlabs/prysm/validator:v5.0.0"
|
||||
command:
|
||||
- --beacon-rpc-provider=beacon-chain:4000
|
||||
- --datadir=/data/consensus/validatordata
|
||||
- --accept-terms-of-use
|
||||
- --interop-num-validators=64
|
||||
- --interop-start-index=0
|
||||
- --chain-config-file=/data/consensus/config.yml
|
||||
- --force-clear-db
|
||||
depends_on:
|
||||
beacon-chain:
|
||||
condition: service_started
|
||||
volumes:
|
||||
- data:/data
|
||||
|
||||
volumes:
|
||||
data:
|
||||
9
common/testcontainers/docker/l1anvil/Dockerfile
Normal file
9
common/testcontainers/docker/l1anvil/Dockerfile
Normal file
@@ -0,0 +1,9 @@
|
||||
FROM ghcr.io/foundry-rs/foundry:latest
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY genesis.json /app/genesis.json
|
||||
|
||||
ENV ANVIL_IP_ADDR=0.0.0.0
|
||||
|
||||
ENTRYPOINT ["anvil", "--init", "/app/genesis.json"]
|
||||
50
common/testcontainers/docker/l1anvil/genesis.json
Normal file
50
common/testcontainers/docker/l1anvil/genesis.json
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"config": {
|
||||
"chainId": 32382,
|
||||
"homesteadBlock": 0,
|
||||
"daoForkSupport": true,
|
||||
"eip150Block": 0,
|
||||
"eip155Block": 0,
|
||||
"eip158Block": 0,
|
||||
"byzantiumBlock": 0,
|
||||
"constantinopleBlock": 0,
|
||||
"petersburgBlock": 0,
|
||||
"istanbulBlock": 0,
|
||||
"muirGlacierBlock": 0,
|
||||
"berlinBlock": 0,
|
||||
"londonBlock": 0,
|
||||
"arrowGlacierBlock": 0,
|
||||
"grayGlacierBlock": 0,
|
||||
"shanghaiTime": 0,
|
||||
"cancunTime": 0,
|
||||
"terminalTotalDifficulty": 0,
|
||||
"terminalTotalDifficultyPassed": true
|
||||
},
|
||||
"nonce": "0x0",
|
||||
"timestamp": "0x65f40695",
|
||||
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000123463a4b065722e99115d6c222f267d9cabb5240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"gasLimit": "0x1c9c380",
|
||||
"difficulty": "0x1",
|
||||
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"coinbase": "0x0000000000000000000000000000000000000000",
|
||||
"alloc": {
|
||||
"1c5a77d9fa7ef466951b2f01f724bca3a5820b63": {
|
||||
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
|
||||
},
|
||||
"33e0f539e31b35170faaa062af703b76a8282bf7": {
|
||||
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
|
||||
},
|
||||
"1e32abcfe6db15c1570709e3fc02725335f50a47": {
|
||||
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
|
||||
},
|
||||
"03a1bba60b5aa37094cf16123add674c01589488": {
|
||||
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
|
||||
}
|
||||
},
|
||||
"number": "0x0",
|
||||
"gasUsed": "0x0",
|
||||
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"baseFeePerGas": null,
|
||||
"excessBlobGas": null,
|
||||
"blobGasUsed": null
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
FROM ethereum/client-go:v1.13.14
|
||||
|
||||
COPY password /l1geth/
|
||||
COPY genesis.json /l1geth/
|
||||
COPY genesis-keystore /l1geth/
|
||||
COPY l1geth_run.sh /bin/
|
||||
|
||||
ENTRYPOINT ["sh", "/bin/l1geth_run.sh"]
|
||||
@@ -1 +0,0 @@
|
||||
{"address":"1c5a77d9fa7ef466951b2f01f724bca3a5820b63","crypto":{"cipher":"aes-128-ctr","ciphertext":"41aa5bb01833d30effb0b91f65214ea43dfc58a2f8f681a0878383baf74ca1d3","cipherparams":{"iv":"d4a3649e6b0807f4533d882fba251db4"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"f3686473147bebdaf0da70d3309026fef35ba51cbf0e9f64b854d88cd429e9e2"},"mac":"2d3038633ca1d10720c6d1acd0819656aff93290d6af91b3c0db79846c0fea18"},"id":"ea5886f5-574c-47ba-89d0-519fb3aa9d9e","version":3}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ ! -f ./keystore ]; then
|
||||
echo "initializing l1geth"
|
||||
cp /l1geth/genesis.json /l1geth/password ./
|
||||
geth --datadir . init genesis.json
|
||||
cp /l1geth/genesis-keystore ./keystore/
|
||||
fi
|
||||
|
||||
if [ ! -n "${IPC_PATH}" ];then
|
||||
IPC_PATH="/tmp/l1geth_path.ipc"
|
||||
fi
|
||||
|
||||
exec geth --mine --datadir "." --unlock 0 --miner.etherbase "0x1c5a77d9fa7ef466951b2f01f724bca3a5820b63" --password "./password" --allow-insecure-unlock --nodiscover \
|
||||
--http --http.addr "0.0.0.0" --http.port 8545 --ws --ws.addr "0.0.0.0" --ws.port 8546 --ipcpath ${IPC_PATH}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
scrolltest
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
0xfad2709d0bb03bf0e8ba3c99bea194575d3e98863133d1af638ed056d1d59345
|
||||
@@ -1 +0,0 @@
|
||||
{"address":"123463a4b065722e99115d6c222f267d9cabb524","crypto":{"cipher":"aes-128-ctr","ciphertext":"93b90389b855889b9f91c89fd15b9bd2ae95b06fe8e2314009fc88859fc6fde9","cipherparams":{"iv":"9dc2eff7967505f0e6a40264d1511742"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"c07503bb1b66083c37527cd8f06f8c7c1443d4c724767f625743bd47ae6179a4"},"mac":"6d359be5d6c432d5bbb859484009a4bf1bd71b76e89420c380bd0593ce25a817"},"id":"622df904-0bb1-4236-b254-f1b8dfdff1ec","version":3}
|
||||
@@ -5,12 +5,10 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/scroll-tech/go-ethereum/ethclient"
|
||||
"github.com/testcontainers/testcontainers-go"
|
||||
"github.com/testcontainers/testcontainers-go/modules/compose"
|
||||
"github.com/testcontainers/testcontainers-go/modules/postgres"
|
||||
"github.com/testcontainers/testcontainers-go/wait"
|
||||
"gorm.io/gorm"
|
||||
@@ -22,7 +20,7 @@ import (
|
||||
type TestcontainerApps struct {
|
||||
postgresContainer *postgres.PostgresContainer
|
||||
l2GethContainer *testcontainers.DockerContainer
|
||||
poSL1Container compose.ComposeStack
|
||||
l1AnvilContainer *testcontainers.DockerContainer
|
||||
|
||||
// common time stamp in nanoseconds.
|
||||
Timestamp int
|
||||
@@ -68,10 +66,9 @@ func (t *TestcontainerApps) StartL2GethContainer() error {
|
||||
}
|
||||
req := testcontainers.ContainerRequest{
|
||||
Image: "scroll_l2geth",
|
||||
ExposedPorts: []string{"8546/tcp", "8545/tcp"},
|
||||
ExposedPorts: []string{"8545/tcp"},
|
||||
WaitingFor: wait.ForAll(
|
||||
wait.ForListeningPort("8546").WithStartupTimeout(100*time.Second),
|
||||
wait.ForListeningPort("8545").WithStartupTimeout(100*time.Second),
|
||||
wait.ForListeningPort("8545").WithStartupTimeout(100 * time.Second),
|
||||
),
|
||||
}
|
||||
genericContainerReq := testcontainers.GenericContainerRequest{
|
||||
@@ -88,48 +85,45 @@ func (t *TestcontainerApps) StartL2GethContainer() error {
|
||||
}
|
||||
|
||||
// StartPoSL1Container starts the PoS L1 container by running the associated Docker Compose configuration
|
||||
func (t *TestcontainerApps) StartPoSL1Container() error {
|
||||
var (
|
||||
err error
|
||||
rootDir string
|
||||
dockerComposeFile string
|
||||
)
|
||||
|
||||
if rootDir, err = findProjectRootDir(); err != nil {
|
||||
return fmt.Errorf("failed to find project root directory: %v", err)
|
||||
func (t *TestcontainerApps) StartL1AnvilContainer() error {
|
||||
if t.l1AnvilContainer != nil && t.l1AnvilContainer.IsRunning() {
|
||||
return nil
|
||||
}
|
||||
|
||||
dockerComposeFile = filepath.Join(rootDir, "common", "testcontainers", "docker-compose.yml")
|
||||
|
||||
if t.poSL1Container, err = compose.NewDockerCompose([]string{dockerComposeFile}...); err != nil {
|
||||
req := testcontainers.ContainerRequest{
|
||||
Image: "scroll_l1anvil",
|
||||
ExposedPorts: []string{"8545/tcp"},
|
||||
WaitingFor: wait.ForAll(
|
||||
wait.ForListeningPort("8545").WithStartupTimeout(100 * time.Second),
|
||||
),
|
||||
}
|
||||
genericContainerReq := testcontainers.GenericContainerRequest{
|
||||
ContainerRequest: req,
|
||||
Started: true,
|
||||
}
|
||||
container, err := testcontainers.GenericContainer(context.Background(), genericContainerReq)
|
||||
if err != nil {
|
||||
log.Printf("failed to start scroll_l1anvil container: %s", err)
|
||||
return err
|
||||
}
|
||||
err = t.poSL1Container.WaitForService("geth", wait.NewHTTPStrategy("/").
|
||||
WithPort("8545/tcp").
|
||||
WithStartupTimeout(15*time.Second)).
|
||||
Up(context.Background())
|
||||
if err != nil {
|
||||
t.poSL1Container = nil
|
||||
return fmt.Errorf("failed to start PoS L1 container: %w", err)
|
||||
}
|
||||
t.l1AnvilContainer, _ = container.(*testcontainers.DockerContainer)
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPoSL1EndPoint returns the endpoint of the running PoS L1 endpoint
|
||||
func (t *TestcontainerApps) GetPoSL1EndPoint() (string, error) {
|
||||
if t.poSL1Container == nil {
|
||||
return "", fmt.Errorf("PoS L1 container is not running")
|
||||
// GetL1AnvilEndPoint returns the endpoint of the running PoS L1 endpoint
|
||||
func (t *TestcontainerApps) GetL1AnvilEndPoint() (string, error) {
|
||||
if t.l1AnvilContainer == nil || !t.l1AnvilContainer.IsRunning() {
|
||||
return "", fmt.Errorf("l1 anvil is not running")
|
||||
}
|
||||
contrainer, err := t.poSL1Container.ServiceContainer(context.Background(), "geth")
|
||||
endpoint, err := t.l1AnvilContainer.PortEndpoint(context.Background(), "8545/tcp", "http")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return contrainer.PortEndpoint(context.Background(), "8545/tcp", "http")
|
||||
return endpoint, nil
|
||||
}
|
||||
|
||||
// GetPoSL1Client returns a ethclient by dialing running PoS L1 client
|
||||
func (t *TestcontainerApps) GetPoSL1Client() (*ethclient.Client, error) {
|
||||
endpoint, err := t.GetPoSL1EndPoint()
|
||||
func (t *TestcontainerApps) GetL1AnvilClient() (*ethclient.Client, error) {
|
||||
endpoint, err := t.GetL1AnvilEndPoint()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -149,7 +143,7 @@ func (t *TestcontainerApps) GetL2GethEndPoint() (string, error) {
|
||||
if t.l2GethContainer == nil || !t.l2GethContainer.IsRunning() {
|
||||
return "", fmt.Errorf("l2 geth is not running")
|
||||
}
|
||||
endpoint, err := t.l2GethContainer.PortEndpoint(context.Background(), "8546/tcp", "ws")
|
||||
endpoint, err := t.l2GethContainer.PortEndpoint(context.Background(), "8545/tcp", "http")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -197,33 +191,9 @@ func (t *TestcontainerApps) Free() {
|
||||
log.Printf("failed to stop scroll_l2geth container: %s", err)
|
||||
}
|
||||
}
|
||||
if t.poSL1Container != nil {
|
||||
if err := t.poSL1Container.Down(context.Background(), compose.RemoveOrphans(true), compose.RemoveVolumes(true), compose.RemoveImagesLocal); err != nil {
|
||||
log.Printf("failed to stop PoS L1 container: %s", err)
|
||||
} else {
|
||||
t.poSL1Container = nil
|
||||
if t.l1AnvilContainer != nil && t.l1AnvilContainer.IsRunning() {
|
||||
if err := t.l1AnvilContainer.Terminate(ctx); err != nil {
|
||||
log.Printf("failed to stop scroll_l1anvil container: %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// findProjectRootDir find project root directory
|
||||
func findProjectRootDir() (string, error) {
|
||||
currentDir, err := os.Getwd()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get working directory: %w", err)
|
||||
}
|
||||
|
||||
for {
|
||||
_, err := os.Stat(filepath.Join(currentDir, "go.work"))
|
||||
if err == nil {
|
||||
return currentDir, nil
|
||||
}
|
||||
|
||||
parentDir := filepath.Dir(currentDir)
|
||||
if parentDir == currentDir {
|
||||
return "", fmt.Errorf("go.work file not found in any parent directory")
|
||||
}
|
||||
|
||||
currentDir = parentDir
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ func TestNewTestcontainerApps(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, ethclient)
|
||||
|
||||
assert.NoError(t, testApps.StartPoSL1Container())
|
||||
endpoint, err = testApps.GetPoSL1EndPoint()
|
||||
assert.NoError(t, testApps.StartL1AnvilContainer())
|
||||
endpoint, err = testApps.GetL1AnvilEndPoint()
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, endpoint)
|
||||
ethclient, err = testApps.GetPoSL1Client()
|
||||
ethclient, err = testApps.GetL1AnvilClient()
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, ethclient)
|
||||
|
||||
@@ -54,7 +54,7 @@ func TestNewTestcontainerApps(t *testing.T) {
|
||||
assert.EqualError(t, err, "l2 geth is not running")
|
||||
assert.Empty(t, endpoint)
|
||||
|
||||
endpoint, err = testApps.GetPoSL1EndPoint()
|
||||
assert.EqualError(t, err, "PoS L1 container is not running")
|
||||
endpoint, err = testApps.GetL1AnvilEndPoint()
|
||||
assert.EqualError(t, err, "l1 anvil is not running")
|
||||
assert.Empty(t, endpoint)
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ func (b *MockApp) MockConfig(store bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
l1GethEndpoint, err := b.testApps.GetPoSL1EndPoint()
|
||||
l1GethEndpoint, err := b.testApps.GetL1AnvilEndPoint()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ func setupEnv(t *testing.T) {
|
||||
testApps = testcontainers.NewTestcontainerApps()
|
||||
assert.NoError(t, testApps.StartPostgresContainer())
|
||||
assert.NoError(t, testApps.StartL2GethContainer())
|
||||
assert.NoError(t, testApps.StartPoSL1Container())
|
||||
assert.NoError(t, testApps.StartL1AnvilContainer())
|
||||
|
||||
cfg.L2Config.RelayerConfig.SenderConfig.Endpoint, err = testApps.GetPoSL1EndPoint()
|
||||
cfg.L2Config.RelayerConfig.SenderConfig.Endpoint, err = testApps.GetL1AnvilEndPoint()
|
||||
assert.NoError(t, err)
|
||||
cfg.L1Config.RelayerConfig.SenderConfig.Endpoint, err = testApps.GetL2GethEndPoint()
|
||||
assert.NoError(t, err)
|
||||
|
||||
@@ -90,6 +90,12 @@ func (s *Sender) estimateBlobGas(to *common.Address, data []byte, sidecar *gethT
|
||||
|
||||
gasFeeCap := getGasFeeCap(new(big.Int).SetUint64(baseFee), gasTipCap)
|
||||
blobGasFeeCap := getBlobGasFeeCap(new(big.Int).SetUint64(blobBaseFee))
|
||||
fmt.Println("sending blob transaction", "gasTipCap", gasTipCap, "gasFeeCap", gasFeeCap, "blobGasFeeCap", blobGasFeeCap, "blockBaseFee", baseFee, "blockBlobBaseFee", blobBaseFee)
|
||||
fmt.Println("sending blob transaction", "gasTipCap", gasTipCap, "gasFeeCap", gasFeeCap, "blobGasFeeCap", blobGasFeeCap, "blockBaseFee", baseFee, "blockBlobBaseFee", blobBaseFee)
|
||||
fmt.Println("sending blob transaction", "gasTipCap", gasTipCap, "gasFeeCap", gasFeeCap, "blobGasFeeCap", blobGasFeeCap, "blockBaseFee", baseFee, "blockBlobBaseFee", blobBaseFee)
|
||||
fmt.Println("sending blob transaction", "gasTipCap", gasTipCap, "gasFeeCap", gasFeeCap, "blobGasFeeCap", blobGasFeeCap, "blockBaseFee", baseFee, "blockBlobBaseFee", blobBaseFee)
|
||||
fmt.Println("sending blob transaction", "gasTipCap", gasTipCap, "gasFeeCap", gasFeeCap, "blobGasFeeCap", blobGasFeeCap, "blockBaseFee", baseFee, "blockBlobBaseFee", blobBaseFee)
|
||||
blobGasFeeCap = gasFeeCap
|
||||
gasLimit, accessList, err := s.estimateGasLimit(to, data, sidecar, nil, gasTipCap, gasFeeCap, blobGasFeeCap)
|
||||
if err != nil {
|
||||
log.Error("estimateBlobGas estimateGasLimit failure",
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"crypto/ecdsa"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
@@ -71,9 +73,9 @@ func setupEnv(t *testing.T) {
|
||||
testApps = testcontainers.NewTestcontainerApps()
|
||||
assert.NoError(t, testApps.StartPostgresContainer())
|
||||
assert.NoError(t, testApps.StartL2GethContainer())
|
||||
assert.NoError(t, testApps.StartPoSL1Container())
|
||||
assert.NoError(t, testApps.StartL1AnvilContainer())
|
||||
|
||||
cfg.L2Config.RelayerConfig.SenderConfig.Endpoint, err = testApps.GetPoSL1EndPoint()
|
||||
cfg.L2Config.RelayerConfig.SenderConfig.Endpoint, err = testApps.GetL1AnvilEndPoint()
|
||||
assert.NoError(t, err)
|
||||
|
||||
db, err = testApps.GetGormDBClient()
|
||||
@@ -82,7 +84,7 @@ func setupEnv(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, migrate.ResetDB(sqlDB))
|
||||
|
||||
l1Client, err := testApps.GetPoSL1Client()
|
||||
l1Client, err := testApps.GetL1AnvilClient()
|
||||
assert.NoError(t, err)
|
||||
|
||||
chainID, err := l1Client.ChainID(context.Background())
|
||||
@@ -102,8 +104,24 @@ func setupEnv(t *testing.T) {
|
||||
err = l1Client.SendTransaction(context.Background(), signedTx)
|
||||
assert.NoError(t, err)
|
||||
|
||||
txData, err := json.MarshalIndent(signedTx, "", " ")
|
||||
if err != nil {
|
||||
log.Crit("failed to JSON marshal transaction", "err", err)
|
||||
return
|
||||
}
|
||||
fmt.Println("contract deployment transaction:\n", string(txData))
|
||||
|
||||
txByte, err := signedTx.MarshalBinary()
|
||||
if err != nil {
|
||||
log.Crit("failed to marshal transaction to RLP encoding", "err", err)
|
||||
return
|
||||
}
|
||||
txHex := hex.EncodeToString(txByte)
|
||||
fmt.Println("rlp-encoding of contract deployment transaction:", txHex)
|
||||
|
||||
assert.Eventually(t, func() bool {
|
||||
_, isPending, err := l1Client.TransactionByHash(context.Background(), signedTx.Hash())
|
||||
fmt.Println("TransactionByHash", "isPending", isPending, "err", err)
|
||||
return err == nil && !isPending
|
||||
}, 30*time.Second, time.Second)
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
|
||||
func setupL1Watcher(t *testing.T) (*L1WatcherClient, *gorm.DB) {
|
||||
db := setupDB(t)
|
||||
client, err := testApps.GetPoSL1Client()
|
||||
client, err := testApps.GetL1AnvilClient()
|
||||
assert.NoError(t, err)
|
||||
l1Cfg := cfg.L1Config
|
||||
watcher := NewL1WatcherClient(context.Background(), client, l1Cfg.StartHeight, l1Cfg.Confirmations, l1Cfg.L1MessageQueueAddress, l1Cfg.RelayerConfig.RollupContractAddress, db, nil)
|
||||
|
||||
@@ -43,10 +43,10 @@ func setupEnv(t *testing.T) (err error) {
|
||||
|
||||
testApps = testcontainers.NewTestcontainerApps()
|
||||
assert.NoError(t, testApps.StartPostgresContainer())
|
||||
assert.NoError(t, testApps.StartPoSL1Container())
|
||||
assert.NoError(t, testApps.StartL1AnvilContainer())
|
||||
assert.NoError(t, testApps.StartL2GethContainer())
|
||||
|
||||
cfg.L2Config.RelayerConfig.SenderConfig.Endpoint, err = testApps.GetPoSL1EndPoint()
|
||||
cfg.L2Config.RelayerConfig.SenderConfig.Endpoint, err = testApps.GetL1AnvilEndPoint()
|
||||
assert.NoError(t, err)
|
||||
cfg.L1Config.RelayerConfig.SenderConfig.Endpoint, err = testApps.GetL2GethEndPoint()
|
||||
assert.NoError(t, err)
|
||||
|
||||
@@ -87,10 +87,10 @@ func setupEnv(t *testing.T) {
|
||||
testApps = tc.NewTestcontainerApps()
|
||||
assert.NoError(t, testApps.StartPostgresContainer())
|
||||
assert.NoError(t, testApps.StartL2GethContainer())
|
||||
assert.NoError(t, testApps.StartPoSL1Container())
|
||||
assert.NoError(t, testApps.StartL1AnvilContainer())
|
||||
rollupApp = bcmd.NewRollupApp(testApps, "../conf/config.json")
|
||||
|
||||
l1Client, err = testApps.GetPoSL1Client()
|
||||
l1Client, err = testApps.GetL1AnvilClient()
|
||||
assert.NoError(t, err)
|
||||
l2Client, err = testApps.GetL2GethClient()
|
||||
assert.NoError(t, err)
|
||||
@@ -105,9 +105,9 @@ func setupEnv(t *testing.T) {
|
||||
|
||||
l1Auth, err = bind.NewKeyedTransactorWithChainID(rollupApp.Config.L2Config.RelayerConfig.CommitSenderPrivateKey, l1GethChainID)
|
||||
assert.NoError(t, err)
|
||||
rollupApp.Config.L1Config.Endpoint, err = testApps.GetPoSL1EndPoint()
|
||||
rollupApp.Config.L1Config.Endpoint, err = testApps.GetL1AnvilEndPoint()
|
||||
assert.NoError(t, err)
|
||||
rollupApp.Config.L2Config.RelayerConfig.SenderConfig.Endpoint, err = testApps.GetPoSL1EndPoint()
|
||||
rollupApp.Config.L2Config.RelayerConfig.SenderConfig.Endpoint, err = testApps.GetL1AnvilEndPoint()
|
||||
assert.NoError(t, err)
|
||||
|
||||
port, err := rand.Int(rand.Reader, big.NewInt(10000))
|
||||
|
||||
@@ -43,7 +43,7 @@ func TestMain(m *testing.M) {
|
||||
func setupEnv(t *testing.T) {
|
||||
testApps = testcontainers.NewTestcontainerApps()
|
||||
assert.NoError(t, testApps.StartPostgresContainer())
|
||||
assert.NoError(t, testApps.StartPoSL1Container())
|
||||
assert.NoError(t, testApps.StartL1AnvilContainer())
|
||||
assert.NoError(t, testApps.StartL2GethContainer())
|
||||
rollupApp = bcmd.NewRollupApp(testApps, "../../rollup/conf/config.json")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user