Skip to content

Commit

Permalink
Downgrade go-ethereum to v1.13.8 (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
songge-cb authored Mar 11, 2024
1 parent 0949ece commit b33f1b5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
26 changes: 12 additions & 14 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"log"
"math/big"
"strconv"

"github.com/coinbase/rosetta-geth-sdk/configuration"
sdkTypes "github.com/coinbase/rosetta-geth-sdk/types"
Expand All @@ -39,7 +40,6 @@ import (
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
"github.com/holiman/uint256"
"golang.org/x/sync/semaphore"
)

Expand Down Expand Up @@ -574,18 +574,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,
) *uint256.Int {
) int64 {
if currentBlock.Int64() == int64(0) {
return uint256.NewInt(0)
return big.NewInt(0).Int64()
}

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

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

return blockReward
Expand All @@ -610,12 +610,12 @@ func (ec *SDKClient) BlockRewardTransaction(
if len(uncles) > 0 {
reward := new(big.Float)
uncleReward := float64(numUncles) / sdkTypes.UnclesRewardMultiplier
rewardFloat := reward.Mul(big.NewFloat(uncleReward), big.NewFloat(miningReward.Float64()))
rewardInt := new(big.Int)
rewardFloat.Int(rewardInt)
minerReward.Add(minerReward, uint256.MustFromBig(rewardInt))
rewardFloat := reward.Mul(big.NewFloat(uncleReward), big.NewFloat(float64(miningReward)))
rewardInt, _ := rewardFloat.Int64()
minerReward += rewardInt
}

const base = 10
miningRewardOp := &RosettaTypes.Operation{
OperationIdentifier: &RosettaTypes.OperationIdentifier{
Index: 0,
Expand All @@ -626,7 +626,7 @@ func (ec *SDKClient) BlockRewardTransaction(
Address: MustChecksum(miner),
},
Amount: &RosettaTypes.Amount{
Value: minerReward.Dec(),
Value: strconv.FormatInt(minerReward, base),
Currency: ec.rosettaConfig.Currency,
},
}
Expand All @@ -636,13 +636,11 @@ func (ec *SDKClient) BlockRewardTransaction(
for _, b := range uncles {
uncleMiner := b.Coinbase.String()
uncleBlock := b.Number.Int64()
miningRewardPerUncle := minerReward.Clone()
miningRewardPerUncle.Div(miningRewardPerUncle, uint256.NewInt(sdkTypes.MaxUncleDepth))
uncleRewardBlock := new(
big.Int,
).Mul(
big.NewInt(uncleBlock+sdkTypes.MaxUncleDepth-blockIdentifier.Index),
miningRewardPerUncle.ToBig(),
big.NewInt(miningReward/sdkTypes.MaxUncleDepth),
)

uncleRewardOp := &RosettaTypes.Operation{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/coinbase/rosetta-sdk-go v0.8.2
github.com/ethereum/go-ethereum v1.13.14
github.com/ethereum/go-ethereum v1.13.8
github.com/holiman/uint256 v1.2.4
github.com/neilotoole/errgroup v0.1.6
github.com/stretchr/testify v1.8.4
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw=
github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY=
github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
github.com/ethereum/go-ethereum v1.13.14 h1:EwiY3FZP94derMCIam1iW4HFVrSgIcpsu0HwTQtm6CQ=
github.com/ethereum/go-ethereum v1.13.14/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU=
github.com/ethereum/go-ethereum v1.13.8 h1:1od+thJel3tM52ZUNQwvpYOeRHlbkVFZ5S8fhi0Lgsg=
github.com/ethereum/go-ethereum v1.13.8/go.mod h1:sc48XYQxCzH3fG9BcrXCOOgQk2JfZzNAmIKnceogzsA=
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c=
github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
Expand Down Expand Up @@ -257,7 +257,7 @@ github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4=
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 h1:3JQNjnMRil1yD0IfZKHF9GxxWKDJGj8I0IqOUol//sw=
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU=
Expand Down

0 comments on commit b33f1b5

Please sign in to comment.