From 02f6cac7b761c2bff350292b158c79fe84720fde Mon Sep 17 00:00:00 2001 From: Andrew Ashikhmin <34320705+yperbasis@users.noreply.github.com> Date: Thu, 13 Apr 2023 13:19:02 +0200 Subject: [PATCH] Move hexutil.Bytes to erigon-lib (#7305) --- cmd/devnet/commands/block.go | 4 +- cmd/devnet/devnetutils/utils.go | 4 +- cmd/evm/internal/t8ntool/transition.go | 9 ++- cmd/rpcdaemon/commands/db_api_deprecated.go | 12 +-- cmd/rpcdaemon/commands/debug_api.go | 13 ++-- cmd/rpcdaemon/commands/engine_api.go | 27 +++---- cmd/rpcdaemon/commands/eth_accounts.go | 6 +- cmd/rpcdaemon/commands/eth_api.go | 25 ++++--- cmd/rpcdaemon/commands/eth_call.go | 8 +- cmd/rpcdaemon/commands/eth_callMany_test.go | 8 +- cmd/rpcdaemon/commands/eth_call_test.go | 19 +++-- cmd/rpcdaemon/commands/eth_deprecated.go | 7 +- cmd/rpcdaemon/commands/eth_txs.go | 7 +- cmd/rpcdaemon/commands/otterscan_api.go | 6 +- .../commands/otterscan_trace_transaction.go | 14 ++-- .../commands/otterscan_transaction_error.go | 5 +- cmd/rpcdaemon/commands/parity_api.go | 8 +- cmd/rpcdaemon/commands/parity_api_test.go | 11 +-- cmd/rpcdaemon/commands/send_transaction.go | 4 +- cmd/rpcdaemon/commands/trace_adhoc.go | 20 ++--- cmd/rpcdaemon/commands/trace_types.go | 55 +++++++------- cmd/rpcdaemon/commands/web3_api.go | 7 +- cmd/rpcdaemon/graphql/graph/helpers.go | 5 +- cmd/rpctest/rpctest/bench_tracecallmany.go | 3 +- cmd/rpctest/rpctest/request_generator.go | 14 ++-- cmd/rpctest/rpctest/type.go | 27 +++---- common/hexutil/json.go | 45 ----------- common/hexutil/json_example_test.go | 4 +- common/hexutil/json_test.go | 74 ------------------- consensus/aura/config.go | 4 +- consensus/aura/consensusconfig/kovan.json | 36 --------- consensus/bor/clerk/clerk.go | 5 +- consensus/parlia/parlia.go | 21 +++--- core/state/dump.go | 20 ++--- core/types/accounts/account_proof.go | 22 +++--- core/types/block.go | 4 +- core/types/bloom9.go | 3 +- core/types/gen_erigon_log_json.go | 5 +- core/types/gen_genesis.go | 6 +- core/types/gen_genesis_account.go | 14 ++-- core/types/gen_header_json.go | 5 +- core/types/gen_log_json.go | 5 +- core/types/gen_receipt_json.go | 5 +- core/types/genesis.go | 13 ++-- core/types/log.go | 3 +- core/types/receipt.go | 3 +- core/types/transaction_marshalling.go | 14 ++-- .../internal/tracetest/calltrace_test.go | 9 ++- eth/tracers/logger/gen_structlog.go | 10 +-- eth/tracers/logger/logger.go | 7 +- eth/tracers/native/call.go | 10 ++- eth/tracers/native/gen_account_json.go | 5 +- eth/tracers/native/gen_callframe_json.go | 9 ++- eth/tracers/native/prestate.go | 4 +- go.mod | 2 +- go.sum | 4 +- params/mining.go | 5 +- tests/block_test_util.go | 5 +- tests/gen_btheader.go | 6 +- tests/state_test_util.go | 11 +-- tests/transaction_test_util.go | 9 ++- turbo/adapter/ethapi/api.go | 12 +-- 62 files changed, 320 insertions(+), 427 deletions(-) delete mode 100644 consensus/aura/consensusconfig/kovan.json diff --git a/cmd/devnet/commands/block.go b/cmd/devnet/commands/block.go index 0afb72388..da7cd8c97 100644 --- a/cmd/devnet/commands/block.go +++ b/cmd/devnet/commands/block.go @@ -5,6 +5,8 @@ import ( "time" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" + "github.com/ledgerwatch/erigon/cmd/devnet/devnetutils" "github.com/ledgerwatch/erigon/cmd/devnet/models" "github.com/ledgerwatch/erigon/cmd/devnet/requests" @@ -153,7 +155,7 @@ func callContractTx() (*libcommon.Hash, error) { } expectedLog := devnetutils.BuildLog(*eventHash, blockNum, address, - devnetutils.GenerateTopic(models.SolContractMethodSignature), hexutil.Bytes{}, hexutil.Uint(1), + devnetutils.GenerateTopic(models.SolContractMethodSignature), hexutility.Bytes{}, hexutil.Uint(1), block.Result.Hash, hexutil.Uint(0), false) if err = requests.GetAndCompareLogs(models.ReqId, 0, 20, expectedLog); err != nil { diff --git a/cmd/devnet/devnetutils/utils.go b/cmd/devnet/devnetutils/utils.go index ba94f300a..790731993 100644 --- a/cmd/devnet/devnetutils/utils.go +++ b/cmd/devnet/devnetutils/utils.go @@ -10,6 +10,8 @@ import ( "strings" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" + "github.com/ledgerwatch/erigon/cmd/devnet/models" "github.com/ledgerwatch/erigon/cmd/rpctest/rpctest" "github.com/ledgerwatch/erigon/common/hexutil" @@ -116,7 +118,7 @@ func HashSlicesAreEqual(s1, s2 []libcommon.Hash) bool { return true } -func BuildLog(hash libcommon.Hash, blockNum string, address libcommon.Address, topics []libcommon.Hash, data hexutil.Bytes, txIndex hexutil.Uint, blockHash libcommon.Hash, index hexutil.Uint, removed bool) rpctest.Log { +func BuildLog(hash libcommon.Hash, blockNum string, address libcommon.Address, topics []libcommon.Hash, data hexutility.Bytes, txIndex hexutil.Uint, blockHash libcommon.Hash, index hexutil.Uint, removed bool) rpctest.Log { return rpctest.Log{ Address: address, Topics: topics, diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go index 757786c3c..86380fee6 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -28,18 +28,19 @@ import ( "path/filepath" "github.com/holiman/uint256" + "github.com/ledgerwatch/log/v3" + "github.com/urfave/cli/v2" + "github.com/ledgerwatch/erigon-lib/chain" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/common/length" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv/kvcfg" "github.com/ledgerwatch/erigon-lib/kv/memdb" - "github.com/ledgerwatch/log/v3" - "github.com/urfave/cli/v2" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/commands" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/consensus/ethash" "github.com/ledgerwatch/erigon/core" @@ -525,7 +526,7 @@ func saveFile(baseDir, filename string, data interface{}) error { // dispatchOutput writes the output data to either stderr or stdout, or to the specified // files -func dispatchOutput(ctx *cli.Context, baseDir string, result *core.EphemeralExecResult, alloc Alloc, body hexutil.Bytes) error { +func dispatchOutput(ctx *cli.Context, baseDir string, result *core.EphemeralExecResult, alloc Alloc, body hexutility.Bytes) error { stdOutObject := make(map[string]interface{}) stdErrObject := make(map[string]interface{}) dispatch := func(baseDir, fName, name string, obj interface{}) error { diff --git a/cmd/rpcdaemon/commands/db_api_deprecated.go b/cmd/rpcdaemon/commands/db_api_deprecated.go index 886987e05..2ee0700a3 100644 --- a/cmd/rpcdaemon/commands/db_api_deprecated.go +++ b/cmd/rpcdaemon/commands/db_api_deprecated.go @@ -4,15 +4,15 @@ import ( "context" "fmt" - "github.com/ledgerwatch/erigon/common/hexutil" + "github.com/ledgerwatch/erigon-lib/common/hexutility" ) // DBAPI the interface for the db_ RPC commands (deprecated) type DBAPI interface { GetString(_ context.Context, _ string, _ string) (string, error) PutString(_ context.Context, _ string, _ string, _ string) (bool, error) - GetHex(_ context.Context, _ string, _ string) (hexutil.Bytes, error) - PutHex(_ context.Context, _ string, _ string, _ hexutil.Bytes) (bool, error) + GetHex(_ context.Context, _ string, _ string) (hexutility.Bytes, error) + PutHex(_ context.Context, _ string, _ string, _ hexutility.Bytes) (bool, error) } // DBAPIImpl data structure to store things needed for db_ commands @@ -41,12 +41,12 @@ func (api *DBAPIImpl) PutString(_ context.Context, _ string, _ string, _ string) // GetHex implements db_getHex. Returns binary data from the local database. // Deprecated: This function will be removed in the future. -func (api *DBAPIImpl) GetHex(_ context.Context, _ string, _ string) (hexutil.Bytes, error) { - return hexutil.Bytes(""), fmt.Errorf(NotAvailableDeprecated, "db_getHex") +func (api *DBAPIImpl) GetHex(_ context.Context, _ string, _ string) (hexutility.Bytes, error) { + return hexutility.Bytes(""), fmt.Errorf(NotAvailableDeprecated, "db_getHex") } // PutHex implements db_putHex. Stores binary data in the local database. // Deprecated: This function will be removed in the future. -func (api *DBAPIImpl) PutHex(_ context.Context, _ string, _ string, _ hexutil.Bytes) (bool, error) { +func (api *DBAPIImpl) PutHex(_ context.Context, _ string, _ string, _ hexutility.Bytes) (bool, error) { return false, fmt.Errorf(NotAvailableDeprecated, "db_putHex") } diff --git a/cmd/rpcdaemon/commands/debug_api.go b/cmd/rpcdaemon/commands/debug_api.go index 5b5ed20f9..e7d6ac510 100644 --- a/cmd/rpcdaemon/commands/debug_api.go +++ b/cmd/rpcdaemon/commands/debug_api.go @@ -6,6 +6,7 @@ import ( jsoniter "github.com/json-iterator/go" "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv/order" "github.com/ledgerwatch/erigon-lib/kv/rawdbv3" @@ -27,7 +28,7 @@ const AccountRangeMaxResults = 256 // PrivateDebugAPI Exposed RPC endpoints for debugging use type PrivateDebugAPI interface { - StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex uint64, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error) + StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex uint64, contractAddress common.Address, keyStart hexutility.Bytes, maxResult int) (StorageRangeResult, error) TraceTransaction(ctx context.Context, hash common.Hash, config *tracers.TraceConfig, stream *jsoniter.Stream) error TraceBlockByHash(ctx context.Context, hash common.Hash, config *tracers.TraceConfig, stream *jsoniter.Stream) error TraceBlockByNumber(ctx context.Context, number rpc.BlockNumber, config *tracers.TraceConfig, stream *jsoniter.Stream) error @@ -55,7 +56,7 @@ func NewPrivateDebugAPI(base *BaseAPI, db kv.RoDB, gascap uint64) *PrivateDebugA } // storageRangeAt implements debug_storageRangeAt. Returns information about a range of storage locations (if any) for the given address. -func (api *PrivateDebugAPIImpl) StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex uint64, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error) { +func (api *PrivateDebugAPIImpl) StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex uint64, contractAddress common.Address, keyStart hexutility.Bytes, maxResult int) (StorageRangeResult, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return StorageRangeResult{}, err @@ -355,8 +356,8 @@ func (api *PrivateDebugAPIImpl) AccountAt(ctx context.Context, blockHash common. } type AccountResult struct { - Balance hexutil.Big `json:"balance"` - Nonce hexutil.Uint64 `json:"nonce"` - Code hexutil.Bytes `json:"code"` - CodeHash common.Hash `json:"codeHash"` + Balance hexutil.Big `json:"balance"` + Nonce hexutil.Uint64 `json:"nonce"` + Code hexutility.Bytes `json:"code"` + CodeHash common.Hash `json:"codeHash"` } diff --git a/cmd/rpcdaemon/commands/engine_api.go b/cmd/rpcdaemon/commands/engine_api.go index 342c55c2e..b50e21c23 100644 --- a/cmd/rpcdaemon/commands/engine_api.go +++ b/cmd/rpcdaemon/commands/engine_api.go @@ -10,6 +10,7 @@ import ( "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/gointerfaces" "github.com/ledgerwatch/erigon-lib/gointerfaces/remote" types2 "github.com/ledgerwatch/erigon-lib/gointerfaces/types" @@ -29,16 +30,16 @@ type ExecutionPayload struct { FeeRecipient common.Address `json:"feeRecipient" gencodec:"required"` StateRoot common.Hash `json:"stateRoot" gencodec:"required"` ReceiptsRoot common.Hash `json:"receiptsRoot" gencodec:"required"` - LogsBloom hexutil.Bytes `json:"logsBloom" gencodec:"required"` + LogsBloom hexutility.Bytes `json:"logsBloom" gencodec:"required"` PrevRandao common.Hash `json:"prevRandao" gencodec:"required"` BlockNumber hexutil.Uint64 `json:"blockNumber" gencodec:"required"` GasLimit hexutil.Uint64 `json:"gasLimit" gencodec:"required"` GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"` Timestamp hexutil.Uint64 `json:"timestamp" gencodec:"required"` - ExtraData hexutil.Bytes `json:"extraData" gencodec:"required"` + ExtraData hexutility.Bytes `json:"extraData" gencodec:"required"` BaseFeePerGas *hexutil.Big `json:"baseFeePerGas" gencodec:"required"` BlockHash common.Hash `json:"blockHash" gencodec:"required"` - Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"` + Transactions []hexutility.Bytes `json:"transactions" gencodec:"required"` Withdrawals []*types.Withdrawal `json:"withdrawals"` ExcessDataGas *hexutil.Big `json:"excessDataGas"` } @@ -72,7 +73,7 @@ type TransitionConfiguration struct { } type ExecutionPayloadBodyV1 struct { - Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"` + Transactions []hexutility.Bytes `json:"transactions" gencodec:"required"` Withdrawals []*types.Withdrawal `json:"withdrawals" gencodec:"required"` } @@ -82,8 +83,8 @@ type EngineAPI interface { NewPayloadV2(context.Context, *ExecutionPayload) (map[string]interface{}, error) ForkchoiceUpdatedV1(ctx context.Context, forkChoiceState *ForkChoiceState, payloadAttributes *PayloadAttributes) (map[string]interface{}, error) ForkchoiceUpdatedV2(ctx context.Context, forkChoiceState *ForkChoiceState, payloadAttributes *PayloadAttributes) (map[string]interface{}, error) - GetPayloadV1(ctx context.Context, payloadID hexutil.Bytes) (*ExecutionPayload, error) - GetPayloadV2(ctx context.Context, payloadID hexutil.Bytes) (*GetPayloadV2Response, error) + GetPayloadV1(ctx context.Context, payloadID hexutility.Bytes) (*ExecutionPayload, error) + GetPayloadV2(ctx context.Context, payloadID hexutility.Bytes) (*GetPayloadV2Response, error) ExchangeTransitionConfigurationV1(ctx context.Context, transitionConfiguration *TransitionConfiguration) (*TransitionConfiguration, error) GetPayloadBodiesByHashV1(ctx context.Context, hashes []common.Hash) ([]*ExecutionPayloadBodyV1, error) GetPayloadBodiesByRangeV1(ctx context.Context, start, count hexutil.Uint64) ([]*ExecutionPayloadBodyV1, error) @@ -140,7 +141,7 @@ func addPayloadId(json map[string]interface{}, payloadId uint64) { if payloadId != 0 { encodedPayloadId := make([]byte, 8) binary.BigEndian.PutUint64(encodedPayloadId, payloadId) - json["payloadId"] = hexutil.Bytes(encodedPayloadId) + json["payloadId"] = hexutility.Bytes(encodedPayloadId) } } @@ -242,7 +243,7 @@ func (e *EngineImpl) newPayload(version uint32, ctx context.Context, payload *Ex return nil, fmt.Errorf("invalid request") } - // Convert slice of hexutil.Bytes to a slice of slice of bytes + // Convert slice of hexutility.Bytes to a slice of slice of bytes transactions := make([][]byte, len(payload.Transactions)) for i, transaction := range payload.Transactions { transactions[i] = transaction @@ -292,8 +293,8 @@ func convertPayloadFromRpc(payload *types2.ExecutionPayload) *ExecutionPayload { var bloom types.Bloom = gointerfaces.ConvertH2048ToBloom(payload.LogsBloom) baseFee := gointerfaces.ConvertH256ToUint256Int(payload.BaseFeePerGas).ToBig() - // Convert slice of hexutil.Bytes to a slice of slice of bytes - transactions := make([]hexutil.Bytes, len(payload.Transactions)) + // Convert slice of hexutility.Bytes to a slice of slice of bytes + transactions := make([]hexutility.Bytes, len(payload.Transactions)) for i, transaction := range payload.Transactions { transactions[i] = transaction } @@ -324,7 +325,7 @@ func convertPayloadFromRpc(payload *types2.ExecutionPayload) *ExecutionPayload { return res } -func (e *EngineImpl) GetPayloadV1(ctx context.Context, payloadID hexutil.Bytes) (*ExecutionPayload, error) { +func (e *EngineImpl) GetPayloadV1(ctx context.Context, payloadID hexutility.Bytes) (*ExecutionPayload, error) { if e.internalCL { log.Error("EXTERNAL CONSENSUS LAYER IS NOT ENABLED, PLEASE RESTART WITH FLAG --externalcl") return nil, fmt.Errorf("engine api should not be used, restart with --externalcl") @@ -341,7 +342,7 @@ func (e *EngineImpl) GetPayloadV1(ctx context.Context, payloadID hexutil.Bytes) return convertPayloadFromRpc(response.ExecutionPayload), nil } -func (e *EngineImpl) GetPayloadV2(ctx context.Context, payloadID hexutil.Bytes) (*GetPayloadV2Response, error) { +func (e *EngineImpl) GetPayloadV2(ctx context.Context, payloadID hexutility.Bytes) (*GetPayloadV2Response, error) { if e.internalCL { log.Error("EXTERNAL CONSENSUS LAYER IS NOT ENABLED, PLEASE RESTART WITH FLAG --externalcl") return nil, fmt.Errorf("engine api should not be used, restart with --externalcl") @@ -482,7 +483,7 @@ func convertExecutionPayloadV1(response *remote.EngineGetPayloadBodiesV1Response result[idx] = nil } else { pl := &ExecutionPayloadBodyV1{ - Transactions: make([]hexutil.Bytes, len(body.Transactions)), + Transactions: make([]hexutility.Bytes, len(body.Transactions)), Withdrawals: privateapi.ConvertWithdrawalsFromRpc(body.Withdrawals), } for i := range body.Transactions { diff --git a/cmd/rpcdaemon/commands/eth_accounts.go b/cmd/rpcdaemon/commands/eth_accounts.go index 8594ad600..40feb36b6 100644 --- a/cmd/rpcdaemon/commands/eth_accounts.go +++ b/cmd/rpcdaemon/commands/eth_accounts.go @@ -75,7 +75,7 @@ func (api *APIImpl) GetTransactionCount(ctx context.Context, address libcommon.A } // GetCode implements eth_getCode. Returns the byte code at a given address (if it's a smart contract). -func (api *APIImpl) GetCode(ctx context.Context, address libcommon.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { +func (api *APIImpl) GetCode(ctx context.Context, address libcommon.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutility.Bytes, error) { tx, err1 := api.db.BeginRo(ctx) if err1 != nil { return nil, fmt.Errorf("getCode cannot open tx: %w", err1) @@ -92,11 +92,11 @@ func (api *APIImpl) GetCode(ctx context.Context, address libcommon.Address, bloc acc, err := reader.ReadAccountData(address) if acc == nil || err != nil { - return hexutil.Bytes(""), nil + return hexutility.Bytes(""), nil } res, _ := reader.ReadAccountCode(address, acc.Incarnation, acc.CodeHash) if res == nil { - return hexutil.Bytes(""), nil + return hexutility.Bytes(""), nil } return res, nil } diff --git a/cmd/rpcdaemon/commands/eth_api.go b/cmd/rpcdaemon/commands/eth_api.go index ca04f1feb..ce8951023 100644 --- a/cmd/rpcdaemon/commands/eth_api.go +++ b/cmd/rpcdaemon/commands/eth_api.go @@ -11,10 +11,12 @@ import ( lru "github.com/hashicorp/golang-lru/v2" "github.com/holiman/uint256" + "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/erigon-lib/chain" "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/common/datadir" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv/kvcache" @@ -35,7 +37,6 @@ import ( ethapi2 "github.com/ledgerwatch/erigon/turbo/adapter/ethapi" "github.com/ledgerwatch/erigon/turbo/rpchelper" "github.com/ledgerwatch/erigon/turbo/services" - "github.com/ledgerwatch/log/v3" ) // EthAPI is a collection of functions that are exposed in the @@ -50,9 +51,9 @@ type EthAPI interface { GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, txIndex hexutil.Uint64) (*RPCTransaction, error) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, txIndex hexutil.Uint) (*RPCTransaction, error) - GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (hexutil.Bytes, error) - GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) (hexutil.Bytes, error) - GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) + GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (hexutility.Bytes, error) + GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) (hexutility.Bytes, error) + GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutility.Bytes, error) // Receipt related (see ./eth_receipts.go) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) @@ -78,7 +79,7 @@ type EthAPI interface { GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error) GetTransactionCount(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error) GetStorageAt(ctx context.Context, address common.Address, index string, blockNrOrHash rpc.BlockNumberOrHash) (string, error) - GetCode(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) + GetCode(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutility.Bytes, error) // System related (see ./eth_system.go) BlockNumber(ctx context.Context) (hexutil.Uint64, error) @@ -88,11 +89,11 @@ type EthAPI interface { GasPrice(_ context.Context) (*hexutil.Big, error) // Sending related (see ./eth_call.go) - Call(ctx context.Context, args ethapi2.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *ethapi2.StateOverrides) (hexutil.Bytes, error) + Call(ctx context.Context, args ethapi2.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *ethapi2.StateOverrides) (hexutility.Bytes, error) EstimateGas(ctx context.Context, argsOrNil *ethapi2.CallArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error) - SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) + SendRawTransaction(ctx context.Context, encodedTx hexutility.Bytes) (common.Hash, error) SendTransaction(_ context.Context, txObject interface{}) (common.Hash, error) - Sign(ctx context.Context, _ common.Address, _ hexutil.Bytes) (hexutil.Bytes, error) + Sign(ctx context.Context, _ common.Address, _ hexutility.Bytes) (hexutility.Bytes, error) SignTransaction(_ context.Context, txObject interface{}) (common.Hash, error) GetProof(ctx context.Context, address common.Address, storageKeys []common.Hash, blockNr rpc.BlockNumberOrHash) (*accounts.AccProofResult, error) CreateAccessList(ctx context.Context, args ethapi2.CallArgs, blockNrOrHash *rpc.BlockNumberOrHash, optimizeGas *bool) (*accessListResult, error) @@ -350,7 +351,7 @@ type RPCTransaction struct { Tip *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"` FeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"` Hash common.Hash `json:"hash"` - Input hexutil.Bytes `json:"input"` + Input hexutility.Bytes `json:"input"` Nonce hexutil.Uint64 `json:"nonce"` To *common.Address `json:"to"` TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` @@ -375,7 +376,7 @@ func newRPCTransaction(tx types.Transaction, blockHash common.Hash, blockNumber Type: hexutil.Uint64(tx.Type()), Gas: hexutil.Uint64(tx.GetGas()), Hash: tx.Hash(), - Input: hexutil.Bytes(tx.GetData()), + Input: hexutility.Bytes(tx.GetData()), Nonce: hexutil.Uint64(tx.GetNonce()), To: tx.GetTo(), Value: (*hexutil.Big)(tx.GetValue().ToBig()), @@ -437,7 +438,7 @@ func newRPCBorTransaction(opaqueTx types.Transaction, txHash common.Hash, blockH GasPrice: (*hexutil.Big)(tx.GasPrice.ToBig()), Gas: hexutil.Uint64(tx.GetGas()), Hash: txHash, - Input: hexutil.Bytes(tx.GetData()), + Input: hexutility.Bytes(tx.GetData()), Nonce: hexutil.Uint64(tx.GetNonce()), From: common.Address{}, To: tx.GetTo(), @@ -465,7 +466,7 @@ func newRPCPendingTransaction(tx types.Transaction, current *types.Header, confi } // newRPCRawTransactionFromBlockIndex returns the bytes of a transaction given a block and a transaction index. -func newRPCRawTransactionFromBlockIndex(b *types.Block, index uint64) (hexutil.Bytes, error) { +func newRPCRawTransactionFromBlockIndex(b *types.Block, index uint64) (hexutility.Bytes, error) { txs := b.Transactions() if index >= uint64(len(txs)) { return nil, nil diff --git a/cmd/rpcdaemon/commands/eth_call.go b/cmd/rpcdaemon/commands/eth_call.go index 4d4944b68..f9ab76249 100644 --- a/cmd/rpcdaemon/commands/eth_call.go +++ b/cmd/rpcdaemon/commands/eth_call.go @@ -7,14 +7,16 @@ import ( "math/big" "github.com/holiman/uint256" + "github.com/ledgerwatch/log/v3" + "google.golang.org/grpc" + libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/gointerfaces" txpool_proto "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv/memdb" types2 "github.com/ledgerwatch/erigon-lib/types" - "github.com/ledgerwatch/log/v3" - "google.golang.org/grpc" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core" @@ -36,7 +38,7 @@ import ( var latestNumOrHash = rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber) // Call implements eth_call. Executes a new message call immediately without creating a transaction on the block chain. -func (api *APIImpl) Call(ctx context.Context, args ethapi2.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *ethapi2.StateOverrides) (hexutil.Bytes, error) { +func (api *APIImpl) Call(ctx context.Context, args ethapi2.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *ethapi2.StateOverrides) (hexutility.Bytes, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err diff --git a/cmd/rpcdaemon/commands/eth_callMany_test.go b/cmd/rpcdaemon/commands/eth_callMany_test.go index 0a1fd3666..4dbeb9488 100644 --- a/cmd/rpcdaemon/commands/eth_callMany_test.go +++ b/cmd/rpcdaemon/commands/eth_callMany_test.go @@ -9,7 +9,9 @@ import ( "testing" "github.com/ledgerwatch/erigon-lib/common/datadir" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/kv/kvcache" + "github.com/ledgerwatch/erigon/accounts/abi/bind" "github.com/ledgerwatch/erigon/accounts/abi/bind/backends" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/commands/contracts" @@ -56,11 +58,11 @@ func TestCallMany(t *testing.T) { ) hexBytes, _ := hex.DecodeString(addr2BalanceCheck) - balanceCallAddr2 := hexutil.Bytes(hexBytes) + balanceCallAddr2 := hexutility.Bytes(hexBytes) hexBytes, _ = hex.DecodeString(addr1BalanceCheck) - balanceCallAddr1 := hexutil.Bytes(hexBytes) + balanceCallAddr1 := hexutility.Bytes(hexBytes) hexBytes, _ = hex.DecodeString(transferAddr2) - transferCallData := hexutil.Bytes(hexBytes) + transferCallData := hexutility.Bytes(hexBytes) //submit 3 Transactions and commit the results transactOpts, _ := bind.NewKeyedTransactorWithChainID(key, chainID) diff --git a/cmd/rpcdaemon/commands/eth_call_test.go b/cmd/rpcdaemon/commands/eth_call_test.go index 05f2de9cc..89099e770 100644 --- a/cmd/rpcdaemon/commands/eth_call_test.go +++ b/cmd/rpcdaemon/commands/eth_call_test.go @@ -7,18 +7,13 @@ import ( "testing" "time" - libcommon "github.com/ledgerwatch/erigon-lib/common" - "github.com/ledgerwatch/erigon-lib/common/length" - "github.com/ledgerwatch/erigon/turbo/trie" - - "github.com/ledgerwatch/erigon/rlp" - "github.com/ledgerwatch/erigon/rpc/rpccfg" - "github.com/ledgerwatch/erigon/turbo/adapter/ethapi" - "github.com/holiman/uint256" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" + "github.com/ledgerwatch/erigon-lib/common/length" "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv/kvcache" @@ -33,10 +28,14 @@ import ( "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/erigon/rpc/rpccfg" + "github.com/ledgerwatch/erigon/turbo/adapter/ethapi" "github.com/ledgerwatch/erigon/turbo/rpchelper" "github.com/ledgerwatch/erigon/turbo/snapshotsync" "github.com/ledgerwatch/erigon/turbo/stages" + "github.com/ledgerwatch/erigon/turbo/trie" ) func TestEstimateGas(t *testing.T) { @@ -91,7 +90,7 @@ func TestEthCallToPrunedBlock(t *testing.T) { api := NewEthAPI(NewBaseApi(nil, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine, m.Dirs), m.DB, nil, nil, nil, 5000000, 100_000) callData := hexutil.MustDecode("0x2e64cec1") - callDataBytes := hexutil.Bytes(callData) + callDataBytes := hexutility.Bytes(callData) if _, err := api.Call(context.Background(), ethapi.CallArgs{ From: &bankAddress, @@ -184,7 +183,7 @@ func decodeNode(t *testing.T, encoded []byte) any { } // proofMap creates a map from hash to proof node -func proofMap(t *testing.T, proof []hexutil.Bytes) (map[libcommon.Hash]any, map[libcommon.Hash][]byte) { +func proofMap(t *testing.T, proof []hexutility.Bytes) (map[libcommon.Hash]any, map[libcommon.Hash][]byte) { res := map[libcommon.Hash]any{} raw := map[libcommon.Hash][]byte{} for _, proofB := range proof { diff --git a/cmd/rpcdaemon/commands/eth_deprecated.go b/cmd/rpcdaemon/commands/eth_deprecated.go index 16a8553d2..6c59ba83e 100644 --- a/cmd/rpcdaemon/commands/eth_deprecated.go +++ b/cmd/rpcdaemon/commands/eth_deprecated.go @@ -5,8 +5,7 @@ import ( "fmt" "github.com/ledgerwatch/erigon-lib/common" - - "github.com/ledgerwatch/erigon/common/hexutil" + "github.com/ledgerwatch/erigon-lib/common/hexutility" ) // Accounts implements eth_accounts. Returns a list of addresses owned by the client. @@ -17,8 +16,8 @@ func (api *APIImpl) Accounts(ctx context.Context) ([]common.Address, error) { // Sign implements eth_sign. Calculates an Ethereum specific signature with: sign(keccak256('\\x19Ethereum Signed Message:\\n' + len(message) + message))). // Deprecated: This function will be removed in the future. -func (api *APIImpl) Sign(ctx context.Context, _ common.Address, _ hexutil.Bytes) (hexutil.Bytes, error) { - return hexutil.Bytes(""), fmt.Errorf(NotAvailableDeprecated, "eth_sign") +func (api *APIImpl) Sign(ctx context.Context, _ common.Address, _ hexutility.Bytes) (hexutility.Bytes, error) { + return hexutility.Bytes(""), fmt.Errorf(NotAvailableDeprecated, "eth_sign") } // SignTransaction deprecated diff --git a/cmd/rpcdaemon/commands/eth_txs.go b/cmd/rpcdaemon/commands/eth_txs.go index 527798a36..21fe98462 100644 --- a/cmd/rpcdaemon/commands/eth_txs.go +++ b/cmd/rpcdaemon/commands/eth_txs.go @@ -6,6 +6,7 @@ import ( "math/big" "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/gointerfaces" "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/erigon-lib/gointerfaces/types" @@ -117,7 +118,7 @@ func (api *APIImpl) GetTransactionByHash(ctx context.Context, txnHash common.Has } // GetRawTransactionByHash returns the bytes of the transaction for the given hash. -func (api *APIImpl) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) { +func (api *APIImpl) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutility.Bytes, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err @@ -204,7 +205,7 @@ func (api *APIImpl) GetTransactionByBlockHashAndIndex(ctx context.Context, block } // GetRawTransactionByBlockHashAndIndex returns the bytes of the transaction for the given block hash and index. -func (api *APIImpl) GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) (hexutil.Bytes, error) { +func (api *APIImpl) GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) (hexutility.Bytes, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err @@ -268,7 +269,7 @@ func (api *APIImpl) GetTransactionByBlockNumberAndIndex(ctx context.Context, blo } // GetRawTransactionByBlockNumberAndIndex returns the bytes of the transaction for the given block number and index. -func (api *APIImpl) GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (hexutil.Bytes, error) { +func (api *APIImpl) GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (hexutility.Bytes, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err diff --git a/cmd/rpcdaemon/commands/otterscan_api.go b/cmd/rpcdaemon/commands/otterscan_api.go index a7dd7e12e..9c9752725 100644 --- a/cmd/rpcdaemon/commands/otterscan_api.go +++ b/cmd/rpcdaemon/commands/otterscan_api.go @@ -8,14 +8,16 @@ import ( "sync" "github.com/holiman/uint256" + "github.com/ledgerwatch/log/v3" + "github.com/ledgerwatch/erigon-lib/chain" "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv/iter" "github.com/ledgerwatch/erigon-lib/kv/order" "github.com/ledgerwatch/erigon-lib/kv/rawdbv3" "github.com/ledgerwatch/erigon/core/state/temporal" - "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/consensus/ethash" @@ -49,7 +51,7 @@ type OtterscanAPI interface { GetBlockTransactions(ctx context.Context, number rpc.BlockNumber, pageNumber uint8, pageSize uint8) (map[string]interface{}, error) HasCode(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (bool, error) TraceTransaction(ctx context.Context, hash common.Hash) ([]*TraceEntry, error) - GetTransactionError(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) + GetTransactionError(ctx context.Context, hash common.Hash) (hexutility.Bytes, error) GetTransactionBySenderAndNonce(ctx context.Context, addr common.Address, nonce uint64) (*common.Hash, error) GetContractCreator(ctx context.Context, addr common.Address) (*ContractCreatorData, error) } diff --git a/cmd/rpcdaemon/commands/otterscan_trace_transaction.go b/cmd/rpcdaemon/commands/otterscan_trace_transaction.go index 79767ec5c..9778c69c9 100644 --- a/cmd/rpcdaemon/commands/otterscan_trace_transaction.go +++ b/cmd/rpcdaemon/commands/otterscan_trace_transaction.go @@ -5,7 +5,9 @@ import ( "math/big" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/vm" @@ -27,12 +29,12 @@ func (api *OtterscanAPIImpl) TraceTransaction(ctx context.Context, hash common.H } type TraceEntry struct { - Type string `json:"type"` - Depth int `json:"depth"` - From common.Address `json:"from"` - To common.Address `json:"to"` - Value *hexutil.Big `json:"value"` - Input hexutil.Bytes `json:"input"` + Type string `json:"type"` + Depth int `json:"depth"` + From common.Address `json:"from"` + To common.Address `json:"to"` + Value *hexutil.Big `json:"value"` + Input hexutility.Bytes `json:"input"` } type TransactionTracer struct { diff --git a/cmd/rpcdaemon/commands/otterscan_transaction_error.go b/cmd/rpcdaemon/commands/otterscan_transaction_error.go index 503bfc183..c15b4c83b 100644 --- a/cmd/rpcdaemon/commands/otterscan_transaction_error.go +++ b/cmd/rpcdaemon/commands/otterscan_transaction_error.go @@ -4,11 +4,10 @@ import ( "context" "github.com/ledgerwatch/erigon-lib/common" - - "github.com/ledgerwatch/erigon/common/hexutil" + "github.com/ledgerwatch/erigon-lib/common/hexutility" ) -func (api *OtterscanAPIImpl) GetTransactionError(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) { +func (api *OtterscanAPIImpl) GetTransactionError(ctx context.Context, hash common.Hash) (hexutility.Bytes, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err diff --git a/cmd/rpcdaemon/commands/parity_api.go b/cmd/rpcdaemon/commands/parity_api.go index a1ac2e935..604b232f0 100644 --- a/cmd/rpcdaemon/commands/parity_api.go +++ b/cmd/rpcdaemon/commands/parity_api.go @@ -6,10 +6,10 @@ import ( "fmt" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/common/length" "github.com/ledgerwatch/erigon-lib/kv" - "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/rpc" ) @@ -20,7 +20,7 @@ var ErrWrongTag = fmt.Errorf("listStorageKeys wrong block tag or number: must be // ParityAPI the interface for the parity_ RPC commands type ParityAPI interface { - ListStorageKeys(ctx context.Context, account libcommon.Address, quantity int, offset *hexutil.Bytes, blockNumber rpc.BlockNumberOrHash) ([]hexutil.Bytes, error) + ListStorageKeys(ctx context.Context, account libcommon.Address, quantity int, offset *hexutility.Bytes, blockNumber rpc.BlockNumberOrHash) ([]hexutility.Bytes, error) } // ParityAPIImpl data structure to store things needed for parity_ commands @@ -36,7 +36,7 @@ func NewParityAPIImpl(db kv.RoDB) *ParityAPIImpl { } // ListStorageKeys implements parity_listStorageKeys. Returns all storage keys of the given address -func (api *ParityAPIImpl) ListStorageKeys(ctx context.Context, account libcommon.Address, quantity int, offset *hexutil.Bytes, blockNumberOrTag rpc.BlockNumberOrHash) ([]hexutil.Bytes, error) { +func (api *ParityAPIImpl) ListStorageKeys(ctx context.Context, account libcommon.Address, quantity int, offset *hexutility.Bytes, blockNumberOrTag rpc.BlockNumberOrHash) ([]hexutility.Bytes, error) { if err := api.checkBlockNumber(blockNumberOrTag); err != nil { return nil, err } @@ -62,7 +62,7 @@ func (api *ParityAPIImpl) ListStorageKeys(ctx context.Context, account libcommon return nil, err } defer c.Close() - keys := make([]hexutil.Bytes, 0) + keys := make([]hexutility.Bytes, 0) var v []byte var seekVal []byte if offset != nil { diff --git a/cmd/rpcdaemon/commands/parity_api_test.go b/cmd/rpcdaemon/commands/parity_api_test.go index d3728cc79..1b23060b8 100644 --- a/cmd/rpcdaemon/commands/parity_api_test.go +++ b/cmd/rpcdaemon/commands/parity_api_test.go @@ -5,12 +5,13 @@ import ( "fmt" "testing" - libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/stretchr/testify/assert" + libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" + "github.com/ledgerwatch/erigon/cmd/rpcdaemon/rpcdaemontest" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/rpc" ) @@ -51,7 +52,7 @@ func TestParityAPIImpl_ListStorageKeys_WithOffset_ExistingPrefix(t *testing.T) { } addr := libcommon.HexToAddress("0x920fd5070602feaea2e251e9e7238b6c376bcae5") offset := common.Hex2Bytes("29") - b := hexutil.Bytes(offset) + b := hexutility.Bytes(offset) result, err := api.ListStorageKeys(context.Background(), addr, 5, &b, latestBlock) if err != nil { t.Errorf("calling ListStorageKeys: %v", err) @@ -72,7 +73,7 @@ func TestParityAPIImpl_ListStorageKeys_WithOffset_NonExistingPrefix(t *testing.T } addr := libcommon.HexToAddress("0x920fd5070602feaea2e251e9e7238b6c376bcae5") offset := common.Hex2Bytes("30") - b := hexutil.Bytes(offset) + b := hexutility.Bytes(offset) result, err := api.ListStorageKeys(context.Background(), addr, 2, &b, latestBlock) if err != nil { t.Errorf("calling ListStorageKeys: %v", err) @@ -89,7 +90,7 @@ func TestParityAPIImpl_ListStorageKeys_WithOffset_EmptyResponse(t *testing.T) { api := NewParityAPIImpl(m.DB) addr := libcommon.HexToAddress("0x920fd5070602feaea2e251e9e7238b6c376bcae5") offset := common.Hex2Bytes("ff") - b := hexutil.Bytes(offset) + b := hexutility.Bytes(offset) result, err := api.ListStorageKeys(context.Background(), addr, 2, &b, latestBlock) if err != nil { t.Errorf("calling ListStorageKeys: %v", err) diff --git a/cmd/rpcdaemon/commands/send_transaction.go b/cmd/rpcdaemon/commands/send_transaction.go index 0efae23c8..2db43dde0 100644 --- a/cmd/rpcdaemon/commands/send_transaction.go +++ b/cmd/rpcdaemon/commands/send_transaction.go @@ -8,10 +8,10 @@ import ( "math/big" "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" txPoolProto "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/log/v3" - "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" @@ -21,7 +21,7 @@ import ( ) // SendRawTransaction implements eth_sendRawTransaction. Creates new message call transaction or a contract creation for previously-signed transactions. -func (api *APIImpl) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) { +func (api *APIImpl) SendRawTransaction(ctx context.Context, encodedTx hexutility.Bytes) (common.Hash, error) { txn, err := types.DecodeTransaction(rlp.NewStream(bytes.NewReader(encodedTx), uint64(len(encodedTx)))) if err != nil { return common.Hash{}, err diff --git a/cmd/rpcdaemon/commands/trace_adhoc.go b/cmd/rpcdaemon/commands/trace_adhoc.go index 2367f9a4c..dfa2fe0d4 100644 --- a/cmd/rpcdaemon/commands/trace_adhoc.go +++ b/cmd/rpcdaemon/commands/trace_adhoc.go @@ -9,10 +9,12 @@ import ( "strings" "github.com/holiman/uint256" + "github.com/ledgerwatch/log/v3" + libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/kv" types2 "github.com/ledgerwatch/erigon-lib/types" - "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" @@ -51,7 +53,7 @@ type TraceCallParam struct { MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"` MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"` Value *hexutil.Big `json:"value"` - Data hexutil.Bytes `json:"data"` + Data hexutility.Bytes `json:"data"` AccessList *types2.AccessList `json:"accessList"` txHash *libcommon.Hash traceTypes []string @@ -59,7 +61,7 @@ type TraceCallParam struct { // TraceCallResult is the response to `trace_call` method type TraceCallResult struct { - Output hexutil.Bytes `json:"output"` + Output hexutility.Bytes `json:"output"` StateDiff map[libcommon.Address]*StateDiffAccount `json:"stateDiff"` Trace []*ParityTrace `json:"trace"` VmTrace *VmTrace `json:"vmTrace"` @@ -80,8 +82,8 @@ type StateDiffBalance struct { } type StateDiffCode struct { - From hexutil.Bytes `json:"from"` - To hexutil.Bytes `json:"to"` + From hexutility.Bytes `json:"from"` + To hexutility.Bytes `json:"to"` } type StateDiffNonce struct { @@ -96,8 +98,8 @@ type StateDiffStorage struct { // VmTrace is the part of `trace_call` response that is under "vmTrace" tag type VmTrace struct { - Code hexutil.Bytes `json:"code"` - Ops []*VmTraceOp `json:"ops"` + Code hexutility.Bytes `json:"code"` + Ops []*VmTraceOp `json:"ops"` } // VmTraceOp is one element of the vmTrace ops trace @@ -659,7 +661,7 @@ func (sd *StateDiff) CompareStates(initialIbs, ibs *state.IntraBlockState) { accountDiff.Balance = m } { - m := make(map[string]hexutil.Bytes) + m := make(map[string]hexutility.Bytes) m["-"] = initialIbs.GetCode(addr) accountDiff.Code = m } @@ -676,7 +678,7 @@ func (sd *StateDiff) CompareStates(initialIbs, ibs *state.IntraBlockState) { accountDiff.Balance = m } { - m := make(map[string]hexutil.Bytes) + m := make(map[string]hexutility.Bytes) m["+"] = ibs.GetCode(addr) accountDiff.Code = m } diff --git a/cmd/rpcdaemon/commands/trace_types.go b/cmd/rpcdaemon/commands/trace_types.go index 9ebdbdf58..a905d3a4c 100644 --- a/cmd/rpcdaemon/commands/trace_types.go +++ b/cmd/rpcdaemon/commands/trace_types.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/types" @@ -56,34 +57,34 @@ type ParityTraces []ParityTrace // TraceAction A parity formatted trace action type TraceAction struct { // Do not change the ordering of these fields -- allows for easier comparison with other clients - Author string `json:"author,omitempty"` - RewardType string `json:"rewardType,omitempty"` - SelfDestructed string `json:"address,omitempty"` - Balance string `json:"balance,omitempty"` - CallType string `json:"callType,omitempty"` - From common.Address `json:"from"` - Gas hexutil.Big `json:"gas"` - Init hexutil.Bytes `json:"init,omitempty"` - Input hexutil.Bytes `json:"input,omitempty"` - RefundAddress string `json:"refundAddress,omitempty"` - To string `json:"to,omitempty"` - Value string `json:"value,omitempty"` + Author string `json:"author,omitempty"` + RewardType string `json:"rewardType,omitempty"` + SelfDestructed string `json:"address,omitempty"` + Balance string `json:"balance,omitempty"` + CallType string `json:"callType,omitempty"` + From common.Address `json:"from"` + Gas hexutil.Big `json:"gas"` + Init hexutility.Bytes `json:"init,omitempty"` + Input hexutility.Bytes `json:"input,omitempty"` + RefundAddress string `json:"refundAddress,omitempty"` + To string `json:"to,omitempty"` + Value string `json:"value,omitempty"` } type CallTraceAction struct { - From common.Address `json:"from"` - CallType string `json:"callType"` - Gas hexutil.Big `json:"gas"` - Input hexutil.Bytes `json:"input"` - To common.Address `json:"to"` - Value hexutil.Big `json:"value"` + From common.Address `json:"from"` + CallType string `json:"callType"` + Gas hexutil.Big `json:"gas"` + Input hexutility.Bytes `json:"input"` + To common.Address `json:"to"` + Value hexutil.Big `json:"value"` } type CreateTraceAction struct { - From common.Address `json:"from"` - Gas hexutil.Big `json:"gas"` - Init hexutil.Bytes `json:"init"` - Value hexutil.Big `json:"value"` + From common.Address `json:"from"` + Gas hexutil.Big `json:"gas"` + Init hexutility.Bytes `json:"init"` + Value hexutil.Big `json:"value"` } type SuicideTraceAction struct { @@ -100,16 +101,16 @@ type RewardTraceAction struct { type CreateTraceResult struct { // Do not change the ordering of these fields -- allows for easier comparison with other clients - Address *common.Address `json:"address,omitempty"` - Code hexutil.Bytes `json:"code"` - GasUsed *hexutil.Big `json:"gasUsed"` + Address *common.Address `json:"address,omitempty"` + Code hexutility.Bytes `json:"code"` + GasUsed *hexutil.Big `json:"gasUsed"` } // TraceResult A parity formatted trace result type TraceResult struct { // Do not change the ordering of these fields -- allows for easier comparison with other clients - GasUsed *hexutil.Big `json:"gasUsed"` - Output hexutil.Bytes `json:"output"` + GasUsed *hexutil.Big `json:"gasUsed"` + Output hexutility.Bytes `json:"output"` } // Allows for easy printing of a geth trace for debugging diff --git a/cmd/rpcdaemon/commands/web3_api.go b/cmd/rpcdaemon/commands/web3_api.go index c35f62c63..d66e99da5 100644 --- a/cmd/rpcdaemon/commands/web3_api.go +++ b/cmd/rpcdaemon/commands/web3_api.go @@ -3,7 +3,8 @@ package commands import ( "context" - "github.com/ledgerwatch/erigon/common/hexutil" + "github.com/ledgerwatch/erigon-lib/common/hexutility" + "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/turbo/rpchelper" ) @@ -11,7 +12,7 @@ import ( // Web3API provides interfaces for the web3_ RPC commands type Web3API interface { ClientVersion(_ context.Context) (string, error) - Sha3(_ context.Context, input hexutil.Bytes) hexutil.Bytes + Sha3(_ context.Context, input hexutility.Bytes) hexutility.Bytes } type Web3APIImpl struct { @@ -33,6 +34,6 @@ func (api *Web3APIImpl) ClientVersion(ctx context.Context) (string, error) { } // Sha3 implements web3_sha3. Returns Keccak-256 (not the standardized SHA3-256) of the given data. -func (api *Web3APIImpl) Sha3(_ context.Context, input hexutil.Bytes) hexutil.Bytes { +func (api *Web3APIImpl) Sha3(_ context.Context, input hexutility.Bytes) hexutility.Bytes { return crypto.Keccak256(input) } diff --git a/cmd/rpcdaemon/graphql/graph/helpers.go b/cmd/rpcdaemon/graphql/graph/helpers.go index 1eb0ff1f0..4bc6c7da4 100644 --- a/cmd/rpcdaemon/graphql/graph/helpers.go +++ b/cmd/rpcdaemon/graphql/graph/helpers.go @@ -7,7 +7,10 @@ import ( "strconv" "github.com/holiman/uint256" + libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" + "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/types" ) @@ -23,7 +26,7 @@ func convertDataToStringP(abstractMap map[string]interface{}, field string) *str return nil } result = v.String() - case hexutil.Bytes: + case hexutility.Bytes: result = v.String() case hexutil.Uint: result = v.String() diff --git a/cmd/rpctest/rpctest/bench_tracecallmany.go b/cmd/rpctest/rpctest/bench_tracecallmany.go index 69b86136d..a3599af7c 100644 --- a/cmd/rpctest/rpctest/bench_tracecallmany.go +++ b/cmd/rpctest/rpctest/bench_tracecallmany.go @@ -8,6 +8,7 @@ import ( "time" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common/hexutil" ) @@ -80,7 +81,7 @@ func BenchTraceCallMany(erigonURL, oeURL string, needCompare bool, blockFrom uin gas := make([]*hexutil.Big, n) gasPrice := make([]*hexutil.Big, n) value := make([]*hexutil.Big, n) - data := make([]hexutil.Bytes, n) + data := make([]hexutility.Bytes, n) for i := 0; i < n; i++ { tx := b.Result.Transactions[i] diff --git a/cmd/rpctest/rpctest/request_generator.go b/cmd/rpctest/rpctest/request_generator.go index 4b5b9aaaf..b5936b898 100644 --- a/cmd/rpctest/rpctest/request_generator.go +++ b/cmd/rpctest/rpctest/request_generator.go @@ -7,9 +7,11 @@ import ( "strings" "time" - libcommon "github.com/ledgerwatch/erigon-lib/common" "github.com/valyala/fastjson" + libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" + "github.com/ledgerwatch/erigon/common/hexutil" ) @@ -97,7 +99,7 @@ func (g *RequestGenerator) getProof(bn uint64, account libcommon.Address, storag return fmt.Sprintf(template, account, strings.Join(storageStr, ","), bn, g.reqID) } -func (g *RequestGenerator) traceCall(from libcommon.Address, to *libcommon.Address, gas *hexutil.Big, gasPrice *hexutil.Big, value *hexutil.Big, data hexutil.Bytes, bn uint64) string { +func (g *RequestGenerator) traceCall(from libcommon.Address, to *libcommon.Address, gas *hexutil.Big, gasPrice *hexutil.Big, value *hexutil.Big, data hexutility.Bytes, bn uint64) string { var sb strings.Builder fmt.Fprintf(&sb, `{ "jsonrpc": "2.0", "method": "trace_call", "params": [{"from":"0x%x"`, from) if to != nil { @@ -120,7 +122,7 @@ func (g *RequestGenerator) traceCall(from libcommon.Address, to *libcommon.Addre return sb.String() } -func (g *RequestGenerator) traceCallMany(from []libcommon.Address, to []*libcommon.Address, gas []*hexutil.Big, gasPrice []*hexutil.Big, value []*hexutil.Big, data []hexutil.Bytes, bn uint64) string { +func (g *RequestGenerator) traceCallMany(from []libcommon.Address, to []*libcommon.Address, gas []*hexutil.Big, gasPrice []*hexutil.Big, value []*hexutil.Big, data []hexutility.Bytes, bn uint64) string { var sb strings.Builder fmt.Fprintf(&sb, `{ "jsonrpc": "2.0", "method": "trace_callMany", "params": [[`) for i, f := range from { @@ -149,7 +151,7 @@ func (g *RequestGenerator) traceCallMany(from []libcommon.Address, to []*libcomm return sb.String() } -func (g *RequestGenerator) debugTraceCall(from libcommon.Address, to *libcommon.Address, gas *hexutil.Big, gasPrice *hexutil.Big, value *hexutil.Big, data hexutil.Bytes, bn uint64) string { +func (g *RequestGenerator) debugTraceCall(from libcommon.Address, to *libcommon.Address, gas *hexutil.Big, gasPrice *hexutil.Big, value *hexutil.Big, data hexutility.Bytes, bn uint64) string { var sb strings.Builder fmt.Fprintf(&sb, `{ "jsonrpc": "2.0", "method": "debug_traceCall", "params": [{"from":"0x%x"`, from) if to != nil { @@ -197,7 +199,7 @@ func (g *RequestGenerator) traceReplayTransaction(hash string) string { return fmt.Sprintf(template, hash, g.reqID) } -func (g *RequestGenerator) ethCall(from libcommon.Address, to *libcommon.Address, gas *hexutil.Big, gasPrice *hexutil.Big, value *hexutil.Big, data hexutil.Bytes, bn uint64) string { +func (g *RequestGenerator) ethCall(from libcommon.Address, to *libcommon.Address, gas *hexutil.Big, gasPrice *hexutil.Big, value *hexutil.Big, data hexutility.Bytes, bn uint64) string { var sb strings.Builder fmt.Fprintf(&sb, `{ "jsonrpc": "2.0", "method": "eth_call", "params": [{"from":"0x%x"`, from) if to != nil { @@ -219,7 +221,7 @@ func (g *RequestGenerator) ethCall(from libcommon.Address, to *libcommon.Address return sb.String() } -func (g *RequestGenerator) ethCallLatest(from libcommon.Address, to *libcommon.Address, gas *hexutil.Big, gasPrice *hexutil.Big, value *hexutil.Big, data hexutil.Bytes) string { +func (g *RequestGenerator) ethCallLatest(from libcommon.Address, to *libcommon.Address, gas *hexutil.Big, gasPrice *hexutil.Big, value *hexutil.Big, data hexutility.Bytes) string { var sb strings.Builder fmt.Fprintf(&sb, `{ "jsonrpc": "2.0", "method": "eth_call", "params": [{"from":"0x%x"`, from) if to != nil { diff --git a/cmd/rpctest/rpctest/type.go b/cmd/rpctest/rpctest/type.go index 64af871d3..134bbbd1b 100644 --- a/cmd/rpctest/rpctest/type.go +++ b/cmd/rpctest/rpctest/type.go @@ -4,6 +4,7 @@ import ( "fmt" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/state" @@ -39,7 +40,7 @@ type EthTransaction struct { Hash string `json:"hash"` Gas hexutil.Big `json:"gas"` GasPrice hexutil.Big `json:"gasPrice"` - Input hexutil.Bytes `json:"input"` + Input hexutility.Bytes `json:"input"` Value hexutil.Big `json:"value"` } @@ -96,7 +97,7 @@ type TraceCall struct { } type TraceCallResult struct { - Output hexutil.Bytes `json:"output"` + Output hexutility.Bytes `json:"output"` Trace []TraceCallTrace `json:"trace"` StateDiff map[libcommon.Address]TraceCallStateDiff `json:"stateDiff"` } @@ -119,16 +120,16 @@ type TraceCallAction struct { Gas hexutil.Big `json:"gas"` Value hexutil.Big `json:"value"` Balance hexutil.Big `json:"balance"` - Init hexutil.Bytes `json:"init"` - Input hexutil.Bytes `json:"input"` + Init hexutility.Bytes `json:"init"` + Input hexutility.Bytes `json:"input"` CallType string `json:"callType"` } type TraceCallTraceResult struct { GasUsed hexutil.Big `json:"gasUsed"` - Output hexutil.Bytes `json:"output"` + Output hexutility.Bytes `json:"output"` Address libcommon.Address `json:"address"` - Code hexutil.Bytes `json:"code"` + Code hexutility.Bytes `json:"code"` } type TraceCallStateDiff struct { @@ -191,7 +192,7 @@ type Log struct { //nolint // list of topics provided by the contract. Topics []libcommon.Hash `json:"topics" gencodec:"required"` // supplied by the contract, usually ABI-encoded - Data hexutil.Bytes `json:"data" gencodec:"required"` + Data hexutility.Bytes `json:"data" gencodec:"required"` // Derived fields. These fields are filled in by the node // but not secured by consensus. @@ -213,11 +214,11 @@ type Log struct { //nolint type Receipt struct { // Consensus fields - PostState libcommon.Hash `json:"root"` - Status hexutil.Uint64 `json:"status"` - CumulativeGasUsed hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"` - Bloom hexutil.Bytes `json:"logsBloom" gencodec:"required"` - Logs []*Log `json:"logs" gencodec:"required"` + PostState libcommon.Hash `json:"root"` + Status hexutil.Uint64 `json:"status"` + CumulativeGasUsed hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"` + Bloom hexutility.Bytes `json:"logsBloom" gencodec:"required"` + Logs []*Log `json:"logs" gencodec:"required"` // Implementation fields (don't reorder!) TxHash libcommon.Hash `json:"transactionHash" gencodec:"required"` @@ -263,5 +264,5 @@ type StorageResult struct { type ParityListStorageKeysResult struct { CommonResponse - Result []hexutil.Bytes `json:"result"` + Result []hexutility.Bytes `json:"result"` } diff --git a/common/hexutil/json.go b/common/hexutil/json.go index 265e98ed3..ce1ce9a05 100644 --- a/common/hexutil/json.go +++ b/common/hexutil/json.go @@ -23,59 +23,14 @@ import ( "math/big" "reflect" "strconv" - - "github.com/ledgerwatch/erigon-lib/common/hexutility" ) var ( - bytesT = reflect.TypeOf(Bytes(nil)) bigT = reflect.TypeOf((*Big)(nil)) uintT = reflect.TypeOf(Uint(0)) uint64T = reflect.TypeOf(Uint64(0)) ) -// Bytes marshals/unmarshals as a JSON string with 0x prefix. -// The empty slice marshals as "0x". -type Bytes []byte - -const hexPrefix = `0x` - -// MarshalText implements encoding.TextMarshaler -func (b Bytes) MarshalText() ([]byte, error) { - result := make([]byte, len(b)*2+2) - copy(result, hexPrefix) - hex.Encode(result[2:], b) - return result, nil -} - -// UnmarshalJSON implements json.Unmarshaler. -func (b *Bytes) UnmarshalJSON(input []byte) error { - if !isString(input) { - return errNonString(bytesT) - } - return wrapTypeError(b.UnmarshalText(input[1:len(input)-1]), bytesT) -} - -// UnmarshalText implements encoding.TextUnmarshaler. -func (b *Bytes) UnmarshalText(input []byte) error { - raw, err := checkText(input, true) - if err != nil { - return err - } - dec := make([]byte, len(raw)/2) - if _, err = hex.Decode(dec, raw); err != nil { - err = mapError(err) - } else { - *b = dec - } - return err -} - -// String returns the hex encoding of b. -func (b Bytes) String() string { - return hexutility.Encode(b) -} - // UnmarshalFixedUnprefixedText decodes the input as a string with optional 0x prefix. The // length of out determines the required input length. This function is commonly used to // implement the UnmarshalText method for fixed-size types. diff --git a/common/hexutil/json_example_test.go b/common/hexutil/json_example_test.go index b513fba60..c256b412e 100644 --- a/common/hexutil/json_example_test.go +++ b/common/hexutil/json_example_test.go @@ -21,8 +21,6 @@ import ( "fmt" "github.com/ledgerwatch/erigon-lib/common/hexutility" - - "github.com/ledgerwatch/erigon/common/hexutil" ) type MyType [5]byte @@ -32,7 +30,7 @@ func (v *MyType) UnmarshalText(input []byte) error { } func (v MyType) String() string { - return hexutil.Bytes(v[:]).String() + return hexutility.Bytes(v[:]).String() } func ExampleUnmarshalFixedText() { diff --git a/common/hexutil/json_test.go b/common/hexutil/json_test.go index ed7d6fad1..21f4a35ce 100644 --- a/common/hexutil/json_test.go +++ b/common/hexutil/json_test.go @@ -18,7 +18,6 @@ package hexutil import ( "bytes" - "encoding/hex" "encoding/json" "errors" "math/big" @@ -49,81 +48,8 @@ func referenceBig(s string) *big.Int { return b } -func referenceBytes(s string) []byte { - b, err := hex.DecodeString(s) - if err != nil { - panic(err) - } - return b -} - var errJSONEOF = errors.New("unexpected end of JSON input") -var unmarshalBytesTests = []unmarshalTest{ - // invalid encoding - {input: "", wantErr: errJSONEOF}, - {input: "null", wantErr: errNonString(bytesT)}, - {input: "10", wantErr: errNonString(bytesT)}, - {input: `"0"`, wantErr: wrapTypeError(ErrMissingPrefix, bytesT)}, - {input: `"0x0"`, wantErr: wrapTypeError(ErrOddLength, bytesT)}, - {input: `"0xxx"`, wantErr: wrapTypeError(ErrSyntax, bytesT)}, - {input: `"0x01zz01"`, wantErr: wrapTypeError(ErrSyntax, bytesT)}, - - // valid encoding - {input: `""`, want: referenceBytes("")}, - {input: `"0x"`, want: referenceBytes("")}, - {input: `"0x02"`, want: referenceBytes("02")}, - {input: `"0X02"`, want: referenceBytes("02")}, - {input: `"0xffffffffff"`, want: referenceBytes("ffffffffff")}, - { - input: `"0xffffffffffffffffffffffffffffffffffff"`, - want: referenceBytes("ffffffffffffffffffffffffffffffffffff"), - }, -} - -func TestUnmarshalBytes(t *testing.T) { - for _, test := range unmarshalBytesTests { - var v Bytes - err := json.Unmarshal([]byte(test.input), &v) - if !checkError(t, test.input, err, test.wantErr) { - continue - } - if !bytes.Equal(test.want.([]byte), v) { - t.Errorf("input %s: value mismatch: got %x, want %x", test.input, &v, test.want) - continue - } - } -} - -func BenchmarkUnmarshalBytes(b *testing.B) { - input := []byte(`"0x123456789abcdef123456789abcdef"`) - for i := 0; i < b.N; i++ { - var v Bytes - if err := v.UnmarshalJSON(input); err != nil { - b.Fatal(err) - } - } -} - -func TestMarshalBytes(t *testing.T) { - for _, test := range encodeBytesTests { - in := test.input.([]byte) - out, err := json.Marshal(Bytes(in)) - if err != nil { - t.Errorf("%x: %v", in, err) - continue - } - if want := `"` + test.want + `"`; string(out) != want { - t.Errorf("%x: MarshalJSON output mismatch: got %q, want %q", in, out, want) - continue - } - if out := Bytes(in).String(); out != test.want { - t.Errorf("%x: String mismatch: got %q, want %q", in, out, test.want) - continue - } - } -} - var unmarshalBigTests = []unmarshalTest{ // invalid encoding {input: "", wantErr: errJSONEOF}, diff --git a/consensus/aura/config.go b/consensus/aura/config.go index 94ec56b8f..8f6bc2706 100644 --- a/consensus/aura/config.go +++ b/consensus/aura/config.go @@ -22,7 +22,9 @@ import ( "sort" "github.com/holiman/uint256" + libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/u256" @@ -126,7 +128,7 @@ type JsonSpec struct { // See https://github.com/gnosischain/specs/blob/master/execution/withdrawals.md WithdrawalContractAddress *libcommon.Address `json:"withdrawalContractAddress"` - RewriteBytecode map[uint64]map[libcommon.Address]hexutil.Bytes `json:"rewriteBytecode"` + RewriteBytecode map[uint64]map[libcommon.Address]hexutility.Bytes `json:"rewriteBytecode"` } type Code struct { diff --git a/consensus/aura/consensusconfig/kovan.json b/consensus/aura/consensusconfig/kovan.json deleted file mode 100644 index 603a5fbdd..000000000 --- a/consensus/aura/consensusconfig/kovan.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "stepDuration": 4, - "blockReward": "0x4563918244F40000", - "validators": { - "multi": { - "0": { - "list": [ - "0x00D6Cc1BA9cf89BD2e58009741f4F7325BAdc0ED", - "0x00427feae2419c15b89d1c21af10d1b6650a4d3d", - "0x4Ed9B08e6354C70fE6F8CB0411b0d3246b424d6c", - "0x0020ee4Be0e2027d76603cB751eE069519bA81A1", - "0x0010f94b296a852aaac52ea6c5ac72e03afd032d", - "0x007733a1FE69CF3f2CF989F81C7b4cAc1693387A", - "0x00E6d2b931F55a3f1701c7389d592a7778897879", - "0x00e4a10650e5a6D6001C38ff8E64F97016a1645c", - "0x00a0a24b9f0e5ec7aa4c7389b8302fd0123194de" - ] - }, - "10960440": { - "list": [ - "0x00D6Cc1BA9cf89BD2e58009741f4F7325BAdc0ED", - "0x0010f94b296a852aaac52ea6c5ac72e03afd032d", - "0x00a0a24b9f0e5ec7aa4c7389b8302fd0123194de" - ] - }, - "10960500": { - "safeContract": "0xaE71807C1B0a093cB1547b682DC78316D945c9B8" - } - } - }, - "validateScoreTransition": 4301764, - "validateStepTransition": 1500000, - "maximumUncleCountTransition": 5067000, - "maximumUncleCount": 0 -} - diff --git a/consensus/bor/clerk/clerk.go b/consensus/bor/clerk/clerk.go index 1069ce8d9..fa7962139 100644 --- a/consensus/bor/clerk/clerk.go +++ b/consensus/bor/clerk/clerk.go @@ -5,15 +5,14 @@ import ( "time" libcommon "github.com/ledgerwatch/erigon-lib/common" - - "github.com/ledgerwatch/erigon/common/hexutil" + "github.com/ledgerwatch/erigon-lib/common/hexutility" ) // EventRecord represents state record type EventRecord struct { ID uint64 `json:"id" yaml:"id"` Contract libcommon.Address `json:"contract" yaml:"contract"` - Data hexutil.Bytes `json:"data" yaml:"data"` + Data hexutility.Bytes `json:"data" yaml:"data"` TxHash libcommon.Hash `json:"tx_hash" yaml:"tx_hash"` LogIndex uint64 `json:"log_index" yaml:"log_index"` ChainID string `json:"bor_chain_id" yaml:"bor_chain_id"` diff --git a/consensus/parlia/parlia.go b/consensus/parlia/parlia.go index e563e33a8..67c97f7a5 100644 --- a/consensus/parlia/parlia.go +++ b/consensus/parlia/parlia.go @@ -13,32 +13,31 @@ import ( "sync" "time" - "github.com/hashicorp/golang-lru/v2" - "github.com/ledgerwatch/erigon-lib/chain" - libcommon "github.com/ledgerwatch/erigon-lib/common" - "github.com/ledgerwatch/erigon-lib/common/length" - - "github.com/ledgerwatch/erigon/core/rawdb" - "github.com/ledgerwatch/erigon/crypto/cryptopool" - + lru "github.com/hashicorp/golang-lru/v2" "github.com/holiman/uint256" - "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/log/v3" "golang.org/x/exp/slices" + "github.com/ledgerwatch/erigon-lib/chain" + libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" + "github.com/ledgerwatch/erigon-lib/common/length" + "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon/accounts/abi" - "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/common/u256" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/consensus/misc" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/forkid" + "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/systemcontracts" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/crypto" + "github.com/ledgerwatch/erigon/crypto/cryptopool" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/rpc" @@ -1034,7 +1033,7 @@ func (p *Parlia) getCurrentValidators(header *types.Header, ibs *state.IntraBloc return nil, err } // call - msgData := hexutil.Bytes(data) + msgData := hexutility.Bytes(data) _, returnData, err := p.systemCall(header.Coinbase, systemcontracts.ValidatorContract, msgData[:], ibs, header, u256.Num0) if err != nil { return nil, err diff --git a/core/state/dump.go b/core/state/dump.go index 2a4c83fd5..62efa87d1 100644 --- a/core/state/dump.go +++ b/core/state/dump.go @@ -22,14 +22,14 @@ import ( "fmt" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv/order" "github.com/ledgerwatch/erigon-lib/kv/rawdbv3" - "github.com/ledgerwatch/erigon/core/state/temporal" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" - "github.com/ledgerwatch/erigon/common/hexutil" + "github.com/ledgerwatch/erigon/core/state/temporal" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/turbo/trie" @@ -46,12 +46,12 @@ type Dumper struct { type DumpAccount struct { Balance string `json:"balance"` Nonce uint64 `json:"nonce"` - Root hexutil.Bytes `json:"root"` - CodeHash hexutil.Bytes `json:"codeHash"` - Code hexutil.Bytes `json:"code,omitempty"` + Root hexutility.Bytes `json:"root"` + CodeHash hexutility.Bytes `json:"codeHash"` + Code hexutility.Bytes `json:"code,omitempty"` Storage map[string]string `json:"storage,omitempty"` Address *libcommon.Address `json:"address,omitempty"` // Address only present in iterative (line-by-line) mode - SecureKey *hexutil.Bytes `json:"key,omitempty"` // If we don't have address, we can output the key + SecureKey *hexutility.Bytes `json:"key,omitempty"` // If we don't have address, we can output the key } // Dump represents the full dump in a collected format, as one large map. @@ -190,8 +190,8 @@ func (d *Dumper) DumpToCollector(c DumpCollector, excludeCode, excludeStorage bo account := DumpAccount{ Balance: acc.Balance.ToBig().String(), Nonce: acc.Nonce, - Root: hexutil.Bytes(emptyHash[:]), // We cannot provide historical storage hash - CodeHash: hexutil.Bytes(emptyCodeHash[:]), + Root: hexutility.Bytes(emptyHash[:]), // We cannot provide historical storage hash + CodeHash: hexutility.Bytes(emptyCodeHash[:]), Storage: make(map[string]string), } accountList = append(accountList, &account) @@ -219,8 +219,8 @@ func (d *Dumper) DumpToCollector(c DumpCollector, excludeCode, excludeStorage bo account := DumpAccount{ Balance: acc.Balance.ToBig().String(), Nonce: acc.Nonce, - Root: hexutil.Bytes(emptyHash[:]), // We cannot provide historical storage hash - CodeHash: hexutil.Bytes(emptyCodeHash[:]), + Root: hexutility.Bytes(emptyHash[:]), // We cannot provide historical storage hash + CodeHash: hexutility.Bytes(emptyCodeHash[:]), Storage: make(map[string]string), } accountList = append(accountList, &account) diff --git a/core/types/accounts/account_proof.go b/core/types/accounts/account_proof.go index d244c71fd..7653445d1 100644 --- a/core/types/accounts/account_proof.go +++ b/core/types/accounts/account_proof.go @@ -2,21 +2,23 @@ package accounts import ( libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" + "github.com/ledgerwatch/erigon/common/hexutil" ) // Result structs for GetProof type AccProofResult struct { - Address libcommon.Address `json:"address"` - AccountProof []hexutil.Bytes `json:"accountProof"` - Balance *hexutil.Big `json:"balance"` - CodeHash libcommon.Hash `json:"codeHash"` - Nonce hexutil.Uint64 `json:"nonce"` - StorageHash libcommon.Hash `json:"storageHash"` - StorageProof []StorProofResult `json:"storageProof"` + Address libcommon.Address `json:"address"` + AccountProof []hexutility.Bytes `json:"accountProof"` + Balance *hexutil.Big `json:"balance"` + CodeHash libcommon.Hash `json:"codeHash"` + Nonce hexutil.Uint64 `json:"nonce"` + StorageHash libcommon.Hash `json:"storageHash"` + StorageProof []StorProofResult `json:"storageProof"` } type StorProofResult struct { - Key libcommon.Hash `json:"key"` - Value *hexutil.Big `json:"value"` - Proof []hexutil.Bytes `json:"proof"` + Key libcommon.Hash `json:"key"` + Value *hexutil.Big `json:"value"` + Proof []hexutility.Bytes `json:"proof"` } diff --git a/core/types/block.go b/core/types/block.go index 211e9bb22..aea6a42ed 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -62,7 +62,7 @@ func (n BlockNonce) Uint64() uint64 { // MarshalText encodes n as a hex string with 0x prefix. func (n BlockNonce) MarshalText() ([]byte, error) { - return hexutil.Bytes(n[:]).MarshalText() + return hexutility.Bytes(n[:]).MarshalText() } // UnmarshalText implements encoding.TextUnmarshaler. @@ -506,7 +506,7 @@ type headerMarshaling struct { GasLimit hexutil.Uint64 GasUsed hexutil.Uint64 Time hexutil.Uint64 - Extra hexutil.Bytes + Extra hexutility.Bytes BaseFee *hexutil.Big ExcessDataGas *hexutil.Big Hash libcommon.Hash `json:"hash"` // adds call to Hash() in MarshalJSON diff --git a/core/types/bloom9.go b/core/types/bloom9.go index b0e499ad9..07ba1f958 100644 --- a/core/types/bloom9.go +++ b/core/types/bloom9.go @@ -23,7 +23,6 @@ import ( "github.com/ledgerwatch/erigon-lib/common/hexutility" - "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/crypto/cryptopool" ) @@ -95,7 +94,7 @@ func (b Bloom) Test(topic []byte) bool { // MarshalText encodes b as a hex string with 0x prefix. func (b Bloom) MarshalText() ([]byte, error) { - return hexutil.Bytes(b[:]).MarshalText() + return hexutility.Bytes(b[:]).MarshalText() } // UnmarshalText b as a hex string with 0x prefix. diff --git a/core/types/gen_erigon_log_json.go b/core/types/gen_erigon_log_json.go index 5b800456c..2360e2fdb 100644 --- a/core/types/gen_erigon_log_json.go +++ b/core/types/gen_erigon_log_json.go @@ -7,6 +7,7 @@ import ( "errors" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common/hexutil" ) @@ -18,7 +19,7 @@ func (l ErigonLog) MarshalJSON() ([]byte, error) { type ErigonLog struct { Address libcommon.Address `json:"address" gencodec:"required"` Topics []libcommon.Hash `json:"topics" gencodec:"required"` - Data hexutil.Bytes `json:"data" gencodec:"required"` + Data hexutility.Bytes `json:"data" gencodec:"required"` BlockNumber hexutil.Uint64 `json:"blockNumber"` TxHash libcommon.Hash `json:"transactionHash" gencodec:"required"` TxIndex hexutil.Uint `json:"transactionIndex"` @@ -48,7 +49,7 @@ func (l *ErigonLog) UnmarshalJSON(input []byte) error { type ErigonLog struct { Address *libcommon.Address `json:"address" gencodec:"required"` Topics []libcommon.Hash `json:"topics" gencodec:"required"` - Data *hexutil.Bytes `json:"data" gencodec:"required"` + Data *hexutility.Bytes `json:"data" gencodec:"required"` BlockNumber *hexutil.Uint64 `json:"blockNumber"` TxHash *libcommon.Hash `json:"transactionHash" gencodec:"required"` TxIndex *hexutil.Uint `json:"transactionIndex"` diff --git a/core/types/gen_genesis.go b/core/types/gen_genesis.go index df619e1ec..de634f4c7 100644 --- a/core/types/gen_genesis.go +++ b/core/types/gen_genesis.go @@ -9,9 +9,9 @@ import ( "github.com/ledgerwatch/erigon-lib/chain" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" ) @@ -23,7 +23,7 @@ func (g Genesis) MarshalJSON() ([]byte, error) { Config *chain.Config `json:"config"` Nonce math.HexOrDecimal64 `json:"nonce"` Timestamp math.HexOrDecimal64 `json:"timestamp"` - ExtraData hexutil.Bytes `json:"extraData"` + ExtraData hexutility.Bytes `json:"extraData"` GasLimit math.HexOrDecimal64 `json:"gasLimit" gencodec:"required"` Difficulty *math.HexOrDecimal256 `json:"difficulty" gencodec:"required"` Mixhash libcommon.Hash `json:"mixHash"` @@ -62,7 +62,7 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { Config *chain.Config `json:"config"` Nonce *math.HexOrDecimal64 `json:"nonce"` Timestamp *math.HexOrDecimal64 `json:"timestamp"` - ExtraData *hexutil.Bytes `json:"extraData"` + ExtraData *hexutility.Bytes `json:"extraData"` GasLimit *math.HexOrDecimal64 `json:"gasLimit" gencodec:"required"` Difficulty *math.HexOrDecimal256 `json:"difficulty" gencodec:"required"` Mixhash *libcommon.Hash `json:"mixHash"` diff --git a/core/types/gen_genesis_account.go b/core/types/gen_genesis_account.go index e50f57670..21fa482d8 100644 --- a/core/types/gen_genesis_account.go +++ b/core/types/gen_genesis_account.go @@ -8,8 +8,8 @@ import ( "math/big" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" - "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" ) @@ -18,12 +18,12 @@ var _ = (*genesisAccountMarshaling)(nil) // MarshalJSON marshals as JSON. func (g GenesisAccount) MarshalJSON() ([]byte, error) { type GenesisAccount struct { - Constructor hexutil.Bytes `json:"constructor,omitempty"` - Code hexutil.Bytes `json:"code,omitempty"` + Constructor hexutility.Bytes `json:"constructor,omitempty"` + Code hexutility.Bytes `json:"code,omitempty"` Storage map[storageJSON]storageJSON `json:"storage,omitempty"` Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"` Nonce math.HexOrDecimal64 `json:"nonce,omitempty"` - PrivateKey hexutil.Bytes `json:"secretKey,omitempty"` + PrivateKey hexutility.Bytes `json:"secretKey,omitempty"` } var enc GenesisAccount enc.Constructor = g.Constructor @@ -43,12 +43,12 @@ func (g GenesisAccount) MarshalJSON() ([]byte, error) { // UnmarshalJSON unmarshals from JSON. func (g *GenesisAccount) UnmarshalJSON(input []byte) error { type GenesisAccount struct { - Constructor *hexutil.Bytes `json:"constructor,omitempty"` - Code *hexutil.Bytes `json:"code,omitempty"` + Constructor *hexutility.Bytes `json:"constructor,omitempty"` + Code *hexutility.Bytes `json:"code,omitempty"` Storage map[storageJSON]storageJSON `json:"storage,omitempty"` Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"` Nonce *math.HexOrDecimal64 `json:"nonce,omitempty"` - PrivateKey *hexutil.Bytes `json:"secretKey,omitempty"` + PrivateKey *hexutility.Bytes `json:"secretKey,omitempty"` } var dec GenesisAccount if err := json.Unmarshal(input, &dec); err != nil { diff --git a/core/types/gen_header_json.go b/core/types/gen_header_json.go index fb8194348..17b70798b 100644 --- a/core/types/gen_header_json.go +++ b/core/types/gen_header_json.go @@ -8,6 +8,7 @@ import ( "math/big" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common/hexutil" ) @@ -29,7 +30,7 @@ func (h Header) MarshalJSON() ([]byte, error) { GasLimit hexutil.Uint64 `json:"gasLimit" gencodec:"required"` GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"` Time hexutil.Uint64 `json:"timestamp" gencodec:"required"` - Extra hexutil.Bytes `json:"extraData" gencodec:"required"` + Extra hexutility.Bytes `json:"extraData" gencodec:"required"` MixDigest libcommon.Hash `json:"mixHash"` Nonce BlockNonce `json:"nonce"` BaseFee *hexutil.Big `json:"baseFeePerGas"` @@ -73,7 +74,7 @@ func (h *Header) UnmarshalJSON(input []byte) error { GasLimit *hexutil.Uint64 `json:"gasLimit" gencodec:"required"` GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"` Time *hexutil.Uint64 `json:"timestamp" gencodec:"required"` - Extra *hexutil.Bytes `json:"extraData" gencodec:"required"` + Extra *hexutility.Bytes `json:"extraData" gencodec:"required"` MixDigest *libcommon.Hash `json:"mixHash"` Nonce *BlockNonce `json:"nonce"` BaseFee *hexutil.Big `json:"baseFeePerGas"` diff --git a/core/types/gen_log_json.go b/core/types/gen_log_json.go index 6b6192593..e3db5873d 100644 --- a/core/types/gen_log_json.go +++ b/core/types/gen_log_json.go @@ -7,6 +7,7 @@ import ( "errors" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common/hexutil" ) @@ -18,7 +19,7 @@ func (l Log) MarshalJSON() ([]byte, error) { type Log struct { Address libcommon.Address `json:"address" gencodec:"required"` Topics []libcommon.Hash `json:"topics" gencodec:"required"` - Data hexutil.Bytes `json:"data" gencodec:"required"` + Data hexutility.Bytes `json:"data" gencodec:"required"` BlockNumber hexutil.Uint64 `json:"blockNumber"` TxHash libcommon.Hash `json:"transactionHash" gencodec:"required"` TxIndex hexutil.Uint `json:"transactionIndex"` @@ -44,7 +45,7 @@ func (l *Log) UnmarshalJSON(input []byte) error { type Log struct { Address *libcommon.Address `json:"address" gencodec:"required"` Topics []libcommon.Hash `json:"topics" gencodec:"required"` - Data *hexutil.Bytes `json:"data" gencodec:"required"` + Data *hexutility.Bytes `json:"data" gencodec:"required"` BlockNumber *hexutil.Uint64 `json:"blockNumber"` TxHash *libcommon.Hash `json:"transactionHash" gencodec:"required"` TxIndex *hexutil.Uint `json:"transactionIndex"` diff --git a/core/types/gen_receipt_json.go b/core/types/gen_receipt_json.go index aae54fecc..8a8986483 100644 --- a/core/types/gen_receipt_json.go +++ b/core/types/gen_receipt_json.go @@ -8,6 +8,7 @@ import ( "math/big" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common/hexutil" ) @@ -18,7 +19,7 @@ var _ = (*receiptMarshaling)(nil) func (r Receipt) MarshalJSON() ([]byte, error) { type Receipt struct { Type hexutil.Uint64 `json:"type,omitempty"` - PostState hexutil.Bytes `json:"root"` + PostState hexutility.Bytes `json:"root"` Status hexutil.Uint64 `json:"status"` CumulativeGasUsed hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"` Bloom Bloom `json:"logsBloom" gencodec:"required"` @@ -50,7 +51,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) { func (r *Receipt) UnmarshalJSON(input []byte) error { type Receipt struct { Type *hexutil.Uint64 `json:"type,omitempty"` - PostState *hexutil.Bytes `json:"root"` + PostState *hexutility.Bytes `json:"root"` Status *hexutil.Uint64 `json:"status"` CumulativeGasUsed *hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"` Bloom *Bloom `json:"logsBloom" gencodec:"required"` diff --git a/core/types/genesis.go b/core/types/genesis.go index dc67d7ff4..10ab14ef0 100644 --- a/core/types/genesis.go +++ b/core/types/genesis.go @@ -26,8 +26,9 @@ import ( "github.com/ledgerwatch/erigon-lib/chain" "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" + common2 "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/params" ) @@ -98,7 +99,7 @@ type GenesisAccount struct { type genesisSpecMarshaling struct { Nonce math.HexOrDecimal64 Timestamp math.HexOrDecimal64 - ExtraData hexutil.Bytes + ExtraData hexutility.Bytes GasLimit math.HexOrDecimal64 GasUsed math.HexOrDecimal64 Number math.HexOrDecimal64 @@ -109,12 +110,12 @@ type genesisSpecMarshaling struct { } type genesisAccountMarshaling struct { - Constructor hexutil.Bytes - Code hexutil.Bytes + Constructor hexutility.Bytes + Code hexutility.Bytes Balance *math.HexOrDecimal256 Nonce math.HexOrDecimal64 Storage map[storageJSON]storageJSON - PrivateKey hexutil.Bytes + PrivateKey hexutility.Bytes } // storageJSON represents a 256 bit byte array, but allows less than 256 bits when @@ -134,7 +135,7 @@ func (h *storageJSON) UnmarshalText(text []byte) error { } func (h storageJSON) MarshalText() ([]byte, error) { - return hexutil.Bytes(h[:]).MarshalText() + return hexutility.Bytes(h[:]).MarshalText() } // GenesisMismatchError is raised when trying to overwrite an existing diff --git a/core/types/log.go b/core/types/log.go index 892b8cf34..552300f49 100644 --- a/core/types/log.go +++ b/core/types/log.go @@ -20,6 +20,7 @@ import ( "io" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/rlp" @@ -189,7 +190,7 @@ Logs: } type logMarshaling struct { - Data hexutil.Bytes + Data hexutility.Bytes BlockNumber hexutil.Uint64 TxIndex hexutil.Uint Index hexutil.Uint diff --git a/core/types/receipt.go b/core/types/receipt.go index 32092fbe2..a8605e567 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -24,6 +24,7 @@ import ( "math/big" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/crypto" @@ -72,7 +73,7 @@ type Receipt struct { type receiptMarshaling struct { Type hexutil.Uint64 - PostState hexutil.Bytes + PostState hexutility.Bytes Status hexutil.Uint64 CumulativeGasUsed hexutil.Uint64 GasUsed hexutil.Uint64 diff --git a/core/types/transaction_marshalling.go b/core/types/transaction_marshalling.go index b11882934..f66134f6f 100644 --- a/core/types/transaction_marshalling.go +++ b/core/types/transaction_marshalling.go @@ -6,10 +6,12 @@ import ( "fmt" "github.com/holiman/uint256" - libcommon "github.com/ledgerwatch/erigon-lib/common" - types2 "github.com/ledgerwatch/erigon-lib/types" "github.com/valyala/fastjson" + libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" + types2 "github.com/ledgerwatch/erigon-lib/types" + "github.com/ledgerwatch/erigon/common/hexutil" ) @@ -24,7 +26,7 @@ type txJSON struct { Tip *hexutil.Big `json:"maxPriorityFeePerGas"` Gas *hexutil.Uint64 `json:"gas"` Value *hexutil.Big `json:"value"` - Data *hexutil.Bytes `json:"input"` + Data *hexutility.Bytes `json:"input"` V *hexutil.Big `json:"v"` R *hexutil.Big `json:"r"` S *hexutil.Big `json:"s"` @@ -47,7 +49,7 @@ func (tx LegacyTx) MarshalJSON() ([]byte, error) { enc.Gas = (*hexutil.Uint64)(&tx.Gas) enc.GasPrice = (*hexutil.Big)(tx.GasPrice.ToBig()) enc.Value = (*hexutil.Big)(tx.Value.ToBig()) - enc.Data = (*hexutil.Bytes)(&tx.Data) + enc.Data = (*hexutility.Bytes)(&tx.Data) enc.To = tx.To enc.V = (*hexutil.Big)(tx.V.ToBig()) enc.R = (*hexutil.Big)(tx.R.ToBig()) @@ -66,7 +68,7 @@ func (tx AccessListTx) MarshalJSON() ([]byte, error) { enc.Gas = (*hexutil.Uint64)(&tx.Gas) enc.GasPrice = (*hexutil.Big)(tx.GasPrice.ToBig()) enc.Value = (*hexutil.Big)(tx.Value.ToBig()) - enc.Data = (*hexutil.Bytes)(&tx.Data) + enc.Data = (*hexutility.Bytes)(&tx.Data) enc.To = tx.To enc.V = (*hexutil.Big)(tx.V.ToBig()) enc.R = (*hexutil.Big)(tx.R.ToBig()) @@ -86,7 +88,7 @@ func (tx DynamicFeeTransaction) MarshalJSON() ([]byte, error) { enc.FeeCap = (*hexutil.Big)(tx.FeeCap.ToBig()) enc.Tip = (*hexutil.Big)(tx.Tip.ToBig()) enc.Value = (*hexutil.Big)(tx.Value.ToBig()) - enc.Data = (*hexutil.Bytes)(&tx.Data) + enc.Data = (*hexutility.Bytes)(&tx.Data) enc.To = tx.To enc.V = (*hexutil.Big)(tx.V.ToBig()) enc.R = (*hexutil.Big)(tx.R.ToBig()) diff --git a/eth/tracers/internal/tracetest/calltrace_test.go b/eth/tracers/internal/tracetest/calltrace_test.go index 0d89de1f8..64911006d 100644 --- a/eth/tracers/internal/tracetest/calltrace_test.go +++ b/eth/tracers/internal/tracetest/calltrace_test.go @@ -26,9 +26,12 @@ import ( "testing" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/chain" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/kv/memdb" + "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" @@ -59,7 +62,7 @@ type callContext struct { type callLog struct { Address libcommon.Address `json:"address"` Topics []libcommon.Hash `json:"topics"` - Data hexutil.Bytes `json:"data"` + Data hexutility.Bytes `json:"data"` } // callTrace is the result of a callTracer run. @@ -68,8 +71,8 @@ type callTrace struct { Gas *hexutil.Uint64 `json:"gas"` GasUsed *hexutil.Uint64 `json:"gasUsed"` To libcommon.Address `json:"to,omitempty"` - Input hexutil.Bytes `json:"input"` - Output hexutil.Bytes `json:"output,omitempty"` + Input hexutility.Bytes `json:"input"` + Output hexutility.Bytes `json:"output,omitempty"` Error string `json:"error,omitempty"` Revertal string `json:"revertReason,omitempty"` Calls []callTrace `json:"calls,omitempty"` diff --git a/eth/tracers/logger/gen_structlog.go b/eth/tracers/logger/gen_structlog.go index 15d827510..fa9de16a7 100644 --- a/eth/tracers/logger/gen_structlog.go +++ b/eth/tracers/logger/gen_structlog.go @@ -5,8 +5,8 @@ import ( "math/big" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" - "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/core/vm" ) @@ -20,11 +20,11 @@ func (s StructLog) MarshalJSON() ([]byte, error) { Op vm.OpCode `json:"op"` Gas math.HexOrDecimal64 `json:"gas"` GasCost math.HexOrDecimal64 `json:"gasCost"` - Memory hexutil.Bytes `json:"memory"` + Memory hexutility.Bytes `json:"memory"` MemorySize int `json:"memSize"` Stack []*math.HexOrDecimal256 `json:"stack"` ReturnStack []math.HexOrDecimal64 `json:"returnStack"` - ReturnData hexutil.Bytes `json:"returnData"` + ReturnData hexutility.Bytes `json:"returnData"` Storage map[libcommon.Hash]libcommon.Hash `json:"-"` Depth int `json:"depth"` RefundCounter uint64 `json:"refund"` @@ -62,10 +62,10 @@ func (s *StructLog) UnmarshalJSON(input []byte) error { Op *vm.OpCode `json:"op"` Gas *math.HexOrDecimal64 `json:"gas"` GasCost *math.HexOrDecimal64 `json:"gasCost"` - Memory *hexutil.Bytes `json:"memory"` + Memory *hexutility.Bytes `json:"memory"` MemorySize *int `json:"memSize"` Stack []*math.HexOrDecimal256 `json:"stack"` - ReturnData *hexutil.Bytes `json:"returnData"` + ReturnData *hexutility.Bytes `json:"returnData"` Storage map[libcommon.Hash]libcommon.Hash `json:"-"` Depth *int `json:"depth"` RefundCounter *uint64 `json:"refund"` diff --git a/eth/tracers/logger/logger.go b/eth/tracers/logger/logger.go index 97934e51c..3beb7e7d9 100644 --- a/eth/tracers/logger/logger.go +++ b/eth/tracers/logger/logger.go @@ -11,10 +11,11 @@ import ( "strings" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/chain" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" - "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" @@ -70,8 +71,8 @@ type structLogMarshaling struct { Stack []*math.HexOrDecimal256 Gas math.HexOrDecimal64 GasCost math.HexOrDecimal64 - Memory hexutil.Bytes - ReturnData hexutil.Bytes + Memory hexutility.Bytes + ReturnData hexutility.Bytes OpName string `json:"opName"` // adds call to OpName() in MarshalJSON ErrorString string `json:"error"` // adds call to ErrorString() in MarshalJSON } diff --git a/eth/tracers/native/call.go b/eth/tracers/native/call.go index 59982d23e..4a70838bd 100644 --- a/eth/tracers/native/call.go +++ b/eth/tracers/native/call.go @@ -23,7 +23,9 @@ import ( "sync/atomic" "github.com/holiman/uint256" + libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/accounts/abi" "github.com/ledgerwatch/erigon/common" @@ -41,7 +43,7 @@ func init() { type callLog struct { Address libcommon.Address `json:"address"` Topics []libcommon.Hash `json:"topics"` - Data hexutil.Bytes `json:"data"` + Data hexutility.Bytes `json:"data"` } type callFrame struct { @@ -96,8 +98,8 @@ type callFrameMarshaling struct { Gas hexutil.Uint64 GasUsed hexutil.Uint64 Value *hexutil.Big - Input hexutil.Bytes - Output hexutil.Bytes + Input hexutility.Bytes + Output hexutility.Bytes } type callTracer struct { @@ -181,7 +183,7 @@ func (t *callTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, sco } data := scope.Memory.GetCopy(int64(mStart.Uint64()), int64(mSize.Uint64())) - log := callLog{Address: scope.Contract.Address(), Topics: topics, Data: hexutil.Bytes(data)} + log := callLog{Address: scope.Contract.Address(), Topics: topics, Data: hexutility.Bytes(data)} t.callstack[len(t.callstack)-1].Logs = append(t.callstack[len(t.callstack)-1].Logs, log) } } diff --git a/eth/tracers/native/gen_account_json.go b/eth/tracers/native/gen_account_json.go index ec2f40728..d4f00b2a4 100644 --- a/eth/tracers/native/gen_account_json.go +++ b/eth/tracers/native/gen_account_json.go @@ -7,6 +7,7 @@ import ( "math/big" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common/hexutil" ) @@ -17,7 +18,7 @@ var _ = (*accountMarshaling)(nil) func (a account) MarshalJSON() ([]byte, error) { type account struct { Balance *hexutil.Big `json:"balance,omitempty"` - Code hexutil.Bytes `json:"code,omitempty"` + Code hexutility.Bytes `json:"code,omitempty"` Nonce uint64 `json:"nonce,omitempty"` Storage map[libcommon.Hash]libcommon.Hash `json:"storage,omitempty"` } @@ -33,7 +34,7 @@ func (a account) MarshalJSON() ([]byte, error) { func (a *account) UnmarshalJSON(input []byte) error { type account struct { Balance *hexutil.Big `json:"balance,omitempty"` - Code *hexutil.Bytes `json:"code,omitempty"` + Code *hexutility.Bytes `json:"code,omitempty"` Nonce *uint64 `json:"nonce,omitempty"` Storage map[libcommon.Hash]libcommon.Hash `json:"storage,omitempty"` } diff --git a/eth/tracers/native/gen_callframe_json.go b/eth/tracers/native/gen_callframe_json.go index ac3cfc938..9a49f0f7c 100644 --- a/eth/tracers/native/gen_callframe_json.go +++ b/eth/tracers/native/gen_callframe_json.go @@ -7,6 +7,7 @@ import ( "math/big" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/vm" @@ -22,8 +23,8 @@ func (c callFrame) MarshalJSON() ([]byte, error) { Gas hexutil.Uint64 `json:"gas"` GasUsed hexutil.Uint64 `json:"gasUsed"` To libcommon.Address `json:"to,omitempty" rlp:"optional"` - Input hexutil.Bytes `json:"input" rlp:"optional"` - Output hexutil.Bytes `json:"output,omitempty" rlp:"optional"` + Input hexutility.Bytes `json:"input" rlp:"optional"` + Output hexutility.Bytes `json:"output,omitempty" rlp:"optional"` Error string `json:"error,omitempty" rlp:"optional"` Revertal string `json:"revertReason,omitempty"` Calls []callFrame `json:"calls,omitempty" rlp:"optional"` @@ -56,8 +57,8 @@ func (c *callFrame) UnmarshalJSON(input []byte) error { Gas *hexutil.Uint64 `json:"gas"` GasUsed *hexutil.Uint64 `json:"gasUsed"` To *libcommon.Address `json:"to,omitempty" rlp:"optional"` - Input *hexutil.Bytes `json:"input" rlp:"optional"` - Output *hexutil.Bytes `json:"output,omitempty" rlp:"optional"` + Input *hexutility.Bytes `json:"input" rlp:"optional"` + Output *hexutility.Bytes `json:"output,omitempty" rlp:"optional"` Error *string `json:"error,omitempty" rlp:"optional"` Revertal *string `json:"revertReason,omitempty"` Calls []callFrame `json:"calls,omitempty" rlp:"optional"` diff --git a/eth/tracers/native/prestate.go b/eth/tracers/native/prestate.go index 89c497d50..3bce65a17 100644 --- a/eth/tracers/native/prestate.go +++ b/eth/tracers/native/prestate.go @@ -23,7 +23,9 @@ import ( "sync/atomic" "github.com/holiman/uint256" + libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/vm" @@ -52,7 +54,7 @@ func (a *account) exists() bool { type accountMarshaling struct { Balance *hexutil.Big - Code hexutil.Bytes + Code hexutility.Bytes } type prestateTracer struct { diff --git a/go.mod b/go.mod index e04bd0a95..551602965 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/ledgerwatch/erigon go 1.19 require ( - github.com/ledgerwatch/erigon-lib v0.0.0-20230412095902-9ef1a57e8418 + github.com/ledgerwatch/erigon-lib v0.0.0-20230413101817-5e9e729d3ce3 github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230404044759-5dec854ce336 github.com/ledgerwatch/log/v3 v3.7.0 github.com/ledgerwatch/secp256k1 v1.0.0 diff --git a/go.sum b/go.sum index 59d2698ea..6ab9c6d88 100644 --- a/go.sum +++ b/go.sum @@ -527,8 +527,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3PYPwICLl+/9oulQauOuETfgFvhBDffs0= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/ledgerwatch/erigon-lib v0.0.0-20230412095902-9ef1a57e8418 h1:7U1yMWGDN4GWpydbej8CMkFAY4R+6knO61MXtDxteLc= -github.com/ledgerwatch/erigon-lib v0.0.0-20230412095902-9ef1a57e8418/go.mod h1:jfv6zfkuhalm02Q7wzlmjDdDHf9jxRLO/KM/1aJMhlw= +github.com/ledgerwatch/erigon-lib v0.0.0-20230413101817-5e9e729d3ce3 h1:oo8E+wE18V2awVlVU8w8uuSGPo9zlyzRYRxZGVw5X3w= +github.com/ledgerwatch/erigon-lib v0.0.0-20230413101817-5e9e729d3ce3/go.mod h1:jfv6zfkuhalm02Q7wzlmjDdDHf9jxRLO/KM/1aJMhlw= github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230404044759-5dec854ce336 h1:Yxmt4Wyd0RCLr7UJJAl0ApCP/f5qkWfvHfgPbnI8ghM= github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230404044759-5dec854ce336/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo= github.com/ledgerwatch/log/v3 v3.7.0 h1:aFPEZdwZx4jzA3+/Pf8wNDN5tCI0cIolq/kfvgcM+og= diff --git a/params/mining.go b/params/mining.go index 34d47d38c..d5e0d8cc8 100644 --- a/params/mining.go +++ b/params/mining.go @@ -6,8 +6,7 @@ import ( "time" libcommon "github.com/ledgerwatch/erigon-lib/common" - - "github.com/ledgerwatch/erigon/common/hexutil" + "github.com/ledgerwatch/erigon-lib/common/hexutility" ) // MiningConfig is the configuration parameters of mining. @@ -18,7 +17,7 @@ type MiningConfig struct { Etherbase libcommon.Address `toml:",omitempty"` // Public address for block mining rewards SigKey *ecdsa.PrivateKey // ECDSA private key for signing blocks Notify []string `toml:",omitempty"` // HTTP URL list to be notified of new work packages(only useful in ethash). - ExtraData hexutil.Bytes `toml:",omitempty"` // Block extra data set by the miner + ExtraData hexutility.Bytes `toml:",omitempty"` // Block extra data set by the miner GasLimit uint64 // Target gas limit for mined blocks. GasPrice *big.Int // Minimum gas price for mining a transaction Recommit time.Duration // The time interval for miner to re-create mining work. diff --git a/tests/block_test_util.go b/tests/block_test_util.go index e79e5e231..784a10c50 100644 --- a/tests/block_test_util.go +++ b/tests/block_test_util.go @@ -27,9 +27,12 @@ import ( "testing" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/chain" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" @@ -94,7 +97,7 @@ type btHeader struct { } type btHeaderMarshaling struct { - ExtraData hexutil.Bytes + ExtraData hexutility.Bytes Number *math.HexOrDecimal256 Difficulty *math.HexOrDecimal256 GasLimit math.HexOrDecimal64 diff --git a/tests/gen_btheader.go b/tests/gen_btheader.go index 41722bf16..b6187760f 100644 --- a/tests/gen_btheader.go +++ b/tests/gen_btheader.go @@ -7,8 +7,8 @@ import ( "math/big" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" - "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/core/types" ) @@ -29,7 +29,7 @@ func (b btHeader) MarshalJSON() ([]byte, error) { StateRoot libcommon.Hash TransactionsTrie libcommon.Hash UncleHash libcommon.Hash - ExtraData hexutil.Bytes + ExtraData hexutility.Bytes Difficulty *math.HexOrDecimal256 GasLimit math.HexOrDecimal64 GasUsed math.HexOrDecimal64 @@ -71,7 +71,7 @@ func (b *btHeader) UnmarshalJSON(input []byte) error { StateRoot *libcommon.Hash TransactionsTrie *libcommon.Hash UncleHash *libcommon.Hash - ExtraData *hexutil.Bytes + ExtraData *hexutility.Bytes Difficulty *math.HexOrDecimal256 GasLimit *math.HexOrDecimal64 GasUsed *math.HexOrDecimal64 diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 8ea699aab..895f18419 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -26,15 +26,16 @@ import ( "strings" "github.com/holiman/uint256" + "golang.org/x/crypto/sha3" + "github.com/ledgerwatch/erigon-lib/chain" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/common/length" "github.com/ledgerwatch/erigon-lib/kv" types2 "github.com/ledgerwatch/erigon-lib/types" - "golang.org/x/crypto/sha3" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/state" @@ -65,14 +66,14 @@ type stJSON struct { Env stEnv `json:"env"` Pre types.GenesisAlloc `json:"pre"` Tx stTransactionMarshaling `json:"transaction"` - Out hexutil.Bytes `json:"out"` + Out hexutility.Bytes `json:"out"` Post map[string][]stPostState `json:"post"` } type stPostState struct { Root common.UnprefixedHash `json:"hash"` Logs common.UnprefixedHash `json:"logs"` - Tx hexutil.Bytes `json:"txbytes"` + Tx hexutility.Bytes `json:"txbytes"` ExpectException string `json:"expectException"` Indexes struct { Data int `json:"data"` @@ -87,7 +88,7 @@ type stTransactionMarshaling struct { MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"` Nonce math.HexOrDecimal64 `json:"nonce"` GasLimit []math.HexOrDecimal64 `json:"gasLimit"` - PrivateKey hexutil.Bytes `json:"secretKey"` + PrivateKey hexutility.Bytes `json:"secretKey"` To string `json:"to"` Data []string `json:"data"` Value []string `json:"value"` diff --git a/tests/transaction_test_util.go b/tests/transaction_test_util.go index 5eee06e75..f2d063650 100644 --- a/tests/transaction_test_util.go +++ b/tests/transaction_test_util.go @@ -23,10 +23,11 @@ import ( "math/big" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/chain" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutility" - "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" @@ -35,8 +36,8 @@ import ( // TransactionTest checks RLP decoding and sender derivation of transactions. type TransactionTest struct { - RLP hexutil.Bytes `json:"txbytes"` - Forks ttForks `json:"result"` + RLP hexutility.Bytes `json:"txbytes"` + Forks ttForks `json:"result"` } type ttForks struct { @@ -60,7 +61,7 @@ type ttFork struct { } func (tt *TransactionTest) Run(chainID *big.Int) error { - validateTx := func(rlpData hexutil.Bytes, signer types.Signer, rules *chain.Rules) (*libcommon.Address, *libcommon.Hash, uint64, error) { + validateTx := func(rlpData hexutility.Bytes, signer types.Signer, rules *chain.Rules) (*libcommon.Address, *libcommon.Hash, uint64, error) { tx, err := types.DecodeTransaction(rlp.NewStream(bytes.NewReader(rlpData), 0)) if err != nil { return nil, nil, 0, err diff --git a/turbo/adapter/ethapi/api.go b/turbo/adapter/ethapi/api.go index 244b1b573..b7e714048 100644 --- a/turbo/adapter/ethapi/api.go +++ b/turbo/adapter/ethapi/api.go @@ -45,7 +45,7 @@ type CallArgs struct { MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"` Value *hexutil.Big `json:"value"` Nonce *hexutil.Uint64 `json:"nonce"` - Data *hexutil.Bytes `json:"data"` + Data *hexutility.Bytes `json:"data"` AccessList *types2.AccessList `json:"accessList"` ChainID *hexutil.Big `json:"chainId,omitempty"` } @@ -157,7 +157,7 @@ func (args *CallArgs) ToMessage(globalGasCap uint64, baseFee *uint256.Int) (type // message. type Account struct { Nonce *hexutil.Uint64 `json:"nonce"` - Code *hexutil.Bytes `json:"code"` + Code *hexutility.Bytes `json:"code"` Balance **hexutil.Big `json:"balance"` State *map[libcommon.Hash]uint256.Int `json:"state"` StateDiff *map[libcommon.Hash]uint256.Int `json:"stateDiff"` @@ -267,7 +267,7 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} { "stateRoot": head.Root, "miner": head.Coinbase, "difficulty": (*hexutil.Big)(head.Difficulty), - "extraData": hexutil.Bytes(head.Extra), + "extraData": hexutility.Bytes(head.Extra), "size": hexutil.Uint64(head.Size()), "gasLimit": hexutil.Uint64(head.GasLimit), "gasUsed": hexutil.Uint64(head.GasUsed), @@ -378,7 +378,7 @@ type RPCTransaction struct { Tip *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"` FeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"` Hash libcommon.Hash `json:"hash"` - Input hexutil.Bytes `json:"input"` + Input hexutility.Bytes `json:"input"` Nonce hexutil.Uint64 `json:"nonce"` To *libcommon.Address `json:"to"` TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` @@ -403,7 +403,7 @@ func newRPCTransaction(tx types.Transaction, blockHash libcommon.Hash, blockNumb Type: hexutil.Uint64(tx.Type()), Gas: hexutil.Uint64(tx.GetGas()), Hash: tx.Hash(), - Input: hexutil.Bytes(tx.GetData()), + Input: hexutility.Bytes(tx.GetData()), Nonce: hexutil.Uint64(tx.GetNonce()), To: tx.GetTo(), Value: (*hexutil.Big)(tx.GetValue().ToBig()), @@ -469,7 +469,7 @@ func newRPCBorTransaction(opaqueTx types.Transaction, txHash libcommon.Hash, blo GasPrice: (*hexutil.Big)(tx.GasPrice.ToBig()), Gas: hexutil.Uint64(tx.GetGas()), Hash: txHash, - Input: hexutil.Bytes(tx.GetData()), + Input: hexutility.Bytes(tx.GetData()), Nonce: hexutil.Uint64(tx.GetNonce()), From: libcommon.Address{}, To: tx.GetTo(),