diff --git a/.gitignore b/.gitignore index 5c6532c305..fa47055a56 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ hiveview # build output for rust simulators files simulators/**/Cargo.lock simulators/**/target + +# simulations outputs +runs diff --git a/simulators/ethereum/engine/client/core.go b/simulators/ethereum/engine/client/core.go index 120a7d56c7..ccc6f784a2 100644 --- a/simulators/ethereum/engine/client/core.go +++ b/simulators/ethereum/engine/client/core.go @@ -8,6 +8,7 @@ import ( "time" "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/hive/simulators/ethereum/engine/config" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -41,7 +42,7 @@ type Genesis interface { Nonce() uint64 SetNonce(nonce uint64) Timestamp() uint64 - SetTimestamp(timestamp int64, cancun bool) + SetTimestamp(timestamp int64, fork config.Fork) ExtraData() []byte SetExtraData(data []byte) GasLimit() uint64 @@ -175,6 +176,7 @@ type NethermindParams struct { Eip1153TransitionTimestamp string `json:"eip1153TransitionTimestamp,omitempty"` Eip5656TransitionTimestamp string `json:"eip5656TransitionTimestamp,omitempty"` Eip6780TransitionTimestamp string `json:"eip6780TransitionTimestamp,omitempty"` + GipXYZTransitionTimestamp string `json:"gipxyzTransitionTimestamp,omitempty"` Eip4844BlobGasPriceUpdateFraction string `json:"eip4844BlobGasPriceUpdateFraction"` Eip4844MaxBlobGasPerBlock string `json:"eip4844MaxBlobGasPerBlock"` Eip4844MinBlobGasPrice string `json:"eip4844MinBlobGasPrice"` @@ -307,20 +309,42 @@ func (n *NethermindChainSpec) Timestamp() uint64 { panic("implement me") } -func (n *NethermindChainSpec) SetTimestamp(timestamp int64, cancun bool) { +func (n *NethermindChainSpec) SetTimestamp(timestamp int64, fork config.Fork) { //n.Params.TerminalTotalDifficulty = fmt.Sprintf("%v", timestamp) - n.Params.Eip3651TransitionTimestamp = fmt.Sprintf("%#x", timestamp) - n.Params.Eip4895TransitionTimestamp = fmt.Sprintf("%#x", timestamp) - n.Params.Eip3855TransitionTimestamp = fmt.Sprintf("%#x", timestamp) - n.Params.Eip3651TransitionTimestamp = fmt.Sprintf("%#x", timestamp) - n.Params.Eip3860TransitionTimestamp = fmt.Sprintf("%#x", timestamp) - if cancun { + shangaiTimestamp := int64(0) + cancunTimestamp := int64(0) + barnetTimestamp := int64(0) + if fork == config.Shanghai { + shangaiTimestamp = timestamp + } else if fork == config.Cancun { + shangaiTimestamp = timestamp + cancunTimestamp = timestamp + } else if fork == config.Barnet { + shangaiTimestamp = timestamp + cancunTimestamp = timestamp + barnetTimestamp = timestamp + } + + // Set Shangai timestamps + if shangaiTimestamp != 0 { + n.Params.Eip3651TransitionTimestamp = fmt.Sprintf("%#x", timestamp) + n.Params.Eip4895TransitionTimestamp = fmt.Sprintf("%#x", timestamp) + n.Params.Eip3855TransitionTimestamp = fmt.Sprintf("%#x", timestamp) + n.Params.Eip3651TransitionTimestamp = fmt.Sprintf("%#x", timestamp) + n.Params.Eip3860TransitionTimestamp = fmt.Sprintf("%#x", timestamp) + } + // Set Cancun timestamps + if cancunTimestamp != 0 { n.Params.Eip4844TransitionTimestamp = fmt.Sprintf("%#x", timestamp) n.Params.Eip4788TransitionTimestamp = fmt.Sprintf("%#x", timestamp) n.Params.Eip1153TransitionTimestamp = fmt.Sprintf("%#x", timestamp) n.Params.Eip5656TransitionTimestamp = fmt.Sprintf("%#x", timestamp) n.Params.Eip6780TransitionTimestamp = fmt.Sprintf("%#x", timestamp) } + // Set Barnet timestamps + if barnetTimestamp != 0 { + n.Params.GipXYZTransitionTimestamp = fmt.Sprintf("%#x", timestamp) + } } func (n *NethermindChainSpec) ExtraData() []byte { @@ -470,8 +494,9 @@ type ErigonConfig struct { Eip1559FeeCollector string `json:"eip1559FeeCollector"` TerminalTotalDifficulty *big.Int `json:"terminalTotalDifficulty"` TerminalTotalDifficultyPassed bool `json:"terminalTotalDifficultyPassed"` - ShanghaiTimestamp *big.Int `json:"shanghaiTime"` + ShanghaiTime *big.Int `json:"shanghaiTime"` CancunTime *big.Int `json:"cancunTime"` + BarnetTime *big.Int `json:"barnetTime"` MinBlobGasPrice int `json:"minBlobGasPrice"` MaxBlobGasPerBlock int `json:"maxBlobGasPerBlock"` TargetBlobGasPerBlock int `json:"targetBlobGasPerBlock"` @@ -512,8 +537,8 @@ func (v *ErigonGenesis) SetExcessBlobGas(u *uint64) { func (v *ErigonGenesis) Config() *params.ChainConfig { chainID := big.NewInt(int64(v.ErigonConfig.ChainID)) ttd := big.NewInt(0).SetBytes(common.Hex2Bytes(v.ErigonDifficulty)) - shangai := v.ErigonConfig.ShanghaiTimestamp.Uint64() //big.NewInt(v.ErigonConfig.ShanghaiTimestamp - cancun := v.ErigonConfig.CancunTime.Uint64() //big.NewInt(v.ErigonConfig.ShanghaiTimestamp + shangai := v.ErigonConfig.ShanghaiTime.Uint64() //big.NewInt(v.ErigonConfig.ShanghaiTime + cancun := v.ErigonConfig.CancunTime.Uint64() //big.NewInt(v.ErigonConfig.ShanghaiTime return ¶ms.ChainConfig{ ChainID: chainID, TerminalTotalDifficulty: ttd, @@ -542,12 +567,16 @@ func (v *ErigonGenesis) Timestamp() uint64 { panic("implement me") } -func (v *ErigonGenesis) SetTimestamp(timestamp int64, cancun bool) { - v.ErigonConfig.ShanghaiTimestamp = big.NewInt(timestamp) - if cancun { +func (v *ErigonGenesis) SetTimestamp(timestamp int64, fork config.Fork) { + if fork == config.Shanghai { + v.ErigonConfig.ShanghaiTime = big.NewInt(timestamp) + } else if fork == config.Cancun { + v.ErigonConfig.ShanghaiTime = big.NewInt(timestamp) + v.ErigonConfig.CancunTime = big.NewInt(timestamp) + } else if fork == config.Barnet { + v.ErigonConfig.ShanghaiTime = big.NewInt(timestamp) v.ErigonConfig.CancunTime = big.NewInt(timestamp) - } else { - v.ErigonConfig.CancunTime = big.NewInt(timestamp+12000000) + v.ErigonConfig.BarnetTime = big.NewInt(timestamp) } } @@ -637,7 +666,7 @@ func (v *ErigonGenesis) ToBlock() *types.Block { alloc := make(core.GenesisAlloc) for address, account := range v.ErigonAlloc { balance := big.NewInt(0) - code := make([]byte, 0) + var code []byte val := account.Balance if val != "" { bytesBalance := common.Hex2Bytes(val) diff --git a/simulators/ethereum/engine/client/core_easyjson.go b/simulators/ethereum/engine/client/core_easyjson.go index 33ef8da792..0854b84a48 100644 --- a/simulators/ethereum/engine/client/core_easyjson.go +++ b/simulators/ethereum/engine/client/core_easyjson.go @@ -18,7 +18,7 @@ var ( _ easyjson.Marshaler ) -func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper(in *jlexer.Lexer, out *NethermindParams) { +func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient(in *jlexer.Lexer, out *NethermindParams) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -103,6 +103,8 @@ func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper(i out.Eip5656TransitionTimestamp = string(in.String()) case "eip6780TransitionTimestamp": out.Eip6780TransitionTimestamp = string(in.String()) + case "gipxyzTransitionTimestamp": + out.GipXYZTransitionTimestamp = string(in.String()) case "eip4844BlobGasPriceUpdateFraction": out.Eip4844BlobGasPriceUpdateFraction = string(in.String()) case "eip4844MaxBlobGasPerBlock": @@ -137,7 +139,7 @@ func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper(i in.Consumed() } } -func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper(out *jwriter.Writer, in NethermindParams) { +func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient(out *jwriter.Writer, in NethermindParams) { out.RawByte('{') first := true _ = first @@ -467,6 +469,16 @@ func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper(o } out.String(string(in.Eip6780TransitionTimestamp)) } + if in.GipXYZTransitionTimestamp != "" { + const prefix string = ",\"gipxyzTransitionTimestamp\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + out.String(string(in.GipXYZTransitionTimestamp)) + } { const prefix string = ",\"eip4844BlobGasPriceUpdateFraction\":" if first { @@ -538,27 +550,27 @@ func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper(o // MarshalJSON supports json.Marshaler interface func (v NethermindParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper(&w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v NethermindParams) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper(w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *NethermindParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper(&r, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *NethermindParams) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper(l, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient(l, v) } -func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper1(in *jlexer.Lexer, out *NethermindGenesis) { +func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient1(in *jlexer.Lexer, out *NethermindGenesis) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -595,7 +607,7 @@ func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper1( in.Consumed() } } -func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper1(out *jwriter.Writer, in NethermindGenesis) { +func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient1(out *jwriter.Writer, in NethermindGenesis) { out.RawByte('{') first := true _ = first @@ -641,25 +653,25 @@ func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper1( // MarshalJSON supports json.Marshaler interface func (v NethermindGenesis) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper1(&w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient1(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v NethermindGenesis) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper1(w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient1(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *NethermindGenesis) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper1(&r, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient1(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *NethermindGenesis) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper1(l, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient1(l, v) } func easyjson3d34c335Decode(in *jlexer.Lexer, out *struct { AuthorityRound struct { @@ -775,7 +787,7 @@ func easyjson3d34c335Encode1(out *jwriter.Writer, in struct { } out.RawByte('}') } -func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper2(in *jlexer.Lexer, out *NethermindEngine) { +func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient2(in *jlexer.Lexer, out *NethermindEngine) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -806,7 +818,7 @@ func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper2( in.Consumed() } } -func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper2(out *jwriter.Writer, in NethermindEngine) { +func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient2(out *jwriter.Writer, in NethermindEngine) { out.RawByte('{') first := true _ = first @@ -822,25 +834,25 @@ func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper2( // MarshalJSON supports json.Marshaler interface func (v NethermindEngine) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper2(&w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient2(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v NethermindEngine) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper2(w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient2(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *NethermindEngine) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper2(&r, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient2(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *NethermindEngine) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper2(l, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient2(l, v) } func easyjson3d34c335Decode2(in *jlexer.Lexer, out *struct { Params AuthorityParams `json:"params,omitempty"` @@ -889,7 +901,7 @@ func easyjson3d34c335Encode2(out *jwriter.Writer, in struct { } out.RawByte('}') } -func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper3(in *jlexer.Lexer, out *NethermindChainSpec) { +func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient3(in *jlexer.Lexer, out *NethermindChainSpec) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -970,7 +982,7 @@ func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper3( in.Consumed() } } -func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper3(out *jwriter.Writer, in NethermindChainSpec) { +func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient3(out *jwriter.Writer, in NethermindChainSpec) { out.RawByte('{') first := true _ = first @@ -1062,27 +1074,27 @@ func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper3( // MarshalJSON supports json.Marshaler interface func (v NethermindChainSpec) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper3(&w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient3(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v NethermindChainSpec) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper3(w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient3(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *NethermindChainSpec) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper3(&r, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient3(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *NethermindChainSpec) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper3(l, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient3(l, v) } -func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper4(in *jlexer.Lexer, out *ErigonGenesis) { +func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient4(in *jlexer.Lexer, out *ErigonGenesis) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1135,7 +1147,7 @@ func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper4( in.Consumed() } } -func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper4(out *jwriter.Writer, in ErigonGenesis) { +func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient4(out *jwriter.Writer, in ErigonGenesis) { out.RawByte('{') first := true _ = first @@ -1186,27 +1198,27 @@ func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper4( // MarshalJSON supports json.Marshaler interface func (v ErigonGenesis) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper4(&w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient4(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v ErigonGenesis) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper4(w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient4(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *ErigonGenesis) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper4(&r, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient4(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *ErigonGenesis) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper4(l, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient4(l, v) } -func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper5(in *jlexer.Lexer, out *ErigonConfig) { +func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient5(in *jlexer.Lexer, out *ErigonConfig) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1270,13 +1282,13 @@ func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper5( case "shanghaiTime": if in.IsNull() { in.Skip() - out.ShanghaiTimestamp = nil + out.ShanghaiTime = nil } else { - if out.ShanghaiTimestamp == nil { - out.ShanghaiTimestamp = new(big.Int) + if out.ShanghaiTime == nil { + out.ShanghaiTime = new(big.Int) } if data := in.Raw(); in.Ok() { - in.AddError((*out.ShanghaiTimestamp).UnmarshalJSON(data)) + in.AddError((*out.ShanghaiTime).UnmarshalJSON(data)) } } case "cancunTime": @@ -1291,6 +1303,18 @@ func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper5( in.AddError((*out.CancunTime).UnmarshalJSON(data)) } } + case "barnetTime": + if in.IsNull() { + in.Skip() + out.BarnetTime = nil + } else { + if out.BarnetTime == nil { + out.BarnetTime = new(big.Int) + } + if data := in.Raw(); in.Ok() { + in.AddError((*out.BarnetTime).UnmarshalJSON(data)) + } + } case "minBlobGasPrice": out.MinBlobGasPrice = int(in.Int()) case "maxBlobGasPerBlock": @@ -1311,7 +1335,7 @@ func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper5( in.Consumed() } } -func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper5(out *jwriter.Writer, in ErigonConfig) { +func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient5(out *jwriter.Writer, in ErigonConfig) { out.RawByte('{') first := true _ = first @@ -1402,10 +1426,10 @@ func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper5( { const prefix string = ",\"shanghaiTime\":" out.RawString(prefix) - if in.ShanghaiTimestamp == nil { + if in.ShanghaiTime == nil { out.RawString("null") } else { - out.Raw((*in.ShanghaiTimestamp).MarshalJSON()) + out.Raw((*in.ShanghaiTime).MarshalJSON()) } } { @@ -1417,6 +1441,15 @@ func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper5( out.Raw((*in.CancunTime).MarshalJSON()) } } + { + const prefix string = ",\"barnetTime\":" + out.RawString(prefix) + if in.BarnetTime == nil { + out.RawString("null") + } else { + out.Raw((*in.BarnetTime).MarshalJSON()) + } + } { const prefix string = ",\"minBlobGasPrice\":" out.RawString(prefix) @@ -1448,27 +1481,27 @@ func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper5( // MarshalJSON supports json.Marshaler interface func (v ErigonConfig) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper5(&w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient5(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v ErigonConfig) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper5(w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient5(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *ErigonConfig) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper5(&r, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient5(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *ErigonConfig) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper5(l, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient5(l, v) } -func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper6(in *jlexer.Lexer, out *ErigonAura) { +func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient6(in *jlexer.Lexer, out *ErigonAura) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1549,7 +1582,7 @@ func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper6( in.Consumed() } } -func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper6(out *jwriter.Writer, in ErigonAura) { +func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient6(out *jwriter.Writer, in ErigonAura) { out.RawByte('{') first := true _ = first @@ -1651,25 +1684,25 @@ func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper6( // MarshalJSON supports json.Marshaler interface func (v ErigonAura) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper6(&w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient6(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v ErigonAura) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper6(w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient6(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *ErigonAura) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper6(&r, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient6(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *ErigonAura) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper6(l, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient6(l, v) } func easyjson3d34c335Decode3(in *jlexer.Lexer, out *struct { Multi map[string]map[string][]string `json:"multi,omitempty"` @@ -1816,7 +1849,7 @@ func easyjson3d34c335Encode3(out *jwriter.Writer, in struct { } out.RawByte('}') } -func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper7(in *jlexer.Lexer, out *ErigonAccount) { +func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient7(in *jlexer.Lexer, out *ErigonAccount) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1851,7 +1884,7 @@ func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper7( in.Consumed() } } -func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper7(out *jwriter.Writer, in ErigonAccount) { +func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient7(out *jwriter.Writer, in ErigonAccount) { out.RawByte('{') first := true _ = first @@ -1876,27 +1909,27 @@ func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper7( // MarshalJSON supports json.Marshaler interface func (v ErigonAccount) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper7(&w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient7(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v ErigonAccount) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper7(w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient7(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *ErigonAccount) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper7(&r, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient7(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *ErigonAccount) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper7(l, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient7(l, v) } -func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper8(in *jlexer.Lexer, out *Builtin) { +func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient8(in *jlexer.Lexer, out *Builtin) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1953,7 +1986,7 @@ func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper8( in.Consumed() } } -func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper8(out *jwriter.Writer, in Builtin) { +func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient8(out *jwriter.Writer, in Builtin) { out.RawByte('{') first := true _ = first @@ -1999,27 +2032,27 @@ func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper8( // MarshalJSON supports json.Marshaler interface func (v Builtin) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper8(&w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient8(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Builtin) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper8(w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient8(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Builtin) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper8(&r, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient8(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Builtin) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper8(l, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient8(l, v) } -func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper9(in *jlexer.Lexer, out *AuthorityParams) { +func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient9(in *jlexer.Lexer, out *AuthorityParams) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2108,7 +2141,7 @@ func easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper9( in.Consumed() } } -func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper9(out *jwriter.Writer, in AuthorityParams) { +func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient9(out *jwriter.Writer, in AuthorityParams) { out.RawByte('{') first := true _ = first @@ -2262,23 +2295,23 @@ func easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper9( // MarshalJSON supports json.Marshaler interface func (v AuthorityParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper9(&w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient9(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v AuthorityParams) MarshalEasyJSON(w *jwriter.Writer) { - easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineHelper9(w, v) + easyjson3d34c335EncodeGithubComEthereumHiveSimulatorsEthereumEngineClient9(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *AuthorityParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper9(&r, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient9(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *AuthorityParams) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineHelper9(l, v) + easyjson3d34c335DecodeGithubComEthereumHiveSimulatorsEthereumEngineClient9(l, v) } diff --git a/simulators/ethereum/engine/config/fork.go b/simulators/ethereum/engine/config/fork.go index a02147f3db..003f64094b 100644 --- a/simulators/ethereum/engine/config/fork.go +++ b/simulators/ethereum/engine/config/fork.go @@ -14,6 +14,7 @@ const ( Paris Fork = "Paris" Shanghai Fork = "Shanghai" Cancun Fork = "Cancun" + Barnet Fork = "Barnet" ) func (f Fork) PreviousFork() Fork { @@ -24,6 +25,8 @@ func (f Fork) PreviousFork() Fork { return Paris case Cancun: return Shanghai + case Barnet: + return Cancun default: return NA } @@ -34,6 +37,7 @@ type ForkConfig struct { ParisNumber *big.Int ShanghaiTimestamp *big.Int CancunTimestamp *big.Int + BarnetTimestamp *big.Int } func (f *ForkConfig) IsShanghai(blockTimestamp uint64) bool { @@ -44,6 +48,10 @@ func (f *ForkConfig) IsCancun(blockTimestamp uint64) bool { return f.CancunTimestamp != nil && new(big.Int).SetUint64(blockTimestamp).Cmp(f.CancunTimestamp) >= 0 } +func (f *ForkConfig) IsBarnet(blockTimestamp uint64) bool { + return f.BarnetTimestamp != nil && new(big.Int).SetUint64(blockTimestamp).Cmp(f.BarnetTimestamp) >= 0 +} + func (f *ForkConfig) ForkchoiceUpdatedVersion(headTimestamp uint64, payloadAttributesTimestamp *uint64) int { // If the payload attributes timestamp is nil, use the head timestamp // to calculate the FcU version. diff --git a/simulators/ethereum/engine/helper/block.go b/simulators/ethereum/engine/helper/block.go index 7873e032a6..89d8a9d622 100644 --- a/simulators/ethereum/engine/helper/block.go +++ b/simulators/ethereum/engine/helper/block.go @@ -9,7 +9,7 @@ import ( func GenerateInvalidPayloadBlock(baseBlock *types.Block, uncle *types.Block, payloadField InvalidPayloadBlockField) (*types.Block, error) { if payloadField == InvalidOmmers { if uncle == nil { - return nil, fmt.Errorf("No ommer provided") + return nil, fmt.Errorf("no ommer provided") } uncles := []*types.Header{ uncle.Header(), diff --git a/simulators/ethereum/engine/helper/helper.go b/simulators/ethereum/engine/helper/helper.go index 115eb9fcd1..6d3a7f881d 100644 --- a/simulators/ethereum/engine/helper/helper.go +++ b/simulators/ethereum/engine/helper/helper.go @@ -18,7 +18,6 @@ import ( "github.com/ethereum/hive/simulators/ethereum/engine/client" "github.com/ethereum/hive/simulators/ethereum/engine/globals" - gokzg4844 "github.com/crate-crypto/go-kzg-4844" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rlp" @@ -27,7 +26,7 @@ import ( typ "github.com/ethereum/hive/simulators/ethereum/engine/types" ) -var kzg4844Context *gokzg4844.Context +// var kzg4844Context *gokzg4844.Context // From ethereum/rpc: @@ -188,7 +187,7 @@ func gethDebugPrevRandaoTransaction(ctx context.Context, c *rpc.Client, tx typ.T return nil } -func nethermindDebugPrevRandaoTransaction(ctx context.Context, c *rpc.Client, tx typ.Transaction, expectedPrevRandao *common.Hash) error { +func nethermindDebugPrevRandaoTransaction(ctx context.Context, c *rpc.Client, tx typ.Transaction, _ *common.Hash) error { var er *interface{} if err := c.CallContext(ctx, &er, "trace_transaction", tx.Hash()); err != nil { return err diff --git a/simulators/ethereum/engine/init/erigon_genesis.json b/simulators/ethereum/engine/init/erigon_genesis.json index 52a265a23d..6fa2ada3ad 100644 --- a/simulators/ethereum/engine/init/erigon_genesis.json +++ b/simulators/ethereum/engine/init/erigon_genesis.json @@ -109,8 +109,9 @@ "eip1559FeeCollector": "0x1559000000000000000000000000000000000000", "terminalTotalDifficulty": 0, "terminalTotalDifficultyPassed": true, - "shanghaiTime": 1684934220, - "cancunTime": 1696272200, + "shanghaiTime": 26865019200, + "cancunTime": 26865019200, + "barnetTime": 26865019200, "minBlobGasPrice": 1000000000, "maxBlobGasPerBlock": 262144, "targetBlobGasPerBlock": 131072, @@ -123,9 +124,7 @@ "validators": { "multi": { "0": { - "list": [ - "0x5cd99ac2f0f8c25a1e670f6bab19d52aad69d875" - ] + "list": ["0x5cd99ac2f0f8c25a1e670f6bab19d52aad69d875"] } } }, diff --git a/simulators/ethereum/engine/init/nethermind_genesis.json b/simulators/ethereum/engine/init/nethermind_genesis.json index 88437aee78..65eb1868e8 100644 --- a/simulators/ethereum/engine/init/nethermind_genesis.json +++ b/simulators/ethereum/engine/init/nethermind_genesis.json @@ -10,9 +10,7 @@ "validators": { "multi": { "0": { - "list": [ - "0x5cd99ac2f0f8c25a1e670f6bab19d52aad69d875" - ] + "list": ["0x5cd99ac2f0f8c25a1e670f6bab19d52aad69d875"] } } }, @@ -69,6 +67,7 @@ "eip1153TransitionTimestamp": "0x64147a940", "eip5656TransitionTimestamp": "0x64147a940", "eip6780TransitionTimestamp": "0x64147a940", + "gipxyzTransitionTimestamp": "0x64147a940", "eip1559BaseFeeMaxChangeDenominator": "0x8", "eip4844BlobGasPriceUpdateFraction": "0x10fafa", "eip4844MaxBlobGasPerBlock": "0x40000", @@ -321,4 +320,4 @@ "constructor": "0x608060405234801561001057600080fd5b5060405161026e38038061026e83398101604081905261002f916101d4565b6040516340c10f1960e01b81526001600160a01b03808316600483015260248201859052839183918316906340c10f1990604401600060405180830381600087803b15801561007d57600080fd5b505af1158015610091573d6000803e3d6000fd5b50506040516340c10f1960e01b81526001600160a01b03898116600483015260248201899052851692506340c10f199150604401600060405180830381600087803b1580156100df57600080fd5b505af11580156100f3573d6000803e3d6000fd5b5050604051633825b60160e11b81526001600160a01b0389811660048301528416925063704b6c029150602401600060405180830381600087803b15801561013a57600080fd5b505af115801561014e573d6000803e3d6000fd5b5050604051633825b60160e11b81526001600160a01b0389811660048301528716925063704b6c029150602401600060405180830381600087803b15801561019557600080fd5b505af11580156101a9573d6000803e3d6000fd5b50505050505050505050610221565b80516001600160a01b03811681146101cf57600080fd5b919050565b600080600080608085870312156101ea57600080fd5b6101f3856101b8565b935060208501519250610208604086016101b8565b9150610216606086016101b8565b905092959194509250565b603f8061022f6000396000f3fe6080604052600080fdfea2646970667358221220736146d047d972ba2411e1910bb9eb02bef6f4135edcdf986f9fe8612931cf5264736f6c63430008090033000000000000000000000000cc4e00a72d871d6c328bcfe9025ad93d0a26df5100000000000000000000000000000000000000000000021e19e0c9bab2400000000000000000000000000000babe2bed00000000000000000000000000000002000000000000000000000000babe2bed00000000000000000000000000000003" } } -} \ No newline at end of file +} diff --git a/simulators/ethereum/engine/libgno/gno.go b/simulators/ethereum/engine/libgno/gno.go index 9162e7cbf3..660554db27 100644 --- a/simulators/ethereum/engine/libgno/gno.go +++ b/simulators/ethereum/engine/libgno/gno.go @@ -23,6 +23,7 @@ var ( // var SYSTEM_SENDER = common.HexToAddress("0xfffffffffffffffffffffffffffffffffffffffe") GNOTokenAddress = common.HexToAddress("0xbabe2bed00000000000000000000000000000002") WithdrawalsContractAddress = common.HexToAddress("0xbabe2bed00000000000000000000000000000003") + FeeCollectorAddress = common.HexToAddress("0x1559000000000000000000000000000000000000") // GNOWithdrawalContractABI represents the path to the GNO withdrawal contract ABI. // diff --git a/simulators/ethereum/engine/main.go b/simulators/ethereum/engine/main.go index 5b09628a20..81d8a30431 100644 --- a/simulators/ethereum/engine/main.go +++ b/simulators/ethereum/engine/main.go @@ -9,6 +9,7 @@ import ( "time" "github.com/ethereum/hive/hivesim" + "github.com/ethereum/hive/simulators/ethereum/engine/config" "github.com/ethereum/hive/simulators/ethereum/engine/globals" "github.com/ethereum/hive/simulators/ethereum/engine/helper" "github.com/ethereum/hive/simulators/ethereum/engine/test" @@ -96,18 +97,19 @@ type ClientGenesis interface { GetTTD() } -func getTimestamp(spec test.Spec) int64 { +func getTimestamp(spec test.Spec) (int64, int64) { now := time.Now() - preShapellaBlock := spec.GetPreShapellaBlockCount() - if preShapellaBlock == 0 { - preShapellaBlock = 1 - } + preMainForkBlock := spec.GetPreShapellaBlockCount() + // if preMainForkBlock == 0 { + // preMainForkBlock = 1 + // } - preShapellaTime := time.Duration(uint64(preShapellaBlock)*spec.GetBlockTimeIncrements()) * time.Second - // after setup wait chain will produce blocks in preShapellaTime and than shapella happens - shanghaiTimestamp := now.Add(SetupTime).Add(preShapellaTime) - return shanghaiTimestamp.Unix() + preForkTime := time.Duration(uint64(preMainForkBlock)*spec.GetBlockTimeIncrements()) * time.Second + // after setup wait chain will produce blocks during `preForkTime` and then main fork happens + genesisTimestamp := now.Add(SetupTime) + mainForkTimestamp := now.Add(SetupTime).Add(preForkTime) + return genesisTimestamp.Unix(), mainForkTimestamp.Unix() } // Add test cases to a given test suite @@ -128,8 +130,12 @@ func addTestsToSuite(sim *hivesim.Simulation, suite *hivesim.Suite, tests []test genesis := currentTest.GetGenesis(clientName) // Set the timestamp of the genesis to the next 2 minutes - timestamp := getTimestamp(currentTest) - genesis.SetTimestamp(timestamp, suite.Name == "engine-cancun") + genesisTimestamp, mainForktimestamp := getTimestamp(currentTest) + currentTest = currentTest.WithTimestamp(uint64(genesisTimestamp)) + genesis.SetTimestamp(mainForktimestamp, currentTest.GetMainFork()) + if currentTest.GetMainFork().PreviousFork() != config.NA { + genesis.SetTimestamp(genesisTimestamp, currentTest.GetMainFork().PreviousFork()) + } genesis.SetDifficulty(big.NewInt(100)) //genesis.UpdateTimestamp(getTimestamp()) genesisStartOption, err := helper.GenesisStartOptionBasedOnClient(genesis, clientName) @@ -207,7 +213,6 @@ func addTestsToSuite(sim *hivesim.Simulation, suite *hivesim.Suite, tests []test defer func() { t.Logf("End test (%s): %s", c.Type, currentTest.GetName()) }() - currentTest.GetName() timeout := 30 * time.Minute // If a test.Spec specifies a timeout, use that instead if currentTest.GetTimeout() != 0 { diff --git a/simulators/ethereum/engine/suites/cancun/config.go b/simulators/ethereum/engine/suites/cancun/config.go index 53376665f1..27f4c14846 100644 --- a/simulators/ethereum/engine/suites/cancun/config.go +++ b/simulators/ethereum/engine/suites/cancun/config.go @@ -1,9 +1,11 @@ package suite_cancun import ( - "github.com/ethereum/hive/simulators/ethereum/engine/client" "time" + "github.com/ethereum/hive/simulators/ethereum/engine/client" + "github.com/ethereum/hive/simulators/ethereum/engine/config" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/hive/simulators/ethereum/engine/test" ) @@ -70,7 +72,7 @@ type CancunBaseSpec struct { // Append the accounts we are going to withdraw to, which should also include // bytecode for testing purposes. -func (cs *CancunBaseSpec) GetGenesis(base string) client.Genesis { +func (cs CancunBaseSpec) GetGenesis(base string) client.Genesis { genesis := cs.BaseSpec.GetGenesis(base) @@ -95,12 +97,12 @@ func (cs *CancunBaseSpec) GetGenesis(base string) client.Genesis { return genesis } -func (cs *CancunBaseSpec) GetPreShapellaBlockCount() int { +func (cs CancunBaseSpec) GetPreShapellaBlockCount() int { return int(cs.BaseSpec.ForkHeight) } // Get the per-block timestamp increments configured for this test -func (cs *CancunBaseSpec) GetBlockTimeIncrements() uint64 { +func (cs CancunBaseSpec) GetBlockTimeIncrements() uint64 { return 1 } @@ -120,8 +122,7 @@ func (cs *CancunBaseSpec) waitForSetup(t *test.Env) { } // Base test case execution procedure for blobs tests. -func (cs *CancunBaseSpec) Execute(t *test.Env) { - +func (cs CancunBaseSpec) Execute(t *test.Env) { t.CLMock.WaitForTTD() cs.waitForSetup(t) @@ -142,5 +143,27 @@ func (cs *CancunBaseSpec) Execute(t *test.Env) { t.Fatalf("FAIL: Error executing step %d: %v", stepId+1, err) } } +} +func (s CancunBaseSpec) WithMainFork(fork config.Fork) test.Spec { + specCopy := s + specCopy.MainFork = fork + return specCopy +} + +func (s CancunBaseSpec) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy } diff --git a/simulators/ethereum/engine/suites/cancun/helpers.go b/simulators/ethereum/engine/suites/cancun/helpers.go index 3f3d50ab4d..0a9713c063 100644 --- a/simulators/ethereum/engine/suites/cancun/helpers.go +++ b/simulators/ethereum/engine/suites/cancun/helpers.go @@ -68,7 +68,7 @@ type TestBlobTxPool struct { HashesByIndex map[uint64]common.Hash } -func (pool *TestBlobTxPool) AddBlobTransaction(tx typ.Transaction) { +func (pool *TestBlobTxPool) AddTransaction(tx typ.Transaction) { if pool.Transactions == nil { pool.Transactions = make(map[common.Hash]typ.Transaction) } diff --git a/simulators/ethereum/engine/suites/cancun/steps.go b/simulators/ethereum/engine/suites/cancun/steps.go index e90efec111..1b2b9c25cf 100644 --- a/simulators/ethereum/engine/suites/cancun/steps.go +++ b/simulators/ethereum/engine/suites/cancun/steps.go @@ -12,6 +12,7 @@ import ( api "github.com/ethereum/go-ethereum/beacon/engine" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/hive/simulators/ethereum/engine/client" "github.com/ethereum/hive/simulators/ethereum/engine/clmock" "github.com/ethereum/hive/simulators/ethereum/engine/config" @@ -19,6 +20,7 @@ import ( "github.com/ethereum/hive/simulators/ethereum/engine/devp2p" "github.com/ethereum/hive/simulators/ethereum/engine/globals" "github.com/ethereum/hive/simulators/ethereum/engine/helper" + "github.com/ethereum/hive/simulators/ethereum/engine/libgno" "github.com/ethereum/hive/simulators/ethereum/engine/test" typ "github.com/ethereum/hive/simulators/ethereum/engine/types" "github.com/pkg/errors" @@ -394,6 +396,30 @@ func (step NewPayloads) VerifyBlobBundle(blobDataInPayload []*BlobWrapData, payl return nil } +func (step NewPayloads) GetFeeCollectorBalance( + client *rpc.Client, + at string, + result *big.Int, +) error { + // Get fee collector balance at a specific block + var raw string + err := client.Call( + &raw, + "eth_getBalance", + libgno.FeeCollectorAddress.Hex(), + at, + ) + if err != nil { + return err + } + + _, ok := result.SetString(raw, 0) + if !ok { + return fmt.Errorf("failed to parse fee collector balance: %s", raw) + } + return nil +} + func (step NewPayloads) Execute(t *CancunTestContext) error { // Create a new payload // Produce the payload @@ -405,10 +431,21 @@ func (step NewPayloads) Execute(t *CancunTestContext) error { t.CLMock.PayloadProductionClientDelay = time.Duration(step.GetPayloadDelay) * time.Second } var ( - previousPayload = t.CLMock.LatestPayloadBuilt + previousPayload = t.CLMock.LatestPayloadBuilt + prevFeeCollectorBalance *big.Int = new(big.Int) + rpc = t.Client.RPC() ) + if rpc == nil { + t.Fatalf("FAIL: Rpc client is nil") + } for p := uint64(0); p < payloadCount; p++ { t.CLMock.ProduceSingleBlock(clmock.BlockProcessCallbacks{ + OnPayloadProducerSelected: func() { + // Get fee collector balance before producing the new payload + if err := step.GetFeeCollectorBalance(rpc, "latest", prevFeeCollectorBalance); err != nil { + t.Fatalf("FAIL: Error getting fee collector balance: %v", err) + } + }, OnPayloadAttributesGenerated: func() { if step.FcUOnPayloadRequest != nil { var ( @@ -585,6 +622,35 @@ func (step NewPayloads) Execute(t *CancunTestContext) error { t.Fatalf("FAIL: Error verifying payload (payload %d/%d): %v", p+1, payloadCount, err) } previousPayload = t.CLMock.LatestPayloadBuilt + + // Get fee collector balance for the new block + feeCollectorBalance := new(big.Int) + if err := step.GetFeeCollectorBalance(rpc, "latest", feeCollectorBalance); err != nil { + t.Fatalf("FAIL: Error getting fee collector balance: %v", err) + } + + // Calculate txs fees for the new block + feesCollected := big.NewInt(0) + for _, binaryTx := range payload.Transactions { + // Unmarshal the tx from the payload + tx := new(types.Transaction) + if err := tx.UnmarshalBinary(binaryTx); err != nil { + t.Fatalf("FAIL: Error getting transaction: %v", err) + } + // Calculate fees + feeCollected := big.NewInt(0) + if tx.Type() != types.BlobTxType { + feeCollected.Add(feeCollected, new(big.Int).Mul(tx.GasPrice(), new(big.Int).SetUint64(tx.Gas()))) + } else if tx.Type() == types.BlobTxType && t.CLMock.IsBarnet(payload.Timestamp) { + // Add blob gas fees if devnet is after barnet fork + feeCollected.Add(feeCollected, new(big.Int).Mul(tx.GasPrice(), new(big.Int).SetUint64(tx.Gas()))) + feeCollected.Add(feeCollected, new(big.Int).Mul(tx.BlobGasFeeCap(), new(big.Int).SetUint64(tx.BlobGas()))) + } + feesCollected.Add(feesCollected, feeCollected) + } + if feesCollected.Cmp(feeCollectorBalance) != 0 { + t.Fatalf("FAIL: Incorrect fee collector balance: expected %s, got %s", feesCollected.String(), feeCollectorBalance.String()) + } }, }) t.Logf("INFO: Correctly produced payload %d/%d", p+1, payloadCount) @@ -675,10 +741,12 @@ func (step SendBlobTransactions) Execute(t *CancunTestContext) error { t.Fatalf("FAIL: Error sending blob transaction: %v", err) } if !step.SkipVerificationFromNode { - VerifyTransactionFromNode(t.TestContext, engine, blobTx) + if err := VerifyTransactionFromNode(t.TestContext, engine, blobTx); err != nil { + t.Fatalf("FAIL: Error verifying blob transaction: %v", err) + } } t.TestBlobTxPool.Mutex.Lock() - t.AddBlobTransaction(blobTx) + t.AddTransaction(blobTx) t.HashesByIndex[t.CurrentTransactionIndex] = blobTx.Hash() t.CurrentTransactionIndex += 1 t.Logf("INFO: Sent blob transaction: %s", blobTx.Hash().String()) @@ -692,6 +760,80 @@ func (step SendBlobTransactions) Description() string { return fmt.Sprintf("SendBlobTransactions: %d Transactions, %d blobs each, %d max data gas fee", step.TransactionCount, step.GetBlobsPerTransaction(), step.BlobTransactionMaxBlobGasCost.Uint64()) } +// Send transactions to the client +type SendTransactions struct { + // Number of transactions to send + TransactionCount uint64 + // Sender Account index + SenderAccountIndex uint64 + // Receiver Account index + ReceiverAccountIndex uint64 + // Gas Fee Cap for every transaction + GasFeeCap *big.Int + // Gas Tip Cap for every transaction + GasTipCap *big.Int + // Amount to send in every transaction + Amount *big.Int + // Skip verification of retrieving the tx from node + SkipVerificationFromNode bool + // Client index to send the transactions to + ClientIndex uint64 +} + +func (step SendTransactions) GetAmount() *big.Int { + if step.Amount == nil || step.Amount.Cmp(big.NewInt(0)) <= 0 { + return big.NewInt(1) + } + return step.Amount +} + +func (step SendTransactions) Execute(t *CancunTestContext) error { + receiver := globals.TestAccounts[step.ReceiverAccountIndex].GetAddress() + var engine client.EngineClient + if step.ClientIndex >= uint64(len(t.Engines)) { + return fmt.Errorf("invalid client index %d", step.ClientIndex) + } + engine = t.Engines[step.ClientIndex] + // Send the transactions + for ntx := uint64(0); ntx < step.TransactionCount; ntx++ { + txCreator := &helper.BaseTransactionCreator{ + Recipient: &receiver, + GasLimit: t.Genesis.GasLimit(), + GasFee: step.GasFeeCap, + GasTip: step.GasTipCap, + Amount: step.GetAmount(), + Payload: nil, + TxType: helper.LegacyTxOnly, + } + sender := globals.TestAccounts[step.SenderAccountIndex] + tx, err := t.SendTransaction( + t.TestContext, + sender, + engine, + txCreator, + ) + if err != nil { + t.Fatalf("FAIL: Error sending transaction: %v", err) + } + if !step.SkipVerificationFromNode { + if err := VerifyTransactionFromNode(t.TestContext, engine, tx); err != nil { + t.Fatalf("FAIL: Error verifying transaction: %v", err) + } + } + t.TestBlobTxPool.Mutex.Lock() + t.AddTransaction(tx) + t.HashesByIndex[t.CurrentTransactionIndex] = tx.Hash() + t.CurrentTransactionIndex += 1 + t.Logf("INFO: Sent transaction: %s", tx.Hash().String()) + t.TestBlobTxPool.Mutex.Unlock() + } + return nil +} + +func (step SendTransactions) Description() string { + return fmt.Sprintf("SendTransactions: %d Transactions, %d amount", step.TransactionCount, step.GetAmount().Uint64()) +} + // Send a modified version of the latest payload produced using NewPayloadV3 type SendModifiedLatestPayload struct { ClientID uint64 diff --git a/simulators/ethereum/engine/suites/cancun/tests.go b/simulators/ethereum/engine/suites/cancun/tests.go index cd3e00824f..ea3056b06a 100644 --- a/simulators/ethereum/engine/suites/cancun/tests.go +++ b/simulators/ethereum/engine/suites/cancun/tests.go @@ -2,12 +2,13 @@ package suite_cancun import ( + "math/big" + "github.com/ethereum/hive/simulators/ethereum/engine/client/hive_rpc" "github.com/ethereum/hive/simulators/ethereum/engine/config" "github.com/ethereum/hive/simulators/ethereum/engine/config/cancun" "github.com/ethereum/hive/simulators/ethereum/engine/helper" "github.com/ethereum/hive/simulators/ethereum/engine/test" - "math/big" ) // Precalculate the first data gas cost increase @@ -15,9 +16,9 @@ var ( DATA_GAS_COST_INCREMENT_EXCEED_BLOBS = GetMinExcessBlobsForBlobGasPrice(2) ) -func pUint64(v uint64) *uint64 { - return &v -} +// func pUint64(v uint64) *uint64 { +// return &v +// } // Execution specification reference: // https://github.com/ethereum/execution-apis/blob/main/src/engine/cancun.md @@ -30,7 +31,7 @@ var Tests = []test.Spec{ Name: "Blob Transactions On Block 1, Shanghai Genesis", About: ` Tests the Cancun fork since Block 1. - + Verifications performed: - Correct implementation of Engine API changes for Cancun: - engine_newPayloadV3, engine_forkchoiceUpdatedV3, engine_getPayloadV3 @@ -50,7 +51,10 @@ var Tests = []test.Spec{ TestSequence: TestSequence{ // We are starting at Shanghai genesis so send a couple payloads to reach the fork - NewPayloads{}, + NewPayloads{ + // Nethermind rejects to receive blobs transactions until at least 1 post cancun block is processed + PayloadCount: 2, + }, // First, we send a couple of blob transactions on genesis, // with enough data gas cost to make sure they are included in the first block. @@ -93,14 +97,14 @@ var Tests = []test.Spec{ }, }, }, - // + &CancunBaseSpec{ BaseSpec: test.BaseSpec{ Name: "Blob Transactions On Block 1, Cancun Genesis", About: ` Tests the Cancun fork since genesis. - + Verifications performed: * See Blob Transactions On Block 1, Shanghai Genesis `, @@ -271,7 +275,9 @@ var Tests = []test.Spec{ }, TestSequence: TestSequence{ - NewPayloads{}, + NewPayloads{ + PayloadCount: 2, + }, // First send the cancun.MAX_BLOBS_PER_BLOCK-1 blob transactions from // account A. SendBlobTransactions{ @@ -368,6 +374,100 @@ var Tests = []test.Spec{ }, }, + &CancunBaseSpec{ + BaseSpec: test.BaseSpec{ + Name: "Fee Collector test for transactions, Cancun genesis", + About: ` + Tests the Fee Collector since Cancun genesis. + + Verifications performed: + - Expected behaivior of the Fee Collector for transactions before the Barnet fork. + `, + MainFork: config.Cancun, + }, + TestSequence: TestSequence{ + NewPayloads{}, + + SendTransactions{ + TransactionCount: 1, + SenderAccountIndex: 0, + }, + + SendBlobTransactions{ + TransactionCount: cancun.TARGET_BLOBS_PER_BLOCK, + BlobTransactionMaxBlobGasCost: big.NewInt(1000000000), + AccountIndex: 1, + }, + + NewPayloads{ + ExpectedIncludedBlobCount: cancun.TARGET_BLOBS_PER_BLOCK, + ExpectedBlobs: helper.GetBlobList(0, cancun.TARGET_BLOBS_PER_BLOCK), + }, + }, + }, + + &CancunBaseSpec{ + BaseSpec: test.BaseSpec{ + Name: "Blob transactions on Barnet, Cancun genesis ", + About: ` + Tests the Barnet fork since Cancun genesis. + + Verifications performed: + - Correct implementation of Barnet fork fix to Blob fee gas collection + `, + MainFork: config.Barnet, + ForkHeight: 1, + }, + + TestSequence: TestSequence{ + NewPayloads{ + PayloadCount: 2, + }, + + SendBlobTransactions{ + TransactionCount: cancun.TARGET_BLOBS_PER_BLOCK, + BlobTransactionMaxBlobGasCost: big.NewInt(1000000000), + }, + + NewPayloads{ + ExpectedIncludedBlobCount: cancun.TARGET_BLOBS_PER_BLOCK, + ExpectedBlobs: helper.GetBlobList(0, cancun.TARGET_BLOBS_PER_BLOCK), + }, + }, + }, + + &CancunBaseSpec{ + BaseSpec: test.BaseSpec{ + Name: "Fee Collector test for transactions, Barnet genesis", + About: ` + Tests the Fee Collector since Barnet genesis. + + Verifications performed: + - Expected behaivior of the Fee Collector for transactions after the Barnet fork. + `, + MainFork: config.Barnet, + }, + TestSequence: TestSequence{ + NewPayloads{}, + + SendTransactions{ + TransactionCount: 1, + SenderAccountIndex: 0, + }, + + SendBlobTransactions{ + TransactionCount: cancun.TARGET_BLOBS_PER_BLOCK, + BlobTransactionMaxBlobGasCost: big.NewInt(1000000000), + AccountIndex: 1, + }, + + NewPayloads{ + ExpectedIncludedBlobCount: cancun.TARGET_BLOBS_PER_BLOCK, + ExpectedBlobs: helper.GetBlobList(0, cancun.TARGET_BLOBS_PER_BLOCK), + }, + }, + }, + //&CancunBaseSpec{ // // BaseSpec: test.BaseSpec{ diff --git a/simulators/ethereum/engine/suites/engine/bad_hash.go b/simulators/ethereum/engine/suites/engine/bad_hash.go index 478f68097f..8e2220b8da 100644 --- a/simulators/ethereum/engine/suites/engine/bad_hash.go +++ b/simulators/ethereum/engine/suites/engine/bad_hash.go @@ -50,6 +50,23 @@ func (s BadHashOnNewPayload) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s BadHashOnNewPayload) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (b BadHashOnNewPayload) GetName() string { return fmt.Sprintf("Bad Hash on NewPayload (Syncing=%v, Sidechain=%v)", b.Syncing, b.Sidechain) } @@ -150,6 +167,23 @@ func (s ParentHashOnNewPayload) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s ParentHashOnNewPayload) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (p ParentHashOnNewPayload) GetName() string { name := "ParentHash equals BlockHash on NewPayload," if p.Syncing { diff --git a/simulators/ethereum/engine/suites/engine/fork_id.go b/simulators/ethereum/engine/suites/engine/fork_id.go index 1cb92acde4..4123f60942 100644 --- a/simulators/ethereum/engine/suites/engine/fork_id.go +++ b/simulators/ethereum/engine/suites/engine/fork_id.go @@ -23,6 +23,23 @@ func (s ForkIDSpec) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s ForkIDSpec) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (ft ForkIDSpec) GetName() string { var name []string name = append(name, fmt.Sprintf("Fork ID: Genesis=%d, %s=%d", ft.GetGenesisTimestamp(), ft.MainFork, ft.ForkTime)) diff --git a/simulators/ethereum/engine/suites/engine/forkchoice.go b/simulators/ethereum/engine/suites/engine/forkchoice.go index bc90020733..18ca06a94e 100644 --- a/simulators/ethereum/engine/suites/engine/forkchoice.go +++ b/simulators/ethereum/engine/suites/engine/forkchoice.go @@ -32,6 +32,23 @@ func (s InconsistentForkchoiceTest) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s InconsistentForkchoiceTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (tc InconsistentForkchoiceTest) GetName() string { return fmt.Sprintf("Inconsistent %s in ForkchoiceState", tc.Field) } @@ -98,6 +115,23 @@ func (s ForkchoiceUpdatedUnknownBlockHashTest) WithMainFork(fork config.Fork) te return specCopy } +func (s ForkchoiceUpdatedUnknownBlockHashTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (tc ForkchoiceUpdatedUnknownBlockHashTest) GetName() string { return fmt.Sprintf("Unknown %sBlockHash", tc.Field) } diff --git a/simulators/ethereum/engine/suites/engine/invalid_ancestor.go b/simulators/ethereum/engine/suites/engine/invalid_ancestor.go index e1f9a5e7ee..71bc862d8a 100644 --- a/simulators/ethereum/engine/suites/engine/invalid_ancestor.go +++ b/simulators/ethereum/engine/suites/engine/invalid_ancestor.go @@ -38,6 +38,23 @@ func (s InvalidMissingAncestorReOrgTest) WithMainFork(fork config.Fork) test.Spe return specCopy } +func (s InvalidMissingAncestorReOrgTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (tc InvalidMissingAncestorReOrgTest) GetName() string { emptyTxsStatus := "False" if tc.EmptyTransactions { @@ -205,6 +222,23 @@ func (s InvalidMissingAncestorReOrgSyncTest) WithMainFork(fork config.Fork) test return specCopy } +func (s InvalidMissingAncestorReOrgSyncTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (tc InvalidMissingAncestorReOrgSyncTest) GetName() string { emptyTxsStatus := "False" if tc.EmptyTransactions { diff --git a/simulators/ethereum/engine/suites/engine/invalid_payload.go b/simulators/ethereum/engine/suites/engine/invalid_payload.go index f148dbe60f..5618db7f0a 100644 --- a/simulators/ethereum/engine/suites/engine/invalid_payload.go +++ b/simulators/ethereum/engine/suites/engine/invalid_payload.go @@ -41,6 +41,23 @@ func (s InvalidPayloadTestCase) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s InvalidPayloadTestCase) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (i InvalidPayloadTestCase) GetName() string { syncStatus := "False" if i.Syncing { @@ -319,6 +336,23 @@ func (s PayloadBuildAfterInvalidPayloadTest) WithMainFork(fork config.Fork) test return specCopy } +func (s PayloadBuildAfterInvalidPayloadTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (i PayloadBuildAfterInvalidPayloadTest) GetName() string { name := fmt.Sprintf("Payload Build after New Invalid Payload: Invalid %s", i.InvalidField) return name @@ -407,6 +441,23 @@ func (s InvalidTxChainIDTest) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s InvalidTxChainIDTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (s InvalidTxChainIDTest) GetName() string { name := fmt.Sprintf("Build Payload with Invalid ChainID Transaction, %s", s.TestTransactionType) return name diff --git a/simulators/ethereum/engine/suites/engine/misc.go b/simulators/ethereum/engine/suites/engine/misc.go index cfb569dfb0..8d27e76dda 100644 --- a/simulators/ethereum/engine/suites/engine/misc.go +++ b/simulators/ethereum/engine/suites/engine/misc.go @@ -20,6 +20,23 @@ func (s NonZeroPreMergeFork) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s NonZeroPreMergeFork) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (b NonZeroPreMergeFork) GetName() string { return "Pre-Merge Fork Number > 0" } diff --git a/simulators/ethereum/engine/suites/engine/payload_attributes.go b/simulators/ethereum/engine/suites/engine/payload_attributes.go index 540159b2a1..69fed82279 100644 --- a/simulators/ethereum/engine/suites/engine/payload_attributes.go +++ b/simulators/ethereum/engine/suites/engine/payload_attributes.go @@ -23,6 +23,23 @@ func (s InvalidPayloadAttributesTest) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s InvalidPayloadAttributesTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (tc InvalidPayloadAttributesTest) GetName() string { name := fmt.Sprintf("Invalid PayloadAttributes, %s,", tc.Description) if tc.Syncing { diff --git a/simulators/ethereum/engine/suites/engine/payload_execution.go b/simulators/ethereum/engine/suites/engine/payload_execution.go index a86c4e253b..562d2873c2 100644 --- a/simulators/ethereum/engine/suites/engine/payload_execution.go +++ b/simulators/ethereum/engine/suites/engine/payload_execution.go @@ -25,6 +25,23 @@ func (s ReExecutePayloadTest) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s ReExecutePayloadTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (s ReExecutePayloadTest) GetName() string { name := "Re-Execute Payload" return name @@ -98,6 +115,23 @@ func (s InOrderPayloadExecutionTest) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s InOrderPayloadExecutionTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (s InOrderPayloadExecutionTest) GetName() string { name := "In-Order Consecutive Payload Execution" return name @@ -220,6 +254,23 @@ func (s MultiplePayloadsExtendingCanonicalChainTest) WithMainFork(fork config.Fo return specCopy } +func (s MultiplePayloadsExtendingCanonicalChainTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (s MultiplePayloadsExtendingCanonicalChainTest) GetName() string { name := "Multiple New Payloads Extending Canonical Chain," if s.SetHeadToFirstPayloadReceived { @@ -316,6 +367,23 @@ func (s NewPayloadOnSyncingClientTest) WithMainFork(fork config.Fork) test.Spec return specCopy } +func (s NewPayloadOnSyncingClientTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (s NewPayloadOnSyncingClientTest) GetName() string { name := "Valid NewPayload->ForkchoiceUpdated on Syncing Client" return name @@ -466,6 +534,23 @@ func (s NewPayloadWithMissingFcUTest) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s NewPayloadWithMissingFcUTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (s NewPayloadWithMissingFcUTest) GetName() string { name := "NewPayload with Missing ForkchoiceUpdated" return name diff --git a/simulators/ethereum/engine/suites/engine/payload_id.go b/simulators/ethereum/engine/suites/engine/payload_id.go index e2afe766bc..e279415a9b 100644 --- a/simulators/ethereum/engine/suites/engine/payload_id.go +++ b/simulators/ethereum/engine/suites/engine/payload_id.go @@ -35,6 +35,23 @@ func (s UniquePayloadIDTest) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s UniquePayloadIDTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (tc UniquePayloadIDTest) GetName() string { return fmt.Sprintf("Unique Payload ID, %s", tc.FieldModification) } diff --git a/simulators/ethereum/engine/suites/engine/prev_randao.go b/simulators/ethereum/engine/suites/engine/prev_randao.go index 6b6906f01d..177e4af55d 100644 --- a/simulators/ethereum/engine/suites/engine/prev_randao.go +++ b/simulators/ethereum/engine/suites/engine/prev_randao.go @@ -24,6 +24,23 @@ func (s PrevRandaoTransactionTest) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s PrevRandaoTransactionTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (t PrevRandaoTransactionTest) GetName() string { return fmt.Sprintf("PrevRandao Opcode Transactions Test, %s", t.TestTransactionType) } diff --git a/simulators/ethereum/engine/suites/engine/reorg.go b/simulators/ethereum/engine/suites/engine/reorg.go index 05a96ee58c..2b6a11f631 100644 --- a/simulators/ethereum/engine/suites/engine/reorg.go +++ b/simulators/ethereum/engine/suites/engine/reorg.go @@ -27,6 +27,23 @@ func (s SidechainReOrgTest) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s SidechainReOrgTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (s SidechainReOrgTest) GetName() string { name := "Sidechain Reorg" return name @@ -136,6 +153,23 @@ func (s TransactionReOrgTest) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s TransactionReOrgTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (s TransactionReOrgTest) GetName() string { name := "Transaction Re-Org" if s.Scenario != "" { @@ -423,6 +457,23 @@ func (s ReOrgBackToCanonicalTest) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s ReOrgBackToCanonicalTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (s ReOrgBackToCanonicalTest) GetName() string { name := fmt.Sprintf("Re-Org Back into Canonical Chain, Depth=%d", s.ReOrgDepth) @@ -559,6 +610,23 @@ func (s ReOrgBackFromSyncingTest) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s ReOrgBackFromSyncingTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (s ReOrgBackFromSyncingTest) GetName() string { name := "Re-Org Back to Canonical Chain From Syncing Chain" return name @@ -648,6 +716,23 @@ func (s ReOrgPrevValidatedPayloadOnSideChainTest) WithMainFork(fork config.Fork) return specCopy } +func (s ReOrgPrevValidatedPayloadOnSideChainTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (s ReOrgPrevValidatedPayloadOnSideChainTest) GetName() string { name := "Re-org to Previously Validated Sidechain Payload" return name @@ -765,6 +850,23 @@ func (s SafeReOrgToSideChainTest) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s SafeReOrgToSideChainTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (s SafeReOrgToSideChainTest) GetName() string { name := "Safe Re-Org to Side Chain" return name diff --git a/simulators/ethereum/engine/suites/engine/rpc.go b/simulators/ethereum/engine/suites/engine/rpc.go index 9d9ab22f35..4f2a659616 100644 --- a/simulators/ethereum/engine/suites/engine/rpc.go +++ b/simulators/ethereum/engine/suites/engine/rpc.go @@ -32,6 +32,23 @@ func (s BlockStatus) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s BlockStatus) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (b BlockStatus) GetName() string { return fmt.Sprintf("RPC: %s", b.CheckType) } diff --git a/simulators/ethereum/engine/suites/engine/suggested_fee_recipient.go b/simulators/ethereum/engine/suites/engine/suggested_fee_recipient.go index 0c604fd87a..e3c76003a2 100644 --- a/simulators/ethereum/engine/suites/engine/suggested_fee_recipient.go +++ b/simulators/ethereum/engine/suites/engine/suggested_fee_recipient.go @@ -24,6 +24,23 @@ func (s SuggestedFeeRecipientTest) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s SuggestedFeeRecipientTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (t SuggestedFeeRecipientTest) GetName() string { return fmt.Sprintf("Suggested Fee Recipient Test, %s", t.TestTransactionType) } diff --git a/simulators/ethereum/engine/suites/engine/tests.go b/simulators/ethereum/engine/suites/engine/tests.go index ab9c08dc22..e90c12158f 100644 --- a/simulators/ethereum/engine/suites/engine/tests.go +++ b/simulators/ethereum/engine/suites/engine/tests.go @@ -1,11 +1,12 @@ package suite_engine import ( + "math/big" + "github.com/ethereum/hive/simulators/ethereum/engine/config" "github.com/ethereum/hive/simulators/ethereum/engine/globals" "github.com/ethereum/hive/simulators/ethereum/engine/helper" "github.com/ethereum/hive/simulators/ethereum/engine/test" - "math/big" "github.com/ethereum/go-ethereum/common" ) diff --git a/simulators/ethereum/engine/suites/engine/versioning.go b/simulators/ethereum/engine/suites/engine/versioning.go index a28517a72b..ffef662163 100644 --- a/simulators/ethereum/engine/suites/engine/versioning.go +++ b/simulators/ethereum/engine/suites/engine/versioning.go @@ -19,6 +19,23 @@ func (s EngineNewPayloadVersionTest) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s EngineNewPayloadVersionTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + // Test modifying the ForkchoiceUpdated version on Payload Request to the previous/upcoming version // when the timestamp payload attribute does not match the upgraded/downgraded version. type ForkchoiceUpdatedOnPayloadRequestTest struct { @@ -32,6 +49,23 @@ func (s ForkchoiceUpdatedOnPayloadRequestTest) WithMainFork(fork config.Fork) te return specCopy } +func (s ForkchoiceUpdatedOnPayloadRequestTest) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (tc ForkchoiceUpdatedOnPayloadRequestTest) GetName() string { return "ForkchoiceUpdated Version on Payload Request: " + tc.BaseSpec.GetName() } diff --git a/simulators/ethereum/engine/suites/exchange_capabilities/tests.go b/simulators/ethereum/engine/suites/exchange_capabilities/tests.go index 26872516eb..be0d3ff884 100644 --- a/simulators/ethereum/engine/suites/exchange_capabilities/tests.go +++ b/simulators/ethereum/engine/suites/exchange_capabilities/tests.go @@ -80,6 +80,23 @@ func (s ExchangeCapabilitiesSpec) WithMainFork(fork config.Fork) test.Spec { return specCopy } +func (s ExchangeCapabilitiesSpec) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + func (s ExchangeCapabilitiesSpec) Execute(t *test.Env) { if returnedCapabilities, err := t.HiveEngine.ExchangeCapabilities(t.TestContext, s.MinimalExpectedCapabilitiesSet); err != nil { t.Fatalf("FAIL (%s): Unable request capabilities: %v", t.TestName, err) diff --git a/simulators/ethereum/engine/suites/sync/tests.go b/simulators/ethereum/engine/suites/sync/tests.go index 73c34d3294..17a1fb7ad0 100644 --- a/simulators/ethereum/engine/suites/sync/tests.go +++ b/simulators/ethereum/engine/suites/sync/tests.go @@ -5,6 +5,7 @@ import ( "fmt" "math/big" "math/rand" + "strings" "time" api "github.com/ethereum/go-ethereum/beacon/engine" @@ -53,8 +54,9 @@ func AddSyncTestsToSuite(sim *hivesim.Simulation, suite *hivesim.Suite, tests [] } testFiles := hivesim.Params{"/genesis.json": genesisPath} // Calculate and set the TTD for this test - genesis := helper.LoadGenesis(genesisPath) - ttd := helper.CalculateRealTTD(&genesis, currentTest.TTD) + clientName := strings.Split(clientDef.Name, "_")[0] + genesis := currentTest.GetGenesis(clientName) + ttd := helper.CalculateRealTTD(genesis, currentTest.TTD) newParams := globals.DefaultClientEnv.Set("HIVE_TERMINAL_TOTAL_DIFFICULTY", fmt.Sprintf("%d", ttd)) if currentTest.ChainFile != "" { // We are using a Proof of Work chain file, remove all clique-related settings @@ -100,7 +102,7 @@ func AddSyncTestsToSuite(sim *hivesim.Simulation, suite *hivesim.Suite, tests [] } // Run the test case - test.Run(¤tTest, big.NewInt(ttd), timeout, t, c, &genesis, rand.New(rand.NewSource(0)), syncClientParams, testFiles.Copy()) + test.Run(¤tTest, big.NewInt(ttd), timeout, t, c, genesis, rand.New(rand.NewSource(0)), syncClientParams, testFiles.Copy()) }, }) } diff --git a/simulators/ethereum/engine/suites/withdrawals/tests.go b/simulators/ethereum/engine/suites/withdrawals/tests.go index 2ffb082c2b..ee1f65f0b6 100644 --- a/simulators/ethereum/engine/suites/withdrawals/tests.go +++ b/simulators/ethereum/engine/suites/withdrawals/tests.go @@ -6,10 +6,11 @@ import ( "crypto/rand" "encoding/json" "fmt" - "github.com/ethereum/hive/simulators/ethereum/engine/client" "math/big" "time" + "github.com/ethereum/hive/simulators/ethereum/engine/client" + "github.com/ethereum/go-ethereum/accounts/abi/bind" beacon "github.com/ethereum/go-ethereum/beacon/engine" "github.com/ethereum/go-ethereum/common" @@ -242,7 +243,7 @@ var Tests = []test.Spec{ // Block value tests // &BlockValueSpec{ - // WithdrawalsBaseSpec: &WithdrawalsBaseSpec{ + // WithdrawalsBaseSpec: WithdrawalsBaseSpec{ // Spec: test.Spec{ // Name: "GetPayloadV2 Block Value", // About: ` @@ -887,6 +888,29 @@ func (ws *WithdrawalsBaseSpec) GetWithdrawalsStartAccount() *big.Int { return big.NewInt(0x1000) } +func (ws *WithdrawalsBaseSpec) WithMainFork(fork config.Fork) test.Spec { + specCopy := *ws + specCopy.MainFork = fork + return &specCopy +} + +func (s *WithdrawalsBaseSpec) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := *s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return &specCopy +} + // Append the accounts we are going to withdraw to, which should also include // bytecode for testing purposes. //func (ws *WithdrawalsBaseSpec) GetGenesisTest(base string) string { @@ -895,6 +919,13 @@ func (ws *WithdrawalsBaseSpec) GetWithdrawalsStartAccount() *big.Int { // return genesis //} +func (ws *WithdrawalsBaseSpec) GetMainFork() config.Fork { + if ws.BaseSpec.MainFork != config.NA { + return ws.BaseSpec.MainFork + } + return config.Shanghai +} + // Append the accounts we are going to withdraw to, which should also include // bytecode for testing purposes. func (ws *WithdrawalsBaseSpec) GetGenesis(base string) client.Genesis { @@ -1328,6 +1359,29 @@ type WithdrawalsSyncSpec struct { SyncShouldFail bool // } +func (ws *WithdrawalsSyncSpec) WithMainFork(fork config.Fork) test.Spec { + specCopy := *ws + specCopy.MainFork = fork + return &specCopy +} + +func (s *WithdrawalsSyncSpec) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := *s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return &specCopy +} + func (ws *WithdrawalsSyncSpec) Execute(t *test.Env) { //var secondaryEngineTestChan chan *test.TestEngineClient //var secondaryEngineChan chan client.EngineClient @@ -1419,6 +1473,29 @@ type WithdrawalsReorgSpec struct { SidechainTimeIncrements uint64 } +func (ws *WithdrawalsReorgSpec) WithMainFork(fork config.Fork) test.Spec { + specCopy := *ws + specCopy.MainFork = fork + return &specCopy +} + +func (s *WithdrawalsReorgSpec) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := *s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return &specCopy +} + func (ws *WithdrawalsReorgSpec) GetSidechainSplitHeight() uint64 { if ws.ReOrgBlockCount > ws.GetTotalPayloadCount() { panic("invalid payload/re-org configuration") @@ -1736,6 +1813,29 @@ type WithdrawalsExecutionLayerSpec struct { ClaimBlocksCount int } +func (ws *WithdrawalsExecutionLayerSpec) WithMainFork(fork config.Fork) test.Spec { + specCopy := *ws + specCopy.MainFork = fork + return &specCopy +} + +func (s *WithdrawalsExecutionLayerSpec) WithTimestamp(genesisTime uint64) test.Spec { + specCopy := *s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return &specCopy +} + func (ws *WithdrawalsExecutionLayerSpec) claimBlocksCount() int { if ws.ClaimBlocksCount == 0 { return 1 diff --git a/simulators/ethereum/engine/test/spec.go b/simulators/ethereum/engine/test/spec.go index caffdad900..737a893c25 100644 --- a/simulators/ethereum/engine/test/spec.go +++ b/simulators/ethereum/engine/test/spec.go @@ -3,10 +3,11 @@ package test import ( "errors" "fmt" - "github.com/ethereum/hive/simulators/ethereum/engine/client" "math/big" "time" + "github.com/ethereum/hive/simulators/ethereum/engine/client" + "github.com/ethereum/hive/simulators/ethereum/engine/clmock" "github.com/ethereum/hive/simulators/ethereum/engine/config" "github.com/ethereum/hive/simulators/ethereum/engine/globals" @@ -32,7 +33,8 @@ type Spec interface { GetForkConfig() *config.ForkConfig // Get the genesis file to initialize the clients GetGenesis(string) client.Genesis - //GetGenesisTest(string) string + // Creates a copy of the spec with the genesis and previous fork timestamps configured + WithTimestamp(uint64) Spec // Get the test transaction type to use throughout the test GetTestTransactionType() helper.TestTransactionType // Get the maximum execution time until a timeout is raised @@ -170,7 +172,9 @@ func (s BaseSpec) GetBlockTime(blockNumber uint64) uint64 { func (s BaseSpec) GetForkTime() uint64 { forkTime := s.ForkTime - if s.ForkHeight > 0 { + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai forkTime = s.GetBlockTime(s.ForkHeight) } return forkTime @@ -197,6 +201,10 @@ func (s BaseSpec) GetForkConfig() *config.ForkConfig { } else if mainFork == config.Cancun { forkConfig.ShanghaiTimestamp = new(big.Int).SetUint64(previousForkTime) forkConfig.CancunTimestamp = new(big.Int).SetUint64(forkTime) + } else if mainFork == config.Barnet { + forkConfig.ShanghaiTimestamp = new(big.Int).SetUint64(previousForkTime) + forkConfig.CancunTimestamp = new(big.Int).SetUint64(previousForkTime) + forkConfig.BarnetTimestamp = new(big.Int).SetUint64(forkTime) } else { panic(fmt.Errorf("unknown fork: %s", mainFork)) } @@ -228,6 +236,23 @@ func (s BaseSpec) GetGenesis(base string) client.Genesis { return genesis } +func (s BaseSpec) WithTimestamp(genesisTime uint64) Spec { + specCopy := s + // Set genesis time if not defined + if s.GenesisTimestamp == nil { + specCopy.GenesisTimestamp = &genesisTime + } + // Set fork time, will be ignored if fork height is set + specCopy.ForkTime = *specCopy.GenesisTimestamp + // Set previous fork time if fork height is set + mainFork := s.GetMainFork() + if s.ForkHeight > 0 && mainFork != config.Paris && mainFork != config.Shanghai { + // No previous fork time for Paris and Shanghai + specCopy.PreviousForkTime = genesisTime + } + return specCopy +} + //func (s BaseSpec) GetGenesisTest(base string) string { // if len(base) != 0 { // base += "_"