Skip to content

Commit

Permalink
Upgrade local Geth version to PoS (#1950)
Browse files Browse the repository at this point in the history
* Upgrade geth to 1.14.6 and prysm to 5.0.4 for a PoS dev network
  • Loading branch information
badgersrus authored Aug 8, 2024
1 parent d32dfda commit 3846fa5
Show file tree
Hide file tree
Showing 65 changed files with 1,240 additions and 1,573 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ jobs:
with:
go-version: 1.21.8

# Set the initial build number environment variable
- name: Set Build Number
run: |
echo "BUILD_NUMBER=1" >> $GITHUB_ENV
# Makes sure the artifacts are built correctly
- name: Build
run: go build -v ./...
Expand All @@ -31,19 +36,25 @@ jobs:
# Close specified ports using lsof before testing / local port list compiled from ./integration/constants.go
- name: Close Integration Test Ports
run: |
killall -9 geth-v1.12.2 || true
killall -9 beacon-chain-v4.0.6 || true
killall -9 validator-v4.0.6 || true
killall -9 geth || true
killall -9 beacon || true
killall -9 validator || true
lowest_port=8000 # Lowest starting port
highest_port=58000 # Highest port considering the offset
additional_ports=(80 81 99) # Additional specific ports
# Find processes listening on ports within the range and kill them
for pid in $(lsof -iTCP:$lowest_port-$highest_port -sTCP:LISTEN -t); do
echo "Killing process $pid on one of the ports from $lowest_port to $highest_port"
kill $pid || true
done
# Find processes listening on ports within the range and kill them
for pid in $(lsof -iUDP:$lowest_port-$highest_port -t); do
echo "Killing process $pid on one of the ports from $lowest_port to $highest_port"
kill $pid || true
done
# Close additional specific ports
for port in "${additional_ports[@]}"; do
Expand All @@ -54,7 +65,7 @@ jobs:
done
- name: Test
run: go test --failfast -v ./... -count=1 -timeout 5m
run: go test --failfast -v ./... -count=1 -timeout 10m

- name: Store simulation logs
uses: actions/upload-artifact@v4
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/manual-deploy-testnet-l1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,5 @@ jobs:
&& docker run -d \
-p 8025:8025 -p 8026:8026 -p 9000:9000 -p 9001:9001 \
--entrypoint /home/obscuro/go-obscuro/integration/eth2network/main/main ${{ vars.DOCKER_BUILD_TAG_ETH2NETWORK }} \
--blockTimeSecs=15 --slotsPerEpoch=2 --slotsPerSecond=15 \
--numNodes=1 --gethHTTPStartPort=8025 --gethWSStartPort=9000 \
--logToFile=false \
--gethHTTPStartPort=8025 --gethWSStartPort=9000 \
--prefundedAddrs="${{ vars.ACCOUNT_ADDR_WORKER }},${{ vars.ACCOUNT_ADDR_NODE_0 }},${{ vars.ACCOUNT_ADDR_NODE_1 }},${{ vars.ACCOUNT_ADDR_NODE_2 }},${{ vars.ACCOUNT_ADDR_L1_BRIDGE_TEST }}"'
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
"peerDependencies": {
"@nomicfoundation/hardhat-verify" : "2.0.8"
}
}
}
4 changes: 2 additions & 2 deletions go/common/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ type Host interface {
// HealthCheck returns the health status of the host + enclave + db
HealthCheck(context.Context) (*HealthCheck, error)

// ObscuroConfig returns the info of the Obscuro network
ObscuroConfig() (*common.ObscuroNetworkInfo, error)
// TenConfig returns the info of the Obscuro network
TenConfig() (*common.TenNetworkInfo, error)

// NewHeadsChan returns live batch headers
// Note - do not use directly. This is meant only for the NewHeadsManager, which multiplexes the headers
Expand Down
2 changes: 1 addition & 1 deletion go/common/query_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (p *QueryPagination) UnmarshalJSON(data []byte) error {
return nil
}

type ObscuroNetworkInfo struct {
type TenNetworkInfo struct {
ManagementContractAddress common.Address
L1StartHash common.Hash
MessageBusAddress common.Address
Expand Down
6 changes: 3 additions & 3 deletions go/config/enclave_cli_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
ProfilerEnabledFlag = "profilerEnabled"
MinGasPriceFlag = "minGasPrice"
MessageBusAddressFlag = "messageBusAddress"
ObscuroGenesisFlag = "obscuroGenesis"
TenGenesisFlag = "tenGenesis"
DebugNamespaceEnabledFlag = "debugNamespaceEnabled"
MaxBatchSizeFlag = "maxBatchSize"
MaxRollupSizeFlag = "maxRollupSize"
Expand Down Expand Up @@ -55,7 +55,7 @@ var EnclaveFlags = map[string]*flag.TenFlag{
L2BaseFeeFlag: flag.NewUint64Flag(L2BaseFeeFlag, params.InitialBaseFee, ""),
L2CoinbaseFlag: flag.NewStringFlag(L2CoinbaseFlag, "0xd6C9230053f45F873Cb66D8A02439380a37A4fbF", ""),
GasBatchExecutionLimit: flag.NewUint64Flag(GasBatchExecutionLimit, 3_000_000_000, "Max gas that can be executed in a single batch"),
ObscuroGenesisFlag: flag.NewStringFlag(ObscuroGenesisFlag, "", "The json string with the obscuro genesis"),
TenGenesisFlag: flag.NewStringFlag(TenGenesisFlag, "", "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"),
Expand All @@ -68,7 +68,7 @@ var EnclaveFlags = map[string]*flag.TenFlag{
var enclaveRestrictedFlags = []string{
L1ChainIDFlag,
ObscuroChainIDFlag,
ObscuroGenesisFlag,
TenGenesisFlag,
UseInMemoryDBFlag,
ProfilerEnabledFlag,
DebugNamespaceEnabledFlag,
Expand Down
6 changes: 3 additions & 3 deletions go/config/enclave_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ type EnclaveConfig struct {
MessageBusAddress gethcommon.Address
// P2P address for validators to connect to the sequencer for live batch data
SequencerP2PAddress string
// A json string that specifies the prefunded addresses at the genesis of the Obscuro network
ObscuroGenesis string
// A json string that specifies the prefunded addresses at the genesis of the Ten network
TenGenesis string
// Whether debug calls are available
DebugNamespaceEnabled bool
// Maximum bytes a batch can be uncompressed.
Expand Down Expand Up @@ -186,7 +186,7 @@ func newConfig(flags map[string]*flag.TenFlag) (*EnclaveConfig, error) {
cfg.ProfilerEnabled = flags[ProfilerEnabledFlag].Bool()
cfg.MinGasPrice = big.NewInt(flags[MinGasPriceFlag].Int64())
cfg.MessageBusAddress = gethcommon.HexToAddress(flags[MessageBusAddressFlag].String())
cfg.ObscuroGenesis = flags[ObscuroGenesisFlag].String()
cfg.TenGenesis = flags[TenGenesisFlag].String()
cfg.DebugNamespaceEnabled = flags[DebugNamespaceEnabledFlag].Bool()
cfg.MaxBatchSize = flags[MaxBatchSizeFlag].Uint64()
cfg.MaxRollupSize = flags[MaxRollupSizeFlag].Uint64()
Expand Down
4 changes: 2 additions & 2 deletions go/config/enclave_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestRestrictedMode(t *testing.T) {
t.Setenv("EDG_TESTMODE", "false")
t.Setenv("EDG_"+strings.ToUpper(L1ChainIDFlag), "4444")
t.Setenv("EDG_"+strings.ToUpper(ObscuroChainIDFlag), "1243")
t.Setenv("EDG_"+strings.ToUpper(ObscuroGenesisFlag), "{}")
t.Setenv("EDG_"+strings.ToUpper(TenGenesisFlag), "{}")
t.Setenv("EDG_"+strings.ToUpper(UseInMemoryDBFlag), "true")
t.Setenv("EDG_"+strings.ToUpper(ProfilerEnabledFlag), "true")
t.Setenv("EDG_"+strings.ToUpper(DebugNamespaceEnabledFlag), "true")
Expand Down Expand Up @@ -115,7 +115,7 @@ func TestRestrictedModeNoCLIDuplication(t *testing.T) {
t.Setenv("EDG_TESTMODE", "false")
t.Setenv("EDG_"+strings.ToUpper(L1ChainIDFlag), "4444")
t.Setenv("EDG_"+strings.ToUpper(ObscuroChainIDFlag), "1243")
t.Setenv("EDG_"+strings.ToUpper(ObscuroGenesisFlag), "{}")
t.Setenv("EDG_"+strings.ToUpper(TenGenesisFlag), "{}")
t.Setenv("EDG_"+strings.ToUpper(UseInMemoryDBFlag), "true")
t.Setenv("EDG_"+strings.ToUpper(ProfilerEnabledFlag), "true")
t.Setenv("EDG_"+strings.ToUpper(DebugNamespaceEnabledFlag), "true")
Expand Down
2 changes: 1 addition & 1 deletion go/enclave/container/enclave_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func NewEnclaveContainerWithLogger(config *config.EnclaveConfig, logger gethlog.
config.GenesisJSON = []byte(hardcodedGenesisJSON)
}

genesis, err := obscuroGenesis.New(config.ObscuroGenesis)
genesis, err := obscuroGenesis.New(config.TenGenesis)
if err != nil {
logger.Crit("unable to parse obscuro genesis", log.ErrKey, err)
}
Expand Down
2 changes: 1 addition & 1 deletion go/host/container/host_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func NewHostContainer(cfg *config.HostConfig, services *host.ServicesRegistry, p
rpcServer.RegisterAPIs([]rpc.API{
{
Namespace: APINamespaceObscuro,
Service: clientapi.NewObscuroAPI(h),
Service: clientapi.NewTenAPI(h),
},
{
Namespace: APINamespaceEth,
Expand Down
4 changes: 2 additions & 2 deletions go/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,15 @@ func (h *host) HealthCheck(ctx context.Context) (*hostcommon.HealthCheck, error)
}

// ObscuroConfig returns info on the Obscuro network
func (h *host) ObscuroConfig() (*common.ObscuroNetworkInfo, error) {
func (h *host) TenConfig() (*common.TenNetworkInfo, error) {
if h.l2MessageBusAddress == nil {
publicCfg, err := h.EnclaveClient().EnclavePublicConfig(context.Background())
if err != nil {
return nil, responses.ToInternalError(fmt.Errorf("unable to get L2 message bus address - %w", err))
}
h.l2MessageBusAddress = &publicCfg.L2MessageBusAddress
}
return &common.ObscuroNetworkInfo{
return &common.TenNetworkInfo{
ManagementContractAddress: h.config.ManagementContractAddress,
L1StartHash: h.config.L1StartHash,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,46 @@ import (
"github.com/ten-protocol/go-ten/go/common/host"
)

// ObscuroAPI implements Obscuro-specific JSON RPC operations.
type ObscuroAPI struct {
// TenAPI implements Ten-specific JSON RPC operations.
type TenAPI struct {
host host.Host
}

func NewObscuroAPI(host host.Host) *ObscuroAPI {
return &ObscuroAPI{
func NewTenAPI(host host.Host) *TenAPI {
return &TenAPI{
host: host,
}
}

// Health returns the health status of obscuro host + enclave + db
func (api *ObscuroAPI) Health(ctx context.Context) (*host.HealthCheck, error) {
// Health returns the health status of Ten host + enclave + db
func (api *TenAPI) Health(ctx context.Context) (*host.HealthCheck, error) {
return api.host.HealthCheck(ctx)
}

// Config returns the config status of obscuro host + enclave + db
func (api *ObscuroAPI) Config() (*ChecksumFormattedObscuroNetworkConfig, error) {
config, err := api.host.ObscuroConfig()
// Config returns the config status of Ten host + enclave + db
func (api *TenAPI) Config() (*ChecksumFormattedTenNetworkConfig, error) {
config, err := api.host.TenConfig()
if err != nil {
return nil, err
}
return checksumFormatted(config), nil
}

// ChecksumFormattedObscuroNetworkConfig serialises the addresses as EIP55 checksum addresses.
type ChecksumFormattedObscuroNetworkConfig struct {
// ChecksumFormattedTenNetworkConfig serialises the addresses as EIP55 checksum addresses.
type ChecksumFormattedTenNetworkConfig struct {
ManagementContractAddress gethcommon.AddressEIP55
L1StartHash gethcommon.Hash
MessageBusAddress gethcommon.AddressEIP55
L2MessageBusAddress gethcommon.AddressEIP55
ImportantContracts map[string]gethcommon.AddressEIP55 // map of contract name to address
}

func checksumFormatted(info *common.ObscuroNetworkInfo) *ChecksumFormattedObscuroNetworkConfig {
func checksumFormatted(info *common.TenNetworkInfo) *ChecksumFormattedTenNetworkConfig {
importantContracts := make(map[string]gethcommon.AddressEIP55)
for name, addr := range info.ImportantContracts {
importantContracts[name] = gethcommon.AddressEIP55(addr)
}
return &ChecksumFormattedObscuroNetworkConfig{
return &ChecksumFormattedTenNetworkConfig{
ManagementContractAddress: gethcommon.AddressEIP55(info.ManagementContractAddress),
L1StartHash: info.L1StartHash,
MessageBusAddress: gethcommon.AddressEIP55(info.MessageBusAddress),
Expand Down
10 changes: 5 additions & 5 deletions go/node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type Config struct {
maxBatchInterval string
rollupInterval string
l1ChainID int
obscuroGenesis string
tenGenesis string
}

func NewNodeConfig(opts ...Option) *Config {
Expand All @@ -64,7 +64,7 @@ func NewNodeConfig(opts ...Option) *Config {
maxBatchInterval: "1s",
rollupInterval: "3s",
l1ChainID: 1337,
obscuroGenesis: "{}",
tenGenesis: "{}",
}

for _, opt := range opts {
Expand All @@ -90,7 +90,7 @@ func (c *Config) ToEnclaveConfig() *config.EnclaveConfig {
cfg.LogLevel = c.logLevel
cfg.Address = fmt.Sprintf("%s:%d", _localhost, c.enclaveWSPort)
cfg.DebugNamespaceEnabled = c.debugNamespaceEnabled
cfg.ObscuroGenesis = c.obscuroGenesis
cfg.TenGenesis = c.tenGenesis

if c.nodeType == "sequencer" && c.coinbaseAddress != "" {
cfg.GasPaymentAddress = gethcommon.HexToAddress(c.coinbaseAddress)
Expand Down Expand Up @@ -338,9 +338,9 @@ func WithL1ChainID(i int) Option {
}
}

func WithObscuroGenesis(g string) Option {
func WithTenGenesis(g string) Option {
return func(c *Config) {
c.obscuroGenesis = g
c.tenGenesis = g
}
}

Expand Down
2 changes: 1 addition & 1 deletion go/node/docker_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (d *DockerNode) startEnclave() error {
"-maxBatchSize=56320",
"-maxRollupSize=65536",
fmt.Sprintf("-logLevel=%d", d.cfg.logLevel),
"-obscuroGenesis", "{}",
"-tenGenesis", "{}",
"-edgelessDBHost", d.cfg.nodeName+"-edgelessdb",
)

Expand Down
4 changes: 2 additions & 2 deletions go/obsclient/obsclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ func (oc *ObsClient) GetBatchTransactions(hash gethcommon.Hash) (*common.Transac
}

// GetConfig returns the network config for obscuro
func (oc *ObsClient) GetConfig() (*common.ObscuroNetworkInfo, error) {
var result common.ObscuroNetworkInfo
func (oc *ObsClient) GetConfig() (*common.TenNetworkInfo, error) {
var result common.TenNetworkInfo
err := oc.rpcClient.Call(&result, rpc.Config)
if err != nil {
return nil, err
Expand Down
6 changes: 0 additions & 6 deletions go/wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ type Wallet interface {
Address() common.Address
// SignTransaction returns a signed transaction
SignTransaction(tx types.TxData) (*types.Transaction, error)
SignTransactionForChainID(tx types.TxData, chainID *big.Int) (*types.Transaction, error)

// SetNonce overrides the current nonce
// The GetTransactionCount is expected to be the next nonce to use in a transaction, not the current account GetTransactionCount
SetNonce(nonce uint64)
Expand Down Expand Up @@ -72,10 +70,6 @@ func (m *inMemoryWallet) SignTransaction(tx types.TxData) (*types.Transaction, e
return types.SignNewTx(m.prvKey, types.NewCancunSigner(m.chainID), tx)
}

func (m *inMemoryWallet) SignTransactionForChainID(tx types.TxData, chainID *big.Int) (*types.Transaction, error) {
return types.SignNewTx(m.prvKey, types.NewLondonSigner(chainID), tx)
}

// Address returns the current wallet address
func (m *inMemoryWallet) Address() common.Address {
return m.pubKeyAddr
Expand Down
2 changes: 1 addition & 1 deletion integration/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func DefaultEnclaveConfig() *config.EnclaveConfig {
SqliteDBPath: "",
ProfilerEnabled: false,
MinGasPrice: big.NewInt(params.InitialBaseFee),
ObscuroGenesis: "",
TenGenesis: "",
DebugNamespaceEnabled: false,
MaxBatchSize: 1024 * 55,
MaxRollupSize: 1024 * 64,
Expand Down
8 changes: 7 additions & 1 deletion integration/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ const (
DefaultGethWSPortOffset = 100
DefaultGethAUTHPortOffset = 200
DefaultGethNetworkPortOffset = 300
DefaultPrysmHTTPPortOffset = 400
DefaultGethHTTPPortOffset = 400
DefaultPrysmP2PPortOffset = 500
DefaultPrysmRPCPortOffset = 550
DefaultHostP2pOffset = 600 // The default offset for the host P2p
DefaultEnclaveOffset = 700 // The default offset between a Geth nodes port and the enclave ports. Used in Socket Simulations.
DefaultHostRPCHTTPOffset = 800 // The default offset for the host's RPC HTTP port
Expand All @@ -36,3 +37,8 @@ const (
EthereumChainID = 1337
TenChainID = 443
)

const (
GethNodeAddress = "0x123463a4b065722e99115d6c222f267d9cabb524"
GethNodePK = "2e0834786285daccd064ca17f1654f67b4aef298acbb82cef9ec422fb4975622"
)
12 changes: 6 additions & 6 deletions integration/contractdeployer/contract_deployer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func init() { //nolint:gochecknoinits
func TestCanDeployLayer2ERC20Contract(t *testing.T) {
startPort := integration.StartPortContractDeployerTest1
hostWSPort := startPort + integration.DefaultHostRPCWSOffset
createObscuroNetwork(t, startPort)
creatTenNetwork(t, startPort)
// This sleep is required to ensure the initial rollup exists, and thus contract deployer can check its balance.
time.Sleep(2 * time.Second)

Expand Down Expand Up @@ -83,7 +83,7 @@ func TestCanDeployLayer2ERC20Contract(t *testing.T) {
func TestFaucetSendsFundsOnlyIfNeeded(t *testing.T) {
startPort := integration.StartPortContractDeployerTest2
hostWSPort := startPort + integration.DefaultHostRPCWSOffset
createObscuroNetwork(t, startPort)
creatTenNetwork(t, startPort)

faucetWallet := wallet.NewInMemoryWalletFromConfig(genesis.TestnetPrefundedPK, integration.TenChainID, testlog.Logger())
faucetClient := getClient(hostWSPort, faucetWallet)
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestFaucetSendsFundsOnlyIfNeeded(t *testing.T) {
}

// Creates a single-node Obscuro network for testing.
func createObscuroNetwork(t *testing.T, startPort int) {
func creatTenNetwork(t *testing.T, startPort int) {
// Create the Obscuro network.
numberOfNodes := 1
wallets := params.NewSimWallets(1, numberOfNodes, integration.EthereumChainID, integration.TenChainID)
Expand All @@ -144,9 +144,9 @@ func createObscuroNetwork(t *testing.T, startPort int) {
WithPrefunding: true,
}
simStats := stats.NewStats(simParams.NumberOfNodes)
obscuroNetwork := network.NewNetworkOfSocketNodes(wallets)
t.Cleanup(obscuroNetwork.TearDown)
_, err := obscuroNetwork.Create(&simParams, simStats)
tenNetwork := network.NewNetworkOfSocketNodes(wallets)
t.Cleanup(tenNetwork.TearDown)
_, err := tenNetwork.Create(&simParams, simStats)
if err != nil {
panic(fmt.Sprintf("failed to create test Obscuro network. Cause: %s", err))
}
Expand Down
Loading

0 comments on commit 3846fa5

Please sign in to comment.