From 58f11712767afe69d7672ce16d7df8be7d3d6030 Mon Sep 17 00:00:00 2001 From: Quentin Mc Gaw Date: Wed, 22 Jan 2025 10:55:23 +0100 Subject: [PATCH] Use now exported `ethtypes.CopyEthHeader` --- accounts/abi/bind/bind_test.go | 2 +- core/types/header_ext.go | 37 +--------------------------------- go.mod | 2 +- go.sum | 4 ++-- scripts/tests.e2e.sh | 2 +- 5 files changed, 6 insertions(+), 41 deletions(-) diff --git a/accounts/abi/bind/bind_test.go b/accounts/abi/bind/bind_test.go index 495a2dc813..b016a042ff 100644 --- a/accounts/abi/bind/bind_test.go +++ b/accounts/abi/bind/bind_test.go @@ -2179,7 +2179,7 @@ func golangBindings(t *testing.T, overload bool) { if out, err := replacer.CombinedOutput(); err != nil { t.Fatalf("failed to replace binding test dependency to current source tree: %v\n%s", err, out) } - replacer = exec.Command(gocmd, "mod", "edit", "-x", "-require", "github.com/ava-labs/libevm@v0.0.0", "-replace", "github.com/ava-labs/libevm=github.com/ava-labs/libevm@v0.0.0-20250121161112-050824131de5") + replacer = exec.Command(gocmd, "mod", "edit", "-x", "-require", "github.com/ava-labs/libevm@v0.0.0", "-replace", "github.com/ava-labs/libevm=github.com/ava-labs/libevm@v0.0.0-20250121162040-b9e5186290df") replacer.Dir = pkg if out, err := replacer.CombinedOutput(); err != nil { t.Fatalf("failed to replace binding test dependency to current source tree: %v\n%s", err, out) diff --git a/core/types/header_ext.go b/core/types/header_ext.go index 924c08fb86..113a7b70ad 100644 --- a/core/types/header_ext.go +++ b/core/types/header_ext.go @@ -82,45 +82,10 @@ func (h *HeaderExtra) Copy(header *Header) *Header { extraCopy.ExtDataGasUsed.SetBytes(h.ExtDataGasUsed.Bytes()) } - cpy := copyBaseHeader(header) + cpy := ethtypes.CopyEthHeader(header) return WithHeaderExtras(cpy, extraCopy) } -// TODO add test to make sure this mirrors copy with a no extra header. -func copyBaseHeader(h *ethtypes.Header) *ethtypes.Header { - cpy := *h - if cpy.Difficulty = new(big.Int); h.Difficulty != nil { - cpy.Difficulty.Set(h.Difficulty) - } - if cpy.Number = new(big.Int); h.Number != nil { - cpy.Number.Set(h.Number) - } - if h.BaseFee != nil { - cpy.BaseFee = new(big.Int).Set(h.BaseFee) - } - if len(h.Extra) > 0 { - cpy.Extra = make([]byte, len(h.Extra)) - copy(cpy.Extra, h.Extra) - } - if h.WithdrawalsHash != nil { - cpy.WithdrawalsHash = new(common.Hash) - *cpy.WithdrawalsHash = *h.WithdrawalsHash - } - if h.ExcessBlobGas != nil { - cpy.ExcessBlobGas = new(uint64) - *cpy.ExcessBlobGas = *h.ExcessBlobGas - } - if h.BlobGasUsed != nil { - cpy.BlobGasUsed = new(uint64) - *cpy.BlobGasUsed = *h.BlobGasUsed - } - if h.ParentBeaconRoot != nil { - cpy.ParentBeaconRoot = new(common.Hash) - *cpy.ParentBeaconRoot = *h.ParentBeaconRoot - } - return &cpy -} - //go:generate go run github.com/fjl/gencodec -type HeaderSerializable -field-override headerMarshaling -out gen_header_json.go //go:generate go run github.com/ava-labs/libevm/rlp/rlpgen -type HeaderSerializable -out gen_header_rlp.go diff --git a/go.mod b/go.mod index 3058108604..59360a063d 100644 --- a/go.mod +++ b/go.mod @@ -136,4 +136,4 @@ require ( rsc.io/tmplfunc v0.0.3 // indirect ) -replace github.com/ava-labs/libevm => github.com/ava-labs/libevm v0.0.0-20250121161112-050824131de5 +replace github.com/ava-labs/libevm => github.com/ava-labs/libevm v0.0.0-20250121162040-b9e5186290df diff --git a/go.sum b/go.sum index a79f9767ce..6f32dd08a6 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/ava-labs/avalanchego v1.12.1-0.20250107220127-32f58b4fa9c8 h1:qN3MOBHB//Ynhgt5Vys3iVe42Sr0EWSeN18VL3ecXzE= github.com/ava-labs/avalanchego v1.12.1-0.20250107220127-32f58b4fa9c8/go.mod h1:2B7+E5neLvkOr2zursGhebjU26d4AfB7RazPxBs8hHg= -github.com/ava-labs/libevm v0.0.0-20250121161112-050824131de5 h1:C7e/il0E4uFqOD6wgxhVwwbBNRzMuolGSptyB8A5dTE= -github.com/ava-labs/libevm v0.0.0-20250121161112-050824131de5/go.mod h1:M8TCw2g1D5GBB7hu7g1F4aot5bRHGSxnBawNVmHE9Z0= +github.com/ava-labs/libevm v0.0.0-20250121162040-b9e5186290df h1:qCro69yW9HuKksYBitRy68Ana8w+621MXEW+0+PySio= +github.com/ava-labs/libevm v0.0.0-20250121162040-b9e5186290df/go.mod h1:M8TCw2g1D5GBB7hu7g1F4aot5bRHGSxnBawNVmHE9Z0= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= diff --git a/scripts/tests.e2e.sh b/scripts/tests.e2e.sh index 6199c9822f..d36583bb79 100755 --- a/scripts/tests.e2e.sh +++ b/scripts/tests.e2e.sh @@ -45,7 +45,7 @@ git checkout -B "test-${AVALANCHE_VERSION}" "${AVALANCHE_VERSION}" echo "updating coreth dependency to point to ${CORETH_PATH}" go mod edit -replace "github.com/ava-labs/coreth=${CORETH_PATH}" -go mod edit -replace "github.com/ava-labs/libevm=github.com/ava-labs/libevm@v0.0.0-20250121161112-050824131de5" +go mod edit -replace "github.com/ava-labs/libevm=github.com/ava-labs/libevm@v0.0.0-20250121162040-b9e5186290df" go mod tidy echo "building avalanchego"