Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment out TTD checks #5

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions simulators/ethereum/engine/clmock/clmock.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"crypto/sha256"
"encoding/binary"
"encoding/json"
"fmt"
"math/big"
"math/rand"
Expand Down Expand Up @@ -273,19 +272,18 @@ func (cl *CLMocker) SetTTDBlockClient(ec client.EngineClient) {
}
cl.HeaderHistory[cl.LatestHeader.Number.Uint64()] = cl.LatestHeader

ctx, cancel = context.WithTimeout(cl.TestContext, globals.RPCTimeout)
defer cancel()

if td, err := ec.GetTotalDifficulty(ctx); err != nil {
cl.Fatalf("CLMocker: Error getting total difficulty from engine client: %v", err)
} else if td.Cmp(ec.TerminalTotalDifficulty()) < 0 {
cl.Fatalf("CLMocker: Attempted to set TTD Block when TTD had not been reached: %d > %d", ec.TerminalTotalDifficulty(), td)
} else {
cl.Logf("CLMocker: TTD has been reached at block %d (%d>=%d)\n", cl.LatestHeader.Number, td, ec.TerminalTotalDifficulty())
jsH, _ := json.MarshalIndent(cl.LatestHeader, "", " ")
cl.Logf("CLMocker: Client: %s, Block %d: %s\n", ec.ID(), cl.LatestHeader.Number, jsH)
cl.ChainTotalDifficulty = td
}
// if td, err := ec.GetTotalDifficulty(ctx); err != nil {
// cl.Fatalf("CLMocker: Error getting total difficulty from engine client: %v", err)
// } else if td.Cmp(ec.TerminalTotalDifficulty()) < 0 {
// cl.Fatalf("CLMocker: Attempted to set TTD Block when TTD had not been reached: %d > %d", ec.TerminalTotalDifficulty(), td)
// } else {
// cl.Logf("CLMocker: TTD has been reached at block %d (%d>=%d)\n", cl.LatestHeader.Number, td, ec.TerminalTotalDifficulty())
// jsH, _ := json.MarshalIndent(cl.LatestHeader, "", " ")
// cl.Logf("CLMocker: Client: %s, Block %d: %s\n", ec.ID(), cl.LatestHeader.Number, jsH)
// cl.ChainTotalDifficulty = td
// }

cl.TTDReached = true

Expand Down
16 changes: 8 additions & 8 deletions simulators/ethereum/engine/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/pkg/errors"

"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"
Expand Down Expand Up @@ -273,13 +272,14 @@ var (

// TTD Check Methods
func CheckTTD(ec client.EngineClient, ctx context.Context) (bool, error) {
ctx, cancel := context.WithTimeout(ctx, globals.RPCTimeout)
defer cancel()
td, err := ec.GetTotalDifficulty(ctx)
if err == nil {
return td.Cmp(ec.TerminalTotalDifficulty()) >= 0, nil
}
return false, err
// ctx, cancel := context.WithTimeout(ctx, globals.RPCTimeout)
// defer cancel()
// td, err := ec.GetTotalDifficulty(ctx)
// if err == nil {
// return td.Cmp(ec.TerminalTotalDifficulty()) >= 0, nil
// }
// return false, err
return true, nil
}

type WaitTTDResponse struct {
Expand Down