Skip to content
This repository was archived by the owner on Jun 9, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cosmos/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ replace (
github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.46.0-beta2.0.20230305125317-672b052f323b
github.com/docker/docker => github.com/docker/docker v20.10.3-0.20221013203545-33ab36d6b304+incompatible // 22.06 branch
// Required for stateful precompiles and supporting the Ethereum JSON-RPC API.
github.com/ethereum/go-ethereum => github.com/berachain/polaris-geth v0.0.0-20230321213944-019945fbf8fc
github.com/ethereum/go-ethereum => github.com/berachain/polaris-geth v0.0.0-20230323170029-a71eb9468a86
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)

Expand Down
4 changes: 2 additions & 2 deletions cosmos/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
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-geth v0.0.0-20230321213944-019945fbf8fc h1:NHofh47tokJQM9G9umhvAd9jNhkBkozm3QyHFZJjZqY=
github.com/berachain/polaris-geth v0.0.0-20230321213944-019945fbf8fc/go.mod h1:it7x0DWnTDMfVFdXcU6Ti4KEFQynLHVRarcSlPr0HBo=
github.com/berachain/polaris-geth v0.0.0-20230323170029-a71eb9468a86 h1:oRVrk36E2lxRWa4ScJpEx1F6O/8g4TtjwPveahhNjtM=
github.com/berachain/polaris-geth v0.0.0-20230323170029-a71eb9468a86/go.mod h1:it7x0DWnTDMfVFdXcU6Ti4KEFQynLHVRarcSlPr0HBo=
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas=
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
Expand Down
14 changes: 1 addition & 13 deletions cosmos/x/evm/plugins/block/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ import (
coretypes "pkg.berachain.dev/polaris/eth/core/types"
)

// TODO: change this.
const bf = uint64(1)

