forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: generate internal
Header.encodeRLP()
for override (#86)
## Why this should be merged This is a precursor to being able to override `types.Header` RLP {en,de}coding. As there is already a `Header.EncodeRLP()` method we either have to modify the generated code or rename the generated method—this PR does the latter. ## How this works The `rlpgen -internal_methods` flag changes the generated methods from `EncodeRLP()` and `DecodeRLP()` to `encodeRLP()` and `decodeRLP()`, respectively. A new CI job checks that generated code is up to date. We can then implement our own `Header.EncodeRLP()` that either overrides or falls back on the original. It appears that `core/gen_genesis.go` was out of date but only because of formatting. ## How this was tested I deliberately excluded the change to `core/types/gen_header_rlp.go` to confirm that the new workflow [detects](https://github.com/ava-labs/libevm/actions/runs/12259667481/job/34202386378?pr=86#step:5:92) the change and fails. The actual change can be inspected via the code diff.
- Loading branch information
Showing
8 changed files
with
119 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2024 the libevm authors. | ||
// | ||
// The libevm additions to go-ethereum are free software: you can redistribute | ||
// them and/or modify them under the terms of the GNU Lesser General Public License | ||
// as published by the Free Software Foundation, either version 3 of the License, | ||
// or (at your option) any later version. | ||
// | ||
// The libevm additions are distributed in the hope that they will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser | ||
// General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the go-ethereum library. If not, see | ||
// <http://www.gnu.org/licenses/>. | ||
|
||
package types | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/ava-labs/libevm/rlp" | ||
) | ||
|
||
func (h *Header) EncodeRLP(w io.Writer) error { | ||
return h.encodeRLP(w) | ||
} | ||
|
||
var _ rlp.Encoder = (*Header)(nil) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2024 the libevm authors. | ||
// | ||
// The libevm additions to go-ethereum are free software: you can redistribute | ||
// them and/or modify them under the terms of the GNU Lesser General Public License | ||
// as published by the Free Software Foundation, either version 3 of the License, | ||
// or (at your option) any later version. | ||
// | ||
// The libevm additions are distributed in the hope that they will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser | ||
// General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the go-ethereum library. If not, see | ||
// <http://www.gnu.org/licenses/>. | ||
|
||
package main | ||
|
||
func (ctx *genContext) encoderMethod() string { | ||
if ctx.internalMethods { | ||
return "encodeRLP" | ||
} | ||
return "EncodeRLP" | ||
} | ||
|
||
func (ctx *genContext) decoderMethod() string { | ||
if ctx.internalMethods { | ||
return "decodeRLP" | ||
} | ||
return "DecodeRLP" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters