From 8de911d3563bfc87b4fcd3a6efc7363216f5ea0e Mon Sep 17 00:00:00 2001 From: taratorio <94537774+taratorio@users.noreply.github.com> Date: Sun, 28 Apr 2024 16:08:58 +0300 Subject: [PATCH] make: add gen commands --- Makefile | 32 +++++++++++++++++++++++++++----- core/types/withdrawal.go | 5 ++--- eth/tracers/native/call.go | 3 +-- eth/tracers/native/prestate.go | 5 ++--- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index b5b581d1042..5d1c2a23b04 100644 --- a/Makefile +++ b/Makefile @@ -204,11 +204,6 @@ devtools: $(GOBUILD) -o $(GOBIN)/mockgen go.uber.org/mock/mockgen $(GOBUILD) -o $(GOBIN)/abigen ./cmd/abigen $(GOBUILD) -o $(GOBIN)/codecgen github.com/ugorji/go/codec/codecgen - PATH=$(GOBIN):$(PATH) go generate ./common -# PATH=$(GOBIN):$(PATH) go generate ./core/types - PATH=$(GOBIN):$(PATH) cd ./cmd/rpcdaemon/graphql && go run github.com/99designs/gqlgen . - PATH=$(GOBIN):$(PATH) go generate ./consensus/aura/... - #PATH=$(GOBIN):$(PATH) go generate ./eth/ethconfig/... @type "npm" 2> /dev/null || echo 'Please install node.js and npm' @type "solc" 2> /dev/null || echo 'Please install solc' @type "protoc" 2> /dev/null || echo 'Please install protoc' @@ -223,6 +218,33 @@ mocks: mocks-clean mocks-clean: grep -r -l --exclude-dir=erigon-lib "^// Code generated by MockGen. DO NOT EDIT.$$" . | xargs rm -r +## solc: generate all solidity contracts +solc: + PATH="$(GOBIN):$(PATH)" go generate -run "solc" ./... + +## abigen: generate abis using abigen +abigen: + $(GOBUILD) -o $(GOBIN)/abigen ./cmd/abigen + PATH="$(GOBIN):$(PATH)" go generate -run "abigen" ./... + +## gencodec: generate marshalling code using gencodec +gencodec: + $(GOBUILD) -o $(GOBIN)/gencodec github.com/fjl/gencodec + PATH="$(GOBIN):$(PATH)" go generate -run "gencodec" ./... + +## codecgen: generate encoder/decoder code using codecgen +codecgen: + $(GOBUILD) -o $(GOBIN)/codecgen github.com/ugorji/go/codec/codecgen + PATH="$(GOBIN):$(PATH)" go generate -run "codecgen" ./... + +## graphql: generate graphql code +graphql: + PATH=$(GOBIN):$(PATH) cd ./cmd/rpcdaemon/graphql && go run github.com/99designs/gqlgen . + +## gen: generate all auto-generated code in the codebase +gen: mocks solc abigen gencodec codecgen graphql + @cd erigon-lib && $(MAKE) gen + ## bindings: generate test contracts and core contracts bindings: PATH=$(GOBIN):$(PATH) go generate ./tests/contracts/ diff --git a/core/types/withdrawal.go b/core/types/withdrawal.go index 5dede6a0abc..286a6e75fce 100644 --- a/core/types/withdrawal.go +++ b/core/types/withdrawal.go @@ -19,16 +19,15 @@ package types import ( "bytes" "fmt" - "github.com/ledgerwatch/erigon-lib/common/hexutil" "io" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutil" "github.com/ledgerwatch/erigon-lib/types/clonable" - "github.com/ledgerwatch/erigon/rlp" ) -//go:generate go run github.com/fjl/gencodec -type Withdrawal -field-override withdrawalMarshaling -out gen_withdrawal_json.go +//go:generate gencodec -type Withdrawal -field-override withdrawalMarshaling -out gen_withdrawal_json.go // Withdrawal represents a validator withdrawal from the consensus layer. // See EIP-4895: Beacon chain push withdrawals as operations. diff --git a/eth/tracers/native/call.go b/eth/tracers/native/call.go index 5b136723e3a..7f3c2321a39 100644 --- a/eth/tracers/native/call.go +++ b/eth/tracers/native/call.go @@ -27,13 +27,12 @@ import ( libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/common/hexutil" "github.com/ledgerwatch/erigon-lib/common/hexutility" - "github.com/ledgerwatch/erigon/accounts/abi" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/eth/tracers" ) -//go:generate go run github.com/fjl/gencodec -type callFrame -field-override callFrameMarshaling -out gen_callframe_json.go +//go:generate gencodec -type callFrame -field-override callFrameMarshaling -out gen_callframe_json.go func init() { register("callTracer", newCallTracer) diff --git a/eth/tracers/native/prestate.go b/eth/tracers/native/prestate.go index 133ca8bcc8a..7c713d6d5a5 100644 --- a/eth/tracers/native/prestate.go +++ b/eth/tracers/native/prestate.go @@ -19,21 +19,20 @@ package native import ( "bytes" "encoding/json" - "github.com/ledgerwatch/erigon-lib/common/hexutil" "math/big" "sync/atomic" "github.com/holiman/uint256" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutil" "github.com/ledgerwatch/erigon-lib/common/hexutility" - "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/eth/tracers" ) -//go:generate go run github.com/fjl/gencodec -type account -field-override accountMarshaling -out gen_account_json.go +//go:generate gencodec -type account -field-override accountMarshaling -out gen_account_json.go func init() { register("prestateTracer", newPrestateTracer)