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 5b7c883
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 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
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 5b7c883

Please sign in to comment.