diff --git a/cosmos/config/parser.go b/cosmos/config/parser.go index 126c8f724..06c9cff8f 100644 --- a/cosmos/config/parser.go +++ b/cosmos/config/parser.go @@ -26,10 +26,10 @@ import ( "github.com/spf13/cast" - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/common/hexutil" - servertypes "github.com/cosmos/cosmos-sdk/server/types" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" ) // baseTen is for the big.Int string conversation. diff --git a/cosmos/config/parser_test.go b/cosmos/config/parser_test.go index bf624b20c..fdce8a21c 100644 --- a/cosmos/config/parser_test.go +++ b/cosmos/config/parser_test.go @@ -25,8 +25,9 @@ import ( "time" "github.com/berachain/polaris/cosmos/config/mocks" - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/common/hexutil" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/cosmos/crypto/hd/algo_test.go b/cosmos/crypto/hd/algo_test.go index 000a4b77f..fd97dd7d8 100644 --- a/cosmos/crypto/hd/algo_test.go +++ b/cosmos/crypto/hd/algo_test.go @@ -25,12 +25,13 @@ import ( ethsecp256k1 "github.com/berachain/polaris/cosmos/crypto/keys/ethsecp256k1" "github.com/berachain/polaris/eth/accounts" - "github.com/berachain/polaris/eth/common" - crypto "github.com/berachain/polaris/eth/crypto" "github.com/berachain/polaris/lib/utils" "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cosmos/crypto/keyring/option_test.go b/cosmos/crypto/keyring/option_test.go index a386f9371..f851bb8d0 100644 --- a/cosmos/crypto/keyring/option_test.go +++ b/cosmos/crypto/keyring/option_test.go @@ -28,7 +28,6 @@ import ( cryptocodec "github.com/berachain/polaris/cosmos/crypto/codec" "github.com/berachain/polaris/cosmos/crypto/hd" accounts "github.com/berachain/polaris/eth/accounts" - "github.com/berachain/polaris/eth/common" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" @@ -36,6 +35,8 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/std" + "github.com/ethereum/go-ethereum/common" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cosmos/crypto/keys/ethsecp256k1/keys.go b/cosmos/crypto/keys/ethsecp256k1/keys.go index 35be79530..ba1d2a696 100644 --- a/cosmos/crypto/keys/ethsecp256k1/keys.go +++ b/cosmos/crypto/keys/ethsecp256k1/keys.go @@ -25,11 +25,11 @@ import ( "crypto/ecdsa" "crypto/subtle" - "github.com/berachain/polaris/eth/crypto" - cmcrypto "github.com/cometbft/cometbft/crypto" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + + ethcrypto "github.com/ethereum/go-ethereum/crypto" ) const ( @@ -66,7 +66,7 @@ func (privKey PrivKey) PubKey() cryptotypes.PubKey { } return &PubKey{ - Key: crypto.CompressPubkey(&ecdsaPrivKey.PublicKey), + Key: ethcrypto.CompressPubkey(&ecdsaPrivKey.PublicKey), } } @@ -84,19 +84,19 @@ func (privKey PrivKey) Type() string { // GenPrivKey generates a new random private key. It returns an error upon // failure. func GenPrivKey() (*PrivKey, error) { - priv, err := crypto.GenerateEthKey() + priv, err := ethcrypto.GenerateKey() if err != nil { return nil, err } return &PrivKey{ - Key: crypto.FromECDSA(priv), + Key: ethcrypto.FromECDSA(priv), }, nil } // ToECDSA returns the ECDSA private key as a reference to ecdsa.PrivateKey type. func (privKey PrivKey) ToECDSA() (*ecdsa.PrivateKey, error) { - return crypto.ToECDSA(privKey.Bytes()) + return ethcrypto.ToECDSA(privKey.Bytes()) } // =============================================================================================== @@ -113,12 +113,12 @@ var _ cryptotypes.PubKey = &PubKey{} // Address returns the address of the ECDSA public key. // The function will return an empty address if the public key is invalid. func (pubKey PubKey) Address() cmcrypto.Address { - key, err := crypto.DecompressPubkey(pubKey.Key) + key, err := ethcrypto.DecompressPubkey(pubKey.Key) if err != nil { return nil } - return cmcrypto.Address(crypto.PubkeyToAddress(*key).Bytes()) + return cmcrypto.Address(ethcrypto.PubkeyToAddress(*key).Bytes()) } // Bytes returns the pubkey byte format. diff --git a/cosmos/crypto/keys/ethsecp256k1/keys_test.go b/cosmos/crypto/keys/ethsecp256k1/keys_test.go index f631b7073..2b31b7ee8 100644 --- a/cosmos/crypto/keys/ethsecp256k1/keys_test.go +++ b/cosmos/crypto/keys/ethsecp256k1/keys_test.go @@ -23,10 +23,10 @@ package ethsecp256k1 import ( "testing" - ethcrypto "github.com/berachain/polaris/eth/crypto" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + ethcrypto "github.com/ethereum/go-ethereum/crypto" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cosmos/crypto/keys/ethsecp256k1/signature_cgo.go b/cosmos/crypto/keys/ethsecp256k1/signature_cgo.go index c16febbb2..d039ecef2 100644 --- a/cosmos/crypto/keys/ethsecp256k1/signature_cgo.go +++ b/cosmos/crypto/keys/ethsecp256k1/signature_cgo.go @@ -21,7 +21,7 @@ package ethsecp256k1 import ( - "github.com/berachain/polaris/eth/crypto" + ethcrypto "github.com/ethereum/go-ethereum/crypto" ) // Sign signs the provided message using the ECDSA private key. It returns an error if the @@ -30,8 +30,8 @@ import ( // where the last byte contains the recovery ID. func (privKey PrivKey) Sign(digestBz []byte) ([]byte, error) { // We hash the provided input since EthSign expects a 32byte hash. - if len(digestBz) != crypto.DigestLength { - digestBz = crypto.Keccak256(digestBz) + if len(digestBz) != ethcrypto.DigestLength { + digestBz = ethcrypto.Keccak256(digestBz) } key, err := privKey.ToECDSA() @@ -39,7 +39,7 @@ func (privKey PrivKey) Sign(digestBz []byte) ([]byte, error) { return nil, err } - return crypto.EthSign(digestBz, key) + return ethcrypto.Sign(digestBz, key) } // VerifySignature verifies that the ECDSA public key created a given signature over @@ -49,16 +49,16 @@ func (pubKey PubKey) VerifySignature(msg, sig []byte) bool { // does not hash messages, we have to accept an unhashed message and hash it. // NOTE: this function will not work correctly if a msg of length 32 is provided, that is actually // the hash of the message that was signed. - if len(msg) != crypto.DigestLength { - msg = crypto.Keccak256(msg) + if len(msg) != ethcrypto.DigestLength { + msg = ethcrypto.Keccak256(msg) } // The signature length must be correct. - if len(sig) == crypto.SignatureLength { + if len(sig) == ethcrypto.SignatureLength { // remove recovery ID (V) if contained in the signature sig = sig[:len(sig)-1] } // The signature needs to be in [R || S] format when provided to `VerifySignature`. - return crypto.VerifySignature(pubKey.Key, msg, sig) + return ethcrypto.VerifySignature(pubKey.Key, msg, sig) } diff --git a/cosmos/crypto/keys/ethsecp256k1/signature_cgo_test.go b/cosmos/crypto/keys/ethsecp256k1/signature_cgo_test.go index dd374deb3..7678137a9 100644 --- a/cosmos/crypto/keys/ethsecp256k1/signature_cgo_test.go +++ b/cosmos/crypto/keys/ethsecp256k1/signature_cgo_test.go @@ -23,7 +23,7 @@ package ethsecp256k1 import ( "crypto/ecdsa" - "github.com/berachain/polaris/eth/crypto" + ethcrypto "github.com/ethereum/go-ethereum/crypto" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -44,9 +44,9 @@ var _ = Describe("PrivKey_PubKey", func() { It("validates signing bytes", func() { msg := []byte("hello world") // for the eth case, we have to manually hash in the test. - sigHash := crypto.Keccak256(msg) + sigHash := ethcrypto.Keccak256(msg) - expectedSig, err := crypto.EthSign(sigHash, ecdsaPrivKey) + expectedSig, err := ethcrypto.Sign(sigHash, ecdsaPrivKey) Expect(err).ToNot(HaveOccurred()) sig, err := privKey.Sign(msg) @@ -56,7 +56,7 @@ var _ = Describe("PrivKey_PubKey", func() { It("validates signature", func() { msg := []byte("hello world") - sigHash := crypto.Keccak256(msg) + sigHash := ethcrypto.Keccak256(msg) sig, err := privKey.Sign(sigHash) Expect(err).ToNot(HaveOccurred()) diff --git a/cosmos/lib/address.go b/cosmos/lib/address.go index 4853bdb1a..1cdddbc5e 100644 --- a/cosmos/lib/address.go +++ b/cosmos/lib/address.go @@ -23,7 +23,7 @@ package lib import ( "cosmossdk.io/core/address" - "github.com/berachain/polaris/eth/common" + "github.com/ethereum/go-ethereum/common" ) /* -------------------------------------------------------------------------- */ diff --git a/cosmos/lib/address_test.go b/cosmos/lib/address_test.go index 91879ad24..8d5347558 100644 --- a/cosmos/lib/address_test.go +++ b/cosmos/lib/address_test.go @@ -22,11 +22,12 @@ package lib_test import ( cosmlib "github.com/berachain/polaris/cosmos/lib" - "github.com/berachain/polaris/eth/common" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cosmos/lib/conversions.go b/cosmos/lib/conversions.go index c60163d04..91090c84f 100644 --- a/cosmos/lib/conversions.go +++ b/cosmos/lib/conversions.go @@ -31,7 +31,6 @@ import ( "github.com/berachain/polaris/contracts/bindings/cosmos/precompile/governance" "github.com/berachain/polaris/contracts/bindings/cosmos/precompile/staking" "github.com/berachain/polaris/cosmos/precompile" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/lib/utils" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -39,6 +38,8 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "github.com/ethereum/go-ethereum/common" ) /** diff --git a/cosmos/lib/evm.go b/cosmos/lib/evm.go index 66923a710..fbef8471a 100644 --- a/cosmos/lib/evm.go +++ b/cosmos/lib/evm.go @@ -25,12 +25,13 @@ import ( "github.com/berachain/polaris/cosmos/x/evm/plugins/precompile" "github.com/berachain/polaris/eth/accounts/abi" - "github.com/berachain/polaris/eth/common" ethprecompile "github.com/berachain/polaris/eth/core/precompile" - "github.com/berachain/polaris/eth/core/vm" "github.com/berachain/polaris/lib/utils" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" ) // TODO: Add these functions to the EVM object itself to allow enforcing calls into diff --git a/cosmos/precompile/bank/bank.go b/cosmos/precompile/bank/bank.go index 210b7d7f7..f4a08669f 100644 --- a/cosmos/precompile/bank/bank.go +++ b/cosmos/precompile/bank/bank.go @@ -29,12 +29,13 @@ import ( "github.com/berachain/polaris/contracts/bindings/cosmos/lib" bankgenerated "github.com/berachain/polaris/contracts/bindings/cosmos/precompile/bank" cosmlib "github.com/berachain/polaris/cosmos/lib" - "github.com/berachain/polaris/eth/common" ethprecompile "github.com/berachain/polaris/eth/core/precompile" "github.com/berachain/polaris/eth/core/vm" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + "github.com/ethereum/go-ethereum/common" ) // Contract is the precompile contract for the bank module. diff --git a/cosmos/precompile/bank/bank_test.go b/cosmos/precompile/bank/bank_test.go index f625415dc..38fa23a33 100644 --- a/cosmos/precompile/bank/bank_test.go +++ b/cosmos/precompile/bank/bank_test.go @@ -34,7 +34,6 @@ import ( testutils "github.com/berachain/polaris/cosmos/testutil" pclog "github.com/berachain/polaris/cosmos/x/evm/plugins/precompile/log" evmtypes "github.com/berachain/polaris/cosmos/x/evm/types" - "github.com/berachain/polaris/eth/common" ethprecompile "github.com/berachain/polaris/eth/core/precompile" "github.com/berachain/polaris/eth/core/vm" "github.com/berachain/polaris/lib/utils" @@ -45,6 +44,8 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/ethereum/go-ethereum/common" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cosmos/precompile/distribution/distribution.go b/cosmos/precompile/distribution/distribution.go index 145ebdae2..6ce48dbe5 100644 --- a/cosmos/precompile/distribution/distribution.go +++ b/cosmos/precompile/distribution/distribution.go @@ -29,12 +29,13 @@ import ( generated "github.com/berachain/polaris/contracts/bindings/cosmos/precompile/distribution" cosmlib "github.com/berachain/polaris/cosmos/lib" "github.com/berachain/polaris/cosmos/precompile/staking" - "github.com/berachain/polaris/eth/common" ethprecompile "github.com/berachain/polaris/eth/core/precompile" - "github.com/berachain/polaris/eth/core/vm" + pvm "github.com/berachain/polaris/eth/core/vm" sdk "github.com/cosmos/cosmos-sdk/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + + "github.com/ethereum/go-ethereum/common" ) // Contract is the precompile contract for the distribution module. @@ -80,7 +81,7 @@ func (c *Contract) SetWithdrawAddress( withdrawAddress common.Address, ) (bool, error) { delAddr, err := cosmlib.StringFromEthAddress( - c.addressCodec, vm.UnwrapPolarContext(ctx).MsgSender(), + c.addressCodec, pvm.UnwrapPolarContext(ctx).MsgSender(), ) if err != nil { return false, err diff --git a/cosmos/precompile/governance/governance.go b/cosmos/precompile/governance/governance.go index e01b39fd6..167b41730 100644 --- a/cosmos/precompile/governance/governance.go +++ b/cosmos/precompile/governance/governance.go @@ -31,7 +31,6 @@ import ( generated "github.com/berachain/polaris/contracts/bindings/cosmos/precompile/governance" cosmlib "github.com/berachain/polaris/cosmos/lib" "github.com/berachain/polaris/cosmos/x/evm/plugins/precompile/log" - "github.com/berachain/polaris/eth/common" ethprecompile "github.com/berachain/polaris/eth/core/precompile" "github.com/berachain/polaris/eth/core/vm" @@ -40,6 +39,8 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + + "github.com/ethereum/go-ethereum/common" ) const ( diff --git a/cosmos/precompile/governance/governance_test.go b/cosmos/precompile/governance/governance_test.go index 9d1667414..7f7e551a2 100644 --- a/cosmos/precompile/governance/governance_test.go +++ b/cosmos/precompile/governance/governance_test.go @@ -34,7 +34,6 @@ import ( cbindings "github.com/berachain/polaris/contracts/bindings/cosmos/lib" generated "github.com/berachain/polaris/contracts/bindings/cosmos/precompile/governance" testutils "github.com/berachain/polaris/cosmos/testutil" - "github.com/berachain/polaris/eth/common" ethprecompile "github.com/berachain/polaris/eth/core/precompile" "github.com/berachain/polaris/eth/core/vm" "github.com/berachain/polaris/lib/utils" @@ -49,6 +48,8 @@ import ( governancetypes "github.com/cosmos/cosmos-sdk/x/gov/types" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + "github.com/ethereum/go-ethereum/common" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cosmos/precompile/governance/testutil.go b/cosmos/precompile/governance/testutil.go index fe91bf759..51a387a40 100644 --- a/cosmos/precompile/governance/testutil.go +++ b/cosmos/precompile/governance/testutil.go @@ -30,7 +30,6 @@ import ( storetypes "cosmossdk.io/store/types" testutils "github.com/berachain/polaris/cosmos/testutil" - "github.com/berachain/polaris/eth/common" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/runtime" @@ -47,6 +46,8 @@ import ( v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/ethereum/go-ethereum/common" + //nolint:stylecheck,revive // Ginkgo is the testing framework. . "github.com/onsi/ginkgo/v2" ) diff --git a/cosmos/precompile/staking/staking.go b/cosmos/precompile/staking/staking.go index 9d049388a..ae922a5fb 100644 --- a/cosmos/precompile/staking/staking.go +++ b/cosmos/precompile/staking/staking.go @@ -33,14 +33,15 @@ import ( cbindings "github.com/berachain/polaris/contracts/bindings/cosmos/lib" generated "github.com/berachain/polaris/contracts/bindings/cosmos/precompile/staking" cosmlib "github.com/berachain/polaris/cosmos/lib" - "github.com/berachain/polaris/eth/common" ethprecompile "github.com/berachain/polaris/eth/core/precompile" - "github.com/berachain/polaris/eth/core/vm" + pvm "github.com/berachain/polaris/eth/core/vm" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "github.com/ethereum/go-ethereum/common" ) type ValidatorStore interface { @@ -452,7 +453,7 @@ func (c *Contract) Delegate( return false, err } caller, err := cosmlib.StringFromEthAddress( - c.accAddrCodec, vm.UnwrapPolarContext(ctx).MsgSender(), + c.accAddrCodec, pvm.UnwrapPolarContext(ctx).MsgSender(), ) if err != nil { return false, err @@ -481,7 +482,7 @@ func (c *Contract) Undelegate( return false, err } caller, err := cosmlib.StringFromEthAddress( - c.accAddrCodec, vm.UnwrapPolarContext(ctx).MsgSender(), + c.accAddrCodec, pvm.UnwrapPolarContext(ctx).MsgSender(), ) if err != nil { return false, err @@ -515,7 +516,7 @@ func (c *Contract) BeginRedelegate( return false, err } caller, err := cosmlib.StringFromEthAddress( - c.accAddrCodec, vm.UnwrapPolarContext(ctx).MsgSender(), + c.accAddrCodec, pvm.UnwrapPolarContext(ctx).MsgSender(), ) if err != nil { return false, err @@ -549,7 +550,7 @@ func (c *Contract) CancelUnbondingDelegation( return false, err } caller, err := cosmlib.StringFromEthAddress( - c.accAddrCodec, vm.UnwrapPolarContext(ctx).MsgSender(), + c.accAddrCodec, pvm.UnwrapPolarContext(ctx).MsgSender(), ) if err != nil { return false, err diff --git a/cosmos/precompile/staking/staking_test.go b/cosmos/precompile/staking/staking_test.go index 57fcbe370..fcb614739 100644 --- a/cosmos/precompile/staking/staking_test.go +++ b/cosmos/precompile/staking/staking_test.go @@ -33,7 +33,6 @@ import ( cosmlib "github.com/berachain/polaris/cosmos/lib" testutil "github.com/berachain/polaris/cosmos/testutil" "github.com/berachain/polaris/eth/accounts/abi" - "github.com/berachain/polaris/eth/common" ethprecompile "github.com/berachain/polaris/eth/core/precompile" "github.com/berachain/polaris/eth/core/vm" "github.com/berachain/polaris/eth/core/vm/mock" @@ -47,6 +46,8 @@ import ( stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/ethereum/go-ethereum/common" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cosmos/runtime/chain/abci.go b/cosmos/runtime/chain/abci.go index 7a8ba7ae1..19622c13a 100644 --- a/cosmos/runtime/chain/abci.go +++ b/cosmos/runtime/chain/abci.go @@ -26,13 +26,13 @@ import ( storetypes "cosmossdk.io/store/types" evmtypes "github.com/berachain/polaris/cosmos/x/evm/types" - "github.com/berachain/polaris/eth/core/types" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/beacon/engine" + ethtypes "github.com/ethereum/go-ethereum/core/types" ) func (wbc *WrappedBlockchain) ProcessProposal( @@ -93,7 +93,7 @@ func (wbc *WrappedBlockchain) ProcessProposal( } // Convert it to a block. - var block *types.Block + var block *ethtypes.Block if block, err = engine.ExecutableDataToBlock(*envelope.ExecutionPayload, nil, nil); err != nil { ctx.Logger().Error("failed to build evm block", "err", err) return &abci.ResponseProcessProposal{ diff --git a/cosmos/runtime/chain/chain.go b/cosmos/runtime/chain/chain.go index dafe63bd5..2edb6c3ec 100644 --- a/cosmos/runtime/chain/chain.go +++ b/cosmos/runtime/chain/chain.go @@ -24,7 +24,8 @@ import ( "context" "github.com/berachain/polaris/eth/core" - "github.com/berachain/polaris/eth/core/types" + + ethtypes "github.com/ethereum/go-ethereum/core/types" ) // WrappedBlockchain is a struct that wraps the core blockchain with additional @@ -53,7 +54,7 @@ func (wbc *WrappedBlockchain) WriteGenesisState( // InsertBlockAndSetHead inserts a block into the blockchain and sets // it as the head. It uses the provided context as the application context. func (wbc *WrappedBlockchain) InsertBlockAndSetHead( - ctx context.Context, block *types.Block, + ctx context.Context, block *ethtypes.Block, ) error { wbc.PreparePlugins(ctx) return wbc.Blockchain.InsertBlockAndSetHead(block) @@ -62,7 +63,7 @@ func (wbc *WrappedBlockchain) InsertBlockAndSetHead( // InsertBlockWithoutSetHead inserts a block into the blockchain without setting it // as the head. It uses the provided context as the application context. func (wbc *WrappedBlockchain) InsertBlockWithoutSetHead( - ctx context.Context, block *types.Block, + ctx context.Context, block *ethtypes.Block, ) error { wbc.PreparePlugins(ctx) return wbc.Blockchain.InsertBlockWithoutSetHead(block) diff --git a/cosmos/runtime/logging.go b/cosmos/runtime/logging.go index f40e6a8cc..0611c5246 100644 --- a/cosmos/runtime/logging.go +++ b/cosmos/runtime/logging.go @@ -23,7 +23,7 @@ package runtime import ( "cosmossdk.io/log" - ethlog "github.com/berachain/polaris/eth/log" + ethlog "github.com/ethereum/go-ethereum/log" ) // LoggerFuncHandler injects the cosmos-sdk logger into geth. diff --git a/cosmos/runtime/miner/miner.go b/cosmos/runtime/miner/miner.go index 9c514426e..641d44521 100644 --- a/cosmos/runtime/miner/miner.go +++ b/cosmos/runtime/miner/miner.go @@ -27,12 +27,12 @@ import ( "github.com/cosmos/gogoproto/proto" "github.com/berachain/polaris/eth" - "github.com/berachain/polaris/eth/core/types" "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/miner" ) @@ -98,7 +98,7 @@ func (m *Miner) constructPayloadArgs(ctx sdk.Context) *miner.BuildPayloadArgs { Timestamp: uint64(ctx.BlockTime().Unix()), FeeRecipient: m.Etherbase(), Random: common.Hash{}, /* todo: generated random */ - Withdrawals: make(types.Withdrawals, 0), + Withdrawals: make(ethtypes.Withdrawals, 0), BeaconRoot: &emptyHash, } } diff --git a/cosmos/runtime/runtime.go b/cosmos/runtime/runtime.go index a8cc3f730..05c19cebb 100644 --- a/cosmos/runtime/runtime.go +++ b/cosmos/runtime/runtime.go @@ -38,7 +38,6 @@ import ( "github.com/berachain/polaris/eth" "github.com/berachain/polaris/eth/consensus" "github.com/berachain/polaris/eth/core" - coretypes "github.com/berachain/polaris/eth/core/types" "github.com/berachain/polaris/eth/node" abci "github.com/cometbft/cometbft/abci/types" @@ -48,6 +47,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/mempool" "github.com/ethereum/go-ethereum/beacon/engine" + ethtypes "github.com/ethereum/go-ethereum/core/types" ) // EVMKeeper is an interface that defines the methods needed for the EVM setup. @@ -136,7 +136,7 @@ func (p *Polaris) SetupServices(clientCtx client.Context) error { clientCtx.TxConfig, evmtypes.WrapPayload)) // Initialize the txpool with a new transaction serializer. - p.WrappedTxPool.Init(p.logger, clientCtx, libtx.NewSerializer[*coretypes.Transaction]( + p.WrappedTxPool.Init(p.logger, clientCtx, libtx.NewSerializer[*ethtypes.Transaction]( clientCtx.TxConfig, evmtypes.WrapTx)) // Register services with Polaris. diff --git a/cosmos/runtime/txpool/ante.go b/cosmos/runtime/txpool/ante.go index 39ee53d89..cbc8e5bc3 100644 --- a/cosmos/runtime/txpool/ante.go +++ b/cosmos/runtime/txpool/ante.go @@ -24,13 +24,13 @@ import ( "errors" "github.com/berachain/polaris/cosmos/x/evm/types" - "github.com/berachain/polaris/eth/common" - coretypes "github.com/berachain/polaris/eth/core/types" "github.com/berachain/polaris/lib/utils" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/txpool" + ethtypes "github.com/ethereum/go-ethereum/core/types" ) // AnteHandle implements sdk.AnteHandler. @@ -53,7 +53,7 @@ func (m *Mempool) AnteHandle( } // shouldEject returns true if the transaction should be ejected from the CometBFT mempool. -func (m *Mempool) shouldEject(tx *coretypes.Transaction) bool { +func (m *Mempool) shouldEject(tx *ethtypes.Transaction) bool { if tx == nil { return false } diff --git a/cosmos/runtime/txpool/handler.go b/cosmos/runtime/txpool/handler.go index 1921e06b1..eb0f83e50 100644 --- a/cosmos/runtime/txpool/handler.go +++ b/cosmos/runtime/txpool/handler.go @@ -27,12 +27,11 @@ import ( "cosmossdk.io/log" - "github.com/berachain/polaris/eth/core" - coretypes "github.com/berachain/polaris/eth/core/types" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/ethereum/go-ethereum/core" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" ) @@ -56,8 +55,8 @@ type TxSubProvider interface { // TxSerializer provides an interface to Serialize Geth Transactions to Bytes (via sdk.Tx). type TxSerializer interface { - ToSdkTx(signedTx *coretypes.Transaction, gasLimit uint64) (sdk.Tx, error) - ToSdkTxBytes(signedTx *coretypes.Transaction, gasLimit uint64) ([]byte, error) + ToSdkTx(signedTx *ethtypes.Transaction, gasLimit uint64) (sdk.Tx, error) + ToSdkTxBytes(signedTx *ethtypes.Transaction, gasLimit uint64) ([]byte, error) } // TxBroadcaster provides an interface to broadcast TxBytes to the comet p2p layer. @@ -72,7 +71,7 @@ type Subscription interface { // failedTx represents a transaction that failed to broadcast. type failedTx struct { - tx *coretypes.Transaction + tx *ethtypes.Transaction retries int } @@ -198,7 +197,7 @@ func (h *handler) stop(err error) { } // broadcastTransactions will propagate a batch of transactions to the CometBFT mempool. -func (h *handler) broadcastTransactions(txs coretypes.Transactions) { +func (h *handler) broadcastTransactions(txs ethtypes.Transactions) { h.logger.Debug("broadcasting transactions", "num_txs", len(txs)) for _, signedEthTx := range txs { h.broadcastTransaction(signedEthTx, maxRetries) @@ -206,7 +205,7 @@ func (h *handler) broadcastTransactions(txs coretypes.Transactions) { } // broadcastTransaction will propagate a transaction to the CometBFT mempool. -func (h *handler) broadcastTransaction(tx *coretypes.Transaction, retries int) { +func (h *handler) broadcastTransaction(tx *ethtypes.Transaction, retries int) { txBytes, err := h.serializer.ToSdkTxBytes(tx, tx.Gas()) if err != nil { h.logger.Error("failed to serialize transaction", "err", err) diff --git a/cosmos/runtime/txpool/handler_test.go b/cosmos/runtime/txpool/handler_test.go index 3d7f3f0e9..fcace11a6 100644 --- a/cosmos/runtime/txpool/handler_test.go +++ b/cosmos/runtime/txpool/handler_test.go @@ -29,8 +29,9 @@ import ( "cosmossdk.io/log" "github.com/berachain/polaris/cosmos/runtime/txpool/mocks" - "github.com/berachain/polaris/eth/core" - coretypes "github.com/berachain/polaris/eth/core/types" + + "github.com/ethereum/go-ethereum/core" + ethtypes "github.com/ethereum/go-ethereum/core/types" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -86,7 +87,7 @@ var _ = Describe("", func() { broadcaster.On("BroadcastTxSync", []byte{123}).Return(nil, nil).Once() h.txsCh <- core.NewTxsEvent{ - Txs: []*coretypes.Transaction{coretypes.NewTx(&coretypes.LegacyTx{Nonce: 5, Gas: 100})}, + Txs: []*ethtypes.Transaction{ethtypes.NewTx(ðtypes.LegacyTx{Nonce: 5, Gas: 100})}, } }) @@ -95,9 +96,9 @@ var _ = Describe("", func() { serializer.On("ToSdkTxBytes", mock.Anything, mock.Anything).Return([]byte{123}, nil).Twice() broadcaster.On("BroadcastTxSync", []byte{123}).Return(nil, nil).Twice() - h.txsCh <- core.NewTxsEvent{Txs: []*coretypes.Transaction{ - coretypes.NewTx(&coretypes.LegacyTx{Nonce: 5, Gas: 10}), - coretypes.NewTx(&coretypes.LegacyTx{Nonce: 6, Gas: 10}), + h.txsCh <- core.NewTxsEvent{Txs: []*ethtypes.Transaction{ + ethtypes.NewTx(ðtypes.LegacyTx{Nonce: 5, Gas: 10}), + ethtypes.NewTx(ðtypes.LegacyTx{Nonce: 6, Gas: 10}), }} }) }) diff --git a/cosmos/runtime/txpool/mempool.go b/cosmos/runtime/txpool/mempool.go index 8dc9dd115..18e67159d 100644 --- a/cosmos/runtime/txpool/mempool.go +++ b/cosmos/runtime/txpool/mempool.go @@ -29,13 +29,13 @@ import ( "github.com/berachain/polaris/cosmos/x/evm/types" "github.com/berachain/polaris/eth" "github.com/berachain/polaris/eth/core" - coretypes "github.com/berachain/polaris/eth/core/types" "github.com/berachain/polaris/lib/utils" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/mempool" "github.com/ethereum/go-ethereum/core/txpool/legacypool" + ethtypes "github.com/ethereum/go-ethereum/core/types" ) // Mempool implements the mempool.Mempool & Lifecycle interfaces. @@ -105,7 +105,7 @@ func (m *Mempool) Insert(ctx context.Context, sdkTx sdk.Tx) error { // We have to return nil for non-ethereum transactions as to not fail check-tx. return nil } else if errs := m.txpool.Add( - []*coretypes.Transaction{wet.Unwrap()}, false, false, + []*ethtypes.Transaction{wet.Unwrap()}, false, false, ); len(errs) != 0 { // Handle case where a node broadcasts to itself, we don't want it to fail CheckTx. if errors.Is(errs[0], legacypool.ErrAlreadyKnown) && sCtx.ExecMode() == sdk.ExecModeCheck { diff --git a/cosmos/runtime/txpool/mempool_test.go b/cosmos/runtime/txpool/mempool_test.go index 7c2ea7933..e48b0475f 100644 --- a/cosmos/runtime/txpool/mempool_test.go +++ b/cosmos/runtime/txpool/mempool_test.go @@ -27,10 +27,11 @@ import ( "github.com/berachain/polaris/cosmos/runtime/txpool/mocks" evmtypes "github.com/berachain/polaris/cosmos/x/evm/types" - coretypes "github.com/berachain/polaris/eth/core/types" sdk "github.com/cosmos/cosmos-sdk/types" + ethtypes "github.com/ethereum/go-ethereum/core/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -50,7 +51,7 @@ var _ = Describe("", func() { txPool = mocks.NewGethTxPool(t) sdkTx = mocks.NewSdkTx(t) mempool = &Mempool{txpool: txPool} - wet, _ = evmtypes.WrapTx(coretypes.NewTx(&coretypes.LegacyTx{})) + wet, _ = evmtypes.WrapTx(ethtypes.NewTx(ðtypes.LegacyTx{})) }) When("we call insert", func() { diff --git a/cosmos/store/cachekv/readonly_store.go b/cosmos/store/cachekv/readonly_store.go index 3101f3edb..1d12e670b 100644 --- a/cosmos/store/cachekv/readonly_store.go +++ b/cosmos/store/cachekv/readonly_store.go @@ -23,7 +23,7 @@ package cachekv import ( storetypes "cosmossdk.io/store/types" - "github.com/berachain/polaris/eth/core/vm" + "github.com/ethereum/go-ethereum/core/vm" ) var _ storetypes.KVStore = (*ReadOnlyStore)(nil) diff --git a/cosmos/testutil/bank.go b/cosmos/testutil/bank.go index ff493a998..fb33fb88b 100644 --- a/cosmos/testutil/bank.go +++ b/cosmos/testutil/bank.go @@ -26,9 +26,9 @@ import ( sdkmath "cosmossdk.io/math" - "github.com/berachain/polaris/eth/common" - sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ethereum/go-ethereum/common" ) type BankKeeper interface { diff --git a/cosmos/testutil/setup.go b/cosmos/testutil/setup.go index 17f1942a4..0848bdec8 100644 --- a/cosmos/testutil/setup.go +++ b/cosmos/testutil/setup.go @@ -31,7 +31,6 @@ import ( storetypes "cosmossdk.io/store/types" evmtypes "github.com/berachain/polaris/cosmos/x/evm/types" - "github.com/berachain/polaris/eth/common" cometproto "github.com/cometbft/cometbft/proto/tendermint/types" @@ -56,6 +55,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "github.com/ethereum/go-ethereum/common" ) var ( diff --git a/cosmos/x/evm/genesis_test.go b/cosmos/x/evm/genesis_test.go index 65718c6bd..2a1292200 100644 --- a/cosmos/x/evm/genesis_test.go +++ b/cosmos/x/evm/genesis_test.go @@ -40,6 +40,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/consensus/beacon" + ethparams "github.com/ethereum/go-ethereum/params" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -158,7 +159,7 @@ var _ = Describe("Genesis", func() { Context("when the genesis is valid", func() { It("should export without fail", func() { ethGen.Config = nil - ethGen.BaseFee = big.NewInt(int64(params.InitialBaseFee)) + ethGen.BaseFee = big.NewInt(int64(ethparams.InitialBaseFee)) Expect(actualGenesis).To(Equal(*ethGen)) }) }) diff --git a/cosmos/x/evm/keeper/keeper.go b/cosmos/x/evm/keeper/keeper.go index b733ee801..eeccd16dc 100644 --- a/cosmos/x/evm/keeper/keeper.go +++ b/cosmos/x/evm/keeper/keeper.go @@ -31,18 +31,19 @@ import ( "github.com/berachain/polaris/cosmos/x/evm/types" "github.com/berachain/polaris/eth/core" ethprecompile "github.com/berachain/polaris/eth/core/precompile" - coretypes "github.com/berachain/polaris/eth/core/types" - "github.com/berachain/polaris/eth/params" sdk "github.com/cosmos/cosmos-sdk/types" + + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" ) type WrappedBlockchain interface { PreparePlugins(context.Context) Config() *params.ChainConfig WriteGenesisState(context.Context, *core.Genesis) error - InsertBlockAndSetHead(context.Context, *coretypes.Block) error - GetBlockByNumber(uint64) *coretypes.Block + InsertBlockAndSetHead(context.Context, *ethtypes.Block) error + GetBlockByNumber(uint64) *ethtypes.Block } type Keeper struct { diff --git a/cosmos/x/evm/keeper/processor.go b/cosmos/x/evm/keeper/processor.go index 84a9fb0e4..f2af7c814 100644 --- a/cosmos/x/evm/keeper/processor.go +++ b/cosmos/x/evm/keeper/processor.go @@ -27,11 +27,11 @@ import ( storetypes "cosmossdk.io/store/types" evmtypes "github.com/berachain/polaris/cosmos/x/evm/types" - "github.com/berachain/polaris/eth/core/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/beacon/engine" + ethtypes "github.com/ethereum/go-ethereum/core/types" ) func (k *Keeper) ProcessPayloadEnvelope( @@ -39,7 +39,7 @@ func (k *Keeper) ProcessPayloadEnvelope( ) (*evmtypes.WrappedPayloadEnvelopeResponse, error) { var ( err error - block *types.Block + block *ethtypes.Block envelope engine.ExecutionPayloadEnvelope ) // TODO: maybe we just consume the block gas limit and call it a day? diff --git a/cosmos/x/evm/plugins/block/genesis.go b/cosmos/x/evm/plugins/block/genesis.go index 8e525eb06..80d9dfe70 100644 --- a/cosmos/x/evm/plugins/block/genesis.go +++ b/cosmos/x/evm/plugins/block/genesis.go @@ -22,9 +22,10 @@ package block import ( "github.com/berachain/polaris/eth/core" - "github.com/berachain/polaris/eth/core/types" sdk "github.com/cosmos/cosmos-sdk/types" + + ethtypes "github.com/ethereum/go-ethereum/core/types" ) // InitGenesis stores the genesis block header in the KVStore under its own genesis key. @@ -48,7 +49,7 @@ func (p *plugin) ExportGenesis(ctx sdk.Context, ethGen *core.Genesis) { } // getGenesisHeader returns the block header at height 0 and does a sanity check. -func (p *plugin) getGenesisHeader() (*types.Header, error) { +func (p *plugin) getGenesisHeader() (*ethtypes.Header, error) { header, err := p.GetHeaderByNumber(0) if err != nil { return nil, err diff --git a/cosmos/x/evm/plugins/block/header.go b/cosmos/x/evm/plugins/block/header.go index 95babffc1..601810f73 100644 --- a/cosmos/x/evm/plugins/block/header.go +++ b/cosmos/x/evm/plugins/block/header.go @@ -26,10 +26,12 @@ import ( "math/big" "github.com/berachain/polaris/cosmos/x/evm/types" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core" coretypes "github.com/berachain/polaris/eth/core/types" errorslib "github.com/berachain/polaris/lib/errors" + + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" ) // prevHeaderHashes is the number of previous header hashes being stored on chain. @@ -38,7 +40,7 @@ const prevHeaderHashes = 256 // GetHeaderByNumber returns the header at the given height, using the plugin's query context. // // GetHeaderByNumber implements core.BlockPlugin. -func (p *plugin) GetHeaderByNumber(number uint64) (*coretypes.Header, error) { +func (p *plugin) GetHeaderByNumber(number uint64) (*ethtypes.Header, error) { bz, err := p.readHeaderBytes(number) if err != nil { return nil, errorslib.Wrap(err, "GetHeaderByNumber: failed to readHeaderBytes") @@ -66,7 +68,7 @@ func (p *plugin) GetHeaderByNumber(number uint64) (*coretypes.Header, error) { // GetHeaderByHash returns the header specified by the given block hash // // GetHeaderByHash implements core.BlockPlugin. -func (p *plugin) GetHeaderByHash(hash common.Hash) (*coretypes.Header, error) { +func (p *plugin) GetHeaderByHash(hash common.Hash) (*ethtypes.Header, error) { numBz := p.ctx.MultiStore().GetKVStore(p.storekey).Get(hash.Bytes()) if numBz == nil { return nil, core.ErrHeaderNotFound @@ -75,7 +77,7 @@ func (p *plugin) GetHeaderByHash(hash common.Hash) (*coretypes.Header, error) { } // StoreHeader implements core.BlockPlugin. -func (p *plugin) StoreHeader(header *coretypes.Header) error { +func (p *plugin) StoreHeader(header *ethtypes.Header) error { headerHash := header.Hash() headerBz, err := coretypes.MarshalHeader(header) if err != nil { diff --git a/cosmos/x/evm/plugins/block/header_test.go b/cosmos/x/evm/plugins/block/header_test.go index d33d62c0f..ca00fd743 100644 --- a/cosmos/x/evm/plugins/block/header_test.go +++ b/cosmos/x/evm/plugins/block/header_test.go @@ -29,13 +29,15 @@ import ( testutil "github.com/berachain/polaris/cosmos/testutil" evmtypes "github.com/berachain/polaris/cosmos/x/evm/types" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core" "github.com/berachain/polaris/eth/core/types" "github.com/berachain/polaris/lib/utils" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -54,7 +56,7 @@ var _ = Describe("Header", func() { }) It("should handle genesis header", func() { - header := &types.Header{ + header := ðtypes.Header{ Number: big.NewInt(0), } genHash := header.Hash() @@ -74,7 +76,7 @@ var _ = Describe("Header", func() { p.Prepare(ctx.WithBlockHeight(10)) // just finished processing block 10 - header := &types.Header{ + header := ðtypes.Header{ ParentHash: common.Hash{0x01}, UncleHash: common.Hash{0x02}, Coinbase: common.Address{0x03}, @@ -122,7 +124,7 @@ var _ = Describe("Header", func() { // check to see that the hashes are actually pruned // these 5 hashes will not be found because we only store last prevHeaderHashes (256) for _, deletedHash := range deletedHashes { - var deletedHeader *types.Header + var deletedHeader *ethtypes.Header deletedHeader, err = p.GetHeaderByHash(deletedHash) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(core.ErrHeaderNotFound)) @@ -146,8 +148,8 @@ func mockQueryContext(height int64, _ bool) (sdk.Context, error) { return ctx, nil } -func generateHeaderAtHeight(height int64) *types.Header { - return &types.Header{ +func generateHeaderAtHeight(height int64) *ethtypes.Header { + return ðtypes.Header{ ParentHash: common.Hash{0x01}, UncleHash: common.Hash{0x02}, Coinbase: common.Address{0x03}, diff --git a/cosmos/x/evm/plugins/historical/historical_data.go b/cosmos/x/evm/plugins/historical/historical_data.go index 16f73ad29..37dd29834 100644 --- a/cosmos/x/evm/plugins/historical/historical_data.go +++ b/cosmos/x/evm/plugins/historical/historical_data.go @@ -26,20 +26,21 @@ import ( "cosmossdk.io/store/prefix" "github.com/berachain/polaris/cosmos/x/evm/types" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core" coretypes "github.com/berachain/polaris/eth/core/types" errorslib "github.com/berachain/polaris/lib/errors" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rlp" ) // TODO: WHO WROTE THIS CODE THE FIRST TIME BLS FIX IT IS HORRIBLE. // StoreBlock implements `core.HistoricalPlugin`. -func (p *plugin) StoreBlock(block *coretypes.Block) error { +func (p *plugin) StoreBlock(block *ethtypes.Block) error { blockNum := block.NumberU64() // store block hash to block number. @@ -74,7 +75,7 @@ func (p *plugin) StoreBlock(block *coretypes.Block) error { } // StoreReceipts implements `core.HistoricalPlugin`. -func (p *plugin) StoreReceipts(blockHash common.Hash, receipts coretypes.Receipts) error { +func (p *plugin) StoreReceipts(blockHash common.Hash, receipts ethtypes.Receipts) error { // store block hash to receipts. receiptsBz, err := coretypes.MarshalReceipts(receipts) if err != nil { @@ -91,7 +92,7 @@ func (p *plugin) StoreReceipts(blockHash common.Hash, receipts coretypes.Receipt // StoreTransactions implements `core.HistoricalPlugin`. func (p *plugin) StoreTransactions( - blockNum uint64, blockHash common.Hash, txs coretypes.Transactions, + blockNum uint64, blockHash common.Hash, txs ethtypes.Transactions, ) error { // store all txns in the block. txStore := prefix.NewStore( @@ -120,11 +121,11 @@ func (p *plugin) StoreTransactions( } // GetBlockByNumber returns the block at the given height. -func (p *plugin) GetBlockByNumber(number uint64) (*coretypes.Block, error) { +func (p *plugin) GetBlockByNumber(number uint64) (*ethtypes.Block, error) { store := p.ctx.MultiStore().GetKVStore(p.storeKey) numBz := sdk.Uint64ToBigEndian(number) blockBz := prefix.NewStore(store, []byte{types.BlockNumKeyToBlockPrefix}).Get(numBz) - block := &coretypes.Block{} + block := ðtypes.Block{} err := rlp.DecodeBytes(blockBz, block) if err != nil { return nil, err @@ -133,7 +134,7 @@ func (p *plugin) GetBlockByNumber(number uint64) (*coretypes.Block, error) { } // GetBlockByHash returns the block at the given hash. -func (p *plugin) GetBlockByHash(blockHash common.Hash) (*coretypes.Block, error) { +func (p *plugin) GetBlockByHash(blockHash common.Hash) (*ethtypes.Block, error) { store := p.ctx.MultiStore().GetKVStore(p.storeKey) numBz := prefix.NewStore( store, []byte{types.BlockHashKeyToNumPrefix}).Get(blockHash.Bytes()) @@ -142,7 +143,7 @@ func (p *plugin) GetBlockByHash(blockHash common.Hash) (*coretypes.Block, error) } blockBz := prefix.NewStore(store, []byte{types.BlockNumKeyToBlockPrefix}).Get(numBz) - block := &coretypes.Block{} + block := ðtypes.Block{} err := rlp.DecodeBytes(blockBz, block) if err != nil { @@ -168,7 +169,7 @@ func (p *plugin) GetTransactionByHash(txHash common.Hash) (*coretypes.TxLookupEn } // GetReceiptsByHash returns the receipts with the given block hash. -func (p *plugin) GetReceiptsByHash(blockHash common.Hash) (coretypes.Receipts, error) { +func (p *plugin) GetReceiptsByHash(blockHash common.Hash) (ethtypes.Receipts, error) { // get receipts from off chain. receiptsBz := prefix.NewStore(p.ctx.MultiStore().GetKVStore(p.storeKey), []byte{types.BlockHashKeyToReceiptsPrefix}).Get(blockHash.Bytes()) diff --git a/cosmos/x/evm/plugins/historical/plugin.go b/cosmos/x/evm/plugins/historical/plugin.go index 38a3006f0..b43f89c3a 100644 --- a/cosmos/x/evm/plugins/historical/plugin.go +++ b/cosmos/x/evm/plugins/historical/plugin.go @@ -27,9 +27,10 @@ import ( "github.com/berachain/polaris/cosmos/x/evm/plugins" "github.com/berachain/polaris/eth/core" - "github.com/berachain/polaris/eth/params" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ethereum/go-ethereum/params" ) // Plugin is the interface that must be implemented by the plugin. diff --git a/cosmos/x/evm/plugins/historical/plugin_test.go b/cosmos/x/evm/plugins/historical/plugin_test.go index 19d4ac48e..21a4816fa 100644 --- a/cosmos/x/evm/plugins/historical/plugin_test.go +++ b/cosmos/x/evm/plugins/historical/plugin_test.go @@ -27,15 +27,15 @@ import ( "cosmossdk.io/log" testutil "github.com/berachain/polaris/cosmos/testutil" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core" "github.com/berachain/polaris/eth/core/mock" - coretypes "github.com/berachain/polaris/eth/core/types" "github.com/berachain/polaris/eth/params" "github.com/berachain/polaris/lib/utils" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/trie" . "github.com/onsi/ginkgo/v2" @@ -77,15 +77,15 @@ var _ = Describe("Historical Data", func() { When("Other blocks", func() { It("should correctly store and return blocks", func() { ctx = ctx.WithBlockHeight(1) - header := &coretypes.Header{ + header := ðtypes.Header{ Number: big.NewInt(1), GasLimit: 1000, } - tx := coretypes.NewTransaction( + tx := ethtypes.NewTransaction( 0, common.Address{0x1}, big.NewInt(1), 1000, big.NewInt(1), []byte{0x12}, ) txHash := tx.Hash() - receipts := coretypes.Receipts{ + receipts := ethtypes.Receipts{ { Type: 2, Status: 1, @@ -96,8 +96,8 @@ var _ = Describe("Historical Data", func() { BlockNumber: big.NewInt(1), }, } - txs := coretypes.Transactions{tx} - block := coretypes.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil)) + txs := ethtypes.Transactions{tx} + block := ethtypes.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil)) blockHash := block.Hash() receipts[0].BlockHash = blockHash diff --git a/cosmos/x/evm/plugins/precompile/log/attributes.go b/cosmos/x/evm/plugins/precompile/log/attributes.go index e2fa0e53e..93686f654 100644 --- a/cosmos/x/evm/plugins/precompile/log/attributes.go +++ b/cosmos/x/evm/plugins/precompile/log/attributes.go @@ -25,7 +25,6 @@ import ( cosmlib "github.com/berachain/polaris/cosmos/lib" "github.com/berachain/polaris/eth/accounts/abi" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core/precompile" abci "github.com/cometbft/cometbft/abci/types" @@ -33,6 +32,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "github.com/ethereum/go-ethereum/common" ) const ( diff --git a/cosmos/x/evm/plugins/precompile/log/factory.go b/cosmos/x/evm/plugins/precompile/log/factory.go index 0d6f96edf..8853ef131 100644 --- a/cosmos/x/evm/plugins/precompile/log/factory.go +++ b/cosmos/x/evm/plugins/precompile/log/factory.go @@ -23,12 +23,13 @@ package log import ( "github.com/berachain/polaris/cosmos/x/evm/plugins/state/events" "github.com/berachain/polaris/eth/core/precompile" - coretypes "github.com/berachain/polaris/eth/core/types" "github.com/berachain/polaris/lib/registry" libtypes "github.com/berachain/polaris/lib/types" "github.com/berachain/polaris/lib/utils" sdk "github.com/cosmos/cosmos-sdk/types" + + ethtypes "github.com/ethereum/go-ethereum/core/types" ) // Factory is a `PrecompileLogFactory` that builds Ethereum logs from Cosmos events. All Ethereum @@ -55,7 +56,7 @@ func NewFactory(precompiles []precompile.Registrable) *Factory { // Build builds an Ethereum log from a Cosmos event. // // Build implements `events.PrecompileLogFactory`. -func (f *Factory) Build(event *sdk.Event) (*coretypes.Log, error) { +func (f *Factory) Build(event *sdk.Event) (*ethtypes.Log, error) { // get the precompile log for the Cosmos event type pl := f.events.Get(event.Type) if pl == nil { @@ -70,7 +71,7 @@ func (f *Factory) Build(event *sdk.Event) (*coretypes.Log, error) { } // build the Ethereum log - log := &coretypes.Log{ + log := ðtypes.Log{ Address: pl.precompileAddr, } if log.Topics, err = f.makeTopics(pl, event); err != nil { diff --git a/cosmos/x/evm/plugins/precompile/log/factory_test.go b/cosmos/x/evm/plugins/precompile/log/factory_test.go index b3f6311c6..76d7ff095 100644 --- a/cosmos/x/evm/plugins/precompile/log/factory_test.go +++ b/cosmos/x/evm/plugins/precompile/log/factory_test.go @@ -30,14 +30,15 @@ import ( cosmlib "github.com/berachain/polaris/cosmos/lib" testutil "github.com/berachain/polaris/cosmos/testutil" "github.com/berachain/polaris/eth/accounts/abi" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core/precompile" "github.com/berachain/polaris/eth/core/precompile/mock" - "github.com/berachain/polaris/eth/crypto" sdk "github.com/cosmos/cosmos-sdk/types" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cosmos/x/evm/plugins/precompile/log/log.go b/cosmos/x/evm/plugins/precompile/log/log.go index 5fb527109..3b2841ccd 100644 --- a/cosmos/x/evm/plugins/precompile/log/log.go +++ b/cosmos/x/evm/plugins/precompile/log/log.go @@ -22,8 +22,9 @@ package log import ( "github.com/berachain/polaris/eth/accounts/abi" - "github.com/berachain/polaris/eth/common" libtypes "github.com/berachain/polaris/lib/types" + + "github.com/ethereum/go-ethereum/common" ) // Compile-time assertion. diff --git a/cosmos/x/evm/plugins/precompile/log/log_test.go b/cosmos/x/evm/plugins/precompile/log/log_test.go index 19ed3b8e2..0b61a6bc0 100644 --- a/cosmos/x/evm/plugins/precompile/log/log_test.go +++ b/cosmos/x/evm/plugins/precompile/log/log_test.go @@ -24,8 +24,9 @@ import ( "testing" "github.com/berachain/polaris/eth/accounts/abi" - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/crypto" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/cosmos/x/evm/plugins/precompile/log/translator.go b/cosmos/x/evm/plugins/precompile/log/translator.go index 5c35e7955..7d54a8d36 100644 --- a/cosmos/x/evm/plugins/precompile/log/translator.go +++ b/cosmos/x/evm/plugins/precompile/log/translator.go @@ -22,11 +22,12 @@ package log import ( "github.com/berachain/polaris/eth/accounts/abi" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core/precompile" "github.com/berachain/polaris/lib/errors" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ethereum/go-ethereum/common" ) // makeTopics generates the Ethereum log `Topics` field for a valid cosmos event. `Topics` is a diff --git a/cosmos/x/evm/plugins/precompile/plugin.go b/cosmos/x/evm/plugins/precompile/plugin.go index a95e1b464..b6921f8f1 100644 --- a/cosmos/x/evm/plugins/precompile/plugin.go +++ b/cosmos/x/evm/plugins/precompile/plugin.go @@ -27,17 +27,19 @@ import ( storetypes "cosmossdk.io/store/types" "github.com/berachain/polaris/cosmos/x/evm/plugins/state" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core" ethprecompile "github.com/berachain/polaris/eth/core/precompile" ethstate "github.com/berachain/polaris/eth/core/state" - "github.com/berachain/polaris/eth/core/vm" - "github.com/berachain/polaris/eth/params" + pvm "github.com/berachain/polaris/eth/core/vm" "github.com/berachain/polaris/lib/registry" libtypes "github.com/berachain/polaris/lib/types" "github.com/berachain/polaris/lib/utils" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/params" ) // Plugin is the interface that must be implemented by the plugin. @@ -126,11 +128,11 @@ func (p *plugin) GetActive(_ params.Rules) []common.Address { // //nolint:nonamedreturns // panic recovery. func (p *plugin) Run( - evm vm.PrecompileEVM, pc vm.PrecompileContainer, input []byte, + evm vm.PrecompileEVM, pc vm.PrecompiledContract, input []byte, caller common.Address, value *big.Int, suppliedGas uint64, readOnly bool, ) (ret []byte, gasRemaining uint64, err error) { // get native Cosmos SDK context, MultiStore, and EventManager from the Polaris StateDB - sdb := utils.MustGetAs[vm.PolarStateDB](evm.GetStateDB()) + sdb := utils.MustGetAs[pvm.PolarStateDB](evm.GetStateDB()) ctx := sdk.UnwrapSDKContext(sdb.GetContext()) ms := utils.MustGetAs[MultiStore](ctx.MultiStore()) cem := utils.MustGetAs[state.ControllableEventManager](ctx.EventManager()) @@ -182,10 +184,10 @@ func (p *plugin) Run( // // EnableReentrancy implements core.PrecompilePlugin. func (p *plugin) EnableReentrancy(evm vm.PrecompileEVM) { - p.enableReentrancy(utils.MustGetAs[vm.PolarStateDB](evm.GetStateDB())) + p.enableReentrancy(utils.MustGetAs[pvm.PolarStateDB](evm.GetStateDB())) } -func (p *plugin) enableReentrancy(sdb vm.PolarStateDB) { +func (p *plugin) enableReentrancy(sdb pvm.PolarStateDB) { sdkCtx := sdk.UnwrapSDKContext(sdb.GetContext()) // end precompile execution => stop emitting Cosmos event as Eth logs for now @@ -202,10 +204,10 @@ func (p *plugin) enableReentrancy(sdb vm.PolarStateDB) { // // DisableReentrancy implements core.PrecompilePlugin. func (p *plugin) DisableReentrancy(evm vm.PrecompileEVM) { - p.disableReentrancy(utils.MustGetAs[vm.PolarStateDB](evm.GetStateDB())) + p.disableReentrancy(utils.MustGetAs[pvm.PolarStateDB](evm.GetStateDB())) } -func (p *plugin) disableReentrancy(sdb vm.PolarStateDB) { +func (p *plugin) disableReentrancy(sdb pvm.PolarStateDB) { sdkCtx := sdk.UnwrapSDKContext(sdb.GetContext()) // resume precompile execution => begin emitting Cosmos event as Eth logs again diff --git a/cosmos/x/evm/plugins/precompile/plugin_test.go b/cosmos/x/evm/plugins/precompile/plugin_test.go index 0c444e6d9..7de6a47c9 100644 --- a/cosmos/x/evm/plugins/precompile/plugin_test.go +++ b/cosmos/x/evm/plugins/precompile/plugin_test.go @@ -34,14 +34,16 @@ import ( "github.com/berachain/polaris/cosmos/x/evm/plugins/state" "github.com/berachain/polaris/cosmos/x/evm/plugins/state/events" "github.com/berachain/polaris/cosmos/x/evm/plugins/state/events/mock" - "github.com/berachain/polaris/eth/common" ethstate "github.com/berachain/polaris/eth/core/state" - coretypes "github.com/berachain/polaris/eth/core/types" - "github.com/berachain/polaris/eth/core/vm" + pvm "github.com/berachain/polaris/eth/core/vm" "github.com/berachain/polaris/lib/utils" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -127,7 +129,7 @@ func (me *mockEVM) GetStateDB() vm.StateDB { } type mockSDB struct { - vm.PolarStateDB + pvm.PolarStateDB ctx sdk.Context logs int } @@ -142,7 +144,7 @@ func (ms *mockSDB) GetContext() context.Context { return ms.ctx } -func (ms *mockSDB) AddLog(*coretypes.Log) { +func (ms *mockSDB) AddLog(*ethtypes.Log) { ms.logs++ } diff --git a/cosmos/x/evm/plugins/precompile/recovery.go b/cosmos/x/evm/plugins/precompile/recovery.go index f03e661aa..8e2aaa846 100644 --- a/cosmos/x/evm/plugins/precompile/recovery.go +++ b/cosmos/x/evm/plugins/precompile/recovery.go @@ -25,10 +25,11 @@ import ( storetypes "cosmossdk.io/store/types" - "github.com/berachain/polaris/eth/core/vm" "github.com/berachain/polaris/lib/utils" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ethereum/go-ethereum/core/vm" ) // RecoveryHandler is used to recover from any WriteProtection and gas consumption panics that diff --git a/cosmos/x/evm/plugins/state/events/interfaces.go b/cosmos/x/evm/plugins/state/events/interfaces.go index 7fb3aeb89..800fc07a9 100644 --- a/cosmos/x/evm/plugins/state/events/interfaces.go +++ b/cosmos/x/evm/plugins/state/events/interfaces.go @@ -21,16 +21,16 @@ package events import ( - coretypes "github.com/berachain/polaris/eth/core/types" - sdk "github.com/cosmos/cosmos-sdk/types" + + ethtypes "github.com/ethereum/go-ethereum/core/types" ) type ( // PrecompileLogFactory is used to build an Ethereum log from a Cosmos event. PrecompileLogFactory interface { // Build builds an Ethereum log from a Cosmos event. - Build(*sdk.Event) (*coretypes.Log, error) + Build(*sdk.Event) (*ethtypes.Log, error) } // LogsDB defines the required function to add a log to the StateDB. This ensures a @@ -38,6 +38,6 @@ type ( // StateDB. LogsDB interface { // AddLog adds a log to the database. - AddLog(*coretypes.Log) + AddLog(*ethtypes.Log) } ) diff --git a/cosmos/x/evm/plugins/state/events/manager.go b/cosmos/x/evm/plugins/state/events/manager.go index 37d94eec8..5b952e4f3 100644 --- a/cosmos/x/evm/plugins/state/events/manager.go +++ b/cosmos/x/evm/plugins/state/events/manager.go @@ -23,11 +23,12 @@ package events import ( "errors" - "github.com/berachain/polaris/eth/core/vm" errlib "github.com/berachain/polaris/lib/errors" "github.com/berachain/polaris/lib/utils" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ethereum/go-ethereum/core/vm" ) const ( diff --git a/cosmos/x/evm/plugins/state/events/mock/log_factory.go b/cosmos/x/evm/plugins/state/events/mock/log_factory.go index 2e3f71c21..445e21b2a 100644 --- a/cosmos/x/evm/plugins/state/events/mock/log_factory.go +++ b/cosmos/x/evm/plugins/state/events/mock/log_factory.go @@ -23,20 +23,20 @@ package mock import ( "errors" - coretypes "github.com/berachain/polaris/eth/core/types" - sdk "github.com/cosmos/cosmos-sdk/types" + + ethtypes "github.com/ethereum/go-ethereum/core/types" ) //go:generate moq -out ./log_factory.mock.go -pkg mock ../ PrecompileLogFactory func NewPrecompileLogFactory() *PrecompileLogFactoryMock { return &PrecompileLogFactoryMock{ - BuildFunc: func(event *sdk.Event) (*coretypes.Log, error) { + BuildFunc: func(event *sdk.Event) (*ethtypes.Log, error) { if event.Type == "non-eth-event" { return nil, errors.New("event is not eth") } - return &coretypes.Log{}, nil + return ðtypes.Log{}, nil }, } } diff --git a/cosmos/x/evm/plugins/state/events/mock/logsdb.go b/cosmos/x/evm/plugins/state/events/mock/logsdb.go index ba4bcc8d3..2bc22442f 100644 --- a/cosmos/x/evm/plugins/state/events/mock/logsdb.go +++ b/cosmos/x/evm/plugins/state/events/mock/logsdb.go @@ -21,13 +21,13 @@ package mock import ( - coretypes "github.com/berachain/polaris/eth/core/types" + ethtypes "github.com/ethereum/go-ethereum/core/types" ) //go:generate moq -out ./logsdb.mock.go -pkg mock ../ LogsDB func NewEmptyLogsDB() *LogsDBMock { return &LogsDBMock{ - AddLogFunc: func(log *coretypes.Log) {}, + AddLogFunc: func(log *ethtypes.Log) {}, } } diff --git a/cosmos/x/evm/plugins/state/genesis.go b/cosmos/x/evm/plugins/state/genesis.go index 08ed276fd..5fdcd29fb 100644 --- a/cosmos/x/evm/plugins/state/genesis.go +++ b/cosmos/x/evm/plugins/state/genesis.go @@ -26,10 +26,11 @@ import ( "golang.org/x/exp/slices" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ethereum/go-ethereum/common" ) // InitGenesis takes in a pointer to a genesis state object and populates the KV store. diff --git a/cosmos/x/evm/plugins/state/genesis_test.go b/cosmos/x/evm/plugins/state/genesis_test.go index e5933c9de..96b132acd 100644 --- a/cosmos/x/evm/plugins/state/genesis_test.go +++ b/cosmos/x/evm/plugins/state/genesis_test.go @@ -27,12 +27,13 @@ import ( testutil "github.com/berachain/polaris/cosmos/testutil" "github.com/berachain/polaris/cosmos/x/evm/plugins/state" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core" - "github.com/berachain/polaris/eth/crypto" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/cosmos/x/evm/plugins/state/keys.go b/cosmos/x/evm/plugins/state/keys.go index ed5b25f90..e8bca381d 100644 --- a/cosmos/x/evm/plugins/state/keys.go +++ b/cosmos/x/evm/plugins/state/keys.go @@ -22,7 +22,8 @@ package state import ( types "github.com/berachain/polaris/cosmos/x/evm/types" - "github.com/berachain/polaris/eth/common" + + "github.com/ethereum/go-ethereum/common" ) // NOTE: we use copy to build keys for max performance: https://github.com/golang/go/issues/55905 diff --git a/cosmos/x/evm/plugins/state/keys_test.go b/cosmos/x/evm/plugins/state/keys_test.go index 208ebd8bd..086f9c35e 100644 --- a/cosmos/x/evm/plugins/state/keys_test.go +++ b/cosmos/x/evm/plugins/state/keys_test.go @@ -22,7 +22,8 @@ package state import ( "github.com/berachain/polaris/cosmos/x/evm/types" - "github.com/berachain/polaris/eth/common" + + "github.com/ethereum/go-ethereum/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/cosmos/x/evm/plugins/state/plugin.go b/cosmos/x/evm/plugins/state/plugin.go index 659a7487b..b6a38bf95 100644 --- a/cosmos/x/evm/plugins/state/plugin.go +++ b/cosmos/x/evm/plugins/state/plugin.go @@ -32,14 +32,15 @@ import ( "github.com/berachain/polaris/cosmos/x/evm/plugins" "github.com/berachain/polaris/cosmos/x/evm/plugins/state/events" "github.com/berachain/polaris/cosmos/x/evm/types" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core" ethstate "github.com/berachain/polaris/eth/core/state" - "github.com/berachain/polaris/eth/crypto" "github.com/berachain/polaris/lib/snapshot" libtypes "github.com/berachain/polaris/lib/types" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" ) const pluginRegistryKey = `statePlugin` diff --git a/cosmos/x/evm/plugins/state/plugin_benchmark_test.go b/cosmos/x/evm/plugins/state/plugin_benchmark_test.go index e71e1b490..c022ce7d7 100644 --- a/cosmos/x/evm/plugins/state/plugin_benchmark_test.go +++ b/cosmos/x/evm/plugins/state/plugin_benchmark_test.go @@ -28,8 +28,9 @@ import ( testutil "github.com/berachain/polaris/cosmos/testutil" "github.com/berachain/polaris/cosmos/x/evm/plugins/state" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core" + + "github.com/ethereum/go-ethereum/common" ) var ( diff --git a/cosmos/x/evm/plugins/state/plugin_test.go b/cosmos/x/evm/plugins/state/plugin_test.go index 7de6040ab..d570258aa 100644 --- a/cosmos/x/evm/plugins/state/plugin_test.go +++ b/cosmos/x/evm/plugins/state/plugin_test.go @@ -27,12 +27,13 @@ import ( testutil "github.com/berachain/polaris/cosmos/testutil" "github.com/berachain/polaris/cosmos/x/evm/plugins/state" - "github.com/berachain/polaris/eth/common" - coretypes "github.com/berachain/polaris/eth/core/types" - "github.com/berachain/polaris/eth/crypto" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -470,8 +471,8 @@ var _ = Describe("State Plugin", func() { type mockPLF struct{} -func (mplf *mockPLF) Build(event *sdk.Event) (*coretypes.Log, error) { - return &coretypes.Log{ +func (mplf *mockPLF) Build(event *sdk.Event) (*ethtypes.Log, error) { + return ðtypes.Log{ Address: common.BytesToAddress([]byte(event.Type)), }, nil } diff --git a/cosmos/x/evm/types/tx.go b/cosmos/x/evm/types/tx.go index 28788fb96..edae8cd0e 100644 --- a/cosmos/x/evm/types/tx.go +++ b/cosmos/x/evm/types/tx.go @@ -23,13 +23,12 @@ package types import ( "fmt" - coretypes "github.com/berachain/polaris/eth/core/types" - "github.com/ethereum/go-ethereum/beacon/engine" + ethtypes "github.com/ethereum/go-ethereum/core/types" ) // WrapTx sets the transaction data from an `coretypes.Transaction`. -func WrapTx(tx *coretypes.Transaction) (*WrappedEthereumTransaction, error) { +func WrapTx(tx *ethtypes.Transaction) (*WrappedEthereumTransaction, error) { bz, err := tx.MarshalBinary() if err != nil { return nil, fmt.Errorf("failed to wrap transaction: %w", err) @@ -41,8 +40,8 @@ func WrapTx(tx *coretypes.Transaction) (*WrappedEthereumTransaction, error) { } // Unwrap extracts the transaction as an `coretypes.Transaction`. -func (etr *WrappedEthereumTransaction) Unwrap() *coretypes.Transaction { - tx := new(coretypes.Transaction) +func (etr *WrappedEthereumTransaction) Unwrap() *ethtypes.Transaction { + tx := new(ethtypes.Transaction) if err := tx.UnmarshalBinary(etr.Data); err != nil { return nil } diff --git a/e2e/localnet/go.mod b/e2e/localnet/go.mod index 50d1c77ee..0286a2e2b 100644 --- a/e2e/localnet/go.mod +++ b/e2e/localnet/go.mod @@ -4,7 +4,6 @@ go 1.21 require ( github.com/berachain/polaris/contracts v0.0.1-alpha - github.com/berachain/polaris/eth v0.0.1-alpha github.com/docker/docker v24.0.7+incompatible github.com/ethereum/go-ethereum v1.13.4 github.com/onsi/ginkgo/v2 v2.13.0 @@ -42,6 +41,7 @@ require ( github.com/gotestyourself/gotestyourself v2.2.0+incompatible // indirect github.com/holiman/uint256 v1.2.3 // indirect github.com/lib/pq v1.10.9 // indirect + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/moby/term v0.5.0 // indirect github.com/morikuni/aec v1.0.0 // indirect @@ -63,6 +63,7 @@ require ( golang.org/x/sys v0.14.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/tools v0.14.0 // indirect + google.golang.org/protobuf v1.28.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools v2.2.0+incompatible // indirect rsc.io/tmplfunc v0.0.3 // indirect diff --git a/e2e/localnet/go.sum b/e2e/localnet/go.sum index a6c30c4a1..35b887fcb 100644 --- a/e2e/localnet/go.sum +++ b/e2e/localnet/go.sum @@ -46,6 +46,8 @@ github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5U github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= +github.com/containerd/continuity v0.4.3 h1:6HVkalIp+2u1ZLH1J/pYX2oBVXlJZvh1X1A7bEZ9Su8= +github.com/containerd/continuity v0.4.3/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= @@ -58,12 +60,18 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deckarep/golang-set/v2 v2.3.1 h1:vjmkvJt/IV27WXPyYQpAh4bRyWJc5Y435D17XQ9QU5A= github.com/deckarep/golang-set/v2 v2.3.1/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/deckarep/golang-set/v2 v2.4.0 h1:DnfgWKdhvHM8Kihdw9fKWXd08EdsPiyoHsk5bfsmkNI= +github.com/deckarep/golang-set/v2 v2.4.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= +github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= +github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM= github.com/docker/docker v24.0.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= @@ -75,6 +83,8 @@ github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/ethereum/go-ethereum v1.13.4 h1:25HJnaWVg3q1O7Z62LaaI6S9wVq8QCw3K88g8wEzrcM= github.com/ethereum/go-ethereum v1.13.4/go.mod h1:I0U5VewuuTzvBtVzKo7b3hJzDhXOUtn9mJW7SsIPB0Q= +github.com/ethereum/go-ethereum v1.13.5 h1:U6TCRciCqZRe4FPXmy1sMGxTfuk8P7u2UoinF3VbaFk= +github.com/ethereum/go-ethereum v1.13.5/go.mod h1:yMTu38GSuyxaYzQMViqNmQ1s3cE84abZexQmTgenWk0= github.com/fjl/memsize v0.0.1 h1:+zhkb+dhUgx0/e+M8sF0QqiouvMQUiKR+QYvdxIOKcQ= github.com/fjl/memsize v0.0.1/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= @@ -86,6 +96,8 @@ github.com/getsentry/sentry-go v0.25.0 h1:q6Eo+hS+yoJlTO3uu/azhQadsD8V+jQn2D8VvX github.com/getsentry/sentry-go v0.25.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= @@ -112,6 +124,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20230901174712-0191c66da455 h1:YhRUmI1ttDC4sxKY2V62BTI8hCXnyZBV9h38eAanInE= github.com/google/pprof v0.0.0-20230901174712-0191c66da455/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a h1:fEBsGL/sjAuJrgah5XqmmYsTLzJp/TO9Lhy39gkverk= +github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -174,14 +188,22 @@ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= +github.com/onsi/ginkgo/v2 v2.13.1 h1:LNGfMbR2OVGBfXjvRZIZ2YCTQdGKtPLvuI1rMCCj3OU= +github.com/onsi/ginkgo/v2 v2.13.1/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= +github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= +github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc4 h1:oOxKUJWnFC4YGHCCMNql1x4YaDfYBTS5Y4x/Cgeo1E0= github.com/opencontainers/image-spec v1.1.0-rc4/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= +github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI= +github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/GDEs= github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= +github.com/opencontainers/runc v1.1.10 h1:EaL5WeO9lv9wmS6SASjszOeQdSctvpbu0DdBQBizE40= +github.com/opencontainers/runc v1.1.10/go.mod h1:+/R6+KmDlh+hOO8NkjmgkG9Qzvypzk0yXxAPYYR65+M= github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= @@ -251,8 +273,12 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= +golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= @@ -264,6 +290,8 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= +golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -293,6 +321,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -301,6 +331,8 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= +golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8= +golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/e2e/localnet/network/fixture.go b/e2e/localnet/network/fixture.go index 22d0b413f..c995e4077 100644 --- a/e2e/localnet/network/fixture.go +++ b/e2e/localnet/network/fixture.go @@ -31,10 +31,9 @@ import ( ginkgo "github.com/onsi/ginkgo/v2" - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/crypto" - "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" ) const ( diff --git a/e2e/localnet/network/fixture_test.go b/e2e/localnet/network/fixture_test.go index 22930b2a3..6eff5d46b 100644 --- a/e2e/localnet/network/fixture_test.go +++ b/e2e/localnet/network/fixture_test.go @@ -31,11 +31,10 @@ import ( tbindings "github.com/berachain/polaris/contracts/bindings/testing" localnet "github.com/berachain/polaris/e2e/localnet/network" - "github.com/berachain/polaris/eth/common" - coretypes "github.com/berachain/polaris/eth/core/types" geth "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" gethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" gethrpc "github.com/ethereum/go-ethereum/rpc" @@ -170,7 +169,7 @@ var _ = Describe("JSON RPC tests", func() { BeforeEach(func() { var err error - var tx *coretypes.Transaction + var tx *gethtypes.Transaction // Run some transactions for alice _, tx, contract, err = tbindings.DeployConsumeGas( tf.GenerateTransactOpts("alice"), client, @@ -190,7 +189,7 @@ var _ = Describe("JSON RPC tests", func() { Expect(tf.WaitForNextBlock()).To(Succeed()) // send a transaction and make sure pending nonce is incremented - var tx *coretypes.Transaction + var tx *gethtypes.Transaction tx, err = contract.ConsumeGas(tf.GenerateTransactOpts("alice"), big.NewInt(10000)) Expect(err).NotTo(HaveOccurred()) @@ -222,11 +221,11 @@ var _ = Describe("JSON RPC tests", func() { Expect(err).NotTo(HaveOccurred()) // send 10 transactions, each one with updated nonce - var txs []*coretypes.Transaction + var txs []*gethtypes.Transaction for i := beforeNonce; i < beforeNonce+10; i++ { txr := tf.GenerateTransactOpts("charlie") txr.Nonce = big.NewInt(int64(i)) - var tx *coretypes.Transaction + var tx *gethtypes.Transaction tx, err = contract.ConsumeGas(txr, big.NewInt(50)) txs = append(txs, tx) Expect(err).ToNot(HaveOccurred()) diff --git a/e2e/localnet/network/node_test.go b/e2e/localnet/network/node_test.go index 9cbd189f8..c9c867d86 100644 --- a/e2e/localnet/network/node_test.go +++ b/e2e/localnet/network/node_test.go @@ -31,7 +31,8 @@ import ( "math/big" localnet "github.com/berachain/polaris/e2e/localnet/network" - coretypes "github.com/berachain/polaris/eth/core/types" + + ethtypes "github.com/ethereum/go-ethereum/core/types" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -75,7 +76,7 @@ var _ = Describe("ContainerizedNode", func() { It("should get recent blocks with websockets", func() { wsclient := c.EthWsClient() - headers := make(chan *coretypes.Header) + headers := make(chan *ethtypes.Header) sub, err := wsclient.SubscribeNewHead(context.Background(), headers) Expect(err).ToNot(HaveOccurred()) GinkgoWriter.Println("Listening for blocks...") diff --git a/e2e/localnet/utils/utils.go b/e2e/localnet/utils/utils.go index 27f0e8ee7..b2cfe463f 100644 --- a/e2e/localnet/utils/utils.go +++ b/e2e/localnet/utils/utils.go @@ -26,13 +26,14 @@ import ( "time" bindings "github.com/berachain/polaris/contracts/bindings/testing" - "github.com/berachain/polaris/eth/common" - coretypes "github.com/berachain/polaris/eth/core/types" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" - . "github.com/onsi/gomega" //nolint:stylecheck,revive,gostaticcheck // Gomega makes sense in tests. + //lint:ignore ST1001 Gomega makes sense in tests + . "github.com/onsi/gomega" //nolint:stylecheck,revive,gostaticcheck // Gomega makes sense in tests ) const ( @@ -41,7 +42,7 @@ const ( ) // ExpectedMined waits for a transaction to be mined. -func ExpectMined(client *ethclient.Client, tx *coretypes.Transaction) { +func ExpectMined(client *ethclient.Client, tx *ethtypes.Transaction) { // Wait for the transaction to be mined. ctx, cancel := context.WithTimeout(context.Background(), DefaultTimeout) defer cancel() @@ -53,8 +54,8 @@ func ExpectMined(client *ethclient.Client, tx *coretypes.Transaction) { // It also checks that the transaction was successful. func ExpectSuccessReceipt( client *ethclient.Client, - tx *coretypes.Transaction, -) *coretypes.Receipt { + tx *ethtypes.Transaction, +) *ethtypes.Receipt { // Wait for the transaction to be mined. ctx, cancel := context.WithTimeout(context.Background(), DefaultTimeout) defer cancel() @@ -72,8 +73,8 @@ func ExpectSuccessReceipt( // It also checks that the transaction was failed. func ExpectFailedReceipt( client *ethclient.Client, - tx *coretypes.Transaction, -) *coretypes.Receipt { + tx *ethtypes.Transaction, +) *ethtypes.Receipt { // Wait for the transaction to be mined. ctx, cancel := context.WithTimeout(context.Background(), DefaultTimeout) defer cancel() diff --git a/e2e/precompile/contracts/bank/bank_test.go b/e2e/precompile/contracts/bank/bank_test.go index 9bbcf8ef6..77a0f1325 100644 --- a/e2e/precompile/contracts/bank/bank_test.go +++ b/e2e/precompile/contracts/bank/bank_test.go @@ -32,7 +32,8 @@ import ( bindings "github.com/berachain/polaris/contracts/bindings/cosmos/precompile/bank" localnet "github.com/berachain/polaris/e2e/localnet/network" utils "github.com/berachain/polaris/e2e/precompile" - "github.com/berachain/polaris/eth/common" + + "github.com/ethereum/go-ethereum/common" . "github.com/berachain/polaris/e2e/localnet/utils" . "github.com/onsi/ginkgo/v2" diff --git a/e2e/precompile/contracts/distribution/distribution_test.go b/e2e/precompile/contracts/distribution/distribution_test.go index f9640ff53..2fbe1fc4f 100644 --- a/e2e/precompile/contracts/distribution/distribution_test.go +++ b/e2e/precompile/contracts/distribution/distribution_test.go @@ -35,12 +35,13 @@ import ( tbindings "github.com/berachain/polaris/contracts/bindings/testing" network "github.com/berachain/polaris/e2e/localnet/network" utils "github.com/berachain/polaris/e2e/precompile" - "github.com/berachain/polaris/eth/common" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/ethereum/go-ethereum/common" + . "github.com/berachain/polaris/e2e/localnet/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/e2e/precompile/contracts/gov/governance_test.go b/e2e/precompile/contracts/gov/governance_test.go index 592ffbf1a..003a9cfe4 100644 --- a/e2e/precompile/contracts/gov/governance_test.go +++ b/e2e/precompile/contracts/gov/governance_test.go @@ -36,12 +36,13 @@ import ( tbindings "github.com/berachain/polaris/contracts/bindings/testing/governance" network "github.com/berachain/polaris/e2e/localnet/network" utils "github.com/berachain/polaris/e2e/precompile" - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/core/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + . "github.com/berachain/polaris/e2e/localnet/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -77,7 +78,7 @@ var _ = Describe("Call the Precompile Directly", func() { common.HexToAddress("0x4381dC2aB14285160c808659aEe005D51255adD7"), tf.EthClient()) // Deploy the contract. - var tx *types.Transaction + var tx *ethtypes.Transaction wrapperAddr, tx, wrapper, err = tbindings.DeployGovernanceWrapper( tf.GenerateTransactOpts("alice"), tf.EthClient(), diff --git a/e2e/precompile/contracts/staking/staking_test.go b/e2e/precompile/contracts/staking/staking_test.go index bcf392a14..cacf0e56e 100644 --- a/e2e/precompile/contracts/staking/staking_test.go +++ b/e2e/precompile/contracts/staking/staking_test.go @@ -35,11 +35,12 @@ import ( tbindings "github.com/berachain/polaris/contracts/bindings/testing" network "github.com/berachain/polaris/e2e/localnet/network" utils "github.com/berachain/polaris/e2e/precompile" - "github.com/berachain/polaris/eth/common" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/ethereum/go-ethereum/common" + . "github.com/berachain/polaris/e2e/localnet/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/e2e/precompile/go.mod b/e2e/precompile/go.mod index bd1676b9b..27968a75c 100644 --- a/e2e/precompile/go.mod +++ b/e2e/precompile/go.mod @@ -4,7 +4,7 @@ go 1.21 require ( github.com/berachain/polaris/contracts v0.0.1-alpha - github.com/berachain/polaris/e2e/localnet v0.0.0-20231107182447-2b91ecc782a6 + github.com/berachain/polaris/e2e/localnet v0.0.0-20231123163754-5a2548de4f12 github.com/berachain/polaris/eth v0.0.1-alpha github.com/cosmos/cosmos-sdk v0.50.1 github.com/cosmos/gogoproto v1.4.11 diff --git a/e2e/precompile/go.sum b/e2e/precompile/go.sum index 32655cc1d..8a298a6ce 100644 --- a/e2e/precompile/go.sum +++ b/e2e/precompile/go.sum @@ -104,8 +104,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/berachain/polaris/contracts v0.0.1-alpha h1:nhmAB8Zz2wUkei2WHisbOwFXu8xokmDy3is/VuZ+dSw= github.com/berachain/polaris/contracts v0.0.1-alpha/go.mod h1:cZ1kKh7+zVnvn/cKMHdjNoxoaVJt8L71W7GXHw94Hm4= -github.com/berachain/polaris/e2e/localnet v0.0.0-20231107182447-2b91ecc782a6 h1:xQ8G7u5kA2aCaL8gsBI2S30Ww5V6WmpYX/7Da9tyPBU= -github.com/berachain/polaris/e2e/localnet v0.0.0-20231107182447-2b91ecc782a6/go.mod h1:5kTiiw+chO6yj5JZQsWK2qNZtbxYaG0t78uSOJZJ2PE= +github.com/berachain/polaris/e2e/localnet v0.0.0-20231123163754-5a2548de4f12 h1:tOpTxidtmMeU97j6IMff8FPat2oWrJNJ8ALTjhp2obE= +github.com/berachain/polaris/e2e/localnet v0.0.0-20231123163754-5a2548de4f12/go.mod h1:DG1PQvQf3Sci9PR7mqxipbNyUZ6nFNWxbYqiJ9dIlUE= github.com/berachain/polaris/eth v0.0.1-alpha h1:+uA1EGaSNGB5C2qQn6Dqzp3uCgI1EE2O5B/IdKr3BNU= github.com/berachain/polaris/eth v0.0.1-alpha/go.mod h1:od/ALWEMzfR+Wj0fI2DE4de4f/Ee4CFXWu/ZkMxKy6A= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= diff --git a/eth/common/hexutil/imported.go b/eth/common/hexutil/imported.go deleted file mode 100644 index 86a99a4d8..000000000 --- a/eth/common/hexutil/imported.go +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -// -// Copyright (C) 2023, Berachain Foundation. All rights reserved. -// Use of this software is govered by the Business Source License included -// in the LICENSE file of this repository and at www.mariadb.com/bsl11. -// -// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY -// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER -// VERSIONS OF THE LICENSED WORK. -// -// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF -// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF -// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). -// -// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, -// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND -// TITLE. - -package hexutil - -import ( - "github.com/ethereum/go-ethereum/common/hexutil" -) - -type ( - Bytes = hexutil.Bytes - Uint = hexutil.Uint -) - -var ( - MustDecode = hexutil.MustDecode - Decode = hexutil.Decode -) diff --git a/eth/common/imported.go b/eth/common/imported.go deleted file mode 100644 index a1904ac3e..000000000 --- a/eth/common/imported.go +++ /dev/null @@ -1,46 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -// -// Copyright (C) 2023, Berachain Foundation. All rights reserved. -// Use of this software is govered by the Business Source License included -// in the LICENSE file of this repository and at www.mariadb.com/bsl11. -// -// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY -// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER -// VERSIONS OF THE LICENSED WORK. -// -// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF -// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF -// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). -// -// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, -// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND -// TITLE. - -package common - -import ( - "github.com/ethereum/go-ethereum/common" -) - -type ( - Address = common.Address - Hash = common.Hash -) - -var ( - AddressLength = common.AddressLength - HashLength = common.HashLength - BytesToAddress = common.BytesToAddress - Big0 = common.Big0 - BigToHash = common.BigToHash - BytesToHash = common.BytesToHash - Bytes2Hex = common.Bytes2Hex - FromHex = common.FromHex - HexToAddress = common.HexToAddress - IsHexAddress = common.IsHexAddress - Hex2Bytes = common.Hex2Bytes - HexToHash = common.HexToHash - LeftPadBytes = common.LeftPadBytes -) diff --git a/eth/consensus/dummy_eth_one.go b/eth/consensus/dummy_eth_one.go index 08c3975aa..3f204defd 100644 --- a/eth/consensus/dummy_eth_one.go +++ b/eth/consensus/dummy_eth_one.go @@ -24,12 +24,12 @@ package consensus import ( "math/big" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core/state" - "github.com/berachain/polaris/eth/core/types" - "github.com/berachain/polaris/eth/rpc" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/trie" ) @@ -42,12 +42,15 @@ var _ Engine = (*DummyEthOne)(nil) type DummyEthOne struct{} // Author is a mock implementation. -func (m *DummyEthOne) Author(header *types.Header) (common.Address, error) { +func (m *DummyEthOne) Author(header *ethtypes.Header) (common.Address, error) { return common.Address{}, nil } // VerifyHeader is a mock implementation. -func (m *DummyEthOne) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header) error { +func (m *DummyEthOne) VerifyHeader( + chain consensus.ChainHeaderReader, + header *ethtypes.Header, +) error { // Set the correct difficulty header.Difficulty = new(big.Int).SetUint64(1) return nil @@ -55,7 +58,7 @@ func (m *DummyEthOne) VerifyHeader(chain consensus.ChainHeaderReader, header *ty // VerifyHeaders is a mock implementation. func (m *DummyEthOne) VerifyHeaders( - chain consensus.ChainHeaderReader, headers []*types.Header) (chan<- struct{}, <-chan error) { + chain consensus.ChainHeaderReader, headers []*ethtypes.Header) (chan<- struct{}, <-chan error) { for _, h := range headers { if err := m.VerifyHeader(chain, h); err != nil { return nil, nil @@ -65,46 +68,46 @@ func (m *DummyEthOne) VerifyHeaders( } // VerifyUncles is a mock implementation. -func (m *DummyEthOne) VerifyUncles(chain consensus.ChainReader, block *types.Block) error { +func (m *DummyEthOne) VerifyUncles(chain consensus.ChainReader, block *ethtypes.Block) error { return nil } // Prepare is a mock implementation. -func (m *DummyEthOne) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error { +func (m *DummyEthOne) Prepare(chain consensus.ChainHeaderReader, header *ethtypes.Header) error { header.Difficulty = new(big.Int).SetUint64(0) return nil } // Finalize is a mock implementation. func (m *DummyEthOne) Finalize(chain consensus.ChainHeaderReader, - header *types.Header, state state.StateDB, txs []*types.Transaction, - uncles []*types.Header, withdrawals []*types.Withdrawal) { + header *ethtypes.Header, state state.StateDB, txs []*ethtypes.Transaction, + uncles []*ethtypes.Header, withdrawals []*ethtypes.Withdrawal) { } // FinalizeAndAssemble is a mock implementation. func (m *DummyEthOne) FinalizeAndAssemble(chain consensus.ChainHeaderReader, - header *types.Header, state state.StateDB, txs []*types.Transaction, - uncles []*types.Header, receipts []*types.Receipt, - withdrawals []*types.Withdrawal) (*types.Block, error) { - return types.NewBlock(header, txs, uncles, receipts, trie.NewStackTrie(nil)), nil + header *ethtypes.Header, state state.StateDB, txs []*ethtypes.Transaction, + uncles []*ethtypes.Header, receipts []*ethtypes.Receipt, + withdrawals []*ethtypes.Withdrawal) (*ethtypes.Block, error) { + return ethtypes.NewBlock(header, txs, uncles, receipts, trie.NewStackTrie(nil)), nil } // Seal is a mock implementation. func (m *DummyEthOne) Seal(chain consensus.ChainHeaderReader, - block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error { + block *ethtypes.Block, results chan<- *ethtypes.Block, stop <-chan struct{}) error { sealedBlock := block // .seal() results <- sealedBlock return nil } // SealHash is a mock implementation. -func (m *DummyEthOne) SealHash(header *types.Header) common.Hash { +func (m *DummyEthOne) SealHash(header *ethtypes.Header) common.Hash { return header.Hash() } // CalcDifficulty is a mock implementation. func (m *DummyEthOne) CalcDifficulty(chain consensus.ChainHeaderReader, - time uint64, parent *types.Header) *big.Int { + time uint64, parent *ethtypes.Header) *big.Int { return big.NewInt(0) } diff --git a/eth/core/chain.go b/eth/core/chain.go index 1f6566f88..b6032ee6b 100644 --- a/eth/core/chain.go +++ b/eth/core/chain.go @@ -26,17 +26,18 @@ import ( "math/big" "sync/atomic" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/consensus" "github.com/berachain/polaris/eth/core/state" "github.com/berachain/polaris/eth/core/types" - "github.com/berachain/polaris/eth/core/vm" - "github.com/berachain/polaris/eth/log" - "github.com/berachain/polaris/eth/params" - lru "github.com/ethereum/go-ethereum/common/lru" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/lru" "github.com/ethereum/go-ethereum/core" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" ) @@ -53,7 +54,7 @@ type Blockchain interface { ChainWriter ChainSubscriber ChainResources - ChainContext + core.ChainContext } // blockchain is the canonical, persistent object that operates the Polaris EVM. @@ -77,19 +78,19 @@ type blockchain struct { config *params.ChainConfig // currentBlock is the current/pending block. - currentBlock atomic.Pointer[types.Block] + currentBlock atomic.Pointer[ethtypes.Block] // finalizedBlock is the finalized/latest block. - finalizedBlock atomic.Pointer[types.Block] + finalizedBlock atomic.Pointer[ethtypes.Block] // receiptsCache is a cache of the receipts for the last `defaultCacheSizeBytes` bytes of // blocks. blockHash -> receipts - receiptsCache *lru.Cache[common.Hash, types.Receipts] + receiptsCache *lru.Cache[common.Hash, ethtypes.Receipts] // blockNumCache is a cache of the blocks for the last `defaultCacheSizeBytes` bytes of blocks. // blockNum -> block - blockNumCache *lru.Cache[uint64, *types.Block] + blockNumCache *lru.Cache[uint64, *ethtypes.Block] // blockHashCache is a cache of the blocks for the last `defaultCacheSizeBytes` bytes of blocks. // blockHash -> block - blockHashCache *lru.Cache[common.Hash, *types.Block] + blockHashCache *lru.Cache[common.Hash, *ethtypes.Block] // txLookupCache is a cache of the transactions for the last `defaultCacheSizeBytes` bytes of // blocks. txHash -> txLookupEntry txLookupCache *lru.Cache[common.Hash, *types.TxLookupEntry] @@ -119,9 +120,9 @@ func NewChain( sp: host.GetStatePlugin(), config: config, vmConfig: &vm.Config{}, - receiptsCache: lru.NewCache[common.Hash, types.Receipts](defaultCacheSize), - blockNumCache: lru.NewCache[uint64, *types.Block](defaultCacheSize), - blockHashCache: lru.NewCache[common.Hash, *types.Block](defaultCacheSize), + receiptsCache: lru.NewCache[common.Hash, ethtypes.Receipts](defaultCacheSize), + blockNumCache: lru.NewCache[uint64, *ethtypes.Block](defaultCacheSize), + blockHashCache: lru.NewCache[common.Hash, *ethtypes.Block](defaultCacheSize), txLookupCache: lru.NewCache[common.Hash, *types.TxLookupEntry](defaultCacheSize), chainHeadFeed: event.Feed{}, scope: event.SubscriptionScope{}, @@ -133,7 +134,7 @@ func NewChain( bc.validator = core.NewBlockValidator(bc.config, bc, bc.engine) // TODO: hmm... bc.currentBlock.Store( - types.NewBlock(&types.Header{Time: 0, Number: big.NewInt(0), + ethtypes.NewBlock(ðtypes.Header{Time: 0, Number: big.NewInt(0), BaseFee: big.NewInt(0)}, nil, nil, nil, trie.NewStackTrie(nil))) bc.finalizedBlock.Store(nil) return bc diff --git a/eth/core/chain_context.go b/eth/core/chain_context.go index ba9660cd5..0411d5d30 100644 --- a/eth/core/chain_context.go +++ b/eth/core/chain_context.go @@ -21,14 +21,13 @@ package core import ( - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/core/types" - + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus" + ethtypes "github.com/ethereum/go-ethereum/core/types" ) // GetHeader returns the header for the given hash or number. This is used by the `GetHashFn`. -func (bc *blockchain) GetHeader(hash common.Hash, number uint64) *types.Header { +func (bc *blockchain) GetHeader(hash common.Hash, number uint64) *ethtypes.Header { header := bc.GetHeaderByNumber(number) if header == nil { header = bc.GetHeaderByHash(hash) diff --git a/eth/core/chain_helpers.go b/eth/core/chain_helpers.go index 60a07ef59..6a44a8921 100644 --- a/eth/core/chain_helpers.go +++ b/eth/core/chain_helpers.go @@ -21,15 +21,17 @@ package core import ( - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core/types" + + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" ) // deriveReceipts derives the receipts from the block. func (bc *blockchain) deriveReceipts( - receipts types.Receipts, + receipts ethtypes.Receipts, blockHash common.Hash, -) (types.Receipts, error) { +) (ethtypes.Receipts, error) { // get the block to derive the receipts block := bc.GetBlockByHash(blockHash) if block == nil { diff --git a/eth/core/chain_reader.go b/eth/core/chain_reader.go index 9fe868cf5..fb6e001a6 100644 --- a/eth/core/chain_reader.go +++ b/eth/core/chain_reader.go @@ -23,9 +23,11 @@ package core import ( "math/big" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core/types" "github.com/berachain/polaris/lib/utils" + + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" ) // ChainReader defines methods that are used to read the state and blocks of the chain. @@ -36,16 +38,16 @@ type ChainReader interface { // ChainBlockReader defines methods that are used to read information about blocks in the chain. type ChainBlockReader interface { - CurrentHeader() *types.Header - CurrentBlock() *types.Header - CurrentFinalBlock() *types.Header - CurrentSafeBlock() *types.Header - GetBlock(common.Hash, uint64) *types.Block - GetReceiptsByHash(common.Hash) types.Receipts - GetBlockByHash(common.Hash) *types.Block - GetHeaderByNumber(uint64) *types.Header - GetHeaderByHash(common.Hash) *types.Header - GetBlockByNumber(uint64) *types.Block + CurrentHeader() *ethtypes.Header + CurrentBlock() *ethtypes.Header + CurrentFinalBlock() *ethtypes.Header + CurrentSafeBlock() *ethtypes.Header + GetBlock(common.Hash, uint64) *ethtypes.Block + GetReceiptsByHash(common.Hash) ethtypes.Receipts + GetBlockByHash(common.Hash) *ethtypes.Block + GetHeaderByNumber(uint64) *ethtypes.Header + GetHeaderByHash(common.Hash) *ethtypes.Header + GetBlockByNumber(uint64) *ethtypes.Block GetTransactionLookup(common.Hash) *types.TxLookupEntry GetTd(common.Hash, uint64) *big.Int HasBlock(common.Hash, uint64) bool @@ -56,8 +58,8 @@ type ChainBlockReader interface { // ========================================================================= // CurrentHeader returns the current header of the blockchain. -func (bc *blockchain) CurrentHeader() *types.Header { - block, ok := utils.GetAs[*types.Block](bc.currentBlock.Load()) +func (bc *blockchain) CurrentHeader() *ethtypes.Header { + block, ok := utils.GetAs[*ethtypes.Block](bc.currentBlock.Load()) if block == nil || !ok { return nil } @@ -67,8 +69,8 @@ func (bc *blockchain) CurrentHeader() *types.Header { } // CurrentBlock returns the current header of the blockchain. -func (bc *blockchain) CurrentBlock() *types.Header { - block, ok := utils.GetAs[*types.Block](bc.currentBlock.Load()) +func (bc *blockchain) CurrentBlock() *ethtypes.Header { + block, ok := utils.GetAs[*ethtypes.Block](bc.currentBlock.Load()) if block == nil || !ok { return nil } @@ -78,14 +80,14 @@ func (bc *blockchain) CurrentBlock() *types.Header { } // CurrentSnapBlock is UNUSED in Polaris. -func (bc *blockchain) CurrentSnapBlock() *types.Header { +func (bc *blockchain) CurrentSnapBlock() *ethtypes.Header { return nil } // GetHeadersFrom returns a contiguous segment of headers, in rlp-form, going // backwards from the given number. -func (bc *blockchain) CurrentFinalBlock() *types.Header { - fb, ok := utils.GetAs[*types.Block](bc.finalizedBlock.Load()) +func (bc *blockchain) CurrentFinalBlock() *ethtypes.Header { + fb, ok := utils.GetAs[*ethtypes.Block](bc.finalizedBlock.Load()) if fb == nil || !ok { return nil } @@ -96,12 +98,12 @@ func (bc *blockchain) CurrentFinalBlock() *types.Header { // CurrentSafeBlock retrieves the current safe block of the canonical // chain. The block is retrieved from the blockchain's internal cache. -func (bc *blockchain) CurrentSafeBlock() *types.Header { +func (bc *blockchain) CurrentSafeBlock() *ethtypes.Header { return bc.CurrentFinalBlock() } // GetBlock returns a block by its hash or number. -func (bc *blockchain) GetBlock(hash common.Hash, number uint64) *types.Block { +func (bc *blockchain) GetBlock(hash common.Hash, number uint64) *ethtypes.Block { if block := bc.GetBlockByHash(hash); block != nil { return block } @@ -110,7 +112,7 @@ func (bc *blockchain) GetBlock(hash common.Hash, number uint64) *types.Block { } // GetBlockByHash retrieves a block from the database by hash, caching it if found. -func (bc *blockchain) GetBlockByHash(hash common.Hash) *types.Block { +func (bc *blockchain) GetBlockByHash(hash common.Hash) *ethtypes.Block { // check the block hash cache if block, ok := bc.blockHashCache.Get(hash); ok { bc.blockNumCache.Add(block.Number().Uint64(), block) @@ -137,21 +139,21 @@ func (bc *blockchain) GetBlockByHash(hash common.Hash) *types.Block { } // GetBlock retrieves a block from the database by hash and number, caching it if found. -func (bc *blockchain) GetBlockByNumber(number uint64) *types.Block { +func (bc *blockchain) GetBlockByNumber(number uint64) *ethtypes.Block { // check the block number cache if block, ok := bc.blockNumCache.Get(number); ok { bc.blockHashCache.Add(block.Hash(), block) return block } - var block *types.Block + var block *ethtypes.Block if number == 0 { // get the genesis block header header, err := bc.bp.GetHeaderByNumber(number) if header == nil || err != nil { return nil } - block = types.NewBlockWithHeader(header) + block = ethtypes.NewBlockWithHeader(header) } else { var err error // check if historical plugin is supported by host chain @@ -175,7 +177,7 @@ func (bc *blockchain) GetBlockByNumber(number uint64) *types.Block { // GetReceipts gathers the receipts that were created in the block defined by // the given hash. -func (bc *blockchain) GetReceiptsByHash(blockHash common.Hash) types.Receipts { +func (bc *blockchain) GetReceiptsByHash(blockHash common.Hash) ethtypes.Receipts { // check the cache if receipts, ok := bc.receiptsCache.Get(blockHash); ok { derived, err := bc.deriveReceipts(receipts, blockHash) @@ -242,18 +244,18 @@ func (bc *blockchain) GetTransactionLookup( } // GetHeaderByNumber retrieves a header from the blockchain. -func (bc *blockchain) GetHeaderByNumber(number uint64) *types.Header { +func (bc *blockchain) GetHeaderByNumber(number uint64) *ethtypes.Header { header, _ := bc.bp.GetHeaderByNumber(number) return header } // GetHeaderByHash retrieves a block header from the database by hash, caching it if // found. -func (bc *blockchain) GetHeaderByHash(hash common.Hash) *types.Header { +func (bc *blockchain) GetHeaderByHash(hash common.Hash) *ethtypes.Header { header, err := bc.bp.GetHeaderByHash(hash) if err != nil && bc.hp != nil { // try searching the historical plugin if the block plugin does not have the header - var block *types.Block + var block *ethtypes.Block block, err = bc.hp.GetBlockByHash(hash) if err != nil { return nil diff --git a/eth/core/chain_resources.go b/eth/core/chain_resources.go index 5c55b6adf..d93131569 100644 --- a/eth/core/chain_resources.go +++ b/eth/core/chain_resources.go @@ -23,10 +23,11 @@ package core import ( "errors" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core/state" - "github.com/berachain/polaris/eth/core/vm" - "github.com/berachain/polaris/eth/params" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/params" ) // ChainResources is the interface that defines functions for code paths within the chain to diff --git a/eth/core/chain_subscriber.go b/eth/core/chain_subscriber.go index a2dcc038e..73482f9a3 100644 --- a/eth/core/chain_subscriber.go +++ b/eth/core/chain_subscriber.go @@ -21,40 +21,42 @@ package core import ( - "github.com/berachain/polaris/eth/core/types" - + "github.com/ethereum/go-ethereum/core" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" ) type ChainSubscriber interface { - SubscribeRemovedLogsEvent(chan<- RemovedLogsEvent) event.Subscription // currently not used - SubscribeChainEvent(chan<- ChainEvent) event.Subscription - SubscribeChainHeadEvent(chan<- ChainHeadEvent) event.Subscription - SubscribeChainSideEvent(ch chan<- ChainSideEvent) event.Subscription // currently not used - SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription + SubscribeRemovedLogsEvent(chan<- core.RemovedLogsEvent) event.Subscription // currently not used + SubscribeChainEvent(chan<- core.ChainEvent) event.Subscription + SubscribeChainHeadEvent(chan<- core.ChainHeadEvent) event.Subscription + SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription // currently not used + SubscribeLogsEvent(ch chan<- []*ethtypes.Log) event.Subscription } // SubscribeRemovedLogsEvent registers a subscription of RemovedLogsEvent. -func (bc *blockchain) SubscribeRemovedLogsEvent(ch chan<- RemovedLogsEvent) event.Subscription { +func (bc *blockchain) SubscribeRemovedLogsEvent( + ch chan<- core.RemovedLogsEvent, +) event.Subscription { return bc.scope.Track(bc.rmLogsFeed.Subscribe(ch)) } // SubscribeChainEvent registers a subscription of ChainEvent. -func (bc *blockchain) SubscribeChainEvent(ch chan<- ChainEvent) event.Subscription { +func (bc *blockchain) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription { return bc.scope.Track(bc.chainFeed.Subscribe(ch)) } // SubscribeChainHeadEvent registers a subscription of ChainHeadEvent. -func (bc *blockchain) SubscribeChainHeadEvent(ch chan<- ChainHeadEvent) event.Subscription { +func (bc *blockchain) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription { return bc.scope.Track(bc.chainHeadFeed.Subscribe(ch)) } // SubscribeChainSideEvent registers a subscription of ChainSideEvent. -func (bc *blockchain) SubscribeChainSideEvent(ch chan<- ChainSideEvent) event.Subscription { +func (bc *blockchain) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription { return bc.scope.Track(bc.chainSideFeed.Subscribe(ch)) } // SubscribeLogsEvent registers a subscription of []*types.Log. -func (bc *blockchain) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription { +func (bc *blockchain) SubscribeLogsEvent(ch chan<- []*ethtypes.Log) event.Subscription { return bc.scope.Track(bc.logsFeed.Subscribe(ch)) } diff --git a/eth/core/chain_writer.go b/eth/core/chain_writer.go index cf5797c05..0f1bc4a37 100644 --- a/eth/core/chain_writer.go +++ b/eth/core/chain_writer.go @@ -26,23 +26,24 @@ import ( "github.com/berachain/polaris/eth/core/state" "github.com/berachain/polaris/eth/core/types" - "github.com/berachain/polaris/eth/log" "github.com/ethereum/go-ethereum/core" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/log" ) // ChainWriter defines methods that are used to perform state and block transitions. type ChainWriter interface { LoadLastState(context.Context, uint64) error - WriteGenesisBlock(block *types.Block) error - InsertBlockAndSetHead(block *types.Block) error - InsertBlockWithoutSetHead(block *types.Block) error - WriteBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, + WriteGenesisBlock(block *ethtypes.Block) error + InsertBlockAndSetHead(block *ethtypes.Block) error + InsertBlockWithoutSetHead(block *ethtypes.Block) error + WriteBlockAndSetHead(block *ethtypes.Block, receipts []*ethtypes.Receipt, logs []*ethtypes.Log, state state.StateDB, emitHeadEvent bool) (status core.WriteStatus, err error) } // WriteGenesisBlock inserts the genesis block into the blockchain. -func (bc *blockchain) WriteGenesisBlock(block *types.Block) error { +func (bc *blockchain) WriteGenesisBlock(block *ethtypes.Block) error { // TODO: add more validation here. if block.NumberU64() != 0 { return errors.New("not the genesis block") @@ -52,7 +53,7 @@ func (bc *blockchain) WriteGenesisBlock(block *types.Block) error { } // InsertBlockWithoutSetHead inserts a block into the blockchain without setting it as the head. -func (bc *blockchain) InsertBlockWithoutSetHead(block *types.Block) error { +func (bc *blockchain) InsertBlockWithoutSetHead(block *ethtypes.Block) error { // Call the private method to insert the block without setting it as the head. _, _, err := bc.insertBlockWithoutSetHead(block) // Return any error that might have occurred. @@ -61,8 +62,8 @@ func (bc *blockchain) InsertBlockWithoutSetHead(block *types.Block) error { // insertBlockWithoutSetHead inserts a block into the blockchain without setting it as the head. func (bc *blockchain) insertBlockWithoutSetHead( - block *types.Block, -) ([]*types.Receipt, []*types.Log, error) { + block *ethtypes.Block, +) ([]*ethtypes.Receipt, []*ethtypes.Log, error) { // Validate that we are about to insert a valid block. // If the block number is greater than 1, // it means it's not the genesis block and needs to be validated. TODO kinda hood. @@ -90,7 +91,7 @@ func (bc *blockchain) insertBlockWithoutSetHead( } // InsertBlockAndSetHead inserts a block into the blockchain and sets the head. -func (bc *blockchain) InsertBlockAndSetHead(block *types.Block) error { +func (bc *blockchain) InsertBlockAndSetHead(block *ethtypes.Block) error { receipts, logs, err := bc.insertBlockWithoutSetHead(block) if err != nil { return err @@ -106,7 +107,7 @@ func (bc *blockchain) InsertBlockAndSetHead(block *types.Block) error { // WriteBlockAndSetHead sets the head of the blockchain to the given block and finalizes the block. func (bc *blockchain) WriteBlockAndSetHead( - block *types.Block, receipts []*types.Receipt, logs []*types.Log, + block *ethtypes.Block, receipts []*ethtypes.Receipt, logs []*ethtypes.Log, _ state.StateDB, emitHeadEvent bool, ) (core.WriteStatus, error) { // Write the block to the store. @@ -155,7 +156,7 @@ func (bc *blockchain) WriteBlockAndSetHead( } // Fire off the feeds. - bc.chainFeed.Send(ChainEvent{Block: block, Hash: block.Hash(), Logs: logs}) + bc.chainFeed.Send(core.ChainEvent{Block: block, Hash: block.Hash(), Logs: logs}) if len(logs) > 0 { bc.logsFeed.Send(logs) } @@ -166,7 +167,7 @@ func (bc *blockchain) WriteBlockAndSetHead( // we will fire an accumulated ChainHeadEvent and disable fire // event here. if emitHeadEvent { - bc.chainHeadFeed.Send(ChainHeadEvent{Block: block}) + bc.chainHeadFeed.Send(core.ChainHeadEvent{Block: block}) } return core.CanonStatTy, nil @@ -175,7 +176,7 @@ func (bc *blockchain) WriteBlockAndSetHead( // writeBlockWithState writes the block along with its state (receipts and logs) // into the blockchain. func (bc *blockchain) writeBlockWithState( - block *types.Block, receipts []*types.Receipt, + block *ethtypes.Block, receipts []*ethtypes.Receipt, ) error { // In Polaris since we are using single block finality. // Finalized == Current == Safe. All are the same. @@ -208,8 +209,8 @@ func (bc *blockchain) writeBlockWithState( // InsertBlock inserts a block into the canonical chain and updates the state of the blockchain. // TODO: WRITE TO EXTERNAL STORE func (bc *blockchain) writeHistoricalData( - block *types.Block, - receipts types.Receipts, + block *ethtypes.Block, + receipts ethtypes.Receipts, ) error { var err error blockHash, blockNum := block.Hash(), block.Number().Uint64() diff --git a/eth/core/genesis.go b/eth/core/genesis.go index 56d935020..47d5fb0db 100644 --- a/eth/core/genesis.go +++ b/eth/core/genesis.go @@ -23,11 +23,10 @@ package core import ( "math/big" - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/common/hexutil" - "github.com/berachain/polaris/eth/core/types" - + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" + ethtypes "github.com/ethereum/go-ethereum/core/types" ) type ( @@ -70,7 +69,7 @@ var DefaultGenesis = &core.Genesis{ } // UnmarshalGenesisHeader sets the fields of the given header into the Genesis struct. -func UnmarshalGenesisHeader(header *types.Header, gen *Genesis) { +func UnmarshalGenesisHeader(header *ethtypes.Header, gen *Genesis) { // Note: cannot set the state root on the genesis. gen.Nonce = header.Nonce.Uint64() gen.Timestamp = header.Time diff --git a/eth/core/host.go b/eth/core/host.go index df22aa96c..826bdee74 100644 --- a/eth/core/host.go +++ b/eth/core/host.go @@ -21,11 +21,13 @@ package core import ( - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core/precompile" "github.com/berachain/polaris/eth/core/state" "github.com/berachain/polaris/eth/core/types" libtypes "github.com/berachain/polaris/lib/types" + + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" ) // PolarisHostChain defines the plugins that the chain running the Polaris EVM should implement. @@ -54,11 +56,11 @@ type ( // BlockPlugin to a default state. libtypes.Preparable // GetHeaderByNumber returns the block header at the given block number. - GetHeaderByNumber(uint64) (*types.Header, error) + GetHeaderByNumber(uint64) (*ethtypes.Header, error) // GetHeaderByHash returns the block header with the given block hash. - GetHeaderByHash(common.Hash) (*types.Header, error) + GetHeaderByHash(common.Hash) (*ethtypes.Header, error) // StoreHeader stores the block header at the given block number. - StoreHeader(*types.Header) error + StoreHeader(*ethtypes.Header) error } // StatePlugin defines the methods that the chain running Polaris EVM should implement. @@ -83,20 +85,20 @@ type ( // HistoricalPlugin implements `libtypes.Preparable`. libtypes.Preparable // GetBlockByNumber returns the block at the given block number. - GetBlockByNumber(uint64) (*types.Block, error) + GetBlockByNumber(uint64) (*ethtypes.Block, error) // GetBlockByHash returns the block at the given block hash. - GetBlockByHash(common.Hash) (*types.Block, error) + GetBlockByHash(common.Hash) (*ethtypes.Block, error) // GetTransactionByHash returns the transaction lookup entry at the given transaction // hash. GetTransactionByHash(common.Hash) (*types.TxLookupEntry, error) // GetReceiptByHash returns the receipts at the given block hash. - GetReceiptsByHash(common.Hash) (types.Receipts, error) + GetReceiptsByHash(common.Hash) (ethtypes.Receipts, error) // StoreBlock stores the given block. - StoreBlock(*types.Block) error + StoreBlock(*ethtypes.Block) error // StoreReceipts stores the receipts for the given block hash. - StoreReceipts(common.Hash, types.Receipts) error + StoreReceipts(common.Hash, ethtypes.Receipts) error // StoreTransactions stores the transactions for the given block hash. - StoreTransactions(uint64, common.Hash, types.Transactions) error + StoreTransactions(uint64, common.Hash, ethtypes.Transactions) error } // PrecompilePlugin defines the methods that the chain running Polaris EVM should implement diff --git a/eth/core/imported.go b/eth/core/imported.go deleted file mode 100644 index aa906be9f..000000000 --- a/eth/core/imported.go +++ /dev/null @@ -1,58 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -// -// Copyright (C) 2023, Berachain Foundation. All rights reserved. -// Use of this software is govered by the Business Source License included -// in the LICENSE file of this repository and at www.mariadb.com/bsl11. -// -// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY -// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER -// VERSIONS OF THE LICENSED WORK. -// -// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF -// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF -// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). -// -// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, -// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND -// TITLE. - -package core - -import ( - "github.com/ethereum/go-ethereum/core" -) - -type ( - // ChainContext provides information about the current blockchain to the EVM. - ChainContext = core.ChainContext - // ChainEvent contains information about the chain. - ChainEvent = core.ChainEvent - // ChainHeadEvent is posted when a new head block is added to the chain. - ChainHeadEvent = core.ChainHeadEvent - // ChainSideEvent is posted when a new side block is added to the chain. - ChainSideEvent = core.ChainSideEvent - // GasPool is a pool of gas that can be consumed by transactions. - GasPool = core.GasPool - // NewTxsEvent is posted when a batch of transactions enter the transaction pool. - NewTxsEvent = core.NewTxsEvent - // Message contains data used ype used to execute transactions. - Message = core.Message - // RemovedLogsEvent is posted pre-removal of a set of logs. - RemovedLogsEvent = core.RemovedLogsEvent -) - -var ( - ApplyTransaction = core.ApplyTransaction - // NewEVMTxContext creates a new context for use in the EVM. - NewEVMTxContext = core.NewEVMTxContext - // NewEVMBlockContext creates a new block context for a given header. - NewEVMBlockContext = core.NewEVMBlockContext -) - -var ( - // ErrInsufficientBalanceForGas is the error return when - // gas required to execute a transaction overflows. - ErrGasUintOverflow = core.ErrGasUintOverflow -) diff --git a/eth/core/mock/precompile_plugin.go b/eth/core/mock/precompile_plugin.go index 2cf24f5d6..0282a0e74 100644 --- a/eth/core/mock/precompile_plugin.go +++ b/eth/core/mock/precompile_plugin.go @@ -21,14 +21,14 @@ package mock import ( - "github.com/berachain/polaris/eth/core/vm" + "github.com/ethereum/go-ethereum/core/vm" ) //go:generate moq -out ./precompile_plugin.mock.go -pkg mock ../ PrecompilePlugin func NewPrecompilePluginMock() *PrecompilePluginMock { return &PrecompilePluginMock{ - RegisterFunc: func(pc vm.PrecompileContainer) error { + RegisterFunc: func(pc vm.PrecompiledContract) error { return nil }, } diff --git a/eth/core/precompile/base_contract.go b/eth/core/precompile/base_contract.go index 42faea5a6..449c10070 100644 --- a/eth/core/precompile/base_contract.go +++ b/eth/core/precompile/base_contract.go @@ -22,7 +22,8 @@ package precompile import ( "github.com/berachain/polaris/eth/accounts/abi" - "github.com/berachain/polaris/eth/common" + + "github.com/ethereum/go-ethereum/common" ) // ============================================================================== diff --git a/eth/core/precompile/default_plugin.go b/eth/core/precompile/default_plugin.go index 366f05a4b..714d71a2a 100644 --- a/eth/core/precompile/default_plugin.go +++ b/eth/core/precompile/default_plugin.go @@ -24,29 +24,30 @@ import ( "context" "math/big" - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/core/vm" - "github.com/berachain/polaris/eth/params" "github.com/berachain/polaris/lib/registry" libtypes "github.com/berachain/polaris/lib/types" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/params" ) // defaultPlugin is the default precompile plugin, should any chain running Polaris EVM not // implement their own precompile plugin. Notably, this plugin can only run the default stateless // precompiles provided by Go-Ethereum. type defaultPlugin struct { - libtypes.Registry[common.Address, vm.PrecompileContainer] + libtypes.Registry[common.Address, vm.PrecompiledContract] } // NewDefaultPlugin returns a new instance of the default precompile plugin. func NewDefaultPlugin() Plugin { return &defaultPlugin{ - Registry: registry.NewMap[common.Address, vm.PrecompileContainer](), + Registry: registry.NewMap[common.Address, vm.PrecompiledContract](), } } // Register is a no-op for the default plugin. -func (dp *defaultPlugin) Register(vm.PrecompileContainer) error { +func (dp *defaultPlugin) Register(vm.PrecompiledContract) error { // no-op return nil } @@ -64,7 +65,7 @@ func (dp *defaultPlugin) GetActive(_ params.Rules) []common.Address { // // Run implements core.PrecompilePlugin. func (dp *defaultPlugin) Run( - evm vm.PrecompileEVM, pc vm.PrecompileContainer, input []byte, + evm vm.PrecompileEVM, pc vm.PrecompiledContract, input []byte, caller common.Address, value *big.Int, suppliedGas uint64, _ bool, ) ([]byte, uint64, error) { gasCost := pc.RequiredGas(input) diff --git a/eth/core/precompile/factories.go b/eth/core/precompile/factories.go index 27383f2c1..a94b2dcd0 100644 --- a/eth/core/precompile/factories.go +++ b/eth/core/precompile/factories.go @@ -23,9 +23,10 @@ package precompile import ( "reflect" - "github.com/berachain/polaris/eth/core/vm" errorslib "github.com/berachain/polaris/lib/errors" "github.com/berachain/polaris/lib/utils" + + "github.com/ethereum/go-ethereum/core/vm" ) const ( @@ -37,7 +38,7 @@ const ( // AbstractFactory is an interface that all precompile container factories must adhere to. type AbstractFactory interface { // Build builds and returns the precompile container for the type of container/factory. - Build(Registrable, Plugin) (vm.PrecompileContainer, error) + Build(Registrable, Plugin) (vm.PrecompiledContract, error) } // Compile-time assertions to ensure these container factories adhere to `AbstractFactory`. @@ -64,7 +65,7 @@ func NewStatelessFactory() *StatelessFactory { // Build implements `AbstractFactory`. func (sf *StatelessFactory) Build( rp Registrable, _ Plugin, -) (vm.PrecompileContainer, error) { +) (vm.PrecompiledContract, error) { pc, ok := utils.GetAs[StatelessImpl](rp) if !ok { return nil, errorslib.Wrap(ErrWrongContainerFactory, statelessContainerName) @@ -90,7 +91,7 @@ func NewStatefulFactory() *StatefulFactory { // Build implements `AbstractFactory`. func (sf *StatefulFactory) Build( rp Registrable, p Plugin, -) (vm.PrecompileContainer, error) { +) (vm.PrecompiledContract, error) { si, ok := utils.GetAs[StatefulImpl](rp) if !ok { return nil, errorslib.Wrap(ErrWrongContainerFactory, statefulContainerName) diff --git a/eth/core/precompile/factories_test.go b/eth/core/precompile/factories_test.go index 85c64aabd..2486c7d8b 100644 --- a/eth/core/precompile/factories_test.go +++ b/eth/core/precompile/factories_test.go @@ -27,9 +27,11 @@ import ( solidity "github.com/berachain/polaris/contracts/bindings/testing" "github.com/berachain/polaris/eth/accounts/abi" - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/core/types" - "github.com/berachain/polaris/eth/core/vm" + pvm "github.com/berachain/polaris/eth/core/vm" + + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -164,7 +166,7 @@ func (ms *mockStateful) GetOutput( ctx context.Context, str string, ) ([]mockObject, error) { - vm.UnwrapPolarContext(ctx).Evm().GetStateDB().AddLog(&types.Log{Address: common.Address{0x1}}) + pvm.UnwrapPolarContext(ctx).Evm().GetStateDB().AddLog(ðtypes.Log{Address: common.Address{0x1}}) return []mockObject{ { CreationHeight: big.NewInt(1), diff --git a/eth/core/precompile/interfaces.go b/eth/core/precompile/interfaces.go index 9bc95e745..803dcac36 100644 --- a/eth/core/precompile/interfaces.go +++ b/eth/core/precompile/interfaces.go @@ -22,9 +22,10 @@ package precompile import ( "github.com/berachain/polaris/eth/accounts/abi" - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/core/vm" libtypes "github.com/berachain/polaris/lib/types" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" ) type ( @@ -35,7 +36,7 @@ type ( // PrecompileManager is the manager for the native precompiles. vm.PrecompileManager // Register registers a new precompiled contract at the given address. - Register(vm.PrecompileContainer) error + Register(vm.PrecompiledContract) error // EnableReentrancy enables the execution of a precompile contract to call back into the // EVM. @@ -59,7 +60,7 @@ type ( StatelessImpl interface { Registrable - vm.PrecompileContainer + vm.PrecompiledContract } // StatefulImpl is the interface for all stateful precompiled contracts, which must diff --git a/eth/core/precompile/method.go b/eth/core/precompile/method.go index 06157fac4..d247ac997 100644 --- a/eth/core/precompile/method.go +++ b/eth/core/precompile/method.go @@ -26,9 +26,10 @@ import ( "reflect" "github.com/berachain/polaris/eth/accounts/abi" - "github.com/berachain/polaris/eth/core/vm" errorslib "github.com/berachain/polaris/lib/errors" "github.com/berachain/polaris/lib/utils" + + "github.com/ethereum/go-ethereum/core/vm" ) // methodID is a fixed length byte array that represents the method ID of a precompile method. diff --git a/eth/core/precompile/method_test.go b/eth/core/precompile/method_test.go index 649396079..b4a4630d6 100644 --- a/eth/core/precompile/method_test.go +++ b/eth/core/precompile/method_test.go @@ -26,10 +26,11 @@ import ( "reflect" "github.com/berachain/polaris/eth/accounts/abi" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core/vm" vmmock "github.com/berachain/polaris/eth/core/vm/mock" + "github.com/ethereum/go-ethereum/common" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/eth/core/precompile/method_validation_test.go b/eth/core/precompile/method_validation_test.go index c9761397d..44bc4e662 100644 --- a/eth/core/precompile/method_validation_test.go +++ b/eth/core/precompile/method_validation_test.go @@ -27,7 +27,8 @@ import ( "github.com/berachain/polaris/contracts/bindings/testing" "github.com/berachain/polaris/eth/accounts/abi" - "github.com/berachain/polaris/eth/common" + + "github.com/ethereum/go-ethereum/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/eth/core/precompile/mock/stateful_impl.go b/eth/core/precompile/mock/stateful_impl.go index 3323256cb..a90f4ed6a 100644 --- a/eth/core/precompile/mock/stateful_impl.go +++ b/eth/core/precompile/mock/stateful_impl.go @@ -21,10 +21,10 @@ package mock import ( - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core/precompile" "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" ) //go:generate moq -out ./stateful_impl.mock.go -skip-ensure -pkg mock ../ StatefulImpl diff --git a/eth/core/precompile/stateful_container.go b/eth/core/precompile/stateful_container.go index 72a4c1dd6..807b6f849 100644 --- a/eth/core/precompile/stateful_container.go +++ b/eth/core/precompile/stateful_container.go @@ -24,14 +24,16 @@ import ( "context" "math/big" - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/core/vm" + pvm "github.com/berachain/polaris/eth/core/vm" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" ) // NumBytesMethodID is the number of bytes used to represent a ABI method's ID. const NumBytesMethodID = 4 -var _ vm.PrecompileContainer = (*statefulContainer)(nil) +var _ vm.PrecompiledContract = (*statefulContainer)(nil) // statefulContainer is a container for running statefulContainer and precompiled contracts. type statefulContainer struct { @@ -51,7 +53,7 @@ type statefulContainer struct { // precompile functions map. func NewStatefulContainer( si StatefulImpl, idsToMethods map[methodID]*method, -) (vm.PrecompileContainer, error) { +) (vm.PrecompiledContract, error) { if idsToMethods == nil { return nil, ErrContainerHasNoMethods } @@ -84,7 +86,7 @@ func (sc *statefulContainer) Run( // Execute the method with the reflected ctx and raw input return method.Call( - vm.NewPolarContext(ctx, evm, caller, value), + pvm.NewPolarContext(ctx, evm, caller, value), input, ) } diff --git a/eth/core/precompile/stateful_container_test.go b/eth/core/precompile/stateful_container_test.go index 0253427e2..2e8231666 100644 --- a/eth/core/precompile/stateful_container_test.go +++ b/eth/core/precompile/stateful_container_test.go @@ -26,17 +26,19 @@ import ( "reflect" solidity "github.com/berachain/polaris/contracts/bindings/testing" - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/core/vm" + pvm "github.com/berachain/polaris/eth/core/vm" vmmock "github.com/berachain/polaris/eth/core/vm/mock" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) var _ = Describe("Stateful Container", func() { - var sc vm.PrecompileContainer - var empty vm.PrecompileContainer + var sc vm.PrecompiledContract + var empty vm.PrecompiledContract var blank []byte var badInput = []byte{1, 2, 3, 4} var err error @@ -48,7 +50,7 @@ var _ = Describe("Stateful Container", func() { empty, err = NewStatefulContainer(nil, nil) Expect(empty).To(BeNil()) Expect(err).To(MatchError("the stateful precompile has no methods to run")) - ctx = vm.NewPolarContext( + ctx = pvm.NewPolarContext( context.Background(), vmmock.NewEVM(), common.Address{}, @@ -72,38 +74,38 @@ var _ = Describe("Stateful Container", func() { // invalid input _, err = sc.Run( ctx, - vm.UnwrapPolarContext(ctx).Evm(), + pvm.UnwrapPolarContext(ctx).Evm(), blank, - vm.UnwrapPolarContext(ctx).MsgSender(), - vm.UnwrapPolarContext(ctx).MsgValue(), + pvm.UnwrapPolarContext(ctx).MsgSender(), + pvm.UnwrapPolarContext(ctx).MsgValue(), ) Expect(err).To(MatchError("input bytes to precompile container are invalid")) // method not found _, err = sc.Run( ctx, - vm.UnwrapPolarContext(ctx).Evm(), - badInput, vm.UnwrapPolarContext(ctx).MsgSender(), - vm.UnwrapPolarContext(ctx).MsgValue(), + pvm.UnwrapPolarContext(ctx).Evm(), + badInput, pvm.UnwrapPolarContext(ctx).MsgSender(), + pvm.UnwrapPolarContext(ctx).MsgValue(), ) Expect(err).To(MatchError("precompile method not found in contract ABI")) // geth unpacking error _, err = sc.Run(ctx, - vm.UnwrapPolarContext(ctx).Evm(), + pvm.UnwrapPolarContext(ctx).Evm(), append(getOutputABI.ID, byte(1), byte(2)), - vm.UnwrapPolarContext(ctx).MsgSender(), - vm.UnwrapPolarContext(ctx).MsgValue(), + pvm.UnwrapPolarContext(ctx).MsgSender(), + pvm.UnwrapPolarContext(ctx).MsgValue(), ) Expect(err).To(HaveOccurred()) // precompile exec error _, err = sc.Run( ctx, - vm.UnwrapPolarContext(ctx).Evm(), + pvm.UnwrapPolarContext(ctx).Evm(), getOutputPartialABI.ID, - vm.UnwrapPolarContext(ctx).MsgSender(), - vm.UnwrapPolarContext(ctx).MsgValue(), + pvm.UnwrapPolarContext(ctx).MsgSender(), + pvm.UnwrapPolarContext(ctx).MsgValue(), ) //nolint:lll // error message. Expect(err.Error()).To(Equal( @@ -118,10 +120,10 @@ var _ = Describe("Stateful Container", func() { var ret []byte ret, err = sc.Run( ctx, - vm.UnwrapPolarContext(ctx).Evm(), + pvm.UnwrapPolarContext(ctx).Evm(), append(getOutputABI.ID, inputs...), - vm.UnwrapPolarContext(ctx).MsgSender(), - vm.UnwrapPolarContext(ctx).MsgValue(), + pvm.UnwrapPolarContext(ctx).MsgSender(), + pvm.UnwrapPolarContext(ctx).MsgValue(), ) Expect(err).ToNot(HaveOccurred()) var outputs []interface{} diff --git a/eth/core/state/interfaces.go b/eth/core/state/interfaces.go index 83d6a8360..032e22bb2 100644 --- a/eth/core/state/interfaces.go +++ b/eth/core/state/interfaces.go @@ -24,8 +24,9 @@ import ( "context" "math/big" - "github.com/berachain/polaris/eth/common" libtypes "github.com/berachain/polaris/lib/types" + + "github.com/ethereum/go-ethereum/common" ) // Plugin is a plugin which tracks the accounts (balances, nonces, codes, states) in the native diff --git a/eth/core/state/journal/access_list.go b/eth/core/state/journal/access_list.go index 74d766751..4879533f9 100644 --- a/eth/core/state/journal/access_list.go +++ b/eth/core/state/journal/access_list.go @@ -21,9 +21,11 @@ package journal import ( - "github.com/berachain/polaris/eth/common" libtypes "github.com/berachain/polaris/lib/types" "github.com/berachain/polaris/lib/utils" + + "github.com/ethereum/go-ethereum/common" + ethstate "github.com/ethereum/go-ethereum/core/state" ) type Accesslist interface { @@ -43,13 +45,13 @@ type Accesslist interface { // accessList is a `baseJournal` that tracks the access list. type accessList struct { - baseJournal[*AccessList] // journal of access lists. + baseJournal[*ethstate.AccessList] // journal of access lists. } // NewAccesslist returns a new `accessList` journal. func NewAccesslist() Accesslist { - journal := newBaseJournal[*AccessList](initCapacity) - journal.Push(NewAccessList()) + journal := newBaseJournal[*ethstate.AccessList](initCapacity) + journal.Push(ethstate.NewAccessList()) return &accessList{ baseJournal: journal, } @@ -97,7 +99,7 @@ func (al *accessList) Finalize() { // Clone implements `libtypes.Cloneable`. func (al *accessList) Clone() Accesslist { cpy := &accessList{ - baseJournal: newBaseJournal[*AccessList](al.Capacity()), + baseJournal: newBaseJournal[*ethstate.AccessList](al.Capacity()), } for i := 0; i < al.Size(); i++ { // skip the root, already pushed above diff --git a/eth/core/state/journal/access_list_test.go b/eth/core/state/journal/access_list_test.go index d5fe18723..471e7d24d 100644 --- a/eth/core/state/journal/access_list_test.go +++ b/eth/core/state/journal/access_list_test.go @@ -21,9 +21,10 @@ package journal import ( - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/lib/utils" + "github.com/ethereum/go-ethereum/common" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/eth/core/state/journal/imported.go b/eth/core/state/journal/imported.go deleted file mode 100644 index 7a814908a..000000000 --- a/eth/core/state/journal/imported.go +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -// -// Copyright (C) 2023, Berachain Foundation. All rights reserved. -// Use of this software is govered by the Business Source License included -// in the LICENSE file of this repository and at www.mariadb.com/bsl11. -// -// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY -// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER -// VERSIONS OF THE LICENSED WORK. -// -// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF -// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF -// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). -// -// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, -// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND -// TITLE. - -package journal - -import "github.com/ethereum/go-ethereum/core/state" - -type ( - AccessList = state.AccessList -) - -var ( - NewAccessList = state.NewAccessList -) diff --git a/eth/core/state/journal/logs.go b/eth/core/state/journal/logs.go index 3f0ff7178..995043eff 100644 --- a/eth/core/state/journal/logs.go +++ b/eth/core/state/journal/logs.go @@ -21,9 +21,10 @@ package journal import ( - "github.com/berachain/polaris/eth/common" - coretypes "github.com/berachain/polaris/eth/core/types" libtypes "github.com/berachain/polaris/lib/types" + + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" ) // Log defines the interface for tracking logs created during a state transition. @@ -37,16 +38,16 @@ type Log interface { // TxIndex returns the current transaction index. TxIndex() int // AddLog adds a log to the logs journal. - AddLog(*coretypes.Log) + AddLog(*ethtypes.Log) // Logs returns the logs of the tx with the exisiting metadata. - Logs() []*coretypes.Log + Logs() []*ethtypes.Log // GetLogs returns the logs of the tx with the given metadata. - GetLogs(hash common.Hash, blockNumber uint64, blockHash common.Hash) []*coretypes.Log + GetLogs(hash common.Hash, blockNumber uint64, blockHash common.Hash) []*ethtypes.Log } // logs is a state plugin that tracks Ethereum logs. type logs struct { - baseJournal[*coretypes.Log] + baseJournal[*ethtypes.Log] txHash common.Hash txIndex int logSize int @@ -55,7 +56,7 @@ type logs struct { // NewLogs returns a new `logs` journal. func NewLogs() Log { return &logs{ - baseJournal: newBaseJournal[*coretypes.Log](initCapacity), + baseJournal: newBaseJournal[*ethtypes.Log](initCapacity), } } @@ -66,7 +67,7 @@ func (l *logs) RegistryKey() string { // SetTxContext sets the transaction hash and index for the current transaction. func (l *logs) SetTxContext(thash common.Hash, ti int) { - l.baseJournal = newBaseJournal[*coretypes.Log](initCapacity) + l.baseJournal = newBaseJournal[*ethtypes.Log](initCapacity) // Set the transaction hash and index. l.txHash = thash l.txIndex = ti @@ -78,7 +79,7 @@ func (l *logs) TxIndex() int { } // AddLog adds a log to the `Logs` store. -func (l *logs) AddLog(log *coretypes.Log) { +func (l *logs) AddLog(log *ethtypes.Log) { log.TxHash = l.txHash log.TxIndex = uint(l.txIndex) log.Index = uint(l.logSize) + uint(l.Size()) @@ -86,9 +87,9 @@ func (l *logs) AddLog(log *coretypes.Log) { } // Logs returns the logs for the current tx with the existing metadata. -func (l *logs) Logs() []*coretypes.Log { +func (l *logs) Logs() []*ethtypes.Log { size := l.Size() - buf := make([]*coretypes.Log, size) + buf := make([]*ethtypes.Log, size) for i := 0; i < size; i++ { buf[i] = l.PeekAt(i) } @@ -96,9 +97,9 @@ func (l *logs) Logs() []*coretypes.Log { } // GetLogs returns the logs for the tx with the given metadata. -func (l *logs) GetLogs(_ common.Hash, blockNumber uint64, blockHash common.Hash) []*coretypes.Log { +func (l *logs) GetLogs(_ common.Hash, blockNumber uint64, blockHash common.Hash) []*ethtypes.Log { size := l.Size() - buf := make([]*coretypes.Log, size) + buf := make([]*ethtypes.Log, size) for i := 0; i < size; i++ { buf[i] = l.PeekAt(i) buf[i].BlockHash = blockHash @@ -119,7 +120,7 @@ func (l *logs) Finalize() { // Clone implements `libtypes.Cloneable`. func (l *logs) Clone() Log { clone := &logs{ - baseJournal: newBaseJournal[*coretypes.Log](l.Capacity()), + baseJournal: newBaseJournal[*ethtypes.Log](l.Capacity()), txHash: l.txHash, txIndex: l.txIndex, logSize: l.logSize, @@ -127,7 +128,7 @@ func (l *logs) Clone() Log { // copy every individual log from the journal for i := 0; i < l.Size(); i++ { - cpy := new(coretypes.Log) + cpy := new(ethtypes.Log) *cpy = *l.PeekAt(i) clone.Push(cpy) } diff --git a/eth/core/state/journal/logs_test.go b/eth/core/state/journal/logs_test.go index cb8bb0217..cce6a1159 100644 --- a/eth/core/state/journal/logs_test.go +++ b/eth/core/state/journal/logs_test.go @@ -21,10 +21,11 @@ package journal import ( - "github.com/berachain/polaris/eth/common" - coretypes "github.com/berachain/polaris/eth/core/types" "github.com/berachain/polaris/lib/utils" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -51,7 +52,7 @@ var _ = Describe("Logs", func() { When("adding logs", func() { BeforeEach(func() { - l.AddLog(&coretypes.Log{Address: a1}) + l.AddLog(ðtypes.Log{Address: a1}) Expect(l.Size()).To(Equal(1)) Expect(l.PeekAt(0).Address).To(Equal(a1)) Expect(l.PeekAt(0).TxHash).To(Equal(thash)) @@ -61,7 +62,7 @@ var _ = Describe("Logs", func() { It("should correctly snapshot and revert", func() { id := l.Snapshot() - l.AddLog(&coretypes.Log{Address: a2}) + l.AddLog(ðtypes.Log{Address: a2}) Expect(l.Size()).To(Equal(2)) Expect(l.PeekAt(1).Address).To(Equal(a2)) @@ -87,7 +88,7 @@ var _ = Describe("Logs", func() { }) It("should correctly clone", func() { - l.AddLog(&coretypes.Log{Address: a2}) + l.AddLog(ðtypes.Log{Address: a2}) Expect(l.Size()).To(Equal(2)) Expect(l.PeekAt(1).Address).To(Equal(a2)) @@ -96,7 +97,7 @@ var _ = Describe("Logs", func() { Expect(l2.PeekAt(0).Address).To(Equal(a1)) Expect(l2.PeekAt(1).Address).To(Equal(a2)) - l2.AddLog(&coretypes.Log{Address: a3}) + l2.AddLog(ðtypes.Log{Address: a3}) Expect(l2.Size()).To(Equal(3)) Expect(l2.PeekAt(2).Address).To(Equal(a3)) Expect(l.Size()).To(Equal(2)) diff --git a/eth/core/state/journal/mock/state_plugin.go b/eth/core/state/journal/mock/state_plugin.go index 412b5361f..0234ef458 100644 --- a/eth/core/state/journal/mock/state_plugin.go +++ b/eth/core/state/journal/mock/state_plugin.go @@ -23,7 +23,7 @@ package mock import ( "math/big" - "github.com/berachain/polaris/eth/common" + "github.com/ethereum/go-ethereum/common" ) //go:generate moq -out ./state_plugin.mock.go -skip-ensure -pkg mock ../ selfDestructStatePlugin diff --git a/eth/core/state/journal/selfdestruct_test.go b/eth/core/state/journal/selfdestruct_test.go index bcb922cea..e4960c65b 100644 --- a/eth/core/state/journal/selfdestruct_test.go +++ b/eth/core/state/journal/selfdestruct_test.go @@ -21,10 +21,11 @@ package journal import ( - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core/state/journal/mock" "github.com/berachain/polaris/lib/utils" + "github.com/ethereum/go-ethereum/common" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/eth/core/state/journal/selfdestructs.go b/eth/core/state/journal/selfdestructs.go index 7a6a4fbe2..b9e2425b4 100644 --- a/eth/core/state/journal/selfdestructs.go +++ b/eth/core/state/journal/selfdestructs.go @@ -23,10 +23,11 @@ package journal import ( "math/big" - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/crypto" libtypes "github.com/berachain/polaris/lib/types" "github.com/berachain/polaris/lib/utils" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" ) // emptyCodeHash is the Keccak256 Hash of empty code diff --git a/eth/core/state/journal/transient_storage_test.go b/eth/core/state/journal/transient_storage_test.go index 66eb51e29..c1b236066 100644 --- a/eth/core/state/journal/transient_storage_test.go +++ b/eth/core/state/journal/transient_storage_test.go @@ -21,9 +21,10 @@ package journal import ( - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/lib/utils" + "github.com/ethereum/go-ethereum/common" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) diff --git a/eth/core/state/mock/state.go b/eth/core/state/mock/state.go index 1c4e2e56f..b875737f4 100644 --- a/eth/core/state/mock/state.go +++ b/eth/core/state/mock/state.go @@ -23,9 +23,10 @@ package mock import ( "math/big" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core/state" - "github.com/berachain/polaris/eth/crypto" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" ) //go:generate moq -out ./state.mock.go -skip-ensure -pkg mock ../ Plugin diff --git a/eth/core/state/statedb.go b/eth/core/state/statedb.go index d873ec58f..7fa5aa206 100644 --- a/eth/core/state/statedb.go +++ b/eth/core/state/statedb.go @@ -23,15 +23,15 @@ package state import ( "context" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core/precompile" "github.com/berachain/polaris/eth/core/state/journal" - coretypes "github.com/berachain/polaris/eth/core/types" - "github.com/berachain/polaris/eth/params" "github.com/berachain/polaris/lib/snapshot" libtypes "github.com/berachain/polaris/lib/types" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" ) // For mocks. @@ -169,7 +169,7 @@ func (sdb *stateDB) Commit(_ uint64, _ bool) (common.Hash, error) { // // Prepare implements vm.PolarStateDB. func (sdb *stateDB) Prepare(rules params.Rules, sender, coinbase common.Address, - dest *common.Address, precompiles []common.Address, txAccesses coretypes.AccessList, + dest *common.Address, precompiles []common.Address, txAccesses ethtypes.AccessList, ) { copyRules := rules sdb.rules = ©Rules diff --git a/eth/core/state/statedb_test.go b/eth/core/state/statedb_test.go index 153784368..66697970e 100644 --- a/eth/core/state/statedb_test.go +++ b/eth/core/state/statedb_test.go @@ -27,12 +27,13 @@ import ( tmock "github.com/stretchr/testify/mock" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/core/state" "github.com/berachain/polaris/eth/core/state/mock" "github.com/berachain/polaris/eth/core/state/mocks" - coretypes "github.com/berachain/polaris/eth/core/types" - "github.com/berachain/polaris/eth/params" + + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -87,8 +88,8 @@ var _ = Describe("StateDB", func() { params.Rules{IsBerlin: true, IsShanghai: true}, alice, bob, &common.Address{3}, []common.Address{{4}}, - coretypes.AccessList{ - coretypes.AccessTuple{ + ethtypes.AccessList{ + ethtypes.AccessTuple{ Address: common.Address{5}, StorageKeys: []common.Hash{{2}, {3}}, }, diff --git a/eth/core/types/header.go b/eth/core/types/header.go index d8bf9b1ed..d5f9ed9a1 100644 --- a/eth/core/types/header.go +++ b/eth/core/types/header.go @@ -20,16 +20,19 @@ package types -import "github.com/ethereum/go-ethereum/rlp" +import ( + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rlp" +) // MarshalHeader marshals a header, as type `Header`, to bytes using rlp encoding. -func MarshalHeader(header *Header) ([]byte, error) { +func MarshalHeader(header *ethtypes.Header) ([]byte, error) { return rlp.EncodeToBytes(header) } // UnmarshalHeader unmarshals a header from bytes to `Header` using rlp decoding. -func UnmarshalHeader(data []byte) (*Header, error) { - header := &Header{} +func UnmarshalHeader(data []byte) (*ethtypes.Header, error) { + header := ðtypes.Header{} err := rlp.DecodeBytes(data, header) return header, err } diff --git a/eth/core/types/imported.go b/eth/core/types/imported.go deleted file mode 100644 index f998461c9..000000000 --- a/eth/core/types/imported.go +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -// -// Copyright (C) 2023, Berachain Foundation. All rights reserved. -// Use of this software is govered by the Business Source License included -// in the LICENSE file of this repository and at www.mariadb.com/bsl11. -// -// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY -// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER -// VERSIONS OF THE LICENSED WORK. -// -// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF -// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF -// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). -// -// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, -// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND -// TITLE. - -package types - -import ( - "github.com/ethereum/go-ethereum/core/types" -) - -type ( - AccessList = types.AccessList - AccessTuple = types.AccessTuple - Block = types.Block - Blocks = types.Blocks - Bloom = types.Bloom - Body = types.Body - Log = types.Log - Receipt = types.Receipt - Receipts = types.Receipts - ReceiptForStorage = types.ReceiptForStorage - Transaction = types.Transaction - Transactions = types.Transactions - Header = types.Header - BlockNonce = types.BlockNonce - DynamicFeeTx = types.DynamicFeeTx - AccessListTx = types.AccessListTx - LegacyTx = types.LegacyTx - TxData = types.TxData - Signer = types.Signer - Withdrawal = types.Withdrawal - Withdrawals = types.Withdrawals -) - -var ( - NewLondonSigner = types.NewLondonSigner - MakeSigner = types.MakeSigner - SignTx = types.SignTx - Sender = types.Sender - NewTx = types.NewTx - NewTransaction = types.NewTransaction - LatestSignerForChainID = types.LatestSignerForChainID - SignNewTx = types.SignNewTx - MustSignNewTx = types.MustSignNewTx - NewBlock = types.NewBlock - NewBlockWithHeader = types.NewBlockWithHeader -) diff --git a/eth/core/types/receipts.go b/eth/core/types/receipts.go index 762ff0c8d..42aa1dc7f 100644 --- a/eth/core/types/receipts.go +++ b/eth/core/types/receipts.go @@ -24,17 +24,16 @@ import ( "math/big" "unsafe" - "github.com/berachain/polaris/eth/params" - "github.com/ethereum/go-ethereum/consensus/misc/eip4844" - "github.com/ethereum/go-ethereum/core/types" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" ) // DeriveReceiptsFromBlock is a helper function for deriving receipts from a block. func DeriveReceiptsFromBlock( - chainConfig *params.ChainConfig, receipts types.Receipts, block *types.Block, -) (types.Receipts, error) { + chainConfig *params.ChainConfig, receipts ethtypes.Receipts, block *ethtypes.Block, +) (ethtypes.Receipts, error) { // calculate the blobGasPrice according to the excess blob gas. var blobGasPrice = new(big.Int) if chainConfig.IsCancun(block.Number(), block.Time()) { @@ -53,9 +52,9 @@ func DeriveReceiptsFromBlock( // MarshalReceipts marshals `Receipts`, as type `[]*ReceiptForStorage`, to bytes using rlp // encoding. -func MarshalReceipts(receipts Receipts) ([]byte, error) { +func MarshalReceipts(receipts ethtypes.Receipts) ([]byte, error) { //#nosec:G103 unsafe pointer is safe here since `ReceiptForStorage` is an alias of `Receipt`. - receiptsForStorage := *(*[]*ReceiptForStorage)(unsafe.Pointer(&receipts)) + receiptsForStorage := *(*[]*ethtypes.ReceiptForStorage)(unsafe.Pointer(&receipts)) bz, err := rlp.EncodeToBytes(receiptsForStorage) if err != nil { @@ -66,11 +65,11 @@ func MarshalReceipts(receipts Receipts) ([]byte, error) { // UnmarshalReceipts unmarshals receipts from bytes to `[]*ReceiptForStorage` to `Receipts` using // rlp decoding. -func UnmarshalReceipts(bz []byte) (Receipts, error) { - var receiptsForStorage []*ReceiptForStorage +func UnmarshalReceipts(bz []byte) (ethtypes.Receipts, error) { + var receiptsForStorage []*ethtypes.ReceiptForStorage if err := rlp.DecodeBytes(bz, &receiptsForStorage); err != nil { return nil, err } //#nosec:G103 unsafe pointer is safe here since `ReceiptForStorage` is an alias of `Receipt`. - return *(*Receipts)(unsafe.Pointer(&receiptsForStorage)), nil + return *(*ethtypes.Receipts)(unsafe.Pointer(&receiptsForStorage)), nil } diff --git a/eth/core/types/transaction.go b/eth/core/types/transaction.go index 7efb24c99..2e1fbd7db 100644 --- a/eth/core/types/transaction.go +++ b/eth/core/types/transaction.go @@ -21,8 +21,8 @@ package types import ( - "github.com/berachain/polaris/eth/common" - + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rlp" ) @@ -30,7 +30,7 @@ import ( // //go:generate rlpgen -type TxLookupEntry -out transaction.rlpgen.go -decoder type TxLookupEntry struct { - Tx *Transaction + Tx *ethtypes.Transaction TxIndex uint64 BlockNum uint64 BlockHash common.Hash diff --git a/eth/core/vm/context.go b/eth/core/vm/context.go index 382054bef..7ce9f42fd 100644 --- a/eth/core/vm/context.go +++ b/eth/core/vm/context.go @@ -25,8 +25,10 @@ import ( "math/big" "time" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/lib/utils" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" ) // ContextKey defines a type alias for a stdlib Context key. @@ -41,7 +43,7 @@ var _ context.Context = (*PolarContext)(nil) // Context is the context for a Polaris EVM execution. type PolarContext struct { baseCtx context.Context - evm PrecompileEVM + evm vm.PrecompileEVM msgSender common.Address msgValue *big.Int } @@ -49,7 +51,7 @@ type PolarContext struct { // NewPolarContext creates a new PolarContext given an EVM call request. func NewPolarContext( baseCtx context.Context, - evm PrecompileEVM, + evm vm.PrecompileEVM, msgSender common.Address, msgValue *big.Int, ) *PolarContext { @@ -69,7 +71,7 @@ func (c *PolarContext) Context() context.Context { return c.baseCtx } -func (c *PolarContext) Evm() PrecompileEVM { +func (c *PolarContext) Evm() vm.PrecompileEVM { return c.evm } @@ -81,7 +83,7 @@ func (c *PolarContext) MsgValue() *big.Int { return c.msgValue } -func (c *PolarContext) Block() *BlockContext { +func (c *PolarContext) Block() *vm.BlockContext { return c.evm.GetContext() } diff --git a/eth/core/vm/imported.go b/eth/core/vm/imported.go deleted file mode 100644 index b9b0bde77..000000000 --- a/eth/core/vm/imported.go +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -// -// Copyright (C) 2023, Berachain Foundation. All rights reserved. -// Use of this software is govered by the Business Source License included -// in the LICENSE file of this repository and at www.mariadb.com/bsl11. -// -// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY -// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER -// VERSIONS OF THE LICENSED WORK. -// -// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF -// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF -// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). -// -// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, -// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND -// TITLE. - -package vm - -import ( - "github.com/ethereum/go-ethereum/core/vm" -) - -type ( - AccountRef = vm.AccountRef - BlockContext = vm.BlockContext - Config = vm.Config - EVM = vm.EVM - StateDB = vm.StateDB - PrecompileContainer = vm.PrecompiledContract - PrecompileManager = vm.PrecompileManager - PrecompileEVM = vm.PrecompileEVM - TxContext = vm.TxContext - PrecompiledContract = vm.PrecompiledContract -) - -var ( - NewEVM = vm.NewEVM - ErrOutOfGas = vm.ErrOutOfGas - ErrExecutionReverted = vm.ErrExecutionReverted - ErrWriteProtection = vm.ErrWriteProtection -) diff --git a/eth/core/vm/interfaces.go b/eth/core/vm/interfaces.go index 172f8e17e..f8d3e9772 100644 --- a/eth/core/vm/interfaces.go +++ b/eth/core/vm/interfaces.go @@ -22,6 +22,8 @@ package vm import ( "context" + + "github.com/ethereum/go-ethereum/core/vm" ) type ( @@ -29,7 +31,7 @@ type ( // additional state transition functionalities. PolarStateDB interface { // StateDB represents vm.StateDB - StateDB + vm.StateDB // GetContext returns the current context of the state plugin. GetContext() context.Context } diff --git a/eth/core/vm/mock/evm.go b/eth/core/vm/mock/evm.go index f7a974547..f9cfe09a4 100644 --- a/eth/core/vm/mock/evm.go +++ b/eth/core/vm/mock/evm.go @@ -23,7 +23,7 @@ package mock import ( "math/big" - "github.com/berachain/polaris/eth/core/vm" + "github.com/ethereum/go-ethereum/core/vm" ) //go:generate moq -out ./evm.mock.go -skip-ensure -pkg mock ../ PrecompileEVM diff --git a/eth/core/vm/mock/statedb.go b/eth/core/vm/mock/statedb.go index e8a883dd6..c53e19a73 100644 --- a/eth/core/vm/mock/statedb.go +++ b/eth/core/vm/mock/statedb.go @@ -23,9 +23,8 @@ package mock import ( "math/big" - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/core/types" - + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" ) @@ -40,7 +39,7 @@ func NewEmptyStateDB() *PolarStateDBMock { AddBalanceFunc: func(address common.Address, intMoqParam *big.Int) { }, - AddLogFunc: func(log *types.Log) { + AddLogFunc: func(log *ethtypes.Log) { }, AddPreimageFunc: func(hash common.Hash, bytes []byte) { @@ -90,7 +89,7 @@ func NewEmptyStateDB() *PolarStateDBMock { }, PrepareFunc: func(rules params.Rules, sender common.Address, coinbase common.Address, dest *common.Address, - precompiles []common.Address, txAccesses types.AccessList, + precompiles []common.Address, txAccesses ethtypes.AccessList, ) { // no-op }, diff --git a/eth/crypto/imported.go b/eth/crypto/imported.go deleted file mode 100644 index 703c7498a..000000000 --- a/eth/crypto/imported.go +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -// -// Copyright (C) 2023, Berachain Foundation. All rights reserved. -// Use of this software is govered by the Business Source License included -// in the LICENSE file of this repository and at www.mariadb.com/bsl11. -// -// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY -// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER -// VERSIONS OF THE LICENSED WORK. -// -// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF -// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF -// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). -// -// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, -// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND -// TITLE. - -package crypto - -import ( - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/crypto/secp256k1" -) - -var ( - SigToPub = crypto.SigToPub - Ecrecover = crypto.Ecrecover - CreateAddress = crypto.CreateAddress - UnmarshalPubkey = crypto.UnmarshalPubkey - CompressPubkey = crypto.CompressPubkey - DecompressPubkey = crypto.DecompressPubkey - DigestLength = crypto.DigestLength - EthSign = crypto.Sign - EthSecp256k1Sign = secp256k1.Sign - LoadECDSA = crypto.LoadECDSA - FromECDSA = crypto.FromECDSA - GenerateEthKey = crypto.GenerateKey - ValidateSignatureValues = crypto.ValidateSignatureValues - Keccak256 = crypto.Keccak256 - Keccak256Hash = crypto.Keccak256Hash - PubkeyToAddress = crypto.PubkeyToAddress - SignatureLength = crypto.SignatureLength - ToECDSA = crypto.ToECDSA - VerifySignature = crypto.VerifySignature - FromECDSAPub = crypto.FromECDSAPub -) diff --git a/eth/eth.go b/eth/eth.go index 6feb8e768..afa404fc2 100644 --- a/eth/eth.go +++ b/eth/eth.go @@ -24,18 +24,19 @@ import ( "fmt" "net/http" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/consensus" - "github.com/berachain/polaris/eth/core" - coretypes "github.com/berachain/polaris/eth/core/types" - "github.com/berachain/polaris/eth/log" + pcore "github.com/berachain/polaris/eth/core" "github.com/berachain/polaris/eth/node" "github.com/berachain/polaris/eth/polar" - "github.com/berachain/polaris/eth/rpc" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/txpool" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/miner" + "github.com/ethereum/go-ethereum/rpc" ) type ( @@ -48,7 +49,7 @@ type ( // TxPool represents the `TxPool` that exists on the backend of the execution layer. TxPool interface { - Add([]*coretypes.Transaction, bool, bool) []error + Add([]*ethtypes.Transaction, bool, bool) []error Stats() (int, int) SubscribeTransactions(ch chan<- core.NewTxsEvent, reorgs bool) event.Subscription Status(hash common.Hash) txpool.TxStatus @@ -95,11 +96,11 @@ type ( // It takes a client type, configuration, host chain, consensus engine, and log handler // as parameters. It returns a pointer to the ExecutionLayer and an error if any. func New( - client string, cfg any, host core.PolarisHostChain, + client string, cfg any, host pcore.PolarisHostChain, engine consensus.Engine, logHandler log.Handler, ) (*ExecutionLayer, error) { clientFactories := map[string]func( - any, core.PolarisHostChain, consensus.Engine, log.Handler, + any, pcore.PolarisHostChain, consensus.Engine, log.Handler, ) (*ExecutionLayer, error){ "geth": newGethExecutionLayer, } @@ -115,7 +116,7 @@ func New( // newGethExecutionLayer creates a new geth execution layer. // It returns a pointer to the ExecutionLayer and an error if any. func newGethExecutionLayer( - anyCfg any, host core.PolarisHostChain, + anyCfg any, host pcore.PolarisHostChain, engine consensus.Engine, logHandler log.Handler, ) (*ExecutionLayer, error) { cfg, ok := anyCfg.(*Config) @@ -176,6 +177,6 @@ func (el *ExecutionLayer) TxPool() TxPool { } // Blockchain returns the blockchain interface of the backend of the execution layer. -func (el *ExecutionLayer) Blockchain() core.Blockchain { +func (el *ExecutionLayer) Blockchain() pcore.Blockchain { return el.backend.Blockchain() } diff --git a/eth/log/imported.go b/eth/log/imported.go deleted file mode 100644 index 3759c7c57..000000000 --- a/eth/log/imported.go +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -// -// Copyright (C) 2023, Berachain Foundation. All rights reserved. -// Use of this software is govered by the Business Source License included -// in the LICENSE file of this repository and at www.mariadb.com/bsl11. -// -// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY -// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER -// VERSIONS OF THE LICENSED WORK. -// -// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF -// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF -// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). -// -// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, -// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND -// TITLE. - -package log - -import "github.com/ethereum/go-ethereum/log" - -type ( - // Record is a log record. - Record = log.Record - - // Logger defines the logger interface. - Logger = log.Logger - - // Handler defines the log handler interface. - Handler = log.Handler -) - -var ( - // Root is the root logger. - Root = log.Root - - // LvlTrace is the trace log level. - LvlTrace = log.LvlTrace - - // LvlDebug is the debug log level. - LvlDebug = log.LvlDebug - - // LvlInfo is the info log level. - LvlInfo = log.LvlInfo - - // LvlWarn is the warn log level. - LvlWarn = log.LvlWarn - - // LvlError is the error log level. - LvlError = log.LvlError - - // LvlCrit is the critical log level. - LvlCrit = log.LvlCrit - - // FuncHandler is the function handler for overriding the logging method within - // the go-ethereum codebase. - FuncHandler = log.FuncHandler - - // Warn is the warning log level. - Warn = log.Warn - - Error = log.Error -) diff --git a/eth/params/chain_config.go b/eth/params/chain_config.go index 038e1e898..be3d258c1 100644 --- a/eth/params/chain_config.go +++ b/eth/params/chain_config.go @@ -22,13 +22,15 @@ package params import ( "math/big" + + "github.com/ethereum/go-ethereum/params" ) const DefaultEIP155ChainID = 2061 var zero = uint64(0) -var DefaultChainConfig = &ChainConfig{ +var DefaultChainConfig = ¶ms.ChainConfig{ ChainID: big.NewInt(DefaultEIP155ChainID), HomesteadBlock: big.NewInt(0), DAOForkBlock: big.NewInt(0), diff --git a/eth/params/imported.go b/eth/params/imported.go deleted file mode 100644 index ad3d10f97..000000000 --- a/eth/params/imported.go +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -// -// Copyright (C) 2023, Berachain Foundation. All rights reserved. -// Use of this software is govered by the Business Source License included -// in the LICENSE file of this repository and at www.mariadb.com/bsl11. -// -// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY -// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER -// VERSIONS OF THE LICENSED WORK. -// -// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF -// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF -// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). -// -// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, -// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND -// TITLE. - -package params - -import "github.com/ethereum/go-ethereum/params" - -type ( - // ChainConfig is the chain parameters config. - ChainConfig = params.ChainConfig - // Rules is the chain rules. - Rules = params.Rules -) - -var ( - // VersionWithMeta holds the textual version string including the metadata. - VersionWithMeta = params.VersionWithMeta - // VersionWithCommit holds the textual version string including the commit hash. - VersionWithCommit = params.VersionWithCommit - // InitialBaseFee is the initial base fee for the first block of the chain. - InitialBaseFee = params.InitialBaseFee -) diff --git a/eth/polar/api/imported.go b/eth/polar/api/imported.go deleted file mode 100644 index 984194e52..000000000 --- a/eth/polar/api/imported.go +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -// -// Copyright (C) 2023, Berachain Foundation. All rights reserved. -// Use of this software is govered by the Business Source License included -// in the LICENSE file of this repository and at www.mariadb.com/bsl11. -// -// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY -// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER -// VERSIONS OF THE LICENSED WORK. -// -// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF -// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF -// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). -// -// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, -// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND -// TITLE. - -package polarapi - -import ( - "github.com/ethereum/go-ethereum/ethapi" -) - -type ( - EthBackend = ethapi.Backend -) - -var ( - GethAPIs = ethapi.GetAPIs - NewEthereumAPI = ethapi.NewEthereumAPI - NewBlockChainAPI = ethapi.NewBlockChainAPI - NewTransactionAPI = ethapi.NewTransactionAPI - NewTxPoolAPI = ethapi.NewTxPoolAPI - NewDebugAPI = ethapi.NewDebugAPI -) diff --git a/eth/polar/api/net.go b/eth/polar/api/net.go index af1e5df51..b7e0476bf 100644 --- a/eth/polar/api/net.go +++ b/eth/polar/api/net.go @@ -21,7 +21,7 @@ package polarapi import ( - "github.com/berachain/polaris/eth/common/hexutil" + "github.com/ethereum/go-ethereum/common/hexutil" ) // NetBackend is the collection of methods required to satisfy the net diff --git a/eth/polar/api/web3.go b/eth/polar/api/web3.go index 5d5f0d8dc..8b93293d0 100644 --- a/eth/polar/api/web3.go +++ b/eth/polar/api/web3.go @@ -21,8 +21,8 @@ package polarapi import ( - "github.com/berachain/polaris/eth/common/hexutil" - "github.com/berachain/polaris/eth/crypto" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/crypto" ) // Web3Backend is the collection of methods required to satisfy the net diff --git a/eth/polar/api_backend.go b/eth/polar/api_backend.go index d3d9a6481..5609a885b 100644 --- a/eth/polar/api_backend.go +++ b/eth/polar/api_backend.go @@ -26,24 +26,26 @@ import ( "math/big" "time" - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/common/hexutil" - "github.com/berachain/polaris/eth/core" + pcore "github.com/berachain/polaris/eth/core" "github.com/berachain/polaris/eth/core/state" - "github.com/berachain/polaris/eth/core/types" - "github.com/berachain/polaris/eth/core/vm" - "github.com/berachain/polaris/eth/log" - "github.com/berachain/polaris/eth/params" polarapi "github.com/berachain/polaris/eth/polar/api" "github.com/berachain/polaris/eth/version" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/consensus" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/bloombits" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/eth/gasprice" + "github.com/ethereum/go-ethereum/ethapi" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" ) @@ -51,7 +53,7 @@ import ( // go-ethereum backend object. type ( APIBackend interface { - polarapi.EthBackend + ethapi.Backend polarapi.NetBackend polarapi.Web3Backend } @@ -113,12 +115,12 @@ func (b *backend) ChainConfig() *params.ChainConfig { } // CurrentHeader returns the current header from the local chains. -func (b *backend) CurrentHeader() *types.Header { +func (b *backend) CurrentHeader() *ethtypes.Header { return b.polar.blockchain.CurrentHeader() } // CurrentBlock returns the current block from the local chain. -func (b *backend) CurrentBlock() *types.Header { +func (b *backend) CurrentBlock() *ethtypes.Header { return b.polar.blockchain.CurrentHeader() } @@ -190,7 +192,7 @@ func (b *backend) SetHead(_ uint64) { func (b *backend) HeaderByNumber( _ context.Context, number rpc.BlockNumber, -) (*types.Header, error) { +) (*ethtypes.Header, error) { switch number { case rpc.PendingBlockNumber: // TODO: handle "miner" stuff, Pending block is only known by the miner @@ -223,7 +225,7 @@ func (b *backend) HeaderByNumber( // HeaderByNumberOrHash returns the header identified by `number` or `hash`. func (b *backend) HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, -) (*types.Header, error) { +) (*ethtypes.Header, error) { if blockNr, ok := blockNrOrHash.Number(); ok { return b.HeaderByNumber(ctx, blockNr) } @@ -234,12 +236,15 @@ func (b *backend) HeaderByNumberOrHash(ctx context.Context, } // HeaderByHash returns the block header with the given hash. -func (b *backend) HeaderByHash(_ context.Context, hash common.Hash) (*types.Header, error) { +func (b *backend) HeaderByHash(_ context.Context, hash common.Hash) (*ethtypes.Header, error) { return b.polar.blockchain.GetHeaderByHash(hash), nil } // BlockByNumber returns the block with the given `number`. -func (b *backend) BlockByNumber(_ context.Context, number rpc.BlockNumber) (*types.Block, error) { +func (b *backend) BlockByNumber( + _ context.Context, + number rpc.BlockNumber, +) (*ethtypes.Block, error) { // Pending block is only known by the miner switch number { case rpc.PendingBlockNumber: @@ -266,7 +271,7 @@ func (b *backend) BlockByNumber(_ context.Context, number rpc.BlockNumber) (*typ } // BlockByHash returns the block with the given `hash`. -func (b *backend) BlockByHash(_ context.Context, hash common.Hash) (*types.Block, error) { +func (b *backend) BlockByHash(_ context.Context, hash common.Hash) (*ethtypes.Block, error) { block := b.polar.blockchain.GetBlockByHash(hash) b.logger.Debug("BlockByHash", "hash", hash, "block", block) if block == nil { @@ -281,14 +286,14 @@ func (b *backend) BlockByHash(_ context.Context, hash common.Hash) (*types.Block func (b *backend) BlockByNumberOrHash( ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, -) (*types.Block, error) { +) (*ethtypes.Block, error) { if blockNr, ok := blockNrOrHash.Number(); ok { return b.BlockByNumber(ctx, blockNr) } if hash, ok := blockNrOrHash.Hash(); ok { block := b.polar.blockchain.GetBlockByHash(hash) if block == nil { - return nil, core.ErrBlockNotFound + return nil, pcore.ErrBlockNotFound } // if blockNrOrHash.RequireCanonical && // b.polar.blockchain.GetCanonicalHash(header.Number.Uint64()) != hash { @@ -306,7 +311,7 @@ func (b *backend) BlockByNumberOrHash( func (b *backend) StateAndHeaderByNumber( ctx context.Context, number rpc.BlockNumber, -) (state.StateDB, *types.Header, error) { +) (state.StateDB, *ethtypes.Header, error) { // Pending state is only known by the miner if number == rpc.PendingBlockNumber { block, state := b.polar.miner.Pending() @@ -322,7 +327,7 @@ func (b *backend) StateAndHeaderByNumber( } if header == nil { // to match Geth - return nil, nil, core.ErrBlockNotFound + return nil, nil, pcore.ErrBlockNotFound } b.logger.Debug("called eth.rpc.backend.StateAndHeaderByNumber", "header", header) @@ -339,7 +344,7 @@ func (b *backend) StateAndHeaderByNumber( func (b *backend) StateAndHeaderByNumberOrHash( ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, -) (state.StateDB, *types.Header, error) { +) (state.StateDB, *ethtypes.Header, error) { if blockNr, ok := blockNrOrHash.Number(); ok { return b.StateAndHeaderByNumber(ctx, blockNr) } @@ -351,7 +356,7 @@ func (b *backend) StateAndHeaderByNumberOrHash( } if header == nil { // to match Geth - return nil, nil, core.ErrBlockNotFound + return nil, nil, pcore.ErrBlockNotFound } // if blockNrOrHash.RequireCanonical && // b.eth.blockchain.GetCanonicalHash(header.Number.Uint64()) != hash { @@ -367,7 +372,7 @@ func (b *backend) StateAndHeaderByNumberOrHash( func (b *backend) GetTransaction( _ context.Context, txHash common.Hash, -) (*types.Transaction, common.Hash, uint64, uint64, error) { +) (*ethtypes.Transaction, common.Hash, uint64, uint64, error) { b.logger.Debug("called eth.rpc.backend.GetTransaction", "tx_hash", txHash) txLookup := b.polar.blockchain.GetTransactionLookup(txHash) if txLookup == nil { @@ -378,7 +383,7 @@ func (b *backend) GetTransaction( // PendingBlockAndReceipts returns the pending block (equivalent to current block in Polaris) // and associated receipts. -func (b *backend) PendingBlockAndReceipts() (*types.Block, types.Receipts) { +func (b *backend) PendingBlockAndReceipts() (*ethtypes.Block, ethtypes.Receipts) { block, receipts := b.polar.miner.PendingBlockAndReceipts() // If the block is non-existent, return nil. // This is to maintain parity with the behavior of the geth backend. @@ -392,16 +397,16 @@ func (b *backend) PendingBlockAndReceipts() (*types.Block, types.Receipts) { } // GetReceipts returns the receipts for the given block hash. -func (b *backend) GetReceipts(_ context.Context, hash common.Hash) (types.Receipts, error) { +func (b *backend) GetReceipts(_ context.Context, hash common.Hash) (ethtypes.Receipts, error) { return b.polar.blockchain.GetReceiptsByHash(hash), nil } // GetLogs returns the logs for the given block hash or number. func (b *backend) GetLogs( _ context.Context, blockHash common.Hash, number uint64, -) ([][]*types.Log, error) { +) ([][]*ethtypes.Log, error) { receipts := b.polar.blockchain.GetReceiptsByHash(blockHash) - logs := make([][]*types.Log, len(receipts)) + logs := make([][]*ethtypes.Log, len(receipts)) for i, receipt := range receipts { logs[i] = receipt.Logs } @@ -420,7 +425,7 @@ func (b *backend) GetTd(_ context.Context, hash common.Hash) *big.Int { // GetEVM returns a new EVM to be used for simulating a transaction, estimating gas etc. func (b *backend) GetEVM(_ context.Context, msg *core.Message, state state.StateDB, - header *types.Header, vmConfig *vm.Config, blockCtx *vm.BlockContext, + header *ethtypes.Header, vmConfig *vm.Config, blockCtx *vm.BlockContext, ) (*vm.EVM, func() error) { if vmConfig == nil { vmConfig = b.polar.blockchain.GetVMConfig() @@ -440,7 +445,7 @@ func (b *backend) GetEVM(_ context.Context, msg *core.Message, state state.State // GetBlockContext returns a new block context to be used by a EVM. func (b *backend) GetBlockContext( - _ context.Context, header *types.Header, + _ context.Context, header *ethtypes.Header, ) *vm.BlockContext { // TODO: we are hardcoding author to coinbase, this may be incorrect. // TODO: Suggestion -> implement Engine.Author() and allow host chain to decide. @@ -467,14 +472,14 @@ func (b *backend) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.S // Transaction Pool API // ============================================================================== -func (b *backend) SendTx(_ context.Context, signedTx *types.Transaction) error { - return b.polar.txPool.Add([]*types.Transaction{signedTx}, true, false)[0] +func (b *backend) SendTx(_ context.Context, signedTx *ethtypes.Transaction) error { + return b.polar.txPool.Add([]*ethtypes.Transaction{signedTx}, true, false)[0] } -func (b *backend) GetPoolTransactions() (types.Transactions, error) { +func (b *backend) GetPoolTransactions() (ethtypes.Transactions, error) { b.logger.Debug("called eth.rpc.backend.GetPoolTransactions") pending := b.polar.txPool.Pending(false) - var txs types.Transactions + var txs ethtypes.Transactions for _, batch := range pending { for _, lazy := range batch { if tx := lazy.Resolve(); tx != nil { @@ -485,7 +490,7 @@ func (b *backend) GetPoolTransactions() (types.Transactions, error) { return txs, nil } -func (b *backend) GetPoolTransaction(hash common.Hash) *types.Transaction { +func (b *backend) GetPoolTransaction(hash common.Hash) *ethtypes.Transaction { b.logger.Debug("called eth.rpc.backend.GetPoolTransaction", "tx_hash", hash) return b.polar.txPool.Get(hash) } @@ -503,8 +508,8 @@ func (b *backend) Stats() (int, int) { } func (b *backend) TxPoolContent() ( - map[common.Address][]*types.Transaction, - map[common.Address][]*types.Transaction, + map[common.Address][]*ethtypes.Transaction, + map[common.Address][]*ethtypes.Transaction, ) { pending, queued := b.polar.txPool.Content() b.logger.Debug( @@ -513,8 +518,8 @@ func (b *backend) TxPoolContent() ( } func (b *backend) TxPoolContentFrom(addr common.Address) ( - []*types.Transaction, - []*types.Transaction, + []*ethtypes.Transaction, + []*ethtypes.Transaction, ) { pending, queued := b.polar.txPool.ContentFrom(addr) b.logger.Debug("called eth.rpc.backend.TxPoolContentFrom", @@ -535,7 +540,7 @@ func (b *backend) GetBody( ctx context.Context, hash common.Hash, number rpc.BlockNumber, -) (*types.Body, error) { +) (*ethtypes.Body, error) { if number < 0 || hash == (common.Hash{}) { b.logger.Error("eth.rpc.backend.GetBody", "number", number, "hash", hash) return nil, errors.New("invalid arguments; expect hash and no special block numbers") @@ -555,11 +560,11 @@ func (b *backend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) eve return b.polar.blockchain.SubscribeRemovedLogsEvent(ch) } -func (b *backend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription { +func (b *backend) SubscribeLogsEvent(ch chan<- []*ethtypes.Log) event.Subscription { return b.polar.blockchain.SubscribeLogsEvent(ch) } -func (b *backend) SubscribePendingLogsEvent(ch chan<- []*types.Log) event.Subscription { +func (b *backend) SubscribePendingLogsEvent(ch chan<- []*ethtypes.Log) event.Subscription { return b.polar.miner.SubscribePendingLogs(ch) } diff --git a/eth/polar/backend.go b/eth/polar/backend.go index a10acb229..be053e82e 100644 --- a/eth/polar/backend.go +++ b/eth/polar/backend.go @@ -23,23 +23,24 @@ package polar import ( "math/big" - "github.com/berachain/polaris/eth/common" "github.com/berachain/polaris/eth/consensus" "github.com/berachain/polaris/eth/core" - "github.com/berachain/polaris/eth/core/types" - "github.com/berachain/polaris/eth/log" polarapi "github.com/berachain/polaris/eth/polar/api" - "github.com/berachain/polaris/eth/rpc" "github.com/ethereum/go-ethereum/cmd/utils" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus/beacon" "github.com/ethereum/go-ethereum/core/txpool" "github.com/ethereum/go-ethereum/core/txpool/legacypool" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/ethereum/go-ethereum/eth/filters" + "github.com/ethereum/go-ethereum/ethapi" "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/miner" "github.com/ethereum/go-ethereum/node" + "github.com/ethereum/go-ethereum/rpc" ) // TODO: break out the node into a separate package and then fully use the @@ -139,7 +140,7 @@ func New( // Setup the miner, we use a dummy isLocal function, since it is not used. pl.miner = miner.New(pl, &pl.config.Miner, &pl.config.Chain, stack.EventMux(), pl.engine, - func(header *types.Header) bool { return true }, + func(header *ethtypes.Header) bool { return true }, ) // Register the backend on the node @@ -167,7 +168,7 @@ func (pl *Polaris) Stop() error { // NOTE, some of these services probably need to be moved to somewhere else. func (pl *Polaris) APIs() []rpc.API { // Grab a bunch of the apis from go-Polaris (thx bae) - apis := polarapi.GethAPIs(pl.apiBackend, pl.blockchain) + apis := ethapi.GetAPIs(pl.apiBackend, pl.blockchain) // Append all the local APIs and return return append(apis, []rpc.API{ diff --git a/eth/polar/config.go b/eth/polar/config.go index 89780c079..94a1ab537 100644 --- a/eth/polar/config.go +++ b/eth/polar/config.go @@ -24,14 +24,15 @@ import ( "math/big" "time" - "github.com/berachain/polaris/eth/common" - "github.com/berachain/polaris/eth/log" "github.com/berachain/polaris/eth/params" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/txpool/legacypool" "github.com/ethereum/go-ethereum/eth/ethconfig" "github.com/ethereum/go-ethereum/eth/gasprice" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/miner" + ethparams "github.com/ethereum/go-ethereum/params" ) const ( @@ -78,7 +79,7 @@ func (c *Config) SafetyMessage() { // Config represents the configurable parameters for Polaris. type Config struct { // The chain configuration to use. - Chain params.ChainConfig + Chain ethparams.ChainConfig // Mining options Miner miner.Config diff --git a/eth/rpc/imported.go b/eth/rpc/imported.go deleted file mode 100644 index 6cb3b1eaa..000000000 --- a/eth/rpc/imported.go +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -// -// Copyright (C) 2023, Berachain Foundation. All rights reserved. -// Use of this software is govered by the Business Source License included -// in the LICENSE file of this repository and at www.mariadb.com/bsl11. -// -// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY -// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER -// VERSIONS OF THE LICENSED WORK. -// -// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF -// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF -// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). -// -// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, -// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND -// TITLE. - -package rpc - -import ( - "github.com/ethereum/go-ethereum/rpc" -) - -type ( - API = rpc.API - BlockNumber = rpc.BlockNumber - BlockNumberOrHash = rpc.BlockNumberOrHash - Server = rpc.Server -) - -var ( - NewServer = rpc.NewServer - SafeBlockNumber = rpc.SafeBlockNumber - FinalizedBlockNumber = rpc.FinalizedBlockNumber - LatestBlockNumber = rpc.LatestBlockNumber - PendingBlockNumber = rpc.PendingBlockNumber - EarliestBlockNumber = rpc.EarliestBlockNumber -) diff --git a/eth/version/version.go b/eth/version/version.go index 32cc9a28e..3944f9691 100644 --- a/eth/version/version.go +++ b/eth/version/version.go @@ -27,7 +27,7 @@ import ( "golang.org/x/text/cases" "golang.org/x/text/language" - "github.com/berachain/polaris/eth/params" + "github.com/ethereum/go-ethereum/params" ) const (