Skip to content

Commit

Permalink
Merge common/math into erigon-lib/common/math (#12522)
Browse files Browse the repository at this point in the history
Gather package `common/math` into a single place
  • Loading branch information
yperbasis authored Oct 29, 2024
1 parent b7b8509 commit 3ee7028
Show file tree
Hide file tree
Showing 64 changed files with 201 additions and 220 deletions.
2 changes: 1 addition & 1 deletion accounts/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
"testing"

libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/math"

"github.com/erigontech/erigon/common"
"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/crypto"
)

Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/erigontech/erigon-lib/chain"
libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/hexutility"
"github.com/erigontech/erigon-lib/common/math"
"github.com/erigontech/erigon-lib/kv"
"github.com/erigontech/erigon-lib/log/v3"
state2 "github.com/erigontech/erigon-lib/state"
Expand All @@ -41,7 +42,6 @@ import (
ethereum "github.com/erigontech/erigon"
"github.com/erigontech/erigon/accounts/abi"
"github.com/erigontech/erigon/accounts/abi/bind"
"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/common/u256"
"github.com/erigontech/erigon/consensus"
"github.com/erigontech/erigon/consensus/ethash"
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"reflect"

common2 "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/math"
"github.com/erigontech/erigon/common"
"github.com/erigontech/erigon/common/math"
)

// packBytesSlice packs the given bytes as [L, V] as the canonical representation
Expand Down
2 changes: 1 addition & 1 deletion cl/merkle_tree/merkle_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/length"
"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon-lib/common/math"
)

