Skip to content

Commit

Permalink
add geth checks
Browse files Browse the repository at this point in the history
  • Loading branch information
otherview committed Dec 26, 2023
1 parent fdb8c05 commit 57dcce5
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
return l2Network.deployments.execute("CrossChainMessenger", {
from: l2Accounts.deployer,
log: true,
gasLimit: 3_000_000
gasLimit: 5_000_000
}, "relayMessage", msg);
};

Expand Down
4 changes: 2 additions & 2 deletions go/config/enclave_cli_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ var EnclaveFlags = map[string]*flag.TenFlag{
MaxRollupSizeFlag: flag.NewUint64Flag(MaxRollupSizeFlag, 1024*64, "The maximum size a rollup is allowed to reach"),
L2BaseFeeFlag: flag.NewUint64Flag(L2BaseFeeFlag, 1, ""),
L2CoinbaseFlag: flag.NewStringFlag(L2CoinbaseFlag, "0xd6C9230053f45F873Cb66D8A02439380a37A4fbF", ""),
GasBatchExecutionLimit: flag.NewUint64Flag(GasBatchExecutionLimit, 10_000_000, "Max gas that can be executed in a single batch"),
GasBatchExecutionLimit: flag.NewUint64Flag(GasBatchExecutionLimit, 30_000_000, "Max gas that can be executed in a single batch"),
ObscuroGenesisFlag: flag.NewStringFlag(ObscuroGenesisFlag, "", "The json string with the obscuro genesis"),
L1ChainIDFlag: flag.NewInt64Flag(L1ChainIDFlag, 1337, "An integer representing the unique chain id of the Ethereum chain used as an L1 (default 1337)"),
ObscuroChainIDFlag: flag.NewInt64Flag(ObscuroChainIDFlag, 443, "An integer representing the unique chain id of the Obscuro chain (default 443)"),
UseInMemoryDBFlag: flag.NewBoolFlag(UseInMemoryDBFlag, true, "Whether the enclave will use an in-memory DB rather than persist data"),
ProfilerEnabledFlag: flag.NewBoolFlag(ProfilerEnabledFlag, false, "Runs a profiler instance (Defaults to false)"),
DebugNamespaceEnabledFlag: flag.NewBoolFlag(DebugNamespaceEnabledFlag, false, "Whether the debug namespace is enabled"),
GasLocalExecutionCapFlag: flag.NewUint64Flag(GasLocalExecutionCapFlag, 12_000_000, "Max gas usage when executing local transactions"),
GasLocalExecutionCapFlag: flag.NewUint64Flag(GasLocalExecutionCapFlag, 40_000_000, "Max gas usage when executing local transactions"),
}

// enclaveRestrictedFlags are the flags that the enclave can receive ONLY over the Ego signed enclave.json
Expand Down
4 changes: 2 additions & 2 deletions integration/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func DefaultEnclaveConfig() *config.EnclaveConfig {
MaxRollupSize: 1024 * 64,
GasPaymentAddress: gethcommon.HexToAddress("0xd6C9230053f45F873Cb66D8A02439380a37A4fbF"),
BaseFee: new(big.Int).SetUint64(1),
GasLocalExecutionCapFlag: 10_000_000,
GasBatchExecutionLimit: 12_000_000,
GasLocalExecutionCapFlag: 40_000_000,
GasBatchExecutionLimit: 30_000_000,
}
}
36 changes: 36 additions & 0 deletions integration/eth2network/eth2_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ten-protocol/go-ten/integration/datagenerator"
"golang.org/x/sync/errgroup"

gethcommon "github.com/ethereum/go-ethereum/common"
)

const (
Expand Down Expand Up @@ -206,6 +208,10 @@ func (n *Impl) Start() error {
startTime := time.Now()
var eg errgroup.Group

if err := n.ensureNoDuplicatedNetwork(); err != nil {
return err
}

// initialize the genesis data on the nodes
for _, nodeDataDir := range n.dataDirs {
dataDir := nodeDataDir
Expand Down Expand Up @@ -506,6 +512,11 @@ func (n *Impl) waitForMergeEvent(startTime time.Time) error {
}

fmt.Printf("Reached the merge block after %s\n", time.Since(startTime))

if err = n.prefundedBalancesActive(dial); err != nil {
fmt.Printf("Error prefunding accounts %s\n", err.Error())
return err
}
return nil
}

Expand Down Expand Up @@ -589,6 +600,31 @@ func (n *Impl) gethImportEnodes(enodes []string) error {
return nil
}

func (n *Impl) prefundedBalancesActive(client *ethclient.Client) error {
for _, addr := range n.preFundedMinerAddrs {
balance, err := client.BalanceAt(context.Background(), gethcommon.HexToAddress(addr), nil)
if err != nil {
return fmt.Errorf("unable to check balance for account %s - %w", addr, err)
}
if balance.Cmp(gethcommon.Big0) == 0 {
return fmt.Errorf("unexpected %s balance for account %s", balance.String(), addr)
}
fmt.Printf("Account %s prefunded with %s", addr, balance.String())
}

return nil
}

func (n *Impl) ensureNoDuplicatedNetwork() error {
for nodeIdx, port := range n.gethWSPorts {
_, err := ethclient.Dial(fmt.Sprintf("ws://127.0.0.1:%d", port))
if err == nil {
return fmt.Errorf("unexpected geth node %d is active before the network is started", nodeIdx)
}
}
return nil
}

func min(a, b int) int {
if a < b {
return a
Expand Down

0 comments on commit 57dcce5

Please sign in to comment.