Skip to content

Commit

Permalink
remove WithExtras hack
Browse files Browse the repository at this point in the history
  • Loading branch information
darioush committed Oct 1, 2024
1 parent 5827f96 commit 758c8bd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion accounts/abi/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,7 @@ func golangBindings(t *testing.T, overload bool) {
if out, err := replacer.CombinedOutput(); err != nil {
t.Fatalf("failed to replace binding test dependency to current source tree: %v\n%s", err, out)
}
replacer = exec.Command(gocmd, "mod", "edit", "-x", "-require", "github.com/ethereum/[email protected]", "-replace", "github.com/ethereum/go-ethereum=github.com/ava-labs/[email protected]20240927183738-d8757174b3f0")
replacer = exec.Command(gocmd, "mod", "edit", "-x", "-require", "github.com/ethereum/[email protected]", "-replace", "github.com/ethereum/go-ethereum=github.com/ava-labs/[email protected]20241001233245-6e652ebfd8b6")
replacer.Dir = pkg
if out, err := replacer.CombinedOutput(); err != nil {
t.Fatalf("failed to replace binding test dependency to current source tree: %v\n%s", err, out)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,6 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/ethereum/go-ethereum => github.com/ava-labs/go-ethereum v0.0.0-20240927183738-d8757174b3f0
replace github.com/ethereum/go-ethereum => github.com/ava-labs/go-ethereum v0.0.0-20241001233245-6e652ebfd8b6

// replace github.com/ethereum/go-ethereum => ../../git2/go-ethereum
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanchego v1.11.12-rc.2 h1:H1C0gsTOtwMD3qrouEqry0hfoBIC//9lEiDh/AvpaaY=
github.com/ava-labs/avalanchego v1.11.12-rc.2/go.mod h1:yFx3V31Jy9NFa8GZlgGnwiVf8KGjeF2+Uc99l9Scd/8=
github.com/ava-labs/go-ethereum v0.0.0-20240927183738-d8757174b3f0 h1:ReturG2I8TilGLZvRdFlNVbFgs0L1Vy4P7rNL8hQkHg=
github.com/ava-labs/go-ethereum v0.0.0-20240927183738-d8757174b3f0/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU=
github.com/ava-labs/go-ethereum v0.0.0-20241001233245-6e652ebfd8b6 h1:5oYs7hFWHtpqHi8CL1Ymy9ESGP7ajvd4vcSZ5EM+VDc=
github.com/ava-labs/go-ethereum v0.0.0-20241001233245-6e652ebfd8b6/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down
14 changes: 2 additions & 12 deletions params/config_extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,6 @@ func IsForkTransition(fork *uint64, parent *uint64, current uint64) bool {
}

func WithExtra(c *ChainConfig, extra *ChainConfigExtra) *ChainConfig {
// XXX: Hack to initialize the ChainConfigExtra pointer in the ChainConfig.
jsonBytes, err := json.Marshal(c)
if err != nil {
panic(err)
}
var newCfg ChainConfig
if err := json.Unmarshal(jsonBytes, &newCfg); err != nil {
panic(err)
}

*GetExtra(&newCfg) = *extra
return &newCfg
extras.SetOnChainConfig(c, extra)
return c
}
8 changes: 4 additions & 4 deletions params/config_libevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (
)

func do_init() any {
getter = gethparams.RegisterExtras(gethparams.Extras[*ChainConfigExtra, RulesExtra]{
extras = gethparams.RegisterExtras(gethparams.Extras[*ChainConfigExtra, RulesExtra]{
ReuseJSONRoot: true, // Reuse the root JSON input when unmarshalling the extra payload.
NewRules: constructRulesExtra,
})
return nil
}

var getter gethparams.ExtraPayloads[*ChainConfigExtra, RulesExtra]
var extras gethparams.ExtraPayloads[*ChainConfigExtra, RulesExtra]

// constructRulesExtra acts as an adjunct to the [params.ChainConfig.Rules]
// method. Its primary purpose is to construct the extra payload for the
Expand Down Expand Up @@ -55,10 +55,10 @@ func constructRulesExtra(c *gethparams.ChainConfig, r *gethparams.Rules, cEx *Ch

// FromChainConfig returns the extra payload carried by the ChainConfig.
func FromChainConfig(c *gethparams.ChainConfig) *ChainConfigExtra {
return getter.FromChainConfig(c)
return extras.FromChainConfig(c)
}

// FromRules returns the extra payload carried by the Rules.
func FromRules(r *gethparams.Rules) RulesExtra {
return getter.FromRules(r)
return extras.FromRules(r)
}

0 comments on commit 758c8bd

Please sign in to comment.