Skip to content

Commit

Permalink
Fixes for running on arm64 (#143)
Browse files Browse the repository at this point in the history
Signed-off-by: Nicko Guyer <[email protected]>
  • Loading branch information
nguyer authored Feb 8, 2022
1 parent 393a7b2 commit 1d1ba52
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
13 changes: 9 additions & 4 deletions internal/blockchain/ethereum/geth/geth_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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
}

Expand All @@ -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)
}
Expand All @@ -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"},
Expand Down
2 changes: 1 addition & 1 deletion internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions internal/stacks/ipfs_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1d1ba52

Please sign in to comment.