diff --git a/accounts/abi/pack.go b/accounts/abi/pack.go index 4ba889472..08d40611a 100644 --- a/accounts/abi/pack.go +++ b/accounts/abi/pack.go @@ -22,6 +22,7 @@ import ( "math/big" "reflect" + common2 "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/math" ) @@ -49,9 +50,9 @@ func packElement(t Type, reflectValue reflect.Value) ([]byte, error) { return common.LeftPadBytes(reflectValue.Bytes(), 32), nil case BoolTy: if reflectValue.Bool() { - return math.PaddedBigBytes(common.Big1, 32), nil + return math.PaddedBigBytes(common2.Big1, 32), nil } - return math.PaddedBigBytes(common.Big0, 32), nil + return math.PaddedBigBytes(common2.Big0, 32), nil case BytesTy: if reflectValue.Kind() == reflect.Array { reflectValue = mustArrayToByteSlice(reflectValue) diff --git a/accounts/abi/unpack.go b/accounts/abi/unpack.go index deb324e10..64f2599a1 100644 --- a/accounts/abi/unpack.go +++ b/accounts/abi/unpack.go @@ -23,15 +23,13 @@ import ( "reflect" libcommon "github.com/ledgerwatch/erigon-lib/common" - - "github.com/ledgerwatch/erigon/common" ) var ( // MaxUint256 is the maximum value that can be represented by a uint256. - MaxUint256 = new(big.Int).Sub(new(big.Int).Lsh(common.Big1, 256), common.Big1) + MaxUint256 = new(big.Int).Sub(new(big.Int).Lsh(libcommon.Big1, 256), libcommon.Big1) // MaxInt256 is the maximum value that can be represented by a int256. - MaxInt256 = new(big.Int).Sub(new(big.Int).Lsh(common.Big1, 255), common.Big1) + MaxInt256 = new(big.Int).Sub(new(big.Int).Lsh(libcommon.Big1, 255), libcommon.Big1) ) // ReadInteger reads the integer based on its kind and returns the appropriate value. @@ -68,7 +66,7 @@ func ReadInteger(typ Type, b []byte) interface{} { ret := new(big.Int).SetBytes(b) if ret.Bit(255) == 1 { ret.Add(MaxUint256, new(big.Int).Neg(ret)) - ret.Add(ret, common.Big1) + ret.Add(ret, libcommon.Big1) ret.Neg(ret) } return ret @@ -258,7 +256,7 @@ func toGoType(index int, t Type, output []byte) (interface{}, error) { // lengthPrefixPointsTo interprets a 32 byte slice as an offset and then determines which indices to look to decode the type. func lengthPrefixPointsTo(index int, output []byte) (start int, length int, err error) { bigOffsetEnd := big.NewInt(0).SetBytes(output[index : index+32]) - bigOffsetEnd.Add(bigOffsetEnd, common.Big32) + bigOffsetEnd.Add(bigOffsetEnd, libcommon.Big32) outputLength := big.NewInt(int64(len(output))) if bigOffsetEnd.Cmp(outputLength) > 0 { diff --git a/cmd/devnet/contracts/gen_subscription.go b/cmd/devnet/contracts/gen_subscription.go index 55309248b..cb1a20974 100644 --- a/cmd/devnet/contracts/gen_subscription.go +++ b/cmd/devnet/contracts/gen_subscription.go @@ -23,7 +23,7 @@ var ( _ = strings.NewReader _ = ethereum.NotFound _ = bind.Bind - _ = common.Big1 + _ = libcommon.Big1 _ = types.BloomLookup _ = event.NewSubscription ) diff --git a/cmd/erigon-el/backend/backend.go b/cmd/erigon-el/backend/backend.go index ef8e58b9a..7979228dc 100644 --- a/cmd/erigon-el/backend/backend.go +++ b/cmd/erigon-el/backend/backend.go @@ -56,7 +56,6 @@ import ( "github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/commands" "github.com/ledgerwatch/erigon/cmd/sentry/sentry" - "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/consensus/bor" @@ -161,7 +160,7 @@ type Ethereum struct { // New creates a new Ethereum object (including the // initialisation of the common Ethereum object) func NewBackend(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethereum, error) { - if config.Miner.GasPrice == nil || config.Miner.GasPrice.Cmp(common.Big0) <= 0 { + if config.Miner.GasPrice == nil || config.Miner.GasPrice.Cmp(libcommon.Big0) <= 0 { log.Warn("Sanitizing invalid miner gas price", "provided", config.Miner.GasPrice, "updated", ethconfig.Defaults.Miner.GasPrice) config.Miner.GasPrice = new(big.Int).Set(ethconfig.Defaults.Miner.GasPrice) } diff --git a/cmd/pics/contracts/gen_token.go b/cmd/pics/contracts/gen_token.go index b7ab9b22a..3973e6d0e 100644 --- a/cmd/pics/contracts/gen_token.go +++ b/cmd/pics/contracts/gen_token.go @@ -23,7 +23,7 @@ var ( _ = strings.NewReader _ = ethereum.NotFound _ = bind.Bind - _ = common.Big1 + _ = libcommon.Big1 _ = types.BloomLookup _ = event.NewSubscription ) diff --git a/cmd/rpcdaemon/commands/bor_api.go b/cmd/rpcdaemon/commands/bor_api.go index 7a37491c2..9bf43905f 100644 --- a/cmd/rpcdaemon/commands/bor_api.go +++ b/cmd/rpcdaemon/commands/bor_api.go @@ -1,7 +1,7 @@ package commands import ( - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/consensus/bor" @@ -12,11 +12,11 @@ import ( type BorAPI interface { // Bor snapshot related (see ./bor_snapshot.go) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error) - GetAuthor(number *rpc.BlockNumber) (*libcommon.Address, error) - GetSnapshotAtHash(hash libcommon.Hash) (*Snapshot, error) - GetSigners(number *rpc.BlockNumber) ([]libcommon.Address, error) - GetSignersAtHash(hash libcommon.Hash) ([]libcommon.Address, error) - GetCurrentProposer() (libcommon.Address, error) + GetAuthor(number *rpc.BlockNumber) (*common.Address, error) + GetSnapshotAtHash(hash common.Hash) (*Snapshot, error) + GetSigners(number *rpc.BlockNumber) ([]common.Address, error) + GetSignersAtHash(hash common.Hash) ([]common.Address, error) + GetCurrentProposer() (common.Address, error) GetCurrentValidators() ([]*bor.Validator, error) GetRootHash(start uint64, end uint64) (string, error) } diff --git a/cmd/rpcdaemon/commands/bor_helper.go b/cmd/rpcdaemon/commands/bor_helper.go index 9cb95a338..a47e521e9 100644 --- a/cmd/rpcdaemon/commands/bor_helper.go +++ b/cmd/rpcdaemon/commands/bor_helper.go @@ -7,7 +7,7 @@ import ( "fmt" "github.com/ledgerwatch/erigon-lib/chain" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/consensus/bor" @@ -74,7 +74,7 @@ func getHeaderByNumber(ctx context.Context, number rpc.BlockNumber, api *BorImpl // getHeaderByHash returns a block's header given a block's hash. // derived from erigon_getHeaderByHash implementation (see ./erigon_block.go) -func getHeaderByHash(ctx context.Context, api *BorImpl, tx kv.Tx, hash libcommon.Hash) (*types.Header, error) { +func getHeaderByHash(ctx context.Context, api *BorImpl, tx kv.Tx, hash common.Hash) (*types.Header, error) { header, err := api._blockReader.HeaderByHash(ctx, tx, hash) if err != nil { return nil, err @@ -87,19 +87,19 @@ func getHeaderByHash(ctx context.Context, api *BorImpl, tx kv.Tx, hash libcommon } // ecrecover extracts the Ethereum account address from a signed header. -func ecrecover(header *types.Header, c *chain.BorConfig) (libcommon.Address, error) { +func ecrecover(header *types.Header, c *chain.BorConfig) (common.Address, error) { // Retrieve the signature from the header extra-data if len(header.Extra) < extraSeal { - return libcommon.Address{}, errMissingSignature + return common.Address{}, errMissingSignature } signature := header.Extra[len(header.Extra)-extraSeal:] // Recover the public key and the Ethereum address pubkey, err := crypto.Ecrecover(bor.SealHash(header, c).Bytes(), signature) if err != nil { - return libcommon.Address{}, err + return common.Address{}, err } - var signer libcommon.Address + var signer common.Address copy(signer[:], crypto.Keccak256(pubkey[1:])[12:]) return signer, nil @@ -155,7 +155,7 @@ func getUpdatedValidatorSet(oldValidatorSet *ValidatorSet, newVals []*bor.Valida // author returns the Ethereum address recovered // from the signature in the header's extra-data section. -func author(api *BorImpl, tx kv.Tx, header *types.Header) (libcommon.Address, error) { +func author(api *BorImpl, tx kv.Tx, header *types.Header) (common.Address, error) { config, _ := api.BaseAPI.chainConfig(tx) return ecrecover(header, config.Bor) } diff --git a/cmd/rpcdaemon/commands/bor_snapshot.go b/cmd/rpcdaemon/commands/bor_snapshot.go index e55566f52..bf033cd61 100644 --- a/cmd/rpcdaemon/commands/bor_snapshot.go +++ b/cmd/rpcdaemon/commands/bor_snapshot.go @@ -8,7 +8,7 @@ import ( "math/big" "github.com/ledgerwatch/erigon-lib/chain" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/log/v3" "github.com/xsleonard/go-merkle" @@ -25,10 +25,10 @@ import ( type Snapshot struct { config *chain.BorConfig // Consensus engine parameters to fine tune behavior - Number uint64 `json:"number"` // Block number where the snapshot was created - Hash libcommon.Hash `json:"hash"` // Block hash where the snapshot was created - ValidatorSet *ValidatorSet `json:"validatorSet"` // Validator set at this moment - Recents map[uint64]libcommon.Address `json:"recents"` // Set of recent signers for spam protections + Number uint64 `json:"number"` // Block number where the snapshot was created + Hash common.Hash `json:"hash"` // Block hash where the snapshot was created + ValidatorSet *ValidatorSet `json:"validatorSet"` // Validator set at this moment + Recents map[uint64]common.Address `json:"recents"` // Set of recent signers for spam protections } // GetSnapshot retrieves the state snapshot at a given block. @@ -63,7 +63,7 @@ func (api *BorImpl) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error) { } // GetAuthor retrieves the author a block. -func (api *BorImpl) GetAuthor(number *rpc.BlockNumber) (*libcommon.Address, error) { +func (api *BorImpl) GetAuthor(number *rpc.BlockNumber) (*common.Address, error) { ctx := context.Background() tx, err := api.db.BeginRo(ctx) if err != nil { @@ -87,7 +87,7 @@ func (api *BorImpl) GetAuthor(number *rpc.BlockNumber) (*libcommon.Address, erro } // GetSnapshotAtHash retrieves the state snapshot at a given block. -func (api *BorImpl) GetSnapshotAtHash(hash libcommon.Hash) (*Snapshot, error) { +func (api *BorImpl) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error) { // init chain db ctx := context.Background() tx, err := api.db.BeginRo(ctx) @@ -114,7 +114,7 @@ func (api *BorImpl) GetSnapshotAtHash(hash libcommon.Hash) (*Snapshot, error) { } // GetSigners retrieves the list of authorized signers at the specified block. -func (api *BorImpl) GetSigners(number *rpc.BlockNumber) ([]libcommon.Address, error) { +func (api *BorImpl) GetSigners(number *rpc.BlockNumber) ([]common.Address, error) { // init chain db ctx := context.Background() tx, err := api.db.BeginRo(ctx) @@ -146,7 +146,7 @@ func (api *BorImpl) GetSigners(number *rpc.BlockNumber) ([]libcommon.Address, er } // GetSignersAtHash retrieves the list of authorized signers at the specified block. -func (api *BorImpl) GetSignersAtHash(hash libcommon.Hash) ([]libcommon.Address, error) { +func (api *BorImpl) GetSignersAtHash(hash common.Hash) ([]common.Address, error) { // init chain db ctx := context.Background() tx, err := api.db.BeginRo(ctx) @@ -175,10 +175,10 @@ func (api *BorImpl) GetSignersAtHash(hash libcommon.Hash) ([]libcommon.Address, } // GetCurrentProposer gets the current proposer -func (api *BorImpl) GetCurrentProposer() (libcommon.Address, error) { +func (api *BorImpl) GetCurrentProposer() (common.Address, error) { snap, err := api.GetSnapshot(nil) if err != nil { - return libcommon.Address{}, err + return common.Address{}, err } return snap.ValidatorSet.GetProposer().Address, nil } @@ -249,7 +249,7 @@ func (s *Snapshot) copy() *Snapshot { Number: s.Number, Hash: s.Hash, ValidatorSet: s.ValidatorSet.Copy(), - Recents: make(map[uint64]libcommon.Address), + Recents: make(map[uint64]common.Address), } for block, signer := range s.Recents { cpy.Recents[block] = signer @@ -259,7 +259,7 @@ func (s *Snapshot) copy() *Snapshot { } // GetSignerSuccessionNumber returns the relative position of signer in terms of the in-turn proposer -func (s *Snapshot) GetSignerSuccessionNumber(signer libcommon.Address) (int, error) { +func (s *Snapshot) GetSignerSuccessionNumber(signer common.Address) (int, error) { validators := s.ValidatorSet.Validators proposer := s.ValidatorSet.GetProposer().Address proposerIndex, _ := s.ValidatorSet.GetByAddress(proposer) @@ -281,8 +281,8 @@ func (s *Snapshot) GetSignerSuccessionNumber(signer libcommon.Address) (int, err } // signers retrieves the list of authorized signers in ascending order. -func (s *Snapshot) signers() []libcommon.Address { - sigs := make([]libcommon.Address, 0, len(s.ValidatorSet.Validators)) +func (s *Snapshot) signers() []common.Address { + sigs := make([]common.Address, 0, len(s.ValidatorSet.Validators)) for _, sig := range s.ValidatorSet.Validators { sigs = append(sigs, sig.Address) } @@ -405,7 +405,7 @@ func snapshot(ctx context.Context, api *BorImpl, db kv.Tx, borDb kv.Tx, header * } // loadSnapshot loads an existing snapshot from the database. -func loadSnapshot(api *BorImpl, db kv.Tx, borDb kv.Tx, hash libcommon.Hash) (*Snapshot, error) { +func loadSnapshot(api *BorImpl, db kv.Tx, borDb kv.Tx, hash common.Hash) (*Snapshot, error) { blob, err := borDb.GetOne(kv.BorSeparate, append([]byte("bor-"), hash[:]...)) if err != nil { return nil, err diff --git a/cmd/rpcdaemon/commands/call_traces_test.go b/cmd/rpcdaemon/commands/call_traces_test.go index 0d4d51912..28964b139 100644 --- a/cmd/rpcdaemon/commands/call_traces_test.go +++ b/cmd/rpcdaemon/commands/call_traces_test.go @@ -7,7 +7,7 @@ import ( "github.com/holiman/uint256" jsoniter "github.com/json-iterator/go" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/kv/kvcache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -47,7 +47,7 @@ func blockNumbersFromTraces(t *testing.T, b []byte) []int { func TestCallTraceOneByOne(t *testing.T) { m := stages.Mock(t) chain, err := core.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, 10, func(i int, gen *core.BlockGen) { - gen.SetCoinbase(libcommon.Address{1}) + gen.SetCoinbase(common.Address{1}) }, false /* intermediateHashes */) if err != nil { t.Fatalf("generate chain: %v", err) @@ -69,11 +69,11 @@ func TestCallTraceOneByOne(t *testing.T) { var fromBlock, toBlock uint64 fromBlock = 1 toBlock = 10 - toAddress1 := libcommon.Address{1} + toAddress1 := common.Address{1} traceReq1 := TraceFilterRequest{ FromBlock: (*hexutil.Uint64)(&fromBlock), ToBlock: (*hexutil.Uint64)(&toBlock), - ToAddress: []*libcommon.Address{&toAddress1}, + ToAddress: []*common.Address{&toAddress1}, } if err = api.Filter(context.Background(), traceReq1, stream); err != nil { t.Fatalf("trace_filter failed: %v", err) @@ -86,16 +86,16 @@ func TestCallTraceUnwind(t *testing.T) { var chainA, chainB *core.ChainPack var err error chainA, err = core.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, 10, func(i int, gen *core.BlockGen) { - gen.SetCoinbase(libcommon.Address{1}) + gen.SetCoinbase(common.Address{1}) }, false /* intermediateHashes */) if err != nil { t.Fatalf("generate chainA: %v", err) } chainB, err = core.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, 20, func(i int, gen *core.BlockGen) { if i < 5 || i >= 10 { - gen.SetCoinbase(libcommon.Address{1}) + gen.SetCoinbase(common.Address{1}) } else { - gen.SetCoinbase(libcommon.Address{2}) + gen.SetCoinbase(common.Address{2}) } }, false /* intermediateHashes */) if err != nil { @@ -113,11 +113,11 @@ func TestCallTraceUnwind(t *testing.T) { var fromBlock, toBlock uint64 fromBlock = 1 toBlock = 10 - toAddress1 := libcommon.Address{1} + toAddress1 := common.Address{1} traceReq1 := TraceFilterRequest{ FromBlock: (*hexutil.Uint64)(&fromBlock), ToBlock: (*hexutil.Uint64)(&toBlock), - ToAddress: []*libcommon.Address{&toAddress1}, + ToAddress: []*common.Address{&toAddress1}, } if err = api.Filter(context.Background(), traceReq1, stream); err != nil { t.Fatalf("trace_filter failed: %v", err) @@ -132,7 +132,7 @@ func TestCallTraceUnwind(t *testing.T) { traceReq2 := TraceFilterRequest{ FromBlock: (*hexutil.Uint64)(&fromBlock), ToBlock: (*hexutil.Uint64)(&toBlock), - ToAddress: []*libcommon.Address{&toAddress1}, + ToAddress: []*common.Address{&toAddress1}, } if err = api.Filter(context.Background(), traceReq2, stream); err != nil { t.Fatalf("trace_filter failed: %v", err) @@ -148,7 +148,7 @@ func TestCallTraceUnwind(t *testing.T) { traceReq3 := TraceFilterRequest{ FromBlock: (*hexutil.Uint64)(&fromBlock), ToBlock: (*hexutil.Uint64)(&toBlock), - ToAddress: []*libcommon.Address{&toAddress1}, + ToAddress: []*common.Address{&toAddress1}, } if err = api.Filter(context.Background(), traceReq3, stream); err != nil { t.Fatalf("trace_filter failed: %v", err) @@ -159,7 +159,7 @@ func TestCallTraceUnwind(t *testing.T) { func TestFilterNoAddresses(t *testing.T) { m := stages.Mock(t) chain, err := core.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, 10, func(i int, gen *core.BlockGen) { - gen.SetCoinbase(libcommon.Address{1}) + gen.SetCoinbase(common.Address{1}) }, false /* intermediateHashes */) if err != nil { t.Fatalf("generate chain: %v", err) @@ -194,13 +194,13 @@ func TestFilterAddressIntersection(t *testing.T) { br := snapshotsync.NewBlockReaderWithSnapshots(m.BlockSnapshots) api := NewTraceAPI(NewBaseApi(nil, kvcache.New(kvcache.DefaultCoherentConfig), br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), m.DB, &httpcfg.HttpCfg{}) - toAddress1, toAddress2, other := libcommon.Address{1}, libcommon.Address{2}, libcommon.Address{3} + toAddress1, toAddress2, other := common.Address{1}, common.Address{2}, common.Address{3} once := new(sync.Once) chain, err := core.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, 15, func(i int, block *core.BlockGen) { - once.Do(func() { block.SetCoinbase(libcommon.Address{4}) }) + once.Do(func() { block.SetCoinbase(common.Address{4}) }) - var rcv libcommon.Address + var rcv common.Address if i < 5 { rcv = toAddress1 } else if i < 10 { @@ -229,8 +229,8 @@ func TestFilterAddressIntersection(t *testing.T) { traceReq1 := TraceFilterRequest{ FromBlock: (*hexutil.Uint64)(&fromBlock), ToBlock: (*hexutil.Uint64)(&toBlock), - FromAddress: []*libcommon.Address{&m.Address, &other}, - ToAddress: []*libcommon.Address{&m.Address, &toAddress2}, + FromAddress: []*common.Address{&m.Address, &other}, + ToAddress: []*common.Address{&m.Address, &toAddress2}, Mode: TraceFilterModeIntersection, } if err = api.Filter(context.Background(), traceReq1, stream); err != nil { @@ -245,8 +245,8 @@ func TestFilterAddressIntersection(t *testing.T) { traceReq1 := TraceFilterRequest{ FromBlock: (*hexutil.Uint64)(&fromBlock), ToBlock: (*hexutil.Uint64)(&toBlock), - FromAddress: []*libcommon.Address{&m.Address, &other}, - ToAddress: []*libcommon.Address{&toAddress1, &m.Address}, + FromAddress: []*common.Address{&m.Address, &other}, + ToAddress: []*common.Address{&toAddress1, &m.Address}, Mode: TraceFilterModeIntersection, } if err = api.Filter(context.Background(), traceReq1, stream); err != nil { @@ -261,8 +261,8 @@ func TestFilterAddressIntersection(t *testing.T) { traceReq1 := TraceFilterRequest{ FromBlock: (*hexutil.Uint64)(&fromBlock), ToBlock: (*hexutil.Uint64)(&toBlock), - ToAddress: []*libcommon.Address{&other}, - FromAddress: []*libcommon.Address{&toAddress2, &toAddress1, &other}, + ToAddress: []*common.Address{&other}, + FromAddress: []*common.Address{&toAddress2, &toAddress1, &other}, Mode: TraceFilterModeIntersection, } if err = api.Filter(context.Background(), traceReq1, stream); err != nil { diff --git a/cmd/rpcdaemon/commands/contracts/gen_poly.go b/cmd/rpcdaemon/commands/contracts/gen_poly.go index 35e86871b..f2749850f 100644 --- a/cmd/rpcdaemon/commands/contracts/gen_poly.go +++ b/cmd/rpcdaemon/commands/contracts/gen_poly.go @@ -23,7 +23,7 @@ var ( _ = strings.NewReader _ = ethereum.NotFound _ = bind.Bind - _ = common.Big1 + _ = libcommon.Big1 _ = types.BloomLookup _ = event.NewSubscription ) diff --git a/cmd/rpcdaemon/commands/contracts/gen_token.go b/cmd/rpcdaemon/commands/contracts/gen_token.go index b7ab9b22a..3973e6d0e 100644 --- a/cmd/rpcdaemon/commands/contracts/gen_token.go +++ b/cmd/rpcdaemon/commands/contracts/gen_token.go @@ -23,7 +23,7 @@ var ( _ = strings.NewReader _ = ethereum.NotFound _ = bind.Bind - _ = common.Big1 + _ = libcommon.Big1 _ = types.BloomLookup _ = event.NewSubscription ) diff --git a/cmd/rpcdaemon/commands/corner_cases_support_test.go b/cmd/rpcdaemon/commands/corner_cases_support_test.go index 5a62f3a81..df03b071e 100644 --- a/cmd/rpcdaemon/commands/corner_cases_support_test.go +++ b/cmd/rpcdaemon/commands/corner_cases_support_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/kv/kvcache" "github.com/stretchr/testify/require" @@ -31,7 +31,7 @@ func TestNotFoundMustReturnNil(t *testing.T) { require.Nil(a) require.Nil(err) - b, err := api.GetTransactionByBlockHashAndIndex(ctx, libcommon.Hash{}, 1) + b, err := api.GetTransactionByBlockHashAndIndex(ctx, common.Hash{}, 1) require.Nil(b) require.Nil(err) @@ -39,11 +39,11 @@ func TestNotFoundMustReturnNil(t *testing.T) { require.Nil(c) require.Nil(err) - d, err := api.GetTransactionReceipt(ctx, libcommon.Hash{}) + d, err := api.GetTransactionReceipt(ctx, common.Hash{}) require.Nil(d) require.Nil(err) - e, err := api.GetBlockByHash(ctx, rpc.BlockNumberOrHashWithHash(libcommon.Hash{}, true), false) + e, err := api.GetBlockByHash(ctx, rpc.BlockNumberOrHashWithHash(common.Hash{}, true), false) require.Nil(e) require.Nil(err) @@ -51,7 +51,7 @@ func TestNotFoundMustReturnNil(t *testing.T) { require.Nil(f) require.Nil(err) - g, err := api.GetUncleByBlockHashAndIndex(ctx, libcommon.Hash{}, 1) + g, err := api.GetUncleByBlockHashAndIndex(ctx, common.Hash{}, 1) require.Nil(g) require.Nil(err) diff --git a/cmd/rpcdaemon/commands/debug_api.go b/cmd/rpcdaemon/commands/debug_api.go index 1d1a0824c..5ef9be946 100644 --- a/cmd/rpcdaemon/commands/debug_api.go +++ b/cmd/rpcdaemon/commands/debug_api.go @@ -5,7 +5,7 @@ import ( "fmt" jsoniter "github.com/json-iterator/go" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv/rawdbv3" @@ -25,15 +25,15 @@ const AccountRangeMaxResults = 256 // PrivateDebugAPI Exposed RPC endpoints for debugging use type PrivateDebugAPI interface { - StorageRangeAt(ctx context.Context, blockHash libcommon.Hash, txIndex uint64, contractAddress libcommon.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error) - TraceTransaction(ctx context.Context, hash libcommon.Hash, config *tracers.TraceConfig, stream *jsoniter.Stream) error - TraceBlockByHash(ctx context.Context, hash libcommon.Hash, config *tracers.TraceConfig, stream *jsoniter.Stream) error + StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex uint64, contractAddress common.Address, keyStart hexutil.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 AccountRange(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, start []byte, maxResults int, nocode, nostorage bool) (state.IteratorDump, error) - GetModifiedAccountsByNumber(ctx context.Context, startNum rpc.BlockNumber, endNum *rpc.BlockNumber) ([]libcommon.Address, error) - GetModifiedAccountsByHash(_ context.Context, startHash libcommon.Hash, endHash *libcommon.Hash) ([]libcommon.Address, error) + GetModifiedAccountsByNumber(ctx context.Context, startNum rpc.BlockNumber, endNum *rpc.BlockNumber) ([]common.Address, error) + GetModifiedAccountsByHash(_ context.Context, startHash common.Hash, endHash *common.Hash) ([]common.Address, error) TraceCall(ctx context.Context, args ethapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, config *tracers.TraceConfig, stream *jsoniter.Stream) error - AccountAt(ctx context.Context, blockHash libcommon.Hash, txIndex uint64, account libcommon.Address) (*AccountResult, error) + AccountAt(ctx context.Context, blockHash common.Hash, txIndex uint64, account common.Address) (*AccountResult, error) } // PrivateDebugAPIImpl is implementation of the PrivateDebugAPI interface based on remote Db access @@ -53,7 +53,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 libcommon.Hash, txIndex uint64, contractAddress libcommon.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error) { +func (api *PrivateDebugAPIImpl) StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex uint64, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return StorageRangeResult{}, err @@ -131,7 +131,7 @@ func (api *PrivateDebugAPIImpl) AccountRange(ctx context.Context, blockNrOrHash } dumper := state.NewDumper(tx, blockNumber) - res, err := dumper.IteratorDump(excludeCode, excludeStorage, libcommon.BytesToAddress(startKey), maxResults) + res, err := dumper.IteratorDump(excludeCode, excludeStorage, common.BytesToAddress(startKey), maxResults) if err != nil { return state.IteratorDump{}, err } @@ -140,7 +140,7 @@ func (api *PrivateDebugAPIImpl) AccountRange(ctx context.Context, blockNrOrHash if err != nil { return state.IteratorDump{}, err } - if hash != (libcommon.Hash{}) { + if hash != (common.Hash{}) { header := rawdb.ReadHeader(tx, hash, blockNumber) if header != nil { res.Root = header.Root.String() @@ -151,7 +151,7 @@ func (api *PrivateDebugAPIImpl) AccountRange(ctx context.Context, blockNrOrHash } // GetModifiedAccountsByNumber implements debug_getModifiedAccountsByNumber. Returns a list of accounts modified in the given block. -func (api *PrivateDebugAPIImpl) GetModifiedAccountsByNumber(ctx context.Context, startNumber rpc.BlockNumber, endNumber *rpc.BlockNumber) ([]libcommon.Address, error) { +func (api *PrivateDebugAPIImpl) GetModifiedAccountsByNumber(ctx context.Context, startNumber rpc.BlockNumber, endNumber *rpc.BlockNumber) ([]common.Address, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err @@ -188,7 +188,7 @@ func (api *PrivateDebugAPIImpl) GetModifiedAccountsByNumber(ctx context.Context, } // GetModifiedAccountsByHash implements debug_getModifiedAccountsByHash. Returns a list of accounts modified in the given block. -func (api *PrivateDebugAPIImpl) GetModifiedAccountsByHash(ctx context.Context, startHash libcommon.Hash, endHash *libcommon.Hash) ([]libcommon.Address, error) { +func (api *PrivateDebugAPIImpl) GetModifiedAccountsByHash(ctx context.Context, startHash common.Hash, endHash *common.Hash) ([]common.Address, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err @@ -223,7 +223,7 @@ func (api *PrivateDebugAPIImpl) GetModifiedAccountsByHash(ctx context.Context, s return changeset.GetModifiedAccounts(tx, startNum, endNum) } -func (api *PrivateDebugAPIImpl) AccountAt(ctx context.Context, blockHash libcommon.Hash, txIndex uint64, address libcommon.Address) (*AccountResult, error) { +func (api *PrivateDebugAPIImpl) AccountAt(ctx context.Context, blockHash common.Hash, txIndex uint64, address common.Address) (*AccountResult, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err @@ -259,5 +259,5 @@ type AccountResult struct { Balance hexutil.Big `json:"balance"` Nonce hexutil.Uint64 `json:"nonce"` Code hexutil.Bytes `json:"code"` - CodeHash libcommon.Hash `json:"codeHash"` + CodeHash common.Hash `json:"codeHash"` } diff --git a/cmd/rpcdaemon/commands/debug_api_test.go b/cmd/rpcdaemon/commands/debug_api_test.go index 1bd2911e0..04c7b8839 100644 --- a/cmd/rpcdaemon/commands/debug_api_test.go +++ b/cmd/rpcdaemon/commands/debug_api_test.go @@ -8,7 +8,7 @@ import ( "github.com/davecgh/go-spew/spew" jsoniter "github.com/json-iterator/go" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv/iter" "github.com/ledgerwatch/erigon-lib/kv/kvcache" @@ -60,7 +60,7 @@ func TestTraceBlockByNumber(t *testing.T) { for _, tt := range debugTraceTransactionTests { var buf bytes.Buffer stream := jsoniter.NewStream(jsoniter.ConfigDefault, &buf, 4096) - tx, err := ethApi.GetTransactionByHash(m.Ctx, libcommon.HexToHash(tt.txHash)) + tx, err := ethApi.GetTransactionByHash(m.Ctx, common.HexToHash(tt.txHash)) if err != nil { t.Errorf("traceBlock %s: %v", tt.txHash, err) } @@ -109,7 +109,7 @@ func TestTraceBlockByHash(t *testing.T) { for _, tt := range debugTraceTransactionTests { var buf bytes.Buffer stream := jsoniter.NewStream(jsoniter.ConfigDefault, &buf, 4096) - tx, err := ethApi.GetTransactionByHash(m.Ctx, libcommon.HexToHash(tt.txHash)) + tx, err := ethApi.GetTransactionByHash(m.Ctx, common.HexToHash(tt.txHash)) if err != nil { t.Errorf("traceBlock %s: %v", tt.txHash, err) } @@ -144,7 +144,7 @@ func TestTraceTransaction(t *testing.T) { for _, tt := range debugTraceTransactionTests { var buf bytes.Buffer stream := jsoniter.NewStream(jsoniter.ConfigDefault, &buf, 4096) - err := api.TraceTransaction(m.Ctx, libcommon.HexToHash(tt.txHash), &tracers.TraceConfig{}, stream) + err := api.TraceTransaction(m.Ctx, common.HexToHash(tt.txHash), &tracers.TraceConfig{}, stream) if err != nil { t.Errorf("traceTransaction %s: %v", tt.txHash, err) } @@ -178,7 +178,7 @@ func TestTraceTransactionNoRefund(t *testing.T) { var buf bytes.Buffer stream := jsoniter.NewStream(jsoniter.ConfigDefault, &buf, 4096) var norefunds = true - err := api.TraceTransaction(m.Ctx, libcommon.HexToHash(tt.txHash), &tracers.TraceConfig{NoRefunds: &norefunds}, stream) + err := api.TraceTransaction(m.Ctx, common.HexToHash(tt.txHash), &tracers.TraceConfig{NoRefunds: &norefunds}, stream) if err != nil { t.Errorf("traceTransaction %s: %v", tt.txHash, err) } @@ -215,7 +215,7 @@ func TestStorageRangeAt(t *testing.T) { return nil }) require.NoError(t, err) - addr := libcommon.HexToAddress("0x537e697c7ab75a26f9ecf0ce810e3154dfcaaf55") + addr := common.HexToAddress("0x537e697c7ab75a26f9ecf0ce810e3154dfcaaf55") expect := StorageRangeResult{storageMap{}, nil} result, err := api.StorageRangeAt(m.Ctx, block4.Hash(), 0, addr, nil, 100) require.NoError(t, err) @@ -228,13 +228,13 @@ func TestStorageRangeAt(t *testing.T) { return nil }) require.NoError(t, err) - addr := libcommon.HexToAddress("0x537e697c7ab75a26f9ecf0ce810e3154dfcaaf44") - keys := []libcommon.Hash{ // hashes of Keys of storage - libcommon.HexToHash("0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace"), - libcommon.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000002"), + addr := common.HexToAddress("0x537e697c7ab75a26f9ecf0ce810e3154dfcaaf44") + keys := []common.Hash{ // hashes of Keys of storage + common.HexToHash("0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace"), + common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000002"), } storage := storageMap{ - keys[0]: {Key: &keys[1], Value: libcommon.HexToHash("0000000000000000000000000d3ab14bbad3d99f4203bd7a11acb94882050e7e")}, + keys[0]: {Key: &keys[1], Value: common.HexToHash("0000000000000000000000000d3ab14bbad3d99f4203bd7a11acb94882050e7e")}, } expect := StorageRangeResult{storageMap{keys[0]: storage[keys[0]]}, nil} @@ -249,25 +249,25 @@ func TestStorageRangeAt(t *testing.T) { return nil }) require.NoError(t, err) - addr := libcommon.HexToAddress("0x537e697c7ab75a26f9ecf0ce810e3154dfcaaf44") - keys := []libcommon.Hash{ // hashes of Keys of storage - libcommon.HexToHash("0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563"), - libcommon.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"), + addr := common.HexToAddress("0x537e697c7ab75a26f9ecf0ce810e3154dfcaaf44") + keys := []common.Hash{ // hashes of Keys of storage + common.HexToHash("0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563"), + common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"), - libcommon.HexToHash("0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace"), - libcommon.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000002"), + common.HexToHash("0x405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace"), + common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000002"), - libcommon.HexToHash("0xb077f7530a1364c54ee00cf94ba99175db81e7e002c97e344aa5d3c4908617c4"), - libcommon.HexToHash("0x9541d803110b392ecde8e03af7ae34d4457eb4934dac09903ccee819bec4a355"), + common.HexToHash("0xb077f7530a1364c54ee00cf94ba99175db81e7e002c97e344aa5d3c4908617c4"), + common.HexToHash("0x9541d803110b392ecde8e03af7ae34d4457eb4934dac09903ccee819bec4a355"), - libcommon.HexToHash("0xb6b80924ee71b506e16a000e00b0f8f3a82f53791c6b87f5958fdf562f3d12c8"), - libcommon.HexToHash("0xf41f8421ae8c8d7bb78783a0bdadb801a5f895bea868c1d867ae007558809ef1"), + common.HexToHash("0xb6b80924ee71b506e16a000e00b0f8f3a82f53791c6b87f5958fdf562f3d12c8"), + common.HexToHash("0xf41f8421ae8c8d7bb78783a0bdadb801a5f895bea868c1d867ae007558809ef1"), } storage := storageMap{ - keys[0]: {Key: &keys[1], Value: libcommon.HexToHash("0x000000000000000000000000000000000000000000000000000000000000000a")}, - keys[2]: {Key: &keys[3], Value: libcommon.HexToHash("0x0000000000000000000000000d3ab14bbad3d99f4203bd7a11acb94882050e7e")}, - keys[4]: {Key: &keys[5], Value: libcommon.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000003")}, - keys[6]: {Key: &keys[7], Value: libcommon.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000007")}, + keys[0]: {Key: &keys[1], Value: common.HexToHash("0x000000000000000000000000000000000000000000000000000000000000000a")}, + keys[2]: {Key: &keys[3], Value: common.HexToHash("0x0000000000000000000000000d3ab14bbad3d99f4203bd7a11acb94882050e7e")}, + keys[4]: {Key: &keys[5], Value: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000003")}, + keys[6]: {Key: &keys[7], Value: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000007")}, } expect := StorageRangeResult{ storageMap{keys[0]: storage[keys[0]], keys[2]: storage[keys[2]], keys[4]: storage[keys[4]], keys[6]: storage[keys[6]]}, @@ -304,7 +304,7 @@ func TestMapTxNum2BlockNum(t *testing.T) { t.Skip() } - addr := libcommon.HexToAddress("0x537e697c7ab75a26f9ecf0ce810e3154dfcaaf44") + addr := common.HexToAddress("0x537e697c7ab75a26f9ecf0ce810e3154dfcaaf44") checkIter := func(t *testing.T, expectTxNums iter.U64, txNumsIter *MapTxNum2BlockNumIter) { for expectTxNums.HasNext() { require.True(t, txNumsIter.HasNext()) diff --git a/cmd/rpcdaemon/commands/engine_api.go b/cmd/rpcdaemon/commands/engine_api.go index 327bd2937..3ac505e42 100644 --- a/cmd/rpcdaemon/commands/engine_api.go +++ b/cmd/rpcdaemon/commands/engine_api.go @@ -9,13 +9,12 @@ import ( "github.com/holiman/uint256" "github.com/ledgerwatch/log/v3" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/gointerfaces" "github.com/ledgerwatch/erigon-lib/gointerfaces/remote" types2 "github.com/ledgerwatch/erigon-lib/gointerfaces/types" "github.com/ledgerwatch/erigon-lib/kv" - "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" @@ -25,19 +24,19 @@ import ( // ExecutionPayload represents an execution payload (aka block) type ExecutionPayload struct { - ParentHash libcommon.Hash `json:"parentHash" gencodec:"required"` - FeeRecipient libcommon.Address `json:"feeRecipient" gencodec:"required"` - StateRoot libcommon.Hash `json:"stateRoot" gencodec:"required"` - ReceiptsRoot libcommon.Hash `json:"receiptsRoot" gencodec:"required"` + ParentHash common.Hash `json:"parentHash" gencodec:"required"` + 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"` - PrevRandao libcommon.Hash `json:"prevRandao" 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"` BaseFeePerGas *hexutil.Big `json:"baseFeePerGas" gencodec:"required"` - BlockHash libcommon.Hash `json:"blockHash" gencodec:"required"` + BlockHash common.Hash `json:"blockHash" gencodec:"required"` Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"` Withdrawals []*types.Withdrawal `json:"withdrawals"` } @@ -50,24 +49,24 @@ type GetPayloadV2Response struct { // PayloadAttributes represent the attributes required to start assembling a payload type ForkChoiceState struct { - HeadHash libcommon.Hash `json:"headBlockHash" gencodec:"required"` - SafeBlockHash libcommon.Hash `json:"safeBlockHash" gencodec:"required"` - FinalizedBlockHash libcommon.Hash `json:"finalizedBlockHash" gencodec:"required"` + HeadHash common.Hash `json:"headBlockHash" gencodec:"required"` + SafeBlockHash common.Hash `json:"safeBlockHash" gencodec:"required"` + FinalizedBlockHash common.Hash `json:"finalizedBlockHash" gencodec:"required"` } // PayloadAttributes represent the attributes required to start assembling a payload type PayloadAttributes struct { Timestamp hexutil.Uint64 `json:"timestamp" gencodec:"required"` - PrevRandao libcommon.Hash `json:"prevRandao" gencodec:"required"` - SuggestedFeeRecipient libcommon.Address `json:"suggestedFeeRecipient" gencodec:"required"` + PrevRandao common.Hash `json:"prevRandao" gencodec:"required"` + SuggestedFeeRecipient common.Address `json:"suggestedFeeRecipient" gencodec:"required"` Withdrawals []*types.Withdrawal `json:"withdrawals"` } // TransitionConfiguration represents the correct configurations of the CL and the EL type TransitionConfiguration struct { - TerminalTotalDifficulty *hexutil.Big `json:"terminalTotalDifficulty" gencodec:"required"` - TerminalBlockHash libcommon.Hash `json:"terminalBlockHash" gencodec:"required"` - TerminalBlockNumber *hexutil.Big `json:"terminalBlockNumber" gencodec:"required"` + TerminalTotalDifficulty *hexutil.Big `json:"terminalTotalDifficulty" gencodec:"required"` + TerminalBlockHash common.Hash `json:"terminalBlockHash" gencodec:"required"` + TerminalBlockNumber *hexutil.Big `json:"terminalBlockNumber" gencodec:"required"` } type ExecutionPayloadBodyV1 struct { @@ -84,7 +83,7 @@ type EngineAPI interface { GetPayloadV1(ctx context.Context, payloadID hexutil.Bytes) (*ExecutionPayload, error) GetPayloadV2(ctx context.Context, payloadID hexutil.Bytes) (*GetPayloadV2Response, error) ExchangeTransitionConfigurationV1(ctx context.Context, transitionConfiguration *TransitionConfiguration) (*TransitionConfiguration, error) - GetPayloadBodiesByHashV1(ctx context.Context, hashes []libcommon.Hash) ([]*ExecutionPayloadBodyV1, error) + GetPayloadBodiesByHashV1(ctx context.Context, hashes []common.Hash) ([]*ExecutionPayloadBodyV1, error) GetPayloadBodiesByRangeV1(ctx context.Context, start uint64, count uint64) ([]*ExecutionPayloadBodyV1, error) } @@ -107,8 +106,8 @@ func convertPayloadStatus(ctx context.Context, db kv.RoDB, x *remote.EnginePaylo return json, nil } - latestValidHash := libcommon.Hash(gointerfaces.ConvertH256ToHash(x.LatestValidHash)) - if latestValidHash == (libcommon.Hash{}) || x.Status == remote.EngineStatus_VALID { + latestValidHash := common.Hash(gointerfaces.ConvertH256ToHash(x.LatestValidHash)) + if latestValidHash == (common.Hash{}) || x.Status == remote.EngineStatus_VALID { json["latestValidHash"] = latestValidHash return json, nil } @@ -129,7 +128,7 @@ func convertPayloadStatus(ctx context.Context, db kv.RoDB, x *remote.EnginePaylo if isValidHashPos { json["latestValidHash"] = latestValidHash } else { - json["latestValidHash"] = libcommon.Hash{} + json["latestValidHash"] = common.Hash{} } return json, nil } @@ -361,12 +360,12 @@ func (e *EngineImpl) ExchangeTransitionConfigurationV1(ctx context.Context, beac return &TransitionConfiguration{ TerminalTotalDifficulty: (*hexutil.Big)(terminalTotalDifficulty), - TerminalBlockHash: libcommon.Hash{}, + TerminalBlockHash: common.Hash{}, TerminalBlockNumber: (*hexutil.Big)(common.Big0), }, nil } -func (e *EngineImpl) GetPayloadBodiesByHashV1(ctx context.Context, hashes []libcommon.Hash) ([]*ExecutionPayloadBodyV1, error) { +func (e *EngineImpl) GetPayloadBodiesByHashV1(ctx context.Context, hashes []common.Hash) ([]*ExecutionPayloadBodyV1, error) { h := make([]*types2.H256, len(hashes)) for i, hash := range hashes { h[i] = gointerfaces.ConvertHashToH256(hash) diff --git a/cmd/rpcdaemon/commands/engine_api_test.go b/cmd/rpcdaemon/commands/engine_api_test.go index 109f30465..d3e7cb883 100644 --- a/cmd/rpcdaemon/commands/engine_api_test.go +++ b/cmd/rpcdaemon/commands/engine_api_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/gointerfaces" "github.com/ledgerwatch/erigon-lib/gointerfaces/remote" "github.com/stretchr/testify/assert" @@ -13,9 +13,9 @@ import ( // Test case for https://github.com/ethereum/execution-apis/pull/217 responses func TestZeroLatestValidHash(t *testing.T) { - payloadStatus := remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID, LatestValidHash: gointerfaces.ConvertHashToH256(libcommon.Hash{})} + payloadStatus := remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID, LatestValidHash: gointerfaces.ConvertHashToH256(common.Hash{})} json, err := convertPayloadStatus(context.TODO(), nil, &payloadStatus) require.NoError(t, err) assert.Equal(t, "INVALID", json["status"]) - assert.Equal(t, libcommon.Hash{}, json["latestValidHash"]) + assert.Equal(t, common.Hash{}, json["latestValidHash"]) } diff --git a/cmd/rpcdaemon/commands/erigon_api.go b/cmd/rpcdaemon/commands/erigon_api.go index 2fa92cde5..fff316278 100644 --- a/cmd/rpcdaemon/commands/erigon_api.go +++ b/cmd/rpcdaemon/commands/erigon_api.go @@ -3,7 +3,7 @@ package commands import ( "context" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/eth/filters" ethFilters "github.com/ledgerwatch/erigon/eth/filters" @@ -25,17 +25,17 @@ type ErigonAPI interface { // Blocks related (see ./erigon_blocks.go) GetHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) - GetHeaderByHash(_ context.Context, hash libcommon.Hash) (*types.Header, error) + GetHeaderByHash(_ context.Context, hash common.Hash) (*types.Header, error) GetBlockByTimestamp(ctx context.Context, timeStamp rpc.Timestamp, fullTx bool) (map[string]interface{}, error) - GetBalanceChangesInBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (map[libcommon.Address]*hexutil.Big, error) + GetBalanceChangesInBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (map[common.Address]*hexutil.Big, error) // Receipt related (see ./erigon_receipts.go) - GetLogsByHash(ctx context.Context, hash libcommon.Hash) ([][]*types.Log, error) + GetLogsByHash(ctx context.Context, hash common.Hash) ([][]*types.Log, error) //GetLogsByNumber(ctx context.Context, number rpc.BlockNumber) ([][]*types.Log, error) GetLogs(ctx context.Context, crit ethFilters.FilterCriteria) (types.ErigonLogs, error) GetLatestLogs(ctx context.Context, crit filters.FilterCriteria, logOptions ethFilters.LogFilterOptions) (types.ErigonLogs, error) // Gets cannonical block receipt through hash. If the block is not cannonical returns error - GetBlockReceiptsByBlockHash(ctx context.Context, cannonicalBlockHash libcommon.Hash) ([]map[string]interface{}, error) + GetBlockReceiptsByBlockHash(ctx context.Context, cannonicalBlockHash common.Hash) ([]map[string]interface{}, error) // CumulativeChainTraffic / related to chain traffic (see ./erigon_cumulative_index.go) CumulativeChainTraffic(ctx context.Context, blockNr rpc.BlockNumber) (ChainTraffic, error) diff --git a/cmd/rpcdaemon/commands/erigon_block.go b/cmd/rpcdaemon/commands/erigon_block.go index d6c138d7c..245dca068 100644 --- a/cmd/rpcdaemon/commands/erigon_block.go +++ b/cmd/rpcdaemon/commands/erigon_block.go @@ -8,7 +8,7 @@ import ( "sort" "github.com/holiman/uint256" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "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/temporal/historyv2" @@ -57,7 +57,7 @@ func (api *ErigonImpl) GetHeaderByNumber(ctx context.Context, blockNumber rpc.Bl } // GetHeaderByHash implements erigon_getHeaderByHash. Returns a block's header given a block's hash. -func (api *ErigonImpl) GetHeaderByHash(ctx context.Context, hash libcommon.Hash) (*types.Header, error) { +func (api *ErigonImpl) GetHeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err @@ -180,7 +180,7 @@ func buildBlockResponse(db kv.Tx, blockNum uint64, fullTx bool) (map[string]inte additionalFields["totalDifficulty"] = (*hexutil.Big)(td) } - response, err := ethapi.RPCMarshalBlockEx(block, true, fullTx, nil, libcommon.Hash{}, additionalFields) + response, err := ethapi.RPCMarshalBlockEx(block, true, fullTx, nil, common.Hash{}, additionalFields) if err == nil && rpc.BlockNumber(block.NumberU64()) == rpc.PendingBlockNumber { // Pending blocks need to nil out a few fields @@ -191,7 +191,7 @@ func buildBlockResponse(db kv.Tx, blockNum uint64, fullTx bool) (map[string]inte return response, err } -func (api *ErigonImpl) GetBalanceChangesInBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (map[libcommon.Address]*hexutil.Big, error) { +func (api *ErigonImpl) GetBalanceChangesInBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (map[common.Address]*hexutil.Big, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err @@ -213,7 +213,7 @@ func (api *ErigonImpl) GetBalanceChangesInBlock(ctx context.Context, blockNrOrHa decodeFn := historyv2.Mapper[kv.AccountChangeSet].Decode - balancesMapping := make(map[libcommon.Address]*hexutil.Big) + balancesMapping := make(map[common.Address]*hexutil.Big) newReader, err := rpchelper.CreateStateReader(ctx, tx, blockNrOrHash, 0, api.filters, api.stateCache, api.historyV3(tx), "") if err != nil { @@ -235,7 +235,7 @@ func (api *ErigonImpl) GetBalanceChangesInBlock(ctx context.Context, blockNrOrHa } oldBalance := oldAcc.Balance - address := libcommon.BytesToAddress(addressBytes) + address := common.BytesToAddress(addressBytes) newAcc, err := newReader.ReadAccountData(address) if err != nil { diff --git a/cmd/rpcdaemon/commands/erigon_receipts.go b/cmd/rpcdaemon/commands/erigon_receipts.go index a36ef41a5..562c59b6e 100644 --- a/cmd/rpcdaemon/commands/erigon_receipts.go +++ b/cmd/rpcdaemon/commands/erigon_receipts.go @@ -7,7 +7,7 @@ import ( "fmt" "github.com/RoaringBitmap/roaring" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "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/bitmapdb" @@ -21,7 +21,7 @@ import ( ) // GetLogsByHash implements erigon_getLogsByHash. Returns an array of arrays of logs generated by the transactions in the block given by the block's hash. -func (api *ErigonImpl) GetLogsByHash(ctx context.Context, hash libcommon.Hash) ([][]*types.Log, error) { +func (api *ErigonImpl) GetLogsByHash(ctx context.Context, hash common.Hash) ([][]*types.Log, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err @@ -109,7 +109,7 @@ func (api *ErigonImpl) GetLogs(ctx context.Context, crit filters.FilterCriteria) return erigonLogs, nil } - addrMap := make(map[libcommon.Address]struct{}, len(crit.Addresses)) + addrMap := make(map[common.Address]struct{}, len(crit.Addresses)) for _, v := range crit.Addresses { addrMap[v] = struct{}{} } @@ -244,11 +244,11 @@ func (api *ErigonImpl) GetLatestLogs(ctx context.Context, crit filters.FilterCri return erigonLogs, nil } - addrMap := make(map[libcommon.Address]struct{}, len(crit.Addresses)) + addrMap := make(map[common.Address]struct{}, len(crit.Addresses)) for _, v := range crit.Addresses { addrMap[v] = struct{}{} } - topicsMap := make(map[libcommon.Hash]struct{}) + topicsMap := make(map[common.Hash]struct{}) for i := range crit.Topics { for j := range crit.Topics { topicsMap[crit.Topics[i][j]] = struct{}{} @@ -356,7 +356,7 @@ func (api *ErigonImpl) GetLatestLogs(ctx context.Context, crit filters.FilterCri return erigonLogs, nil } -func (api *ErigonImpl) GetBlockReceiptsByBlockHash(ctx context.Context, cannonicalBlockHash libcommon.Hash) ([]map[string]interface{}, error) { +func (api *ErigonImpl) GetBlockReceiptsByBlockHash(ctx context.Context, cannonicalBlockHash common.Hash) ([]map[string]interface{}, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err diff --git a/cmd/rpcdaemon/commands/erigon_system.go b/cmd/rpcdaemon/commands/erigon_system.go index 6f1494d42..fd05b84f1 100644 --- a/cmd/rpcdaemon/commands/erigon_system.go +++ b/cmd/rpcdaemon/commands/erigon_system.go @@ -3,7 +3,7 @@ package commands import ( "context" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/forkid" @@ -13,9 +13,9 @@ import ( // Forks is a data type to record a list of forks passed by this node type Forks struct { - GenesisHash libcommon.Hash `json:"genesis"` - HeightForks []uint64 `json:"heightForks"` - TimeForks []uint64 `json:"timeForks"` + GenesisHash common.Hash `json:"genesis"` + HeightForks []uint64 `json:"heightForks"` + TimeForks []uint64 `json:"timeForks"` } // Forks implements erigon_forks. Returns the genesis block hash and a sorted list of all forks block numbers diff --git a/cmd/rpcdaemon/commands/eth_api.go b/cmd/rpcdaemon/commands/eth_api.go index e6f1ad07e..77ca2a149 100644 --- a/cmd/rpcdaemon/commands/eth_api.go +++ b/cmd/rpcdaemon/commands/eth_api.go @@ -9,7 +9,7 @@ import ( lru "github.com/hashicorp/golang-lru" "github.com/holiman/uint256" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" types2 "github.com/ledgerwatch/erigon-lib/types" "github.com/ledgerwatch/log/v3" @@ -39,26 +39,26 @@ type EthAPI interface { GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) GetBlockByHash(ctx context.Context, hash rpc.BlockNumberOrHash, fullTx bool) (map[string]interface{}, error) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*hexutil.Uint, error) - GetBlockTransactionCountByHash(ctx context.Context, blockHash libcommon.Hash) (*hexutil.Uint, error) + GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) (*hexutil.Uint, error) // Transaction related (see ./eth_txs.go) - GetTransactionByHash(ctx context.Context, hash libcommon.Hash) (*RPCTransaction, error) - GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash libcommon.Hash, txIndex hexutil.Uint64) (*RPCTransaction, error) + 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 libcommon.Hash, index hexutil.Uint) (hexutil.Bytes, error) - GetRawTransactionByHash(ctx context.Context, hash libcommon.Hash) (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) // Receipt related (see ./eth_receipts.go) - GetTransactionReceipt(ctx context.Context, hash libcommon.Hash) (map[string]interface{}, error) + GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) GetLogs(ctx context.Context, crit ethFilters.FilterCriteria) (types.Logs, error) GetBlockReceipts(ctx context.Context, number rpc.BlockNumber) ([]map[string]interface{}, error) // Uncle related (see ./eth_uncles.go) GetUncleByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (map[string]interface{}, error) - GetUncleByBlockHashAndIndex(ctx context.Context, hash libcommon.Hash, index hexutil.Uint) (map[string]interface{}, error) + GetUncleByBlockHashAndIndex(ctx context.Context, hash common.Hash, index hexutil.Uint) (map[string]interface{}, error) GetUncleCountByBlockNumber(ctx context.Context, number rpc.BlockNumber) (*hexutil.Uint, error) - GetUncleCountByBlockHash(ctx context.Context, hash libcommon.Hash) (*hexutil.Uint, error) + GetUncleCountByBlockHash(ctx context.Context, hash common.Hash) (*hexutil.Uint, error) // Filter related (see ./eth_filters.go) NewPendingTransactionFilter(_ context.Context) (string, error) @@ -68,11 +68,11 @@ type EthAPI interface { GetFilterChanges(_ context.Context, index string) ([]interface{}, error) // Account related (see ./eth_accounts.go) - Accounts(ctx context.Context) ([]libcommon.Address, error) - GetBalance(ctx context.Context, address libcommon.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error) - GetTransactionCount(ctx context.Context, address libcommon.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error) - GetStorageAt(ctx context.Context, address libcommon.Address, index string, blockNrOrHash rpc.BlockNumberOrHash) (string, error) - GetCode(ctx context.Context, address libcommon.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) + Accounts(ctx context.Context) ([]common.Address, error) + 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) // System related (see ./eth_system.go) BlockNumber(ctx context.Context) (hexutil.Uint64, error) @@ -84,20 +84,20 @@ type EthAPI interface { // Sending related (see ./eth_call.go) Call(ctx context.Context, args ethapi2.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *ethapi2.StateOverrides) (hexutil.Bytes, error) EstimateGas(ctx context.Context, argsOrNil *ethapi2.CallArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error) - SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (libcommon.Hash, error) - SendTransaction(_ context.Context, txObject interface{}) (libcommon.Hash, error) - Sign(ctx context.Context, _ libcommon.Address, _ hexutil.Bytes) (hexutil.Bytes, error) - SignTransaction(_ context.Context, txObject interface{}) (libcommon.Hash, error) - GetProof(ctx context.Context, address libcommon.Address, storageKeys []string, blockNr rpc.BlockNumber) (*interface{}, error) + SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) + SendTransaction(_ context.Context, txObject interface{}) (common.Hash, error) + Sign(ctx context.Context, _ common.Address, _ hexutil.Bytes) (hexutil.Bytes, error) + SignTransaction(_ context.Context, txObject interface{}) (common.Hash, error) + GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNr rpc.BlockNumber) (*interface{}, error) CreateAccessList(ctx context.Context, args ethapi2.CallArgs, blockNrOrHash *rpc.BlockNumberOrHash, optimizeGas *bool) (*accessListResult, error) // Mining related (see ./eth_mining.go) - Coinbase(ctx context.Context) (libcommon.Address, error) + Coinbase(ctx context.Context) (common.Address, error) Hashrate(ctx context.Context) (uint64, error) Mining(ctx context.Context) (bool, error) GetWork(ctx context.Context) ([4]string, error) - SubmitWork(ctx context.Context, nonce types.BlockNonce, powHash, digest libcommon.Hash) (bool, error) - SubmitHashrate(ctx context.Context, hashRate hexutil.Uint64, id libcommon.Hash) (bool, error) + SubmitWork(ctx context.Context, nonce types.BlockNonce, powHash, digest common.Hash) (bool, error) + SubmitHashrate(ctx context.Context, hashRate hexutil.Uint64, id common.Hash) (bool, error) } type BaseAPI struct { @@ -147,7 +147,7 @@ func (api *BaseAPI) genesis(tx kv.Tx) (*types.Block, error) { return genesis, err } -func (api *BaseAPI) txnLookup(ctx context.Context, tx kv.Tx, txnHash libcommon.Hash) (uint64, bool, error) { +func (api *BaseAPI) txnLookup(ctx context.Context, tx kv.Tx, txnHash common.Hash) (uint64, bool, error) { return api._txnReader.TxnLookup(ctx, tx, txnHash) } @@ -159,7 +159,7 @@ func (api *BaseAPI) blockByNumberWithSenders(tx kv.Tx, number uint64) (*types.Bl return api.blockWithSenders(tx, hash, number) } -func (api *BaseAPI) blockByHashWithSenders(tx kv.Tx, hash libcommon.Hash) (*types.Block, error) { +func (api *BaseAPI) blockByHashWithSenders(tx kv.Tx, hash common.Hash) (*types.Block, error) { if api.blocksLRU != nil { if it, ok := api.blocksLRU.Get(hash); ok && it != nil { return it.(*types.Block), nil @@ -173,7 +173,7 @@ func (api *BaseAPI) blockByHashWithSenders(tx kv.Tx, hash libcommon.Hash) (*type return api.blockWithSenders(tx, hash, *number) } -func (api *BaseAPI) blockWithSenders(tx kv.Tx, hash libcommon.Hash, number uint64) (*types.Block, error) { +func (api *BaseAPI) blockWithSenders(tx kv.Tx, hash common.Hash, number uint64) (*types.Block, error) { if api.blocksLRU != nil { if it, ok := api.blocksLRU.Get(hash); ok && it != nil { return it.(*types.Block), nil @@ -300,17 +300,17 @@ func NewEthAPI(base *BaseAPI, db kv.RoDB, eth rpchelper.ApiBackend, txPool txpoo // RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction type RPCTransaction struct { - BlockHash *libcommon.Hash `json:"blockHash"` + BlockHash *common.Hash `json:"blockHash"` BlockNumber *hexutil.Big `json:"blockNumber"` - From libcommon.Address `json:"from"` + From common.Address `json:"from"` Gas hexutil.Uint64 `json:"gas"` GasPrice *hexutil.Big `json:"gasPrice,omitempty"` Tip *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"` FeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"` - Hash libcommon.Hash `json:"hash"` + Hash common.Hash `json:"hash"` Input hexutil.Bytes `json:"input"` Nonce hexutil.Uint64 `json:"nonce"` - To *libcommon.Address `json:"to"` + To *common.Address `json:"to"` TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` Value *hexutil.Big `json:"value"` Type hexutil.Uint64 `json:"type"` @@ -323,7 +323,7 @@ type RPCTransaction struct { // newRPCTransaction returns a transaction that will serialize to the RPC // representation, with the given location metadata set (if available). -func newRPCTransaction(tx types.Transaction, blockHash libcommon.Hash, blockNumber uint64, index uint64, baseFee *big.Int) *RPCTransaction { +func newRPCTransaction(tx types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64, baseFee *big.Int) *RPCTransaction { // Determine the signer. For replay-protected transactions, use the most permissive // signer, because we assume that signers are backwards-compatible with old // transactions. For non-protected transactions, the homestead signer signer is used @@ -367,7 +367,7 @@ func newRPCTransaction(tx types.Transaction, blockHash libcommon.Hash, blockNumb result.S = (*hexutil.Big)(t.S.ToBig()) result.Accesses = &t.AccessList baseFee, overflow := uint256.FromBig(baseFee) - if baseFee != nil && !overflow && blockHash != (libcommon.Hash{}) { + if baseFee != nil && !overflow && blockHash != (common.Hash{}) { // price = min(tip + baseFee, gasFeeCap) price := math.Min256(new(uint256.Int).Add(tx.GetTip(), baseFee), tx.GetFeeCap()) result.GasPrice = (*hexutil.Big)(price.ToBig()) @@ -377,7 +377,7 @@ func newRPCTransaction(tx types.Transaction, blockHash libcommon.Hash, blockNumb } signer := types.LatestSignerForChainID(chainId.ToBig()) result.From, _ = tx.Sender(*signer) - if blockHash != (libcommon.Hash{}) { + if blockHash != (common.Hash{}) { result.BlockHash = &blockHash result.BlockNumber = (*hexutil.Big)(new(big.Int).SetUint64(blockNumber)) result.TransactionIndex = (*hexutil.Uint64)(&index) @@ -387,7 +387,7 @@ func newRPCTransaction(tx types.Transaction, blockHash libcommon.Hash, blockNumb // newRPCBorTransaction returns a Bor transaction that will serialize to the RPC // representation, with the given location metadata set (if available). -func newRPCBorTransaction(opaqueTx types.Transaction, txHash libcommon.Hash, blockHash libcommon.Hash, blockNumber uint64, index uint64, baseFee *big.Int, chainId *big.Int) *RPCTransaction { +func newRPCBorTransaction(opaqueTx types.Transaction, txHash common.Hash, blockHash common.Hash, blockNumber uint64, index uint64, baseFee *big.Int, chainId *big.Int) *RPCTransaction { tx := opaqueTx.(*types.LegacyTx) result := &RPCTransaction{ Type: hexutil.Uint64(tx.Type()), @@ -397,14 +397,14 @@ func newRPCBorTransaction(opaqueTx types.Transaction, txHash libcommon.Hash, blo Hash: txHash, Input: hexutil.Bytes(tx.GetData()), Nonce: hexutil.Uint64(tx.GetNonce()), - From: libcommon.Address{}, + From: common.Address{}, To: tx.GetTo(), Value: (*hexutil.Big)(tx.GetValue().ToBig()), V: (*hexutil.Big)(big.NewInt(0)), R: (*hexutil.Big)(big.NewInt(0)), S: (*hexutil.Big)(big.NewInt(0)), } - if blockHash != (libcommon.Hash{}) { + if blockHash != (common.Hash{}) { result.ChainID = (*hexutil.Big)(new(big.Int).SetUint64(chainId.Uint64())) result.BlockHash = &blockHash result.BlockNumber = (*hexutil.Big)(new(big.Int).SetUint64(blockNumber)) @@ -419,7 +419,7 @@ func newRPCPendingTransaction(tx types.Transaction, current *types.Header, confi if current != nil { baseFee = misc.CalcBaseFee(config, current) } - return newRPCTransaction(tx, libcommon.Hash{}, 0, 0, baseFee) + return newRPCTransaction(tx, common.Hash{}, 0, 0, baseFee) } // newRPCRawTransactionFromBlockIndex returns the bytes of a transaction given a block and a transaction index. @@ -435,19 +435,19 @@ func newRPCRawTransactionFromBlockIndex(b *types.Block, index uint64) (hexutil.B type GasPriceCache struct { latestPrice *big.Int - latestHash libcommon.Hash + latestHash common.Hash mtx sync.Mutex } func NewGasPriceCache() *GasPriceCache { return &GasPriceCache{ latestPrice: big.NewInt(0), - latestHash: libcommon.Hash{}, + latestHash: common.Hash{}, } } -func (c *GasPriceCache) GetLatest() (libcommon.Hash, *big.Int) { - var hash libcommon.Hash +func (c *GasPriceCache) GetLatest() (common.Hash, *big.Int) { + var hash common.Hash var price *big.Int c.mtx.Lock() hash = c.latestHash @@ -456,7 +456,7 @@ func (c *GasPriceCache) GetLatest() (libcommon.Hash, *big.Int) { return hash, price } -func (c *GasPriceCache) SetLatest(hash libcommon.Hash, price *big.Int) { +func (c *GasPriceCache) SetLatest(hash common.Hash, price *big.Int) { c.mtx.Lock() c.latestPrice = price c.latestHash = hash diff --git a/cmd/rpcdaemon/commands/eth_api_test.go b/cmd/rpcdaemon/commands/eth_api_test.go index d5ab82334..252244ad9 100644 --- a/cmd/rpcdaemon/commands/eth_api_test.go +++ b/cmd/rpcdaemon/commands/eth_api_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/holiman/uint256" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/stretchr/testify/assert" "github.com/ledgerwatch/erigon/common/hexutil" @@ -34,10 +34,10 @@ func TestGetBalanceChangesInBlock(t *testing.T) { if err != nil { t.Errorf("calling GetBalanceChangesInBlock resulted in an error: %v", err) } - expected := map[libcommon.Address]*hexutil.Big{ - libcommon.HexToAddress("0x0D3ab14BBaD3D99F4203bd7a11aCB94882050E7e"): (*hexutil.Big)(uint256.NewInt(200000000000000000).ToBig()), - libcommon.HexToAddress("0x703c4b2bD70c169f5717101CaeE543299Fc946C7"): (*hexutil.Big)(uint256.NewInt(300000000000000000).ToBig()), - libcommon.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): (*hexutil.Big)(uint256.NewInt(9000000000000000000).ToBig()), + expected := map[common.Address]*hexutil.Big{ + common.HexToAddress("0x0D3ab14BBaD3D99F4203bd7a11aCB94882050E7e"): (*hexutil.Big)(uint256.NewInt(200000000000000000).ToBig()), + common.HexToAddress("0x703c4b2bD70c169f5717101CaeE543299Fc946C7"): (*hexutil.Big)(uint256.NewInt(300000000000000000).ToBig()), + common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): (*hexutil.Big)(uint256.NewInt(9000000000000000000).ToBig()), } assert.Equal(len(expected), len(balances)) for i := range balances { @@ -54,7 +54,7 @@ func TestGetTransactionReceipt(t *testing.T) { stateCache := kvcache.New(kvcache.DefaultCoherentConfig) api := NewEthAPI(NewBaseApi(nil, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), db, nil, nil, nil, 5000000, 100_000) // Call GetTransactionReceipt for transaction which is not in the database - if _, err := api.GetTransactionReceipt(context.Background(), libcommon.Hash{}); err != nil { + if _, err := api.GetTransactionReceipt(context.Background(), common.Hash{}); err != nil { t.Errorf("calling GetTransactionReceipt with empty hash: %v", err) } } @@ -66,7 +66,7 @@ func TestGetTransactionReceiptUnprotected(t *testing.T) { stateCache := kvcache.New(kvcache.DefaultCoherentConfig) api := NewEthAPI(NewBaseApi(nil, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), m.DB, nil, nil, nil, 5000000, 100_000) // Call GetTransactionReceipt for un-protected transaction - if _, err := api.GetTransactionReceipt(context.Background(), libcommon.HexToHash("0x3f3cb8a0e13ed2481f97f53f7095b9cbc78b6ffb779f2d3e565146371a8830ea")); err != nil { + if _, err := api.GetTransactionReceipt(context.Background(), common.HexToHash("0x3f3cb8a0e13ed2481f97f53f7095b9cbc78b6ffb779f2d3e565146371a8830ea")); err != nil { t.Errorf("calling GetTransactionReceipt for unprotected tx: %v", err) } } @@ -80,14 +80,14 @@ func TestGetStorageAt_ByBlockNumber_WithRequireCanonicalDefault(t *testing.T) { br := snapshotsync.NewBlockReaderWithSnapshots(m.BlockSnapshots) stateCache := kvcache.New(kvcache.DefaultCoherentConfig) api := NewEthAPI(NewBaseApi(nil, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), m.DB, nil, nil, nil, 5000000, 100_000) - addr := libcommon.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") + addr := common.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") result, err := api.GetStorageAt(context.Background(), addr, "0x0", rpc.BlockNumberOrHashWithNumber(0)) if err != nil { t.Errorf("calling GetStorageAt: %v", err) } - assert.Equal(libcommon.HexToHash("0x0").String(), result) + assert.Equal(common.HexToHash("0x0").String(), result) } func TestGetStorageAt_ByBlockHash_WithRequireCanonicalDefault(t *testing.T) { @@ -97,14 +97,14 @@ func TestGetStorageAt_ByBlockHash_WithRequireCanonicalDefault(t *testing.T) { br := snapshotsync.NewBlockReaderWithSnapshots(m.BlockSnapshots) stateCache := kvcache.New(kvcache.DefaultCoherentConfig) api := NewEthAPI(NewBaseApi(nil, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), m.DB, nil, nil, nil, 5000000, 100_000) - addr := libcommon.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") + addr := common.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") result, err := api.GetStorageAt(context.Background(), addr, "0x0", rpc.BlockNumberOrHashWithHash(m.Genesis.Hash(), false)) if err != nil { t.Errorf("calling GetStorageAt: %v", err) } - assert.Equal(libcommon.HexToHash("0x0").String(), result) + assert.Equal(common.HexToHash("0x0").String(), result) } func TestGetStorageAt_ByBlockHash_WithRequireCanonicalTrue(t *testing.T) { @@ -114,14 +114,14 @@ func TestGetStorageAt_ByBlockHash_WithRequireCanonicalTrue(t *testing.T) { br := snapshotsync.NewBlockReaderWithSnapshots(m.BlockSnapshots) stateCache := kvcache.New(kvcache.DefaultCoherentConfig) api := NewEthAPI(NewBaseApi(nil, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), m.DB, nil, nil, nil, 5000000, 100_000) - addr := libcommon.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") + addr := common.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") result, err := api.GetStorageAt(context.Background(), addr, "0x0", rpc.BlockNumberOrHashWithHash(m.Genesis.Hash(), true)) if err != nil { t.Errorf("calling GetStorageAt: %v", err) } - assert.Equal(libcommon.HexToHash("0x0").String(), result) + assert.Equal(common.HexToHash("0x0").String(), result) } func TestGetStorageAt_ByBlockHash_WithRequireCanonicalDefault_BlockNotFoundError(t *testing.T) { @@ -130,7 +130,7 @@ func TestGetStorageAt_ByBlockHash_WithRequireCanonicalDefault_BlockNotFoundError br := snapshotsync.NewBlockReaderWithSnapshots(m.BlockSnapshots) stateCache := kvcache.New(kvcache.DefaultCoherentConfig) api := NewEthAPI(NewBaseApi(nil, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), m.DB, nil, nil, nil, 5000000, 100_000) - addr := libcommon.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") + addr := common.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") offChain, err := core.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, 1, func(i int, block *core.BlockGen) { }, true) @@ -154,7 +154,7 @@ func TestGetStorageAt_ByBlockHash_WithRequireCanonicalTrue_BlockNotFoundError(t br := snapshotsync.NewBlockReaderWithSnapshots(m.BlockSnapshots) stateCache := kvcache.New(kvcache.DefaultCoherentConfig) api := NewEthAPI(NewBaseApi(nil, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), m.DB, nil, nil, nil, 5000000, 100_000) - addr := libcommon.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") + addr := common.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") offChain, err := core.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, 1, func(i int, block *core.BlockGen) { }, true) @@ -179,7 +179,7 @@ func TestGetStorageAt_ByBlockHash_WithRequireCanonicalDefault_NonCanonicalBlock( br := snapshotsync.NewBlockReaderWithSnapshots(m.BlockSnapshots) stateCache := kvcache.New(kvcache.DefaultCoherentConfig) api := NewEthAPI(NewBaseApi(nil, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), m.DB, nil, nil, nil, 5000000, 100_000) - addr := libcommon.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") + addr := common.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") orphanedBlock := orphanedChain[0].Blocks[0] @@ -192,7 +192,7 @@ func TestGetStorageAt_ByBlockHash_WithRequireCanonicalDefault_NonCanonicalBlock( t.Error("error expected") } - assert.Equal(libcommon.HexToHash("0x0").String(), result) + assert.Equal(common.HexToHash("0x0").String(), result) } func TestGetStorageAt_ByBlockHash_WithRequireCanonicalTrue_NonCanonicalBlock(t *testing.T) { @@ -201,7 +201,7 @@ func TestGetStorageAt_ByBlockHash_WithRequireCanonicalTrue_NonCanonicalBlock(t * br := snapshotsync.NewBlockReaderWithSnapshots(m.BlockSnapshots) stateCache := kvcache.New(kvcache.DefaultCoherentConfig) api := NewEthAPI(NewBaseApi(nil, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), m.DB, nil, nil, nil, 5000000, 100_000) - addr := libcommon.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") + addr := common.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") orphanedBlock := orphanedChain[0].Blocks[0] @@ -220,8 +220,8 @@ func TestCall_ByBlockHash_WithRequireCanonicalDefault_NonCanonicalBlock(t *testi br := snapshotsync.NewBlockReaderWithSnapshots(m.BlockSnapshots) stateCache := kvcache.New(kvcache.DefaultCoherentConfig) api := NewEthAPI(NewBaseApi(nil, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), m.DB, nil, nil, nil, 5000000, 100_000) - from := libcommon.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") - to := libcommon.HexToAddress("0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e") + from := common.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") + to := common.HexToAddress("0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e") orphanedBlock := orphanedChain[0].Blocks[0] @@ -246,8 +246,8 @@ func TestCall_ByBlockHash_WithRequireCanonicalTrue_NonCanonicalBlock(t *testing. br := snapshotsync.NewBlockReaderWithSnapshots(m.BlockSnapshots) stateCache := kvcache.New(kvcache.DefaultCoherentConfig) api := NewEthAPI(NewBaseApi(nil, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), m.DB, nil, nil, nil, 5000000, 100_000) - from := libcommon.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") - to := libcommon.HexToAddress("0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e") + from := common.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7") + to := common.HexToAddress("0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e") orphanedBlock := orphanedChain[0].Blocks[0] diff --git a/cmd/rpcdaemon/commands/eth_block.go b/cmd/rpcdaemon/commands/eth_block.go index bafdd4a74..8c80e40a9 100644 --- a/cmd/rpcdaemon/commands/eth_block.go +++ b/cmd/rpcdaemon/commands/eth_block.go @@ -6,7 +6,7 @@ import ( "math/big" "time" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/log/v3" @@ -26,7 +26,7 @@ import ( "github.com/ledgerwatch/erigon/turbo/transactions" ) -func (api *APIImpl) CallBundle(ctx context.Context, txHashes []libcommon.Hash, stateBlockNumberOrHash rpc.BlockNumberOrHash, timeoutMilliSecondsPtr *int64) (map[string]interface{}, error) { +func (api *APIImpl) CallBundle(ctx context.Context, txHashes []common.Hash, stateBlockNumberOrHash rpc.BlockNumberOrHash, timeoutMilliSecondsPtr *int64) (map[string]interface{}, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err @@ -182,7 +182,7 @@ func (api *APIImpl) CallBundle(ctx context.Context, txHashes []libcommon.Hash, s if result.Err != nil { jsonResult["error"] = result.Err.Error() } else { - jsonResult["value"] = libcommon.BytesToHash(result.Return()) + jsonResult["value"] = common.BytesToHash(result.Return()) } results = append(results, jsonResult) @@ -222,7 +222,7 @@ func (api *APIImpl) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber return nil, err } var borTx types.Transaction - var borTxHash libcommon.Hash + var borTxHash common.Hash if chainConfig.Bor != nil { borTx, _, _, _ = rawdb.ReadBorTransactionForBlock(tx, b) if borTx != nil { @@ -284,7 +284,7 @@ func (api *APIImpl) GetBlockByHash(ctx context.Context, numberOrHash rpc.BlockNu return nil, err } var borTx types.Transaction - var borTxHash libcommon.Hash + var borTxHash common.Hash if chainConfig.Bor != nil { borTx, _, _, _ = rawdb.ReadBorTransactionForBlock(tx, block) if borTx != nil { @@ -344,7 +344,7 @@ func (api *APIImpl) GetBlockTransactionCountByNumber(ctx context.Context, blockN } // GetBlockTransactionCountByHash implements eth_getBlockTransactionCountByHash. Returns the number of transactions in a block given the block's block hash. -func (api *APIImpl) GetBlockTransactionCountByHash(ctx context.Context, blockHash libcommon.Hash) (*hexutil.Uint, error) { +func (api *APIImpl) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) (*hexutil.Uint, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err diff --git a/cmd/rpcdaemon/commands/eth_block_test.go b/cmd/rpcdaemon/commands/eth_block_test.go index cc9b707a5..f893b0e2b 100644 --- a/cmd/rpcdaemon/commands/eth_block_test.go +++ b/cmd/rpcdaemon/commands/eth_block_test.go @@ -5,7 +5,7 @@ import ( "math/big" "testing" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/erigon-lib/kv/kvcache" "github.com/stretchr/testify/assert" @@ -30,7 +30,7 @@ func TestGetBlockByNumberWithLatestTag(t *testing.T) { stateCache := kvcache.New(kvcache.DefaultCoherentConfig) api := NewEthAPI(NewBaseApi(nil, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), m.DB, nil, nil, nil, 5000000, 100_000) b, err := api.GetBlockByNumber(context.Background(), rpc.LatestBlockNumber, false) - expected := libcommon.HexToHash("0x6804117de2f3e6ee32953e78ced1db7b20214e0d8c745a03b8fecf7cc8ee76ef") + expected := common.HexToHash("0x6804117de2f3e6ee32953e78ced1db7b20214e0d8c745a03b8fecf7cc8ee76ef") if err != nil { t.Errorf("error getting block number with latest tag: %s", err) } @@ -47,7 +47,7 @@ func TestGetBlockByNumberWithLatestTag_WithHeadHashInDb(t *testing.T) { if err != nil { t.Errorf("could not begin read write transaction: %s", err) } - latestBlockHash := libcommon.HexToHash("0x6804117de2f3e6ee32953e78ced1db7b20214e0d8c745a03b8fecf7cc8ee76ef") + latestBlockHash := common.HexToHash("0x6804117de2f3e6ee32953e78ced1db7b20214e0d8c745a03b8fecf7cc8ee76ef") latestBlock, err := rawdb.ReadBlockByHash(tx, latestBlockHash) if err != nil { tx.Rollback() @@ -55,7 +55,7 @@ func TestGetBlockByNumberWithLatestTag_WithHeadHashInDb(t *testing.T) { } rawdb.WriteHeaderNumber(tx, latestBlockHash, latestBlock.NonceU64()) rawdb.WriteForkchoiceHead(tx, latestBlockHash) - if safedHeadBlock := rawdb.ReadForkchoiceHead(tx); safedHeadBlock == (libcommon.Hash{}) { + if safedHeadBlock := rawdb.ReadForkchoiceHead(tx); safedHeadBlock == (common.Hash{}) { tx.Rollback() t.Error("didn't find forkchoice head hash") } @@ -66,7 +66,7 @@ func TestGetBlockByNumberWithLatestTag_WithHeadHashInDb(t *testing.T) { if err != nil { t.Errorf("error retrieving block by number: %s", err) } - expectedHash := libcommon.HexToHash("0x71b89b6ca7b65debfd2fbb01e4f07de7bba343e6617559fa81df19b605f84662") + expectedHash := common.HexToHash("0x71b89b6ca7b65debfd2fbb01e4f07de7bba343e6617559fa81df19b605f84662") assert.Equal(t, expectedHash, block["hash"]) } @@ -123,7 +123,7 @@ func TestGetBlockByNumber_WithFinalizedTag_WithFinalizedBlockInDb(t *testing.T) if err != nil { t.Errorf("could not begin read write transaction: %s", err) } - latestBlockHash := libcommon.HexToHash("0x6804117de2f3e6ee32953e78ced1db7b20214e0d8c745a03b8fecf7cc8ee76ef") + latestBlockHash := common.HexToHash("0x6804117de2f3e6ee32953e78ced1db7b20214e0d8c745a03b8fecf7cc8ee76ef") latestBlock, err := rawdb.ReadBlockByHash(tx, latestBlockHash) if err != nil { tx.Rollback() @@ -131,7 +131,7 @@ func TestGetBlockByNumber_WithFinalizedTag_WithFinalizedBlockInDb(t *testing.T) } rawdb.WriteHeaderNumber(tx, latestBlockHash, latestBlock.NonceU64()) rawdb.WriteForkchoiceFinalized(tx, latestBlockHash) - if safedFinalizedBlock := rawdb.ReadForkchoiceFinalized(tx); safedFinalizedBlock == (libcommon.Hash{}) { + if safedFinalizedBlock := rawdb.ReadForkchoiceFinalized(tx); safedFinalizedBlock == (common.Hash{}) { tx.Rollback() t.Error("didn't find forkchoice finalized hash") } @@ -142,7 +142,7 @@ func TestGetBlockByNumber_WithFinalizedTag_WithFinalizedBlockInDb(t *testing.T) if err != nil { t.Errorf("error retrieving block by number: %s", err) } - expectedHash := libcommon.HexToHash("0x71b89b6ca7b65debfd2fbb01e4f07de7bba343e6617559fa81df19b605f84662") + expectedHash := common.HexToHash("0x71b89b6ca7b65debfd2fbb01e4f07de7bba343e6617559fa81df19b605f84662") assert.Equal(t, expectedHash, block["hash"]) } @@ -168,7 +168,7 @@ func TestGetBlockByNumber_WithSafeTag_WithSafeBlockInDb(t *testing.T) { if err != nil { t.Errorf("could not begin read write transaction: %s", err) } - latestBlockHash := libcommon.HexToHash("0x6804117de2f3e6ee32953e78ced1db7b20214e0d8c745a03b8fecf7cc8ee76ef") + latestBlockHash := common.HexToHash("0x6804117de2f3e6ee32953e78ced1db7b20214e0d8c745a03b8fecf7cc8ee76ef") latestBlock, err := rawdb.ReadBlockByHash(tx, latestBlockHash) if err != nil { tx.Rollback() @@ -176,7 +176,7 @@ func TestGetBlockByNumber_WithSafeTag_WithSafeBlockInDb(t *testing.T) { } rawdb.WriteHeaderNumber(tx, latestBlockHash, latestBlock.NonceU64()) rawdb.WriteForkchoiceSafe(tx, latestBlockHash) - if safedSafeBlock := rawdb.ReadForkchoiceSafe(tx); safedSafeBlock == (libcommon.Hash{}) { + if safedSafeBlock := rawdb.ReadForkchoiceSafe(tx); safedSafeBlock == (common.Hash{}) { tx.Rollback() t.Error("didn't find forkchoice safe block hash") } @@ -187,7 +187,7 @@ func TestGetBlockByNumber_WithSafeTag_WithSafeBlockInDb(t *testing.T) { if err != nil { t.Errorf("error retrieving block by number: %s", err) } - expectedHash := libcommon.HexToHash("0x71b89b6ca7b65debfd2fbb01e4f07de7bba343e6617559fa81df19b605f84662") + expectedHash := common.HexToHash("0x71b89b6ca7b65debfd2fbb01e4f07de7bba343e6617559fa81df19b605f84662") assert.Equal(t, expectedHash, block["hash"]) } @@ -199,7 +199,7 @@ func TestGetBlockTransactionCountByHash(t *testing.T) { stateCache := kvcache.New(kvcache.DefaultCoherentConfig) api := NewEthAPI(NewBaseApi(nil, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), m.DB, nil, nil, nil, 5000000, 100_000) - blockHash := libcommon.HexToHash("0x6804117de2f3e6ee32953e78ced1db7b20214e0d8c745a03b8fecf7cc8ee76ef") + blockHash := common.HexToHash("0x6804117de2f3e6ee32953e78ced1db7b20214e0d8c745a03b8fecf7cc8ee76ef") tx, err := m.DB.BeginRw(ctx) if err != nil { @@ -234,7 +234,7 @@ func TestGetBlockTransactionCountByNumber(t *testing.T) { ctx := context.Background() stateCache := kvcache.New(kvcache.DefaultCoherentConfig) api := NewEthAPI(NewBaseApi(nil, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine), m.DB, nil, nil, nil, 5000000, 100_000) - blockHash := libcommon.HexToHash("0x6804117de2f3e6ee32953e78ced1db7b20214e0d8c745a03b8fecf7cc8ee76ef") + blockHash := common.HexToHash("0x6804117de2f3e6ee32953e78ced1db7b20214e0d8c745a03b8fecf7cc8ee76ef") tx, err := m.DB.BeginRw(ctx) if err != nil { diff --git a/cmd/rpcdaemon/commands/eth_call.go b/cmd/rpcdaemon/commands/eth_call.go index 9c1477478..0254f57d1 100644 --- a/cmd/rpcdaemon/commands/eth_call.go +++ b/cmd/rpcdaemon/commands/eth_call.go @@ -15,7 +15,6 @@ import ( "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" - "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/state" @@ -172,7 +171,7 @@ func (api *APIImpl) EstimateGas(ctx context.Context, argsOrNil *ethapi2.CallArgs } else if args.MaxFeePerGas != nil { feeCap = args.MaxFeePerGas.ToInt() } else { - feeCap = common.Big0 + feeCap = libcommon.Big0 } // Recap the highest gas limit with account's available balance. if feeCap.Sign() != 0 { diff --git a/cmd/rpcdaemon/commands/eth_callMany.go b/cmd/rpcdaemon/commands/eth_callMany.go index 65f5f593c..c330803a3 100644 --- a/cmd/rpcdaemon/commands/eth_callMany.go +++ b/cmd/rpcdaemon/commands/eth_callMany.go @@ -8,7 +8,7 @@ import ( "time" "github.com/holiman/uint256" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/erigon/common/hexutil" @@ -26,12 +26,12 @@ import ( type BlockOverrides struct { BlockNumber *hexutil.Uint64 - Coinbase *libcommon.Address + Coinbase *common.Address Timestamp *hexutil.Uint64 GasLimit *hexutil.Uint Difficulty *hexutil.Uint BaseFee *uint256.Int - BlockHash *map[uint64]libcommon.Hash + BlockHash *map[uint64]common.Hash } type Bundle struct { @@ -44,7 +44,7 @@ type StateContext struct { TransactionIndex *int } -func blockHeaderOverride(blockCtx *evmtypes.BlockContext, blockOverride BlockOverrides, overrideBlockHash map[uint64]libcommon.Hash) { +func blockHeaderOverride(blockCtx *evmtypes.BlockContext, blockOverride BlockOverrides, overrideBlockHash map[uint64]common.Hash) { if blockOverride.BlockNumber != nil { blockCtx.BlockNumber = uint64(*blockOverride.BlockNumber) } @@ -72,16 +72,16 @@ func blockHeaderOverride(blockCtx *evmtypes.BlockContext, blockOverride BlockOve func (api *APIImpl) CallMany(ctx context.Context, bundles []Bundle, simulateContext StateContext, stateOverride *ethapi.StateOverrides, timeoutMilliSecondsPtr *int64) ([][]map[string]interface{}, error) { var ( - hash libcommon.Hash + hash common.Hash replayTransactions types.Transactions evm *vm.EVM blockCtx evmtypes.BlockContext txCtx evmtypes.TxContext - overrideBlockHash map[uint64]libcommon.Hash + overrideBlockHash map[uint64]common.Hash baseFee uint256.Int ) - overrideBlockHash = make(map[uint64]libcommon.Hash) + overrideBlockHash = make(map[uint64]common.Hash) tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err @@ -145,7 +145,7 @@ func (api *APIImpl) CallMany(ctx context.Context, bundles []Bundle, simulateCont return nil, fmt.Errorf("block %d(%x) not found", blockNum, hash) } - getHash := func(i uint64) libcommon.Hash { + getHash := func(i uint64) common.Hash { if hash, ok := overrideBlockHash[i]; ok { return hash } diff --git a/cmd/rpcdaemon/commands/eth_deprecated.go b/cmd/rpcdaemon/commands/eth_deprecated.go index e1e8e2a2f..16a8553d2 100644 --- a/cmd/rpcdaemon/commands/eth_deprecated.go +++ b/cmd/rpcdaemon/commands/eth_deprecated.go @@ -4,24 +4,24 @@ import ( "context" "fmt" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/common/hexutil" ) // Accounts implements eth_accounts. Returns a list of addresses owned by the client. // Deprecated: This function will be removed in the future. -func (api *APIImpl) Accounts(ctx context.Context) ([]libcommon.Address, error) { - return []libcommon.Address{}, fmt.Errorf(NotAvailableDeprecated, "eth_accounts") +func (api *APIImpl) Accounts(ctx context.Context) ([]common.Address, error) { + return []common.Address{}, fmt.Errorf(NotAvailableDeprecated, "eth_accounts") } // 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, _ libcommon.Address, _ hexutil.Bytes) (hexutil.Bytes, error) { +func (api *APIImpl) Sign(ctx context.Context, _ common.Address, _ hexutil.Bytes) (hexutil.Bytes, error) { return hexutil.Bytes(""), fmt.Errorf(NotAvailableDeprecated, "eth_sign") } // SignTransaction deprecated -func (api *APIImpl) SignTransaction(_ context.Context, txObject interface{}) (libcommon.Hash, error) { - return libcommon.Hash{0}, fmt.Errorf(NotAvailableDeprecated, "eth_signTransaction") +func (api *APIImpl) SignTransaction(_ context.Context, txObject interface{}) (common.Hash, error) { + return common.Hash{0}, fmt.Errorf(NotAvailableDeprecated, "eth_signTransaction") } diff --git a/cmd/rpcdaemon/commands/eth_txs.go b/cmd/rpcdaemon/commands/eth_txs.go index a4012c703..6314be9d7 100644 --- a/cmd/rpcdaemon/commands/eth_txs.go +++ b/cmd/rpcdaemon/commands/eth_txs.go @@ -5,7 +5,7 @@ import ( "context" "math/big" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/gointerfaces" "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/erigon-lib/gointerfaces/types" @@ -19,7 +19,7 @@ import ( ) // GetTransactionByHash implements eth_getTransactionByHash. Returns information about a transaction given the transaction's hash. -func (api *APIImpl) GetTransactionByHash(ctx context.Context, txnHash libcommon.Hash) (*RPCTransaction, error) { +func (api *APIImpl) GetTransactionByHash(ctx context.Context, txnHash common.Hash) (*RPCTransaction, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err @@ -67,7 +67,7 @@ func (api *APIImpl) GetTransactionByHash(ctx context.Context, txnHash libcommon. // Add GasPrice for the DynamicFeeTransaction var baseFee *big.Int - if chainConfig.IsLondon(blockNum) && blockHash != (libcommon.Hash{}) { + if chainConfig.IsLondon(blockNum) && blockHash != (common.Hash{}) { baseFee = block.BaseFee() } @@ -116,7 +116,7 @@ func (api *APIImpl) GetTransactionByHash(ctx context.Context, txnHash libcommon. } // GetRawTransactionByHash returns the bytes of the transaction for the given hash. -func (api *APIImpl) GetRawTransactionByHash(ctx context.Context, hash libcommon.Hash) (hexutil.Bytes, error) { +func (api *APIImpl) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err @@ -164,7 +164,7 @@ func (api *APIImpl) GetRawTransactionByHash(ctx context.Context, hash libcommon. } // GetTransactionByBlockHashAndIndex implements eth_getTransactionByBlockHashAndIndex. Returns information about a transaction given the block's hash and a transaction index. -func (api *APIImpl) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash libcommon.Hash, txIndex hexutil.Uint64) (*RPCTransaction, error) { +func (api *APIImpl) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, txIndex hexutil.Uint64) (*RPCTransaction, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err @@ -203,7 +203,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 libcommon.Hash, index hexutil.Uint) (hexutil.Bytes, error) { +func (api *APIImpl) GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) (hexutil.Bytes, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err diff --git a/cmd/rpcdaemon/commands/eth_uncles.go b/cmd/rpcdaemon/commands/eth_uncles.go index 653e1bb36..31ae196a3 100644 --- a/cmd/rpcdaemon/commands/eth_uncles.go +++ b/cmd/rpcdaemon/commands/eth_uncles.go @@ -3,7 +3,7 @@ package commands import ( "context" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/erigon/common/hexutil" @@ -50,7 +50,7 @@ func (api *APIImpl) GetUncleByBlockNumberAndIndex(ctx context.Context, number rp } // GetUncleByBlockHashAndIndex implements eth_getUncleByBlockHashAndIndex. Returns information about an uncle given a block's hash and the index of the uncle. -func (api *APIImpl) GetUncleByBlockHashAndIndex(ctx context.Context, hash libcommon.Hash, index hexutil.Uint) (map[string]interface{}, error) { +func (api *APIImpl) GetUncleByBlockHashAndIndex(ctx context.Context, hash common.Hash, index hexutil.Uint) (map[string]interface{}, error) { tx, err := api.db.BeginRo(ctx) if err != nil { return nil, err @@ -109,7 +109,7 @@ func (api *APIImpl) GetUncleCountByBlockNumber(ctx context.Context, number rpc.B } // GetUncleCountByBlockHash implements eth_getUncleCountByBlockHash. Returns the number of uncles in the block, if any. -func (api *APIImpl) GetUncleCountByBlockHash(ctx context.Context, hash libcommon.Hash) (*hexutil.Uint, error) { +func (api *APIImpl) GetUncleCountByBlockHash(ctx context.Context, hash common.Hash) (*hexutil.Uint, error) { n := hexutil.Uint(0) tx, err := api.db.BeginRo(ctx) if err != nil { diff --git a/cmd/rpcdaemon/commands/send_transaction.go b/cmd/rpcdaemon/commands/send_transaction.go index f903dde16..bd274d192 100644 --- a/cmd/rpcdaemon/commands/send_transaction.go +++ b/cmd/rpcdaemon/commands/send_transaction.go @@ -7,7 +7,7 @@ import ( "fmt" "math/big" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" txPoolProto "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/log/v3" @@ -21,24 +21,24 @@ 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) (libcommon.Hash, error) { +func (api *APIImpl) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) { txn, err := types.DecodeTransaction(rlp.NewStream(bytes.NewReader(encodedTx), uint64(len(encodedTx)))) if err != nil { - return libcommon.Hash{}, err + return common.Hash{}, err } // If the transaction fee cap is already specified, ensure the // fee of the given transaction is _reasonable_. if err := checkTxFee(txn.GetPrice().ToBig(), txn.GetGas(), ethconfig.Defaults.RPCTxFeeCap); err != nil { - return libcommon.Hash{}, err + return common.Hash{}, err } if !txn.Protected() { - return libcommon.Hash{}, errors.New("only replay-protected (EIP-155) transactions allowed over RPC") + return common.Hash{}, errors.New("only replay-protected (EIP-155) transactions allowed over RPC") } hash := txn.Hash() res, err := api.txPool.Add(ctx, &txPoolProto.AddRequest{RlpTxs: [][]byte{encodedTx}}) if err != nil { - return libcommon.Hash{}, err + return common.Hash{}, err } if res.Imported[0] != txPoolProto.ImportResult_SUCCESS { @@ -47,31 +47,31 @@ func (api *APIImpl) SendRawTransaction(ctx context.Context, encodedTx hexutil.By tx, err := api.db.BeginRo(ctx) if err != nil { - return libcommon.Hash{}, err + return common.Hash{}, err } defer tx.Rollback() // Print a log with full txn details for manual investigations and interventions blockNum := rawdb.ReadCurrentBlockNumber(tx) if blockNum == nil { - return libcommon.Hash{}, err + return common.Hash{}, err } cc, err := api.chainConfig(tx) if err != nil { - return libcommon.Hash{}, err + return common.Hash{}, err } txnChainId := txn.GetChainID() chainId := cc.ChainID if chainId.Cmp(txnChainId.ToBig()) != 0 { - return libcommon.Hash{}, fmt.Errorf("invalid chain id, expected: %d got: %d", chainId, *txnChainId) + return common.Hash{}, fmt.Errorf("invalid chain id, expected: %d got: %d", chainId, *txnChainId) } signer := types.MakeSigner(cc, *blockNum) from, err := txn.Sender(*signer) if err != nil { - return libcommon.Hash{}, err + return common.Hash{}, err } if txn.GetTo() == nil { @@ -85,8 +85,8 @@ func (api *APIImpl) SendRawTransaction(ctx context.Context, encodedTx hexutil.By } // SendTransaction implements eth_sendTransaction. Creates new message call transaction or a contract creation if the data field contains code. -func (api *APIImpl) SendTransaction(_ context.Context, txObject interface{}) (libcommon.Hash, error) { - return libcommon.Hash{0}, fmt.Errorf(NotImplemented, "eth_sendTransaction") +func (api *APIImpl) SendTransaction(_ context.Context, txObject interface{}) (common.Hash, error) { + return common.Hash{0}, fmt.Errorf(NotImplemented, "eth_sendTransaction") } // checkTxFee is an internal function used to check whether the fee of diff --git a/cmd/rpcdaemon/commands/send_transaction_test.go b/cmd/rpcdaemon/commands/send_transaction_test.go index c1fc2f191..199f66f57 100644 --- a/cmd/rpcdaemon/commands/send_transaction_test.go +++ b/cmd/rpcdaemon/commands/send_transaction_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/holiman/uint256" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/gointerfaces/sentry" "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/erigon-lib/kv/kvcache" @@ -32,7 +32,7 @@ func TestSendRawTransaction(t *testing.T) { m, require := stages.Mock(t), require.New(t) chain, err := core.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, 1, func(i int, b *core.BlockGen) { - b.SetCoinbase(libcommon.Address{1}) + b.SetCoinbase(common.Address{1}) }, false /* intermediateHashes */) require.NoError(err) { // Do 1 step to start txPool @@ -66,7 +66,7 @@ func TestSendRawTransaction(t *testing.T) { } expectValue := uint64(1234) - txn, err := types.SignTx(types.NewTransaction(0, libcommon.Address{1}, uint256.NewInt(expectValue), params.TxGas, uint256.NewInt(10*params.GWei), nil), *types.LatestSignerForChainID(m.ChainConfig.ChainID), m.Key) + txn, err := types.SignTx(types.NewTransaction(0, common.Address{1}, uint256.NewInt(expectValue), params.TxGas, uint256.NewInt(10*params.GWei), nil), *types.LatestSignerForChainID(m.ChainConfig.ChainID), m.Key) require.NoError(err) ctx, conn := rpcdaemontest.CreateTestGrpcConn(t, m) @@ -106,6 +106,6 @@ func transaction(nonce uint64, gaslimit uint64, key *ecdsa.PrivateKey) types.Tra } func pricedTransaction(nonce uint64, gaslimit uint64, gasprice *uint256.Int, key *ecdsa.PrivateKey) types.Transaction { - tx, _ := types.SignTx(types.NewTransaction(nonce, libcommon.Address{}, uint256.NewInt(100), gaslimit, gasprice, nil), *types.LatestSignerForChainID(big.NewInt(1337)), key) + tx, _ := types.SignTx(types.NewTransaction(nonce, common.Address{}, uint256.NewInt(100), gaslimit, gasprice, nil), *types.LatestSignerForChainID(big.NewInt(1337)), key) return tx } diff --git a/cmd/rpcdaemon/commands/trace_filtering.go b/cmd/rpcdaemon/commands/trace_filtering.go index 34e6dfb06..2e7b5ccd9 100644 --- a/cmd/rpcdaemon/commands/trace_filtering.go +++ b/cmd/rpcdaemon/commands/trace_filtering.go @@ -9,13 +9,12 @@ import ( "github.com/RoaringBitmap/roaring/roaring64" jsoniter "github.com/json-iterator/go" "github.com/ledgerwatch/erigon-lib/chain" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv/bitmapdb" "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/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/consensus/ethash" "github.com/ledgerwatch/erigon/core" @@ -32,7 +31,7 @@ import ( ) // Transaction implements trace_transaction -func (api *TraceAPIImpl) Transaction(ctx context.Context, txHash libcommon.Hash) (ParityTraces, error) { +func (api *TraceAPIImpl) Transaction(ctx context.Context, txHash common.Hash) (ParityTraces, error) { tx, err := api.kv.BeginRo(ctx) if err != nil { return nil, err @@ -119,7 +118,7 @@ func (api *TraceAPIImpl) Transaction(ctx context.Context, txHash libcommon.Hash) } // Get implements trace_get -func (api *TraceAPIImpl) Get(ctx context.Context, txHash libcommon.Hash, indicies []hexutil.Uint64) (*ParityTrace, error) { +func (api *TraceAPIImpl) Get(ctx context.Context, txHash common.Hash, indicies []hexutil.Uint64) (*ParityTrace, error) { // Parity fails if it gets more than a single index. It returns nothing in this case. Must we? if len(indicies) > 1 { return nil, nil @@ -205,7 +204,7 @@ func (api *TraceAPIImpl) Block(ctx context.Context, blockNr rpc.BlockNumber) (Pa rewardAction.Value.ToInt().Set(minerReward.ToBig()) } tr.Action = rewardAction - tr.BlockHash = &libcommon.Hash{} + tr.BlockHash = &common.Hash{} copy(tr.BlockHash[:], block.Hash().Bytes()) tr.BlockNumber = new(uint64) *tr.BlockNumber = block.NumberU64() @@ -223,7 +222,7 @@ func (api *TraceAPIImpl) Block(ctx context.Context, blockNr rpc.BlockNumber) (Pa rewardAction.RewardType = "uncle" // nolint: goconst rewardAction.Value.ToInt().Set(uncleRewards[i].ToBig()) tr.Action = rewardAction - tr.BlockHash = &libcommon.Hash{} + tr.BlockHash = &common.Hash{} copy(tr.BlockHash[:], block.Hash().Bytes()) tr.BlockNumber = new(uint64) *tr.BlockNumber = block.NumberU64() @@ -237,9 +236,9 @@ func (api *TraceAPIImpl) Block(ctx context.Context, blockNr rpc.BlockNumber) (Pa return out, err } -func traceFilterBitmaps(tx kv.Tx, req TraceFilterRequest, from, to uint64) (fromAddresses, toAddresses map[libcommon.Address]struct{}, allBlocks *roaring64.Bitmap, err error) { - fromAddresses = make(map[libcommon.Address]struct{}, len(req.FromAddress)) - toAddresses = make(map[libcommon.Address]struct{}, len(req.ToAddress)) +func traceFilterBitmaps(tx kv.Tx, req TraceFilterRequest, from, to uint64) (fromAddresses, toAddresses map[common.Address]struct{}, allBlocks *roaring64.Bitmap, err error) { + fromAddresses = make(map[common.Address]struct{}, len(req.FromAddress)) + toAddresses = make(map[common.Address]struct{}, len(req.ToAddress)) allBlocks = roaring64.New() var blocksTo roaring64.Bitmap for _, addr := range req.FromAddress { @@ -290,9 +289,9 @@ func traceFilterBitmaps(tx kv.Tx, req TraceFilterRequest, from, to uint64) (from return fromAddresses, toAddresses, allBlocks, nil } -func traceFilterBitmapsV3(tx kv.TemporalTx, req TraceFilterRequest, from, to uint64) (fromAddresses, toAddresses map[libcommon.Address]struct{}, allBlocks iter.U64, err error) { - fromAddresses = make(map[libcommon.Address]struct{}, len(req.FromAddress)) - toAddresses = make(map[libcommon.Address]struct{}, len(req.ToAddress)) +func traceFilterBitmapsV3(tx kv.TemporalTx, req TraceFilterRequest, from, to uint64) (fromAddresses, toAddresses map[common.Address]struct{}, allBlocks iter.U64, err error) { + fromAddresses = make(map[common.Address]struct{}, len(req.FromAddress)) + toAddresses = make(map[common.Address]struct{}, len(req.ToAddress)) var blocksTo iter.U64 for _, addr := range req.FromAddress { @@ -508,7 +507,7 @@ func (api *TraceAPIImpl) Filter(ctx context.Context, req TraceFilterRequest, str rewardAction.RewardType = "block" // nolint: goconst rewardAction.Value.ToInt().Set(minerReward.ToBig()) tr.Action = rewardAction - tr.BlockHash = &libcommon.Hash{} + tr.BlockHash = &common.Hash{} copy(tr.BlockHash[:], block.Hash().Bytes()) tr.BlockNumber = new(uint64) *tr.BlockNumber = block.NumberU64() @@ -546,7 +545,7 @@ func (api *TraceAPIImpl) Filter(ctx context.Context, req TraceFilterRequest, str rewardAction.RewardType = "uncle" // nolint: goconst rewardAction.Value.ToInt().Set(uncleRewards[i].ToBig()) tr.Action = rewardAction - tr.BlockHash = &libcommon.Hash{} + tr.BlockHash = &common.Hash{} copy(tr.BlockHash[:], block.Hash().Bytes()) tr.BlockNumber = new(uint64) *tr.BlockNumber = block.NumberU64() @@ -625,7 +624,7 @@ func (api *TraceAPIImpl) filterV3(ctx context.Context, dbtx kv.TemporalTx, fromB includeAll := len(fromAddresses) == 0 && len(toAddresses) == 0 it := MapTxNum2BlockNum(dbtx, allTxs) - var lastBlockHash libcommon.Hash + var lastBlockHash common.Hash var lastHeader *types.Header var lastSigner *types.Signer var lastRules *chain.Rules @@ -699,7 +698,7 @@ func (api *TraceAPIImpl) filterV3(ctx context.Context, dbtx kv.TemporalTx, fromB rewardAction.RewardType = "block" // nolint: goconst rewardAction.Value.ToInt().Set(minerReward.ToBig()) tr.Action = rewardAction - tr.BlockHash = &libcommon.Hash{} + tr.BlockHash = &common.Hash{} copy(tr.BlockHash[:], lastBlockHash.Bytes()) tr.BlockNumber = new(uint64) *tr.BlockNumber = blockNum @@ -737,7 +736,7 @@ func (api *TraceAPIImpl) filterV3(ctx context.Context, dbtx kv.TemporalTx, fromB rewardAction.RewardType = "uncle" // nolint: goconst rewardAction.Value.ToInt().Set(uncleRewards[i].ToBig()) tr.Action = rewardAction - tr.BlockHash = &libcommon.Hash{} + tr.BlockHash = &common.Hash{} copy(tr.BlockHash[:], lastBlockHash[:]) tr.BlockNumber = new(uint64) *tr.BlockNumber = blockNum @@ -836,7 +835,7 @@ func (api *TraceAPIImpl) filterV3(ctx context.Context, dbtx kv.TemporalTx, fromB stream.WriteObjectEnd() continue } - traceResult.Output = libcommon.Copy(execResult.ReturnData) + traceResult.Output = common.Copy(execResult.ReturnData) if err = ibs.FinalizeTx(evm.ChainRules(), noop); err != nil { if first { first = false @@ -894,7 +893,7 @@ func (api *TraceAPIImpl) filterV3(ctx context.Context, dbtx kv.TemporalTx, fromB return stream.Flush() } -func filter_trace(pt *ParityTrace, fromAddresses map[libcommon.Address]struct{}, toAddresses map[libcommon.Address]struct{}) bool { +func filter_trace(pt *ParityTrace, fromAddresses map[common.Address]struct{}, toAddresses map[common.Address]struct{}) bool { switch action := pt.Action.(type) { case *CallTraceAction: _, f := fromAddresses[action.From] @@ -926,7 +925,7 @@ func filter_trace(pt *ParityTrace, fromAddresses map[libcommon.Address]struct{}, return false } -func (api *TraceAPIImpl) callManyTransactions(ctx context.Context, dbtx kv.Tx, txs []types.Transaction, traceTypes []string, parentHash libcommon.Hash, parentNo rpc.BlockNumber, header *types.Header, txIndex int, signer *types.Signer, rules *chain.Rules) ([]*TraceCallResult, error) { +func (api *TraceAPIImpl) callManyTransactions(ctx context.Context, dbtx kv.Tx, txs []types.Transaction, traceTypes []string, parentHash common.Hash, parentNo rpc.BlockNumber, header *types.Header, txIndex int, signer *types.Signer, rules *chain.Rules) ([]*TraceCallResult, error) { callParams := make([]TraceCallParam, 0, len(txs)) msgs := make([]types.Message, len(txs)) for i, tx := range txs { @@ -956,13 +955,13 @@ func (api *TraceAPIImpl) callManyTransactions(ctx context.Context, dbtx kv.Tx, t // TraceFilterRequest represents the arguments for trace_filter type TraceFilterRequest struct { - FromBlock *hexutil.Uint64 `json:"fromBlock"` - ToBlock *hexutil.Uint64 `json:"toBlock"` - FromAddress []*libcommon.Address `json:"fromAddress"` - ToAddress []*libcommon.Address `json:"toAddress"` - Mode TraceFilterMode `json:"mode"` - After *uint64 `json:"after"` - Count *uint64 `json:"count"` + FromBlock *hexutil.Uint64 `json:"fromBlock"` + ToBlock *hexutil.Uint64 `json:"toBlock"` + FromAddress []*common.Address `json:"fromAddress"` + ToAddress []*common.Address `json:"toAddress"` + Mode TraceFilterMode `json:"mode"` + After *uint64 `json:"after"` + Count *uint64 `json:"count"` } type TraceFilterMode string diff --git a/cmd/rpcdaemon/commands/trace_types.go b/cmd/rpcdaemon/commands/trace_types.go index b7db120f7..9ebdbdf58 100644 --- a/cmd/rpcdaemon/commands/trace_types.go +++ b/cmd/rpcdaemon/commands/trace_types.go @@ -3,7 +3,7 @@ package commands import ( "fmt" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/types" @@ -38,16 +38,16 @@ type GethTraces []*GethTrace // ParityTrace A trace in the desired format (Parity/OpenEtherum) See: https://openethereum.github.io/wiki/JSONRPC-trace-module type ParityTrace struct { // Do not change the ordering of these fields -- allows for easier comparison with other clients - Action interface{} `json:"action"` // Can be either CallTraceAction or CreateTraceAction - BlockHash *libcommon.Hash `json:"blockHash,omitempty"` - BlockNumber *uint64 `json:"blockNumber,omitempty"` - Error string `json:"error,omitempty"` - Result interface{} `json:"result"` - Subtraces int `json:"subtraces"` - TraceAddress []int `json:"traceAddress"` - TransactionHash *libcommon.Hash `json:"transactionHash,omitempty"` - TransactionPosition *uint64 `json:"transactionPosition,omitempty"` - Type string `json:"type"` + Action interface{} `json:"action"` // Can be either CallTraceAction or CreateTraceAction + BlockHash *common.Hash `json:"blockHash,omitempty"` + BlockNumber *uint64 `json:"blockNumber,omitempty"` + Error string `json:"error,omitempty"` + Result interface{} `json:"result"` + Subtraces int `json:"subtraces"` + TraceAddress []int `json:"traceAddress"` + TransactionHash *common.Hash `json:"transactionHash,omitempty"` + TransactionPosition *uint64 `json:"transactionPosition,omitempty"` + Type string `json:"type"` } // ParityTraces An array of parity traces @@ -56,53 +56,53 @@ 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 libcommon.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 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"` } type CallTraceAction struct { - From libcommon.Address `json:"from"` - CallType string `json:"callType"` - Gas hexutil.Big `json:"gas"` - Input hexutil.Bytes `json:"input"` - To libcommon.Address `json:"to"` - Value hexutil.Big `json:"value"` + 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"` } type CreateTraceAction struct { - From libcommon.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 hexutil.Bytes `json:"init"` + Value hexutil.Big `json:"value"` } type SuicideTraceAction struct { - Address libcommon.Address `json:"address"` - RefundAddress libcommon.Address `json:"refundAddress"` - Balance hexutil.Big `json:"balance"` + Address common.Address `json:"address"` + RefundAddress common.Address `json:"refundAddress"` + Balance hexutil.Big `json:"balance"` } type RewardTraceAction struct { - Author libcommon.Address `json:"author"` - RewardType string `json:"rewardType"` - Value hexutil.Big `json:"value,omitempty"` + Author common.Address `json:"author"` + RewardType string `json:"rewardType"` + Value hexutil.Big `json:"value,omitempty"` } type CreateTraceResult struct { // Do not change the ordering of these fields -- allows for easier comparison with other clients - Address *libcommon.Address `json:"address,omitempty"` - Code hexutil.Bytes `json:"code"` - GasUsed *hexutil.Big `json:"gasUsed"` + Address *common.Address `json:"address,omitempty"` + Code hexutil.Bytes `json:"code"` + GasUsed *hexutil.Big `json:"gasUsed"` } // TraceResult A parity formatted trace result @@ -155,7 +155,7 @@ func (t ParityTrace) String() string { // Takes a hierarchical Geth trace with fields of different meaning stored in the same named fields depending on 'type'. Parity traces // are flattened depth first and each field is put in its proper place -func (api *TraceAPIImpl) convertToParityTrace(gethTrace GethTrace, blockHash libcommon.Hash, blockNumber uint64, tx types.Transaction, txIndex uint64, depth []int) ParityTraces { //nolint: unused +func (api *TraceAPIImpl) convertToParityTrace(gethTrace GethTrace, blockHash common.Hash, blockNumber uint64, tx types.Transaction, txIndex uint64, depth []int) ParityTraces { //nolint: unused var traces ParityTraces // nolint prealloc return traces } diff --git a/cmd/rpcdaemon/commands/tracing.go b/cmd/rpcdaemon/commands/tracing.go index edcdcbcb8..7769bf21a 100644 --- a/cmd/rpcdaemon/commands/tracing.go +++ b/cmd/rpcdaemon/commands/tracing.go @@ -8,7 +8,7 @@ import ( "github.com/holiman/uint256" jsoniter "github.com/json-iterator/go" - libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/erigon/core/vm/evmtypes" @@ -33,7 +33,7 @@ func (api *PrivateDebugAPIImpl) TraceBlockByNumber(ctx context.Context, blockNum } // TraceBlockByHash implements debug_traceBlockByHash. Returns Geth style block traces. -func (api *PrivateDebugAPIImpl) TraceBlockByHash(ctx context.Context, hash libcommon.Hash, config *tracers.TraceConfig, stream *jsoniter.Stream) error { +func (api *PrivateDebugAPIImpl) TraceBlockByHash(ctx context.Context, hash common.Hash, config *tracers.TraceConfig, stream *jsoniter.Stream) error { return api.traceBlock(ctx, rpc.BlockNumberOrHashWithHash(hash, true), config, stream) } @@ -48,7 +48,7 @@ func (api *PrivateDebugAPIImpl) traceBlock(ctx context.Context, blockNrOrHash rp block *types.Block number rpc.BlockNumber numberOk bool - hash libcommon.Hash + hash common.Hash hashOk bool ) if number, numberOk = blockNrOrHash.Number(); numberOk { @@ -100,7 +100,7 @@ func (api *PrivateDebugAPIImpl) traceBlock(ctx context.Context, blockNrOrHash rp msg, _ := txn.AsMessage(*signer, block.BaseFee(), rules) if msg.FeeCap().IsZero() && engine != nil { - syscall := func(contract libcommon.Address, data []byte) ([]byte, error) { + syscall := func(contract common.Address, data []byte) ([]byte, error) { return core.SysCallContract(contract, data, *chainConfig, ibs, block.Header(), engine, true /* constCall */) } msg.SetIsFree(engine.IsServiceTransaction(msg.From(), syscall)) @@ -139,7 +139,7 @@ func (api *PrivateDebugAPIImpl) traceBlock(ctx context.Context, blockNrOrHash rp } // TraceTransaction implements debug_traceTransaction. Returns Geth style transaction traces. -func (api *PrivateDebugAPIImpl) TraceTransaction(ctx context.Context, hash libcommon.Hash, config *tracers.TraceConfig, stream *jsoniter.Stream) error { +func (api *PrivateDebugAPIImpl) TraceTransaction(ctx context.Context, hash common.Hash, config *tracers.TraceConfig, stream *jsoniter.Stream) error { tx, err := api.db.BeginRo(ctx) if err != nil { stream.WriteNil() @@ -276,16 +276,16 @@ func (api *PrivateDebugAPIImpl) TraceCall(ctx context.Context, args ethapi.CallA func (api *PrivateDebugAPIImpl) TraceCallMany(ctx context.Context, bundles []Bundle, simulateContext StateContext, config *tracers.TraceConfig, stream *jsoniter.Stream) error { var ( - hash libcommon.Hash + hash common.Hash replayTransactions types.Transactions evm *vm.EVM blockCtx evmtypes.BlockContext txCtx evmtypes.TxContext - overrideBlockHash map[uint64]libcommon.Hash + overrideBlockHash map[uint64]common.Hash baseFee uint256.Int ) - overrideBlockHash = make(map[uint64]libcommon.Hash) + overrideBlockHash = make(map[uint64]common.Hash) tx, err := api.db.BeginRo(ctx) if err != nil { stream.WriteNil() @@ -356,7 +356,7 @@ func (api *PrivateDebugAPIImpl) TraceCallMany(ctx context.Context, bundles []Bun return fmt.Errorf("block %d(%x) not found", blockNum, hash) } - getHash := func(i uint64) libcommon.Hash { + getHash := func(i uint64) common.Hash { if hash, ok := overrideBlockHash[i]; ok { return hash } @@ -435,7 +435,7 @@ func (api *PrivateDebugAPIImpl) TraceCallMany(ctx context.Context, bundles []Bun } txCtx = core.NewEVMTxContext(msg) ibs := evm.IntraBlockState().(*state.IntraBlockState) - ibs.Prepare(libcommon.Hash{}, parent.Hash(), txn_index) + ibs.Prepare(common.Hash{}, parent.Hash(), txn_index) err = transactions.TraceTx(ctx, msg, blockCtx, txCtx, evm.IntraBlockState(), config, chainConfig, stream, api.evmCallTimeout) if err != nil { diff --git a/common/big.go b/common/big.go deleted file mode 100644 index 49cc2acf9..000000000 --- a/common/big.go +++ /dev/null @@ -1,13 +0,0 @@ -package common - -import "math/big" - -var ( - Big0 = big.NewInt(0) - Big1 = big.NewInt(1) - Big2 = big.NewInt(2) - Big3 = big.NewInt(3) - Big32 = big.NewInt(32) - Big256 = big.NewInt(256) - Big257 = big.NewInt(257) -) diff --git a/common/math/modexp.go b/common/math/modexp.go index 3d49f4f5b..b2a4f1bf0 100644 --- a/common/math/modexp.go +++ b/common/math/modexp.go @@ -8,7 +8,7 @@ import ( "math/big" "math/bits" - "github.com/ledgerwatch/erigon/common" + "github.com/ledgerwatch/erigon-lib/common" ) // FastExp is semantically equivalent to x.Exp(x,y, m), but is faster for even diff --git a/consensus/aura/auraabi/gen_block_reward.go b/consensus/aura/auraabi/gen_block_reward.go index 2af342be2..3fda2b5bf 100644 --- a/consensus/aura/auraabi/gen_block_reward.go +++ b/consensus/aura/auraabi/gen_block_reward.go @@ -12,7 +12,6 @@ import ( ethereum "github.com/ledgerwatch/erigon" "github.com/ledgerwatch/erigon/accounts/abi" "github.com/ledgerwatch/erigon/accounts/abi/bind" - "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/event" ) @@ -23,7 +22,7 @@ var ( _ = strings.NewReader _ = ethereum.NotFound _ = bind.Bind - _ = common.Big1 + _ = libcommon.Big1 _ = types.BloomLookup _ = event.NewSubscription ) diff --git a/consensus/aura/auraabi/gen_validator_set.go b/consensus/aura/auraabi/gen_validator_set.go index 5d418dd2d..74b9b0779 100644 --- a/consensus/aura/auraabi/gen_validator_set.go +++ b/consensus/aura/auraabi/gen_validator_set.go @@ -12,7 +12,6 @@ import ( ethereum "github.com/ledgerwatch/erigon" "github.com/ledgerwatch/erigon/accounts/abi" "github.com/ledgerwatch/erigon/accounts/abi/bind" - "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/event" ) @@ -23,7 +22,7 @@ var ( _ = strings.NewReader _ = ethereum.NotFound _ = bind.Bind - _ = common.Big1 + _ = libcommon.Big1 _ = types.BloomLookup _ = event.NewSubscription ) diff --git a/consensus/misc/eip1559.go b/consensus/misc/eip1559.go index 78989671a..bf9490961 100644 --- a/consensus/misc/eip1559.go +++ b/consensus/misc/eip1559.go @@ -21,8 +21,8 @@ import ( "math/big" "github.com/ledgerwatch/erigon-lib/chain" + "github.com/ledgerwatch/erigon-lib/common" - "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/params" diff --git a/consensus/misc/eip1559_test.go b/consensus/misc/eip1559_test.go index f9c646139..bb2908a6b 100644 --- a/consensus/misc/eip1559_test.go +++ b/consensus/misc/eip1559_test.go @@ -21,8 +21,8 @@ import ( "testing" "github.com/ledgerwatch/erigon-lib/chain" + "github.com/ledgerwatch/erigon-lib/common" - "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/params" ) diff --git a/consensus/serenity/serenity.go b/consensus/serenity/serenity.go index 03395e147..da5fa663f 100644 --- a/consensus/serenity/serenity.go +++ b/consensus/serenity/serenity.go @@ -10,7 +10,6 @@ import ( "github.com/ledgerwatch/erigon-lib/chain" libcommon "github.com/ledgerwatch/erigon-lib/common" - "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/consensus/aura" "github.com/ledgerwatch/erigon/consensus/misc" @@ -22,7 +21,7 @@ import ( // Constants for Serenity as specified into https://eips.ethereum.org/EIPS/eip-2982 var ( - SerenityDifficulty = common.Big0 // Serenity block's difficulty is always 0. + SerenityDifficulty = libcommon.Big0 // Serenity block's difficulty is always 0. SerenityNonce = types.BlockNonce{} // Serenity chain's nonces are 0. RewardSerenity = big.NewInt(300000000000000000) ) @@ -202,7 +201,7 @@ func (s *Serenity) verifyHeader(chain consensus.ChainHeaderReader, header, paren } // Verify that the block number is parent's +1 - if diff := new(big.Int).Sub(header.Number, parent.Number); diff.Cmp(common.Big1) != 0 { + if diff := new(big.Int).Sub(header.Number, parent.Number); diff.Cmp(libcommon.Big1) != 0 { return consensus.ErrInvalidNumber } diff --git a/core/chain_makers.go b/core/chain_makers.go index 49ed2ef1f..2899758f6 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -455,8 +455,8 @@ func MakeEmptyHeader(parent *types.Header, chainConfig *chain.Config, timestamp header := &types.Header{ Root: parent.Root, ParentHash: parent.Hash(), - Number: new(big.Int).Add(parent.Number, common.Big1), - Difficulty: common.Big0, + Number: new(big.Int).Add(parent.Number, libcommon.Big1), + Difficulty: libcommon.Big0, Time: timestamp, } diff --git a/core/genesis.go b/core/genesis.go index 85d51b28b..80673e5ef 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -548,7 +548,7 @@ func (g *Genesis) Write(tx kv.RwTx) (*types.Block, *state.IntraBlockState, error if err := rawdb.WriteTotalIssued(tx, 0, genesisIssuance); err != nil { return nil, nil, err } - return block, statedb, rawdb.WriteTotalBurnt(tx, 0, common.Big0) + return block, statedb, rawdb.WriteTotalBurnt(tx, 0, libcommon.Big0) } // MustCommit writes the genesis block and state to db, panicking on error. diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index c001fd326..b8842bcf5 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -1571,7 +1571,7 @@ func Transitioned(db kv.Getter, blockNum uint64, terminalTotalDifficulty *big.In return false, nil } - if terminalTotalDifficulty.Cmp(common.Big0) == 0 { + if terminalTotalDifficulty.Cmp(libcommon.Big0) == 0 { return true, nil } header := ReadHeaderByNumber(db, blockNum) @@ -1579,7 +1579,7 @@ func Transitioned(db kv.Getter, blockNum uint64, terminalTotalDifficulty *big.In return false, nil } - if header.Difficulty.Cmp(common.Big0) == 0 { + if header.Difficulty.Cmp(libcommon.Big0) == 0 { return true, nil } @@ -1601,7 +1601,7 @@ func IsPosBlock(db kv.Getter, blockHash libcommon.Hash) (trans bool, err error) return false, nil } - return header.Difficulty.Cmp(common.Big0) == 0, nil + return header.Difficulty.Cmp(libcommon.Big0) == 0, nil } var SnapshotsKey = []byte("snapshots") diff --git a/core/state/contracts/gen_changer.go b/core/state/contracts/gen_changer.go index 1b7980d7d..ffe8ef43d 100644 --- a/core/state/contracts/gen_changer.go +++ b/core/state/contracts/gen_changer.go @@ -23,7 +23,7 @@ var ( _ = strings.NewReader _ = ethereum.NotFound _ = bind.Bind - _ = common.Big1 + _ = libcommon.Big1 _ = types.BloomLookup _ = event.NewSubscription ) diff --git a/core/state/contracts/gen_phoenix.go b/core/state/contracts/gen_phoenix.go index ef2d61192..e26dfa963 100644 --- a/core/state/contracts/gen_phoenix.go +++ b/core/state/contracts/gen_phoenix.go @@ -23,7 +23,7 @@ var ( _ = strings.NewReader _ = ethereum.NotFound _ = bind.Bind - _ = common.Big1 + _ = libcommon.Big1 _ = types.BloomLookup _ = event.NewSubscription ) diff --git a/core/state/contracts/gen_poly.go b/core/state/contracts/gen_poly.go index d0e86b4b4..8da9b79bf 100644 --- a/core/state/contracts/gen_poly.go +++ b/core/state/contracts/gen_poly.go @@ -23,7 +23,7 @@ var ( _ = strings.NewReader _ = ethereum.NotFound _ = bind.Bind - _ = common.Big1 + _ = libcommon.Big1 _ = types.BloomLookup _ = event.NewSubscription ) diff --git a/core/state/contracts/gen_revive.go b/core/state/contracts/gen_revive.go index 71b6cc9b7..f769b9272 100644 --- a/core/state/contracts/gen_revive.go +++ b/core/state/contracts/gen_revive.go @@ -23,7 +23,7 @@ var ( _ = strings.NewReader _ = ethereum.NotFound _ = bind.Bind - _ = common.Big1 + _ = libcommon.Big1 _ = types.BloomLookup _ = event.NewSubscription ) diff --git a/core/state/contracts/gen_revive2.go b/core/state/contracts/gen_revive2.go index a63e81620..d7dbfe850 100644 --- a/core/state/contracts/gen_revive2.go +++ b/core/state/contracts/gen_revive2.go @@ -23,7 +23,7 @@ var ( _ = strings.NewReader _ = ethereum.NotFound _ = bind.Bind - _ = common.Big1 + _ = libcommon.Big1 _ = types.BloomLookup _ = event.NewSubscription ) diff --git a/core/state/contracts/gen_selfdestruct.go b/core/state/contracts/gen_selfdestruct.go index 9c974ae39..1049bda85 100644 --- a/core/state/contracts/gen_selfdestruct.go +++ b/core/state/contracts/gen_selfdestruct.go @@ -23,7 +23,7 @@ var ( _ = strings.NewReader _ = ethereum.NotFound _ = bind.Bind - _ = common.Big1 + _ = libcommon.Big1 _ = types.BloomLookup _ = event.NewSubscription ) diff --git a/core/types/block.go b/core/types/block.go index 26e73b094..ae41c8378 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -577,7 +577,7 @@ func (h *Header) EncodeSSZ(dst []byte) (buf []byte, err error) { // NOTE: it is skipping extra data func (h *Header) DecodeHeaderMetadataForSSZ(buf []byte) (pos int) { h.UncleHash = EmptyUncleHash - h.Difficulty = common.Big0 + h.Difficulty = libcommon.Big0 copy(h.ParentHash[:], buf) pos = len(h.ParentHash) diff --git a/core/types/block_test.go b/core/types/block_test.go index 7b9a99a7f..a189fb63e 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -394,7 +394,7 @@ func TestWithdrawalsEncoding(t *testing.T) { ParentHash: libcommon.HexToHash("0x8b00fcf1e541d371a3a1b79cc999a85cc3db5ee5637b5159646e1acd3613fd15"), Coinbase: libcommon.HexToAddress("0x571846e42308df2dad8ed792f44a8bfddf0acb4d"), Root: libcommon.HexToHash("0x351780124dae86b84998c6d4fe9a88acfb41b4856b4f2c56767b51a4e2f94dd4"), - Difficulty: common.Big0, + Difficulty: libcommon.Big0, Number: big.NewInt(20_000_000), GasLimit: 30_000_000, GasUsed: 3_074_345, diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index c1f3ea47e..25ef06828 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -439,7 +439,7 @@ func TestTransactionCoding(t *testing.T) { t.Fatalf("could not generate key: %v", err) } var ( - signer = LatestSignerForChainID(common.Big1) + signer = LatestSignerForChainID(libcommon.Big1) addr = libcommon.HexToAddress("0x0000000000000000000000000000000000000001") recipient = libcommon.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87") accesses = types2.AccessList{{Address: addr, StorageKeys: []libcommon.Hash{{0}}}} diff --git a/core/vm/contracts.go b/core/vm/contracts.go index 63c3cc056..c3a4beb23 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -456,7 +456,7 @@ func (c *bigModExp) Run(input []byte) ([]byte, error) { case mod.BitLen() == 0: // Modulo 0 is undefined, return zero return common.LeftPadBytes([]byte{}, int(modLen)), nil - case base.Cmp(common.Big1) == 0: + case base.Cmp(libcommon.Big1) == 0: //If base == 1, then we can just return base % mod (if mod >= 1, which it is) v = base.Mod(base, mod).Bytes() //case mod.Bit(0) == 0: diff --git a/eth/backend.go b/eth/backend.go index aeea926c1..33d950d83 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -75,7 +75,6 @@ import ( "github.com/ledgerwatch/erigon/cmd/sentinel/sentinel/handshake" "github.com/ledgerwatch/erigon/cmd/sentinel/sentinel/service" "github.com/ledgerwatch/erigon/cmd/sentry/sentry" - "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/consensus/bor" @@ -191,7 +190,7 @@ func splitAddrIntoHostAndPort(addr string) (host string, port int, err error) { // New creates a new Ethereum object (including the // initialisation of the common Ethereum object) func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethereum, error) { - if config.Miner.GasPrice == nil || config.Miner.GasPrice.Cmp(common.Big0) <= 0 { + if config.Miner.GasPrice == nil || config.Miner.GasPrice.Cmp(libcommon.Big0) <= 0 { log.Warn("Sanitizing invalid miner gas price", "provided", config.Miner.GasPrice, "updated", ethconfig.Defaults.Miner.GasPrice) config.Miner.GasPrice = new(big.Int).Set(ethconfig.Defaults.Miner.GasPrice) } diff --git a/eth/gasprice/feehistory.go b/eth/gasprice/feehistory.go index 1013485d3..246f00a04 100644 --- a/eth/gasprice/feehistory.go +++ b/eth/gasprice/feehistory.go @@ -26,7 +26,6 @@ import ( "github.com/holiman/uint256" libcommon "github.com/ledgerwatch/erigon-lib/common" - "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus/misc" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/rpc" @@ -203,7 +202,7 @@ func (oracle *Oracle) resolveBlockRange(ctx context.Context, lastBlock rpc.Block // value can be derived from the newest block. func (oracle *Oracle) FeeHistory(ctx context.Context, blocks int, unresolvedLastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error) { if blocks < 1 { - return common.Big0, nil, nil, nil, nil // returning with no data and no error means there are no retrievable blocks + return libcommon.Big0, nil, nil, nil, nil // returning with no data and no error means there are no retrievable blocks } if blocks > maxFeeHistory { log.Warn("Sanitizing fee history length", "requested", blocks, "truncated", maxFeeHistory) @@ -211,10 +210,10 @@ func (oracle *Oracle) FeeHistory(ctx context.Context, blocks int, unresolvedLast } for i, p := range rewardPercentiles { if p < 0 || p > 100 { - return common.Big0, nil, nil, nil, fmt.Errorf("%w: %f", ErrInvalidPercentile, p) + return libcommon.Big0, nil, nil, nil, fmt.Errorf("%w: %f", ErrInvalidPercentile, p) } if i > 0 && p < rewardPercentiles[i-1] { - return common.Big0, nil, nil, nil, fmt.Errorf("%w: #%d:%f > #%d:%f", ErrInvalidPercentile, i-1, rewardPercentiles[i-1], i, p) + return libcommon.Big0, nil, nil, nil, fmt.Errorf("%w: #%d:%f > #%d:%f", ErrInvalidPercentile, i-1, rewardPercentiles[i-1], i, p) } } // Only process blocks if reward percentiles were requested @@ -229,7 +228,7 @@ func (oracle *Oracle) FeeHistory(ctx context.Context, blocks int, unresolvedLast ) pendingBlock, pendingReceipts, lastBlock, blocks, err := oracle.resolveBlockRange(ctx, unresolvedLastBlock, blocks, maxHistory) if err != nil || blocks == 0 { - return common.Big0, nil, nil, nil, err + return libcommon.Big0, nil, nil, nil, err } oldestBlock := lastBlock + 1 - uint64(blocks) @@ -244,7 +243,7 @@ func (oracle *Oracle) FeeHistory(ctx context.Context, blocks int, unresolvedLast ) for ; blocks > 0; blocks-- { if err = libcommon.Stopped(ctx.Done()); err != nil { - return common.Big0, nil, nil, nil, err + return libcommon.Big0, nil, nil, nil, err } // Retrieve the next block number to fetch with this goroutine blockNumber := atomic.AddUint64(&next, 1) - 1 @@ -273,7 +272,7 @@ func (oracle *Oracle) FeeHistory(ctx context.Context, blocks int, unresolvedLast } if fees.err != nil { - return common.Big0, nil, nil, nil, fees.err + return libcommon.Big0, nil, nil, nil, fees.err } i := int(fees.blockNumber - oldestBlock) if fees.header != nil { @@ -286,7 +285,7 @@ func (oracle *Oracle) FeeHistory(ctx context.Context, blocks int, unresolvedLast } } if firstMissing == 0 { - return common.Big0, nil, nil, nil, nil + return libcommon.Big0, nil, nil, nil, nil } if len(rewardPercentiles) != 0 { reward = reward[:firstMissing] diff --git a/eth/stagedsync/stage_headers.go b/eth/stagedsync/stage_headers.go index b842d6f25..992b5de13 100644 --- a/eth/stagedsync/stage_headers.go +++ b/eth/stagedsync/stage_headers.go @@ -647,7 +647,7 @@ func saveDownloadedPoSHeaders(tx kv.RwTx, cfg HeadersCfg, headerInserter *header return headerInserter.FeedHeaderPoS(tx, &h, h.Hash()) } - foundPow = h.Difficulty.Cmp(common.Big0) != 0 + foundPow = h.Difficulty.Cmp(libcommon.Big0) != 0 if foundPow { return headerInserter.FeedHeaderPoS(tx, &h, h.Hash()) } diff --git a/ethdb/privateapi/engine_test.go b/ethdb/privateapi/engine_test.go index c5f25a0bf..12762a078 100644 --- a/ethdb/privateapi/engine_test.go +++ b/ethdb/privateapi/engine_test.go @@ -13,7 +13,6 @@ import ( "github.com/ledgerwatch/erigon-lib/kv/memdb" "github.com/stretchr/testify/require" - "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/turbo/engineapi" "github.com/ledgerwatch/erigon/turbo/shards" @@ -96,7 +95,7 @@ func TestMockDownloadRequest(t *testing.T) { hd := headerdownload.NewHeaderDownload(0, 0, nil, nil) hd.SetPOSSync(true) events := shards.NewEvents() - backend := NewEthBackendServer(ctx, nil, db, events, nil, &chain.Config{TerminalTotalDifficulty: common.Big1}, nil, hd, false) + backend := NewEthBackendServer(ctx, nil, db, events, nil, &chain.Config{TerminalTotalDifficulty: libcommon.Big1}, nil, hd, false) var err error var reply *remote.EnginePayloadStatus @@ -155,7 +154,7 @@ func TestMockValidExecution(t *testing.T) { hd.SetPOSSync(true) events := shards.NewEvents() - backend := NewEthBackendServer(ctx, nil, db, events, nil, &chain.Config{TerminalTotalDifficulty: common.Big1}, nil, hd, false) + backend := NewEthBackendServer(ctx, nil, db, events, nil, &chain.Config{TerminalTotalDifficulty: libcommon.Big1}, nil, hd, false) var err error var reply *remote.EnginePayloadStatus @@ -191,7 +190,7 @@ func TestMockInvalidExecution(t *testing.T) { hd.SetPOSSync(true) events := shards.NewEvents() - backend := NewEthBackendServer(ctx, nil, db, events, nil, &chain.Config{TerminalTotalDifficulty: common.Big1}, nil, hd, false) + backend := NewEthBackendServer(ctx, nil, db, events, nil, &chain.Config{TerminalTotalDifficulty: libcommon.Big1}, nil, hd, false) var err error var reply *remote.EnginePayloadStatus diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go index 15bf0219c..ef96ed6cb 100644 --- a/ethstats/ethstats.go +++ b/ethstats/ethstats.go @@ -37,7 +37,6 @@ import ( "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/erigon/cmd/sentry/sentry" - "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" @@ -537,7 +536,7 @@ func (s *Service) reportBlock(conn *connWrapper) error { // and assembles the block stats. If block is nil, the current head is processed. func (s *Service) assembleBlockStats(block *types.Block, td *big.Int) *blockStats { if td == nil { - td = common.Big0 + td = libcommon.Big0 } // Gather the block infos from the local blockchain txs := make([]txStats, 0, len(block.Transactions())) diff --git a/go.mod b/go.mod index 5611f135c..c6c7ae39c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/ledgerwatch/erigon go 1.18 require ( - github.com/ledgerwatch/erigon-lib v0.0.0-20230126112554-7c1f7af5cac5 + github.com/ledgerwatch/erigon-lib v0.0.0-20230127042956-cea02d548b14 github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230120022649-cd9409a200da github.com/ledgerwatch/log/v3 v3.7.0 github.com/ledgerwatch/secp256k1 v1.0.0 diff --git a/go.sum b/go.sum index 500ac8449..f981f4aac 100644 --- a/go.sum +++ b/go.sum @@ -555,8 +555,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-20230126112554-7c1f7af5cac5 h1:gjHEHoudBZiI3XnN6dUqA1qinJs/nrXUCHqHtEYJ39o= -github.com/ledgerwatch/erigon-lib v0.0.0-20230126112554-7c1f7af5cac5/go.mod h1:NDe2LVxaewSK8PNTC9GshWNz03No8whA/W69cVTWCKM= +github.com/ledgerwatch/erigon-lib v0.0.0-20230127042956-cea02d548b14 h1:+evJgKTZXDIKV2sYIzqwQhXFC4CWd5a9xZxcbqRJoWk= +github.com/ledgerwatch/erigon-lib v0.0.0-20230127042956-cea02d548b14/go.mod h1:NDe2LVxaewSK8PNTC9GshWNz03No8whA/W69cVTWCKM= github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230120022649-cd9409a200da h1:lQQBOHzAUThkymfXJj/m07vAjyMx9XoMMy3OomaeOrA= github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230120022649-cd9409a200da/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo= github.com/ledgerwatch/log/v3 v3.7.0 h1:aFPEZdwZx4jzA3+/Pf8wNDN5tCI0cIolq/kfvgcM+og= diff --git a/tests/contracts/gen_selfDestructor.go b/tests/contracts/gen_selfDestructor.go index 5e2d76e7e..77149f59f 100644 --- a/tests/contracts/gen_selfDestructor.go +++ b/tests/contracts/gen_selfDestructor.go @@ -23,7 +23,7 @@ var ( _ = strings.NewReader _ = ethereum.NotFound _ = bind.Bind - _ = common.Big1 + _ = libcommon.Big1 _ = types.BloomLookup _ = event.NewSubscription ) diff --git a/tests/contracts/gen_testcontract.go b/tests/contracts/gen_testcontract.go index ec9e489d2..ac88800a0 100644 --- a/tests/contracts/gen_testcontract.go +++ b/tests/contracts/gen_testcontract.go @@ -23,7 +23,7 @@ var ( _ = strings.NewReader _ = ethereum.NotFound _ = bind.Bind - _ = common.Big1 + _ = libcommon.Big1 _ = types.BloomLookup _ = event.NewSubscription ) diff --git a/turbo/stages/mock_sentry.go b/turbo/stages/mock_sentry.go index efe2f84f4..35a9fb364 100644 --- a/turbo/stages/mock_sentry.go +++ b/turbo/stages/mock_sentry.go @@ -38,7 +38,6 @@ import ( "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/cmd/sentry/sentry" - "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/consensus/ethash" "github.com/ledgerwatch/erigon/core" @@ -520,7 +519,7 @@ func MockWithZeroTTD(t *testing.T, withPosDownloader bool) *MockSentry { key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") address := crypto.PubkeyToAddress(key.PublicKey) chainConfig := params.AllProtocolChanges - chainConfig.TerminalTotalDifficulty = common.Big0 + chainConfig.TerminalTotalDifficulty = libcommon.Big0 gspec := &core.Genesis{ Config: chainConfig, Alloc: core.GenesisAlloc{ diff --git a/turbo/stages/sentry_mock_test.go b/turbo/stages/sentry_mock_test.go index b6e0563dd..6cdc8d44c 100644 --- a/turbo/stages/sentry_mock_test.go +++ b/turbo/stages/sentry_mock_test.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/u256" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" @@ -629,7 +628,7 @@ func TestPoSSyncWithInvalidHeader(t *testing.T) { lastValidHeader := chain.Headers[0] invalidParent := types.CopyHeader(chain.Headers[1]) - invalidParent.Difficulty = common.Big1 + invalidParent.Difficulty = libcommon.Big1 invalidTip := chain.TopBlock.Header() invalidTip.ParentHash = invalidParent.Hash() diff --git a/turbo/trie/trie_test.go b/turbo/trie/trie_test.go index c3d7b568d..e6e884968 100644 --- a/turbo/trie/trie_test.go +++ b/turbo/trie/trie_test.go @@ -229,7 +229,7 @@ func BenchmarkHash(b *testing.B) { for i := 0; i < len(accounts); i++ { var ( nonce = uint64(random.Int63()) - balance = new(big.Int).Rand(random, new(big.Int).Exp(common.Big2, common.Big256, nil)) + balance = new(big.Int).Rand(random, new(big.Int).Exp(libcommon.Big2, libcommon.Big256, nil)) root = EmptyRoot code = crypto.Keccak256(nil) ) @@ -312,7 +312,7 @@ func TestCodeNodeValid(t *testing.T) { for i := 0; i < len(addresses); i++ { codeValues[i] = genRandomByteArrayOfLen(128) codeHash := libcommon.BytesToHash(crypto.Keccak256(codeValues[i])) - balance := new(big.Int).Rand(random, new(big.Int).Exp(common.Big2, common.Big256, nil)) + balance := new(big.Int).Rand(random, new(big.Int).Exp(libcommon.Big2, libcommon.Big256, nil)) acc := accounts.NewAccount() acc.Nonce = uint64(random.Int63()) acc.Balance.SetFromBig(balance) @@ -340,7 +340,7 @@ func TestCodeNodeUpdateNotExisting(t *testing.T) { codeValue := genRandomByteArrayOfLen(128) codeHash := libcommon.BytesToHash(crypto.Keccak256(codeValue)) - balance := new(big.Int).Rand(random, new(big.Int).Exp(common.Big2, common.Big256, nil)) + balance := new(big.Int).Rand(random, new(big.Int).Exp(libcommon.Big2, libcommon.Big256, nil)) acc := accounts.NewAccount() acc.Nonce = uint64(random.Int63()) @@ -368,7 +368,7 @@ func TestCodeNodeGetNotExistingAccount(t *testing.T) { codeValue := genRandomByteArrayOfLen(128) codeHash := libcommon.BytesToHash(crypto.Keccak256(codeValue)) - balance := new(big.Int).Rand(random, new(big.Int).Exp(common.Big2, common.Big256, nil)) + balance := new(big.Int).Rand(random, new(big.Int).Exp(libcommon.Big2, libcommon.Big256, nil)) acc := accounts.NewAccount() acc.Nonce = uint64(random.Int63()) @@ -413,7 +413,7 @@ func TestCodeNodeGetExistingAccountNoCodeNotEmpty(t *testing.T) { codeValue := genRandomByteArrayOfLen(128) codeHash := libcommon.BytesToHash(crypto.Keccak256(codeValue)) - balance := new(big.Int).Rand(random, new(big.Int).Exp(common.Big2, common.Big256, nil)) + balance := new(big.Int).Rand(random, new(big.Int).Exp(libcommon.Big2, libcommon.Big256, nil)) acc := accounts.NewAccount() acc.Nonce = uint64(random.Int63()) @@ -436,7 +436,7 @@ func TestCodeNodeGetExistingAccountEmptyCode(t *testing.T) { address := getAddressForIndex(0) codeHash := EmptyCodeHash - balance := new(big.Int).Rand(random, new(big.Int).Exp(common.Big2, common.Big256, nil)) + balance := new(big.Int).Rand(random, new(big.Int).Exp(libcommon.Big2, libcommon.Big256, nil)) acc := accounts.NewAccount() acc.Nonce = uint64(random.Int63()) @@ -461,7 +461,7 @@ func TestCodeNodeWrongHash(t *testing.T) { codeValue1 := genRandomByteArrayOfLen(128) codeHash1 := libcommon.BytesToHash(crypto.Keccak256(codeValue1)) - balance := new(big.Int).Rand(random, new(big.Int).Exp(common.Big2, common.Big256, nil)) + balance := new(big.Int).Rand(random, new(big.Int).Exp(libcommon.Big2, libcommon.Big256, nil)) acc := accounts.NewAccount() acc.Nonce = uint64(random.Int63()) @@ -486,7 +486,7 @@ func TestCodeNodeUpdateAccountAndCodeValidHash(t *testing.T) { codeValue1 := genRandomByteArrayOfLen(128) codeHash1 := libcommon.BytesToHash(crypto.Keccak256(codeValue1)) - balance := new(big.Int).Rand(random, new(big.Int).Exp(common.Big2, common.Big256, nil)) + balance := new(big.Int).Rand(random, new(big.Int).Exp(libcommon.Big2, libcommon.Big256, nil)) acc := accounts.NewAccount() acc.Nonce = uint64(random.Int63()) @@ -518,7 +518,7 @@ func TestCodeNodeUpdateAccountAndCodeInvalidHash(t *testing.T) { codeValue1 := genRandomByteArrayOfLen(128) codeHash1 := libcommon.BytesToHash(crypto.Keccak256(codeValue1)) - balance := new(big.Int).Rand(random, new(big.Int).Exp(common.Big2, common.Big256, nil)) + balance := new(big.Int).Rand(random, new(big.Int).Exp(libcommon.Big2, libcommon.Big256, nil)) acc := accounts.NewAccount() acc.Nonce = uint64(random.Int63()) @@ -552,7 +552,7 @@ func TestCodeNodeUpdateAccountChangeCodeHash(t *testing.T) { codeValue1 := genRandomByteArrayOfLen(128) codeHash1 := libcommon.BytesToHash(crypto.Keccak256(codeValue1)) - balance := new(big.Int).Rand(random, new(big.Int).Exp(common.Big2, common.Big256, nil)) + balance := new(big.Int).Rand(random, new(big.Int).Exp(libcommon.Big2, libcommon.Big256, nil)) acc := accounts.NewAccount() acc.Nonce = uint64(random.Int63()) @@ -585,7 +585,7 @@ func TestCodeNodeUpdateAccountNoChangeCodeHash(t *testing.T) { codeValue1 := genRandomByteArrayOfLen(128) codeHash1 := libcommon.BytesToHash(crypto.Keccak256(codeValue1)) - balance := new(big.Int).Rand(random, new(big.Int).Exp(common.Big2, common.Big256, nil)) + balance := new(big.Int).Rand(random, new(big.Int).Exp(libcommon.Big2, libcommon.Big256, nil)) acc := accounts.NewAccount() acc.Nonce = uint64(random.Int63()) @@ -598,7 +598,7 @@ func TestCodeNodeUpdateAccountNoChangeCodeHash(t *testing.T) { assert.Nil(t, err, "should successfully insert code") acc.Nonce = uint64(random.Int63()) - balance = new(big.Int).Rand(random, new(big.Int).Exp(common.Big2, common.Big256, nil)) + balance = new(big.Int).Rand(random, new(big.Int).Exp(libcommon.Big2, libcommon.Big256, nil)) acc.Balance.SetFromBig(balance) trie.UpdateAccount(crypto.Keccak256(address[:]), &acc)