func ceil(num, divisor int) int {
Expand Down
16 changes: 8 additions & 8 deletions cl/sentinel/service/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ import (
"strings"
"time"

"github.com/erigontech/erigon/cl/gossip"
"github.com/erigontech/erigon/cl/persistence/blob_storage"
"github.com/erigontech/erigon/cl/phase1/forkchoice"
"github.com/erigontech/erigon/cl/sentinel"
"github.com/erigontech/erigon/cl/utils/eth_clock"
"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/turbo/snapshotsync/freezeblocks"

"google.golang.org/grpc"
"google.golang.org/grpc/credentials"

"github.com/erigontech/erigon-lib/common/math"
"github.com/erigontech/erigon-lib/direct"
sentinelrpc "github.com/erigontech/erigon-lib/gointerfaces/sentinelproto"
"github.com/erigontech/erigon-lib/kv"
"github.com/erigontech/erigon-lib/log/v3"

"github.com/erigontech/erigon/cl/cltypes"
"github.com/erigontech/erigon/cl/gossip"
"github.com/erigontech/erigon/cl/persistence/blob_storage"
"github.com/erigontech/erigon/cl/phase1/forkchoice"
"github.com/erigontech/erigon/cl/sentinel"
"github.com/erigontech/erigon/cl/utils/eth_clock"
"github.com/erigontech/erigon/turbo/snapshotsync/freezeblocks"
)

const AttestationSubnetSubscriptions = 2
Expand Down
5 changes: 2 additions & 3 deletions cmd/devnet/requests/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ import (
"encoding/json"
"math/big"

hexutil2 "github.com/erigontech/erigon-lib/common/hexutil"

libcommon "github.com/erigontech/erigon-lib/common"
hexutil2 "github.com/erigontech/erigon-lib/common/hexutil"
"github.com/erigontech/erigon-lib/common/math"

"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/core/types"
"github.com/erigontech/erigon/rpc"
"github.com/erigontech/erigon/turbo/jsonrpc"
Expand Down
3 changes: 2 additions & 1 deletion cmd/evm/internal/t8ntool/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ import (

"github.com/erigontech/erigon-lib/chain"
libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/math"
"github.com/erigontech/erigon-lib/kv"
state3 "github.com/erigontech/erigon-lib/state"

"github.com/erigontech/erigon/common"
"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/consensus/ethash"
"github.com/erigontech/erigon/core/state"
"github.com/erigontech/erigon/core/tracing"
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/internal/t8ntool/gen_stenv.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions cmd/evm/internal/t8ntool/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,26 @@ import (
"github.com/holiman/uint256"
"github.com/urfave/cli/v2"

"github.com/erigontech/erigon-lib/common/datadir"
"github.com/erigontech/erigon-lib/kv/rawdbv3"
"github.com/erigontech/erigon-lib/kv/temporal/temporaltest"
"github.com/erigontech/erigon-lib/log/v3"
"github.com/erigontech/erigon/eth/consensuschain"

"github.com/erigontech/erigon-lib/chain"
libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/datadir"
"github.com/erigontech/erigon-lib/common/hexutility"
"github.com/erigontech/erigon-lib/common/length"
"github.com/erigontech/erigon-lib/common/math"
"github.com/erigontech/erigon-lib/kv"
"github.com/erigontech/erigon-lib/kv/rawdbv3"
"github.com/erigontech/erigon-lib/kv/temporal/temporaltest"
"github.com/erigontech/erigon-lib/log/v3"
libstate "github.com/erigontech/erigon-lib/state"
"github.com/erigontech/erigon/common/math"

"github.com/erigontech/erigon/consensus/ethash"
"github.com/erigontech/erigon/consensus/merge"
"github.com/erigontech/erigon/core"
"github.com/erigontech/erigon/core/state"
"github.com/erigontech/erigon/core/types"
"github.com/erigontech/erigon/core/vm"
"github.com/erigontech/erigon/crypto"
"github.com/erigontech/erigon/eth/consensuschain"
trace_logger "github.com/erigontech/erigon/eth/tracers/logger"
"github.com/erigontech/erigon/rlp"
"github.com/erigontech/erigon/tests"
Expand Down
3 changes: 2 additions & 1 deletion cmd/utils/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ import (
"strings"

"github.com/c2h5oh/datasize"
"github.com/erigontech/erigon/common/math"
"github.com/urfave/cli/v2"

"github.com/erigontech/erigon-lib/common/math"
)

// DirectoryString is custom type which is registered in the flags library which cli uses for
Expand Down
111 changes: 0 additions & 111 deletions common/math/integer.go

This file was deleted.

2 changes: 1 addition & 1 deletion consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ import (

"github.com/erigontech/erigon-lib/chain"
libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/math"
"github.com/erigontech/erigon-lib/log/v3"

"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/common/u256"
"github.com/erigontech/erigon/consensus"
"github.com/erigontech/erigon/consensus/ethash/ethashcfg"
Expand Down
2 changes: 1 addition & 1 deletion consensus/ethash/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (

"github.com/erigontech/erigon-lib/chain"
libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/math"

"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/core/types"
"github.com/erigontech/erigon/params"
)
Expand Down
4 changes: 2 additions & 2 deletions consensus/ethash/ethash.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ import (
"github.com/edsrzf/mmap-go"
"github.com/hashicorp/golang-lru/v2/simplelru"

"github.com/erigontech/erigon-lib/common/math"
"github.com/erigontech/erigon-lib/log/v3"

"github.com/erigontech/erigon/common/debug"
cmath "github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/consensus"
"github.com/erigontech/erigon/consensus/ethash/ethashcfg"
"github.com/erigontech/erigon/core/vm/evmtypes"
Expand Down Expand Up @@ -143,7 +143,7 @@ func memoryMapAndGenerate(path string, size uint64, lock bool, generator func(bu
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
return nil, nil, nil, err
}
suffix, err := cmath.RandInt64()
suffix, err := math.RandInt64()
if err != nil {
return nil, nil, nil, fmt.Errorf("failed to get random integer: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion consensus/misc/eip1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (

"github.com/erigontech/erigon-lib/chain"
"github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/math"
"github.com/erigontech/erigon-lib/kv"
"github.com/erigontech/erigon/polygon/bor/borcfg"

"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/core/rawdb"
"github.com/erigontech/erigon/core/types"
"github.com/erigontech/erigon/params"
Expand Down
2 changes: 1 addition & 1 deletion core/asm/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"os"
"strings"

"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon-lib/common/math"
"github.com/erigontech/erigon/core/vm"
)

Expand Down
3 changes: 2 additions & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ import (
"github.com/erigontech/erigon-lib/chain"
libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/dbg"
"github.com/erigontech/erigon-lib/common/math"
"github.com/erigontech/erigon-lib/log/v3"
"github.com/erigontech/erigon-lib/metrics"
"github.com/erigontech/erigon/common/math"

"github.com/erigontech/erigon/common/u256"
"github.com/erigontech/erigon/consensus"
"github.com/erigontech/erigon/core/state"
Expand Down
4 changes: 2 additions & 2 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import (

libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/fixedgas"
"github.com/erigontech/erigon-lib/common/math"
"github.com/erigontech/erigon-lib/log/v3"
"github.com/erigontech/erigon-lib/txpool/txpoolcfg"
types2 "github.com/erigontech/erigon-lib/types"

cmath "github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/common/u256"
"github.com/erigontech/erigon/core/tracing"
"github.com/erigontech/erigon/core/types"
Expand Down Expand Up @@ -469,7 +469,7 @@ func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (*evmtype
effectiveTip := st.gasPrice
if rules.IsLondon {
if st.gasFeeCap.Gt(st.evm.Context.BaseFee) {
effectiveTip = cmath.Min256(st.tip, new(uint256.Int).Sub(st.gasFeeCap, st.evm.Context.BaseFee))
effectiveTip = math.Min256(st.tip, new(uint256.Int).Sub(st.gasFeeCap, st.evm.Context.BaseFee))
} else {
effectiveTip = u256.Num0
}
Expand Down
2 changes: 1 addition & 1 deletion core/types/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ import (

libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/common/hexutility"
"github.com/erigontech/erigon-lib/common/math"
"github.com/erigontech/erigon-lib/log/v3"
types2 "github.com/erigontech/erigon-lib/types"

"github.com/erigontech/erigon/common"
"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/common/u256"
"github.com/erigontech/erigon/crypto"
"github.com/erigontech/erigon/params"
Expand Down
2 changes: 1 addition & 1 deletion core/types/gen_genesis.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/types/gen_genesis_account.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3ee7028

Please sign in to comment.