Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Running the following commands will start a Docker container in
a data directory at `<working directory>/ethereum-data` and the Rosetta API accessible
at port `8080`.

The `NETWORK` environment variable can be set to `MAINNET`, `ROPSTEN`, `RINKEBY`, `GOERLI` or `TESTNET` (which defaults to `ROPSTEN`).

_It is possible to run `rosetta-ethereum` using a remote node by adding
`-e "GETH=<node url>"` to any online command._

Expand Down
37 changes: 31 additions & 6 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,19 @@ const (
// to make outbound connections.
Offline Mode = "OFFLINE"

// Mainnet is the Bitcoin Mainnet.
// Mainnet is the Ethereum Mainnet.
Mainnet string = "MAINNET"

// Testnet is Bitcoin Testnet3.
// Ropsten is the Ethereum Ropsten testnet.
Ropsten string = "ROPSTEN"

// Rinkeby is the Ethereum Rinkeby testnet.
Rinkeby string = "RINKEBY"

// Goerli is the Ethereum Görli testnet.
Goerli string = "GOERLI"

// Testnet defaults to `Ropsten` for backwards compatibility.
Testnet string = "TESTNET"

// DataDirectory is the default location for all
Expand Down Expand Up @@ -117,14 +126,30 @@ func LoadConfiguration() (*Configuration, error) {
config.GenesisBlockIdentifier = ethereum.MainnetGenesisBlockIdentifier
config.Params = params.MainnetChainConfig
config.GethArguments = ethereum.MainnetGethArguments
case Testnet:
case Testnet, Ropsten:
config.Network = &types.NetworkIdentifier{
Blockchain: ethereum.Blockchain,
Network: ethereum.TestnetNetwork,
Network: ethereum.RopstenNetwork,
}
config.GenesisBlockIdentifier = ethereum.TestnetGenesisBlockIdentifier
config.GenesisBlockIdentifier = ethereum.RopstenGenesisBlockIdentifier
config.Params = params.RopstenChainConfig
config.GethArguments = ethereum.TestnetGethArguments
config.GethArguments = ethereum.RopstenGethArguments
case Rinkeby:
config.Network = &types.NetworkIdentifier{
Blockchain: ethereum.Blockchain,
Network: ethereum.RinkebyNetwork,
}
config.GenesisBlockIdentifier = ethereum.RinkebyGenesisBlockIdentifier
config.Params = params.RinkebyChainConfig
config.GethArguments = ethereum.RinkebyGethArguments
case Goerli:
config.Network = &types.NetworkIdentifier{
Blockchain: ethereum.Blockchain,
Network: ethereum.GoerliNetwork,
}
config.GenesisBlockIdentifier = ethereum.GoerliGenesisBlockIdentifier
config.Params = params.GoerliChainConfig
config.GethArguments = ethereum.GoerliGethArguments
case "":
return nil, errors.New("NETWORK must be populated")
default:
Expand Down
61 changes: 56 additions & 5 deletions configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,77 @@ func TestLoadConfiguration(t *testing.T) {
GethArguments: ethereum.MainnetGethArguments,
},
},
"all set (ropsten)": {
Mode: string(Online),
Network: Ropsten,
Port: "1000",
cfg: &Configuration{
Mode: Online,
Network: &types.NetworkIdentifier{
Network: ethereum.RopstenNetwork,
Blockchain: ethereum.Blockchain,
},
Params: params.RopstenChainConfig,
GenesisBlockIdentifier: ethereum.RopstenGenesisBlockIdentifier,
Port: 1000,
GethURL: DefaultGethURL,
GethArguments: ethereum.RopstenGethArguments,
},
},
"all set (rinkeby)": {
Mode: string(Online),
Network: Rinkeby,
Port: "1000",
cfg: &Configuration{
Mode: Online,
Network: &types.NetworkIdentifier{
Network: ethereum.RinkebyNetwork,
Blockchain: ethereum.Blockchain,
},
Params: params.RinkebyChainConfig,
GenesisBlockIdentifier: ethereum.RinkebyGenesisBlockIdentifier,
Port: 1000,
GethURL: DefaultGethURL,
GethArguments: ethereum.RinkebyGethArguments,
},
},
"all set (goerli)": {
Mode: string(Online),
Network: Goerli,
Port: "1000",
cfg: &Configuration{
Mode: Online,
Network: &types.NetworkIdentifier{
Network: ethereum.GoerliNetwork,
Blockchain: ethereum.Blockchain,
},
Params: params.GoerliChainConfig,
GenesisBlockIdentifier: ethereum.GoerliGenesisBlockIdentifier,
Port: 1000,
GethURL: DefaultGethURL,
GethArguments: ethereum.GoerliGethArguments,
},
},
"all set (testnet)": {
Mode: string(Online),
Network: Testnet,
Port: "1000",
cfg: &Configuration{
Mode: Online,
Network: &types.NetworkIdentifier{
Network: ethereum.TestnetNetwork,
Network: ethereum.RopstenNetwork,
Blockchain: ethereum.Blockchain,
},
Params: params.RopstenChainConfig,
GenesisBlockIdentifier: ethereum.TestnetGenesisBlockIdentifier,
GenesisBlockIdentifier: ethereum.RopstenGenesisBlockIdentifier,
Port: 1000,
GethURL: DefaultGethURL,
GethArguments: ethereum.TestnetGethArguments,
GethArguments: ethereum.RopstenGethArguments,
},
},
"invalid mode": {
Mode: "bad mode",
Network: Testnet,
Network: Ropsten,
Port: "1000",
err: errors.New("bad mode is not a valid mode"),
},
Expand All @@ -115,7 +166,7 @@ func TestLoadConfiguration(t *testing.T) {
},
"invalid port": {
Mode: string(Offline),
Network: Testnet,
Network: Ropsten,
Port: "bad port",
err: errors.New("unable to parse port bad port"),
},
Expand Down
44 changes: 36 additions & 8 deletions ethereum/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@ const (
// in MainnetNetworkIdentifier.
MainnetNetwork string = "Mainnet"

// TestnetNetwork is the value of the network
// in TestnetNetworkIdentifier.
TestnetNetwork string = "Ropsten"
// RopstenNetwork is the value of the network
// in RopstenNetworkIdentifier.
RopstenNetwork string = "Ropsten"

// RinkebyNetwork is the value of the network
// in RinkebyNetworkNetworkIdentifier.
RinkebyNetwork string = "RinkebyNetwork"

// GoerliNetwork is the value of the network
// in GoerliNetworkNetworkIdentifier.
GoerliNetwork string = "GoerliNetwork"

// Symbol is the symbol value
// used in Currency.
Expand Down Expand Up @@ -119,8 +127,14 @@ const (
)

var (
// TestnetGethArguments are the arguments to start a ropsten geth instance.
TestnetGethArguments = fmt.Sprintf("%s --ropsten", MainnetGethArguments)
// RopstenGethArguments are the arguments to start a ropsten geth instance.
RopstenGethArguments = fmt.Sprintf("%s --ropsten", MainnetGethArguments)

// RinkebyGethArguments are the arguments to start a rinkeby geth instance.
RinkebyGethArguments = fmt.Sprintf("%s --rinkeby", MainnetGethArguments)

// GoerliGethArguments are the arguments to start a ropsten geth instance.
GoerliGethArguments = fmt.Sprintf("%s --goerli", MainnetGethArguments)

// MainnetGenesisBlockIdentifier is the *types.BlockIdentifier
// of the mainnet genesis block.
Expand All @@ -129,13 +143,27 @@ var (
Index: GenesisBlockIndex,
}

// TestnetGenesisBlockIdentifier is the *types.BlockIdentifier
// of the testnet genesis block.
TestnetGenesisBlockIdentifier = &types.BlockIdentifier{
// RopstenGenesisBlockIdentifier is the *types.BlockIdentifier
// of the Ropsten genesis block.
RopstenGenesisBlockIdentifier = &types.BlockIdentifier{
Hash: params.RopstenGenesisHash.Hex(),
Index: GenesisBlockIndex,
}

// RinkebyGenesisBlockIdentifier is the *types.BlockIdentifier
// of the Ropsten genesis block.
RinkebyGenesisBlockIdentifier = &types.BlockIdentifier{
Hash: params.RinkebyGenesisHash.Hex(),
Index: GenesisBlockIndex,
}

// GoerliGenesisBlockIdentifier is the *types.BlockIdentifier
// of the Goerli genesis block.
GoerliGenesisBlockIdentifier = &types.BlockIdentifier{
Hash: params.GoerliGenesisHash.Hex(),
Index: GenesisBlockIndex,
}

// Currency is the *types.Currency for all
// Ethereum networks.
Currency = &types.Currency{
Expand Down
2 changes: 1 addition & 1 deletion services/construction_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func forceMarshalMap(t *testing.T, i interface{}) map[string]interface{} {

func TestConstructionService(t *testing.T) {
networkIdentifier = &types.NetworkIdentifier{
Network: ethereum.TestnetNetwork,
Network: ethereum.RopstenNetwork,
Blockchain: ethereum.Blockchain,
}

Expand Down