From 1d1ba52d7a5926d145421581b54cda6cf933acda Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Mon, 7 Feb 2022 21:50:43 -0500 Subject: [PATCH] Fixes for running on arm64 (#143) Signed-off-by: Nicko Guyer --- internal/blockchain/ethereum/geth/geth_provider.go | 13 +++++++++---- internal/constants/constants.go | 2 +- internal/stacks/ipfs_config.go | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/internal/blockchain/ethereum/geth/geth_provider.go b/internal/blockchain/ethereum/geth/geth_provider.go index a0c44a5b..44f1f3b3 100644 --- a/internal/blockchain/ethereum/geth/geth_provider.go +++ b/internal/blockchain/ethereum/geth/geth_provider.go @@ -32,6 +32,8 @@ import ( "github.com/hyperledger/firefly-cli/pkg/types" ) +var gethImage = "ethereum/client-go:release-1.10" + type GethProvider struct { Log log.Logger Verbose bool @@ -88,7 +90,7 @@ func (p *GethProvider) FirstTimeSetup() error { // Mount the directory containing all members' private keys and password, and import the accounts using the geth CLI for _, member := range p.Stack.Members { - if err := docker.RunDockerCommand(constants.StacksDir, p.Verbose, p.Verbose, "run", "--rm", "-v", fmt.Sprintf("%s:/geth", gethConfigDir), "-v", fmt.Sprintf("%s:/data", gethVolumeName), "ethereum/client-go:release-1.9", "--nousb", "account", "import", "--password", "/geth/password", "--keystore", "/data/keystore", fmt.Sprintf("/geth/%s/keyfile", member.ID)); err != nil { + if err := docker.RunDockerCommand(constants.StacksDir, p.Verbose, p.Verbose, "run", "--rm", "-v", fmt.Sprintf("%s:/geth", gethConfigDir), "-v", fmt.Sprintf("%s:/data", gethVolumeName), gethImage, "account", "import", "--password", "/geth/password", "--keystore", "/data/keystore", fmt.Sprintf("/geth/%s/keyfile", member.ID)); err != nil { return err } } @@ -104,7 +106,7 @@ func (p *GethProvider) FirstTimeSetup() error { } // Initialize the genesis block - if err := docker.RunDockerCommand(constants.StacksDir, p.Verbose, p.Verbose, "run", "--rm", "-v", fmt.Sprintf("%s:/data", gethVolumeName), "ethereum/client-go:release-1.9", "--datadir", "/data", "--nousb", "init", "/data/genesis.json"); err != nil { + if err := docker.RunDockerCommand(constants.StacksDir, p.Verbose, p.Verbose, "run", "--rm", "-v", fmt.Sprintf("%s:/data", gethVolumeName), gethImage, "--datadir", "/data", "init", "/data/genesis.json"); err != nil { return err } @@ -123,6 +125,9 @@ func (p *GethProvider) PostStart() error { p.Log.Info(fmt.Sprintf("unlocking account for member %s", m.ID)) for { if err := gethClient.UnlockAccount(m.Address, "correcthorsebatterystaple"); err != nil { + if p.Verbose { + p.Log.Debug(err.Error()) + } if retries == 0 { return fmt.Errorf("unable to unlock account %s for member %s", m.Address, m.ID) } @@ -148,13 +153,13 @@ func (p *GethProvider) GetDockerServiceDefinitions() []*docker.ServiceDefinition addresses = addresses + "," } } - gethCommand := fmt.Sprintf(`--datadir /data --syncmode 'full' --port 30311 --rpcvhosts=* --rpccorsdomain "*" --miner.gastarget 804247552 --rpc --rpcaddr "0.0.0.0" --rpcport 8545 --rpcapi 'admin,personal,db,eth,net,web3,txpool,miner,clique' --networkid 2021 --miner.gasprice 0 --unlock '%s' --password /data/password --mine --nousb --allow-insecure-unlock --nodiscover`, addresses) + gethCommand := fmt.Sprintf(`--datadir /data --syncmode 'full' --port 30311 --http --http.addr "0.0.0.0" --http.port 8545 --http.vhosts "*" --http.api 'admin,personal,eth,net,web3,txpool,miner,clique' --networkid 2021 --miner.gasprice 0 --password /data/password --mine --allow-insecure-unlock --nodiscover`) serviceDefinitions := make([]*docker.ServiceDefinition, 1) serviceDefinitions[0] = &docker.ServiceDefinition{ ServiceName: "geth", Service: &docker.Service{ - Image: "ethereum/client-go:release-1.9", + Image: gethImage, ContainerName: fmt.Sprintf("%s_geth", p.Stack.Name), Command: gethCommand, Volumes: []string{"geth:/data"}, diff --git a/internal/constants/constants.go b/internal/constants/constants.go index 834b64d2..ee4bb9a6 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -24,6 +24,6 @@ import ( var homeDir, _ = os.UserHomeDir() var StacksDir = filepath.Join(homeDir, ".firefly", "stacks") -var IPFSImageName = "ipfs/go-ipfs" +var IPFSImageName = "ipfs/go-ipfs:v0.10.0" var PostgresImageName = "postgres" var PrometheusImageName = "prom/prometheus" diff --git a/internal/stacks/ipfs_config.go b/internal/stacks/ipfs_config.go index 5ebab114..32240351 100644 --- a/internal/stacks/ipfs_config.go +++ b/internal/stacks/ipfs_config.go @@ -25,6 +25,8 @@ import ( "github.com/libp2p/go-libp2p-core/peer" ) +var ipfsConfigBytes []byte + func GenerateSwarmKey() string { key := make([]byte, 32) rand.Read(key)