type Plugin interface {
plugins.BaseCosmosPolaris
core.BlockPlugin
Expand Down Expand Up @@ -65,14 +62,6 @@ func (p *plugin) Prepare(ctx context.Context) {
p.ctx = sdk.UnwrapSDKContext(ctx)
}

// BaseFee returns the base fee for the current block.
// TODO: implement properly with DynamicFee Module of some kind.
//
// BaseFee implements core.BlockPlugin.
func (p *plugin) BaseFee() uint64 {
return bf
}

// NewHeaderWithBlockNumber builds an ethereum style block header from the current
// context.
func (p *plugin) NewHeaderWithBlockNumber(number int64) *coretypes.Header {
Expand All @@ -98,6 +87,7 @@ func (p *plugin) NewHeaderWithBlockNumber(number int64) *coretypes.Header {
parentHash = header.Hash()
}

// BaseFee is set by the Polaris Ethereum module.
return &coretypes.Header{
// ParentHash is set to the hash of the previous block.
ParentHash: parentHash,
Expand All @@ -117,8 +107,6 @@ func (p *plugin) NewHeaderWithBlockNumber(number int64) *coretypes.Header {
GasLimit: blockGasLimitFromCosmosContext(p.ctx),
// Time is set to the block timestamp.
Time: uint64(cometHeader.Time.UTC().Unix()),
// BaseFee is set to the block base fee.
BaseFee: big.NewInt(int64(p.BaseFee())),
// ReceiptHash set to empty. It is filled during `Finalize` in the StateProcessor.
ReceiptHash: common.Hash{},
// Bloom is set to empty. It is filled during `Finalize` in the StateProcessor.
Expand Down
2 changes: 2 additions & 0 deletions eth/common/imported.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ var (
HexToAddress = common.HexToAddress
Hex2Bytes = common.Hex2Bytes
HexToHash = common.HexToHash

Big0 = common.Big0
)
10 changes: 9 additions & 1 deletion eth/core/chain_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ package core
import (
"context"

"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/consensus/misc"

"pkg.berachain.dev/polaris/eth/core/types"
"pkg.berachain.dev/polaris/eth/core/vm"
"pkg.berachain.dev/polaris/lib/utils"
)

Expand Down Expand Up @@ -64,6 +65,13 @@ func (bc *blockchain) Prepare(ctx context.Context, height int64) {

// If we are processing a new block, then we assume that the previous was finalized.
header := bc.bp.NewHeaderWithBlockNumber(height)

// We can use the finalized block's header here because we assume that the previous block was
// finalized.
if parent := bc.finalizedBlock.Load(); parent != nil {
header.BaseFee = misc.CalcBaseFee(bc.ChainConfig(), parent.Header())
}

bc.processor.Prepare(
ctx,
bc.GetEVM(ctx, vm.TxContext{}, bc.statedb, header, bc.vmConfig),
Expand Down
2 changes: 0 additions & 2 deletions eth/core/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ type (
GetHeaderByNumber(int64) (*types.Header, error)
// SetHeaderByNumber sets the block header at the given block number.
SetHeaderByNumber(int64, *types.Header) error
// BaseFee returns the base fee of the current block.
BaseFee() uint64
}

// ConfigurationPlugin defines the methods that the chain running Polaris EVM should
Expand Down
2 changes: 1 addition & 1 deletion eth/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module pkg.berachain.dev/polaris/eth
go 1.20

// Required for stateful precompiles and supporting the Ethereum JSON-RPC API.
replace github.com/ethereum/go-ethereum => github.com/berachain/polaris-geth v0.0.0-20230321213944-019945fbf8fc
replace github.com/ethereum/go-ethereum => github.com/berachain/polaris-geth v0.0.0-20230323170029-a71eb9468a86

require (
github.com/ethereum/go-ethereum v1.11.4
Expand Down
4 changes: 2 additions & 2 deletions eth/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
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-geth v0.0.0-20230321213944-019945fbf8fc h1:NHofh47tokJQM9G9umhvAd9jNhkBkozm3QyHFZJjZqY=
github.com/berachain/polaris-geth v0.0.0-20230321213944-019945fbf8fc/go.mod h1:it7x0DWnTDMfVFdXcU6Ti4KEFQynLHVRarcSlPr0HBo=
github.com/berachain/polaris-geth v0.0.0-20230323170029-a71eb9468a86 h1:oRVrk36E2lxRWa4ScJpEx1F6O/8g4TtjwPveahhNjtM=
github.com/berachain/polaris-geth v0.0.0-20230323170029-a71eb9468a86/go.mod h1:it7x0DWnTDMfVFdXcU6Ti4KEFQynLHVRarcSlPr0HBo=
github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U=
github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
Expand Down
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ use (
./lib
./magefiles
./playground
)
)
2 changes: 2 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/berachain/polaris-geth v0.0.0-20230323170029-a71eb9468a86 h1:oRVrk36E2lxRWa4ScJpEx1F6O/8g4TtjwPveahhNjtM=
github.com/berachain/polaris-geth v0.0.0-20230323170029-a71eb9468a86/go.mod h1:it7x0DWnTDMfVFdXcU6Ti4KEFQynLHVRarcSlPr0HBo=
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
github.com/docker/docker v20.10.3-0.20221013203545-33ab36d6b304+incompatible h1:ieHXawdo9MXKnRkKuVWEfEN3PDQUqIjz/T8vMfIaHkM=
github.com/docker/docker v20.10.3-0.20221013203545-33ab36d6b304+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
Expand Down
2 changes: 1 addition & 1 deletion playground/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module pkg.berachain.dev/polaris/playground
go 1.20

// Required for stateful precompiles and supporting the Ethereum JSON-RPC API.
replace github.com/ethereum/go-ethereum => github.com/berachain/polaris-geth v0.0.0-20230321213944-019945fbf8fc
replace github.com/ethereum/go-ethereum => github.com/berachain/polaris-geth v0.0.0-20230323170029-a71eb9468a86

require (
github.com/rs/zerolog v1.29.0
Expand Down
4 changes: 2 additions & 2 deletions playground/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
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-geth v0.0.0-20230321213944-019945fbf8fc h1:NHofh47tokJQM9G9umhvAd9jNhkBkozm3QyHFZJjZqY=
github.com/berachain/polaris-geth v0.0.0-20230321213944-019945fbf8fc/go.mod h1:it7x0DWnTDMfVFdXcU6Ti4KEFQynLHVRarcSlPr0HBo=
github.com/berachain/polaris-geth v0.0.0-20230323170029-a71eb9468a86 h1:oRVrk36E2lxRWa4ScJpEx1F6O/8g4TtjwPveahhNjtM=
github.com/berachain/polaris-geth v0.0.0-20230323170029-a71eb9468a86/go.mod h1:it7x0DWnTDMfVFdXcU6Ti4KEFQynLHVRarcSlPr0HBo=
github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U=
github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
Expand Down