Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate coreth nits #109

Merged
merged 2 commits into from
May 24, 2022
Merged
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ The Subnet EVM is compatible with almost all Ethereum tooling, including [Remix,
- Removed Atomic Txs and Shared Memory
- Removed Multicoin Contract and State

## Block Format

To support these changes, there have been a number of changes to the SubnetEVM block format compared to what exists on the C-Chain and Ethereum. Here we list the changes to the block format as compared to Ethereum.

### Block Header

* `BaseFee`: Added by EIP-1559 to represent the base fee of the block (present in Ethereum as of EIP-1559)
* `BlockGasCost`: surcharge for producing a block faster than the target rate


## Run Local Network

See [Create a Local EVM Subnet](https://docs.avax.network/subnets/create-a-local-subnet).
Expand Down
69 changes: 0 additions & 69 deletions ethdb/cappedbatch.go

This file was deleted.

3 changes: 0 additions & 3 deletions plugin/evm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const (
defaultSnapshotAsync = true
defaultRpcGasCap = 50_000_000 // Default to 50M Gas Limit
defaultRpcTxFeeCap = 100 // 100 AVAX
defaultMetricsEnabled = true
defaultMetricsExpensiveEnabled = false
defaultApiMaxDuration = 0 // Default to no maximum API call duration
defaultWsCpuRefillRate = 0 // Default to no maximum WS CPU usage
Expand Down Expand Up @@ -84,7 +83,6 @@ type Config struct {
PopulateMissingTriesParallelism int `json:"populate-missing-tries-parallelism"` // Number of concurrent readers to use when re-populating missing tries on startup.

// Metric Settings
MetricsEnabled bool `json:"metrics-enabled"`
MetricsExpensiveEnabled bool `json:"metrics-expensive-enabled"`

// API Settings
Expand Down Expand Up @@ -139,7 +137,6 @@ func (c *Config) SetDefaults() {
c.EnabledEthAPIs = defaultEnabledAPIs
c.RPCGasCap = defaultRpcGasCap
c.RPCTxFeeCap = defaultRpcTxFeeCap
c.MetricsEnabled = defaultMetricsEnabled
c.MetricsExpensiveEnabled = defaultMetricsExpensiveEnabled
c.APIMaxDuration.Duration = defaultApiMaxDuration
c.WSCPURefillRate.Duration = defaultWsCpuRefillRate
Expand Down
2 changes: 2 additions & 0 deletions plugin/evm/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/ava-labs/avalanchego/database"
)

var _ ethdb.Database = &Database{}

// Database implements ethdb.Database
type Database struct{ database.Database }

Expand Down
6 changes: 0 additions & 6 deletions plugin/evm/message/block_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,3 @@ func (b BlockRequest) Handle(ctx context.Context, nodeID ids.NodeID, requestID u
type BlockResponse struct {
Blocks [][]byte `serialize:"true"`
}

// SerializedMap is map of Keys and Vals to track leaf sync progress
type SerializedMap struct {
Keys []common.Hash `serialize:"true"`
Vals []common.Hash `serialize:"true"`
}
1 change: 0 additions & 1 deletion plugin/evm/message/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func BuildCodec() (codec.Manager, error) {
c.RegisterType(LeafsResponse{}),
c.RegisterType(CodeRequest{}),
c.RegisterType(CodeResponse{}),
c.RegisterType(SerializedMap{}),

codecManager.RegisterCodec(Version, c),
)
Expand Down
1 change: 0 additions & 1 deletion plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ func (vm *VM) Initialize(
return errUnsupportedFXs
}

metrics.Enabled = vm.config.MetricsEnabled
metrics.EnabledExpensive = vm.config.MetricsExpensiveEnabled

vm.shutdownChan = make(chan struct{}, 1)
Expand Down
1 change: 1 addition & 0 deletions plugin/evm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func buildGenesisTest(t *testing.T, genesisJSON string) []byte {
func NewContext() *snow.Context {
ctx := snow.DefaultContextTest()
ctx.NetworkID = testNetworkID
ctx.NodeID = ids.GenerateTestNodeID()
ctx.ChainID = testCChainID
ctx.AVAXAssetID = testAvaxAssetID
ctx.XChainID = testXChainID
Expand Down
7 changes: 5 additions & 2 deletions trie/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,11 @@ func (e seekError) Error() string {
}

func newNodeIterator(trie *Trie, start []byte) NodeIterator {
if trie.Hash() == emptyState {
return new(nodeIterator)
if trie.Hash() == emptyRoot {
return &nodeIterator{
trie: trie,
err: errIteratorEnd,
}
}
it := &nodeIterator{trie: trie}
it.err = it.seek(start)
Expand Down
13 changes: 13 additions & 0 deletions trie/iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ import (
"github.com/ethereum/go-ethereum/crypto"
)

func TestEmptyIterator(t *testing.T) {
trie := newEmpty()
iter := trie.NodeIterator(nil)

seen := make(map[string]struct{})
for iter.Next(true) {
seen[string(iter.Path())] = struct{}{}
}
if len(seen) != 0 {
t.Fatal("Unexpected trie node iterated")
}
}

func TestIterator(t *testing.T) {
trie := newEmpty()
vals := []struct{ k, v string }{
Expand Down
2 changes: 1 addition & 1 deletion trie/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ func VerifyRangeProof(rootHash common.Hash, firstKey []byte, lastKey []byte, key
}
// todo(rjl493456442) different length edge keys should be supported
if len(firstKey) != len(lastKey) {
return false, errors.New("inconsistent edge keys")
return false, fmt.Errorf("inconsistent edge keys (%d != %d)", len(firstKey), len(lastKey))
}
// Convert the edge proofs to edge trie paths. Then we can
// have the same tree architecture with the original one.
Expand Down
4 changes: 0 additions & 4 deletions trie/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,13 @@ import (

"github.com/ava-labs/subnet-evm/core/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
)

var (
// emptyRoot is the known root hash of an empty trie.
emptyRoot = common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")

// emptyState is the known hash of an empty state trie entry.
emptyState = crypto.Keccak256Hash(nil)
)

// LeafCallback is a callback type invoked when a trie operation reaches a leaf
Expand Down