Skip to content

Commit

Permalink
Update go/ethereum to v1.15.5 (#145)
Browse files Browse the repository at this point in the history
* Update go/ethereum to v1.15.5
* Update golang to v1.23 to match go-ethereum
* Fix rewards code to use uint256
  • Loading branch information
rafalio-cb authored Mar 5, 2025
1 parent 18b4556 commit f798d33
Show file tree
Hide file tree
Showing 8 changed files with 290 additions and 767 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:

env:
go_version: 1.21
go_version: 1.23
GO111MODULE: on
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GOIMPORTS_CMD=goimports
LINT_SETTINGS=golint,misspell,gocyclo,gocritic,whitespace,goconst,gocognit,bodyclose,unconvert,lll,unparam
ADDLICENSE_INSTALL=go install github.com/google/addlicense@latest
ADDLICENSE_CMD=addlicense
ADDLICENSE_IGNORE=-ignore ".github/**/*" -ignore ".idea/**/*" -ignore .codeflow.yml -ignore "examples/ethereum/*/*/*"
ADDLICENSE_IGNORE=-ignore ".github/**/*" -ignore ".idea/**/*" -ignore .codeflow.yml -ignore salus.yaml -ignore "examples/ethereum/*/*/*"
ADDLICENCE_SCRIPT=${ADDLICENSE_CMD} -c "Coinbase, Inc." -l "apache" -v ${ADDLICENSE_IGNORE}
GOLINES_INSTALL=go install github.com/segmentio/golines@latest
GOLINES_CMD=golines
Expand Down
22 changes: 11 additions & 11 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"net/http"
"strconv"

"github.com/holiman/uint256"

"github.com/coinbase/rosetta-geth-sdk/configuration"
sdkTypes "github.com/coinbase/rosetta-geth-sdk/types"

Expand Down Expand Up @@ -601,20 +603,18 @@ func FlattenTraces(data *Call, flattened []*FlatCall) []*FlatCall {
// https://github.com/ethereum/go-ethereum/blob/master/consensus/ethash/consensus.go#L646-L653
func (ec *SDKClient) miningReward(
currentBlock *big.Int,
) int64 {
) *uint256.Int {
if currentBlock.Int64() == int64(0) {
return big.NewInt(0).Int64()
return uint256.NewInt(0)
}

blockReward := ethash.FrontierBlockReward.Int64()
blockReward := ethash.FrontierBlockReward

if ec.P.IsByzantium(currentBlock) {
blockReward = ethash.ByzantiumBlockReward.Int64()
blockReward = ethash.ByzantiumBlockReward
}
if ec.P.IsConstantinople(currentBlock) {
blockReward = ethash.ConstantinopleBlockReward.Int64()
blockReward = ethash.ConstantinopleBlockReward
}

return blockReward
}

Expand All @@ -624,7 +624,7 @@ func (ec *SDKClient) BlockRewardTransaction(
uncles []*EthTypes.Header,
) *RosettaTypes.Transaction {
var ops []*RosettaTypes.Operation
miningReward := ec.miningReward(big.NewInt(blockIdentifier.Index))
miningReward := ec.miningReward(big.NewInt(blockIdentifier.Index)).Uint64()

// https://github.com/ethereum/go-ethereum/blob/
// aaca58a7a1d9acbd24bbc74c49933efa2f1af183/consensus/ethash/consensus.go#L645
Expand All @@ -638,7 +638,7 @@ func (ec *SDKClient) BlockRewardTransaction(
reward := new(big.Float)
uncleReward := float64(numUncles) / sdkTypes.UnclesRewardMultiplier
rewardFloat := reward.Mul(big.NewFloat(uncleReward), big.NewFloat(float64(miningReward)))
rewardInt, _ := rewardFloat.Int64()
rewardInt, _ := rewardFloat.Uint64()
minerReward += rewardInt
}

Expand All @@ -653,7 +653,7 @@ func (ec *SDKClient) BlockRewardTransaction(
Address: MustChecksum(miner),
},
Amount: &RosettaTypes.Amount{
Value: strconv.FormatInt(minerReward, base),
Value: strconv.FormatUint(minerReward, base),
Currency: ec.rosettaConfig.Currency,
},
}
Expand All @@ -667,7 +667,7 @@ func (ec *SDKClient) BlockRewardTransaction(
big.Int,
).Mul(
big.NewInt(uncleBlock+sdkTypes.MaxUncleDepth-blockIdentifier.Index),
big.NewInt(miningReward/sdkTypes.MaxUncleDepth),
new(big.Int).SetUint64(miningReward/sdkTypes.MaxUncleDepth),
)

uncleRewardOp := &RosettaTypes.Operation{
Expand Down
32 changes: 16 additions & 16 deletions examples/ethereum/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ const (
// in MainnetNetworkIdentifier.
MainnetNetwork string = "Mainnet"

// GoerliNetwork is the value of the network
// in GoerliNetworkNetworkIdentifier.
GoerliNetwork string = "Goerli"
// HoleskyNetwork is the value of the network
// in HoleskyNetworkNetworkIdentifier.
HoleskyNetwork string = "Holesky"

// SepoliaNetwork is the value of the network
// in SepoliaNetworkNetworkIdentifier.
Expand All @@ -66,8 +66,8 @@ const (
// Mainnet is the Ethereum Mainnet.
Mainnet string = "MAINNET"

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

// Sepolia is the Ethereum Sepolia testnet.
Sepolia string = "SEPOLIA"
Expand Down Expand Up @@ -128,8 +128,8 @@ const (
)

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

// SepoliaGethArguments are the arguments to start a sepolia geth instance.
SepoliaGethArguments = fmt.Sprintf("%s --sepolia", MainnetGethArguments)
Expand All @@ -141,10 +141,10 @@ var (
Index: GenesisBlockIndex,
}

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

Expand Down Expand Up @@ -185,14 +185,14 @@ func LoadConfiguration() (*configuration.Configuration, error) {
config.GenesisBlockIdentifier = MainnetGenesisBlockIdentifier
config.ChainConfig = params.MainnetChainConfig
config.GethArguments = MainnetGethArguments
case Goerli:
case Holesky:
config.Network = &types.NetworkIdentifier{
Blockchain: Blockchain,
Network: GoerliNetwork,
Network: HoleskyNetwork,
}
config.GenesisBlockIdentifier = GoerliGenesisBlockIdentifier
config.ChainConfig = params.GoerliChainConfig
config.GethArguments = GoerliGethArguments
config.GenesisBlockIdentifier = HoleskyGenesisBlockIdentifier
config.ChainConfig = params.HoleskyChainConfig
config.GethArguments = HoleskyGethArguments
case Sepolia:
config.Network = &types.NetworkIdentifier{
Blockchain: Blockchain,
Expand Down
117 changes: 50 additions & 67 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,94 +1,77 @@
module github.com/coinbase/rosetta-geth-sdk

go 1.20
go 1.23.7

toolchain go1.24.0

require (
github.com/coinbase/rosetta-sdk-go v0.8.9
github.com/coinbase/rosetta-sdk-go/types v1.0.0
github.com/ethereum/go-ethereum v1.13.8
github.com/hashicorp/golang-lru v0.5.1
github.com/ethereum/go-ethereum v1.15.5
github.com/hashicorp/golang-lru v1.0.2
github.com/neilotoole/errgroup v0.1.6
github.com/stretchr/testify v1.8.4
golang.org/x/crypto v0.17.0
golang.org/x/sync v0.5.0
github.com/stretchr/testify v1.10.0
golang.org/x/crypto v0.36.0
golang.org/x/sync v0.12.0
)

require (
github.com/DataDog/zstd v1.5.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/DataDog/zstd v1.5.6 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect
github.com/bits-and-blooms/bitset v1.21.0 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.8.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect
github.com/cockroachdb/redact v1.0.8 // indirect
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/consensys/bavard v0.1.29 // indirect
github.com/consensys/gnark-crypto v0.16.0 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
github.com/crate-crypto/go-kzg-4844 v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
github.com/deckarep/golang-set/v2 v2.7.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
github.com/ethereum/c-kzg-4844 v1.0.3 // indirect
github.com/ethereum/go-verkle v0.2.2 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/gofrs/flock v0.12.1 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/holiman/uint256 v1.3.2
github.com/huin/goupnp v1.3.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pion/dtls/v2 v2.2.12 // indirect
github.com/pion/logging v0.2.3 // indirect
github.com/pion/stun/v2 v2.0.0 // indirect
github.com/pion/transport/v2 v2.2.10 // indirect
github.com/pion/transport/v3 v3.0.7 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.0 // indirect
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/segmentio/fasthash v1.0.3 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/status-im/keycard-go v0.2.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/supranational/blst v0.3.14 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.15.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/grpc v1.61.2 // indirect
google.golang.org/protobuf v1.31.0 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.9.0 // indirect
github.com/wlynxg/anet v0.0.5 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/exp v0.0.0-20250228200357-dead58393ab7 // indirect
golang.org/x/net v0.36.0 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/text v0.23.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/grpc v1.71.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
Loading

0 comments on commit f798d33

Please sign in to comment.