Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Config and refactor #21

Merged
merged 7 commits into from
May 10, 2019
Merged

Config and refactor #21

merged 7 commits into from
May 10, 2019

Conversation

austinabell
Copy link
Contributor

Creating config for Atlantis specific functionality and testing, maps ETH test forks to corresponding ETC chain config (or RuleSet).

Refactored jump_table.go to allow for adding other variables for the functionality of upcoming EIPs and reduce merge conflicts when implementing the variables to map to each opcode.

For example for adding the writes variable to map which variables modify state for STATICCALL implementation, the type can be easily changed to:

type jumpPtr struct {
	fn    instrFn
	valid bool

	writes bool
}

and a state modifying opcode can be easily tagged as this variable with:

	jumpTable[SSTORE] = jumpPtr{
		...
		writes: true,
	}

also, can correctly just add the opcodes per Atlantis block by putting them in a

	if ruleset.IsHomestead(blockNumber) {
		jumpTable[...] = jumpPtr{
			...
		}
	}

function.

Copy link

@GregTheGreek GregTheGreek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- Really nice refactor

Copy link
Contributor

@soc1c soc1c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK + 2 questions

tests/init.go Outdated
},
"EIP158": {
HomesteadBlock: big.NewInt(0),
AtlantisBlock: big.NewInt(0),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on this? why is EIP-158 mapped to Homestead and Atlantis here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Essentially, when the HomesteadBlock and AtlantisBlock are defined, it enables the Homestead and Atlantis specific interactions through the RuleSet interface implementations of

func (r RuleSet) IsHomestead(n *big.Int) bool {
	return n.Cmp(r.HomesteadBlock) >= 0
}

func (r RuleSet) IsAtlantis(n *big.Int) bool {
	return n.Cmp(r.AtlantisBlock) >= 0
}

In this case. I had mapped EIP158 to Atlantis because we were including the state clearing functionality (EIP158/161) in the Atlantis fork. Now that I think about it, I should just skip the EIP158 fork subtests altogether, because if a test uses an opcode included in Atlantis for example, it will fail those specific tests. I will change this now along with other changes.

I will make this change in a fixing commit but will hopefully get input into what the best way to go about this is.

tests/init.go Outdated
HomesteadBlock: big.NewInt(0),
AtlantisBlock: big.NewInt(0),
},
"ConstantinopleFix": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no Byzantium, Constantinople, and Petersburg in Classic. Only Atlantis and Agharta.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I am aware. the point of this mapping is because the tests submodule we are using for testing this, separates the "post" subtests into their respective fork, and I am making config map to the respective ETC RuleSet.

	// Ruleset mapping from ETH network to ETC
	ruleSet, ok := Forks[subtest.Fork]
	if !ok {
		return UnsupportedForkError{subtest.Fork}
	}

Now that I think about it though, it may be a better experience for the people implementing Agharta to just hit the UnsupportedForkError when they remove the skipping of Constantinople and Petersburg tests. Right now, these fork mappings are ignored because they are intentionally skipped in state_test.go

					// Not supported implementations to test
					if subtest.Fork == "Constantinople" || subtest.Fork == "ConstantinopleFix" {
						continue
					}

but when the functionality does get implemented, the mapping would end up looking something like this:

...
"Constantinople": {
	HomesteadBlock: big.NewInt(0),
	AtlantisBlock:  big.NewInt(0),
	AghartaBlock:  big.NewInt(0),
},
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, ETC previously hard coded in a RuleSet for each individual test:

func TestEIP150HomesteadBounds(t *testing.T) {
	ruleSet := RuleSet{
		HomesteadBlock:           new(big.Int),
		HomesteadGasRepriceBlock: big.NewInt(2457000),
	}

	fn := filepath.Join(stateTestDir, "EIP150", "Homestead", "stBoundsTest.json")
	if err := RunStateTest(ruleSet, fn, StateSkipTests); err != nil {
		t.Error(err)
	}
}

and I had previously hard coded in a RuleSet which defaulted HomesteadBlock to 0, but I had always planned on changing to mapping to specific configurations to handle the edge cases and test combinations. This was necessary when testing the new opcode EIPs because to be completely backwards compatible, those opcodes should only be active when the IsAtlantis(..) function returns true and the tests before Atlantis (mapping from Byzantium in tests) should not utilize those opcode functionalities.

Sorry if I did a bad job explaining all of this, I can try to clarify here or on a call if anyone is confused.

@austinabell
Copy link
Contributor Author

Also one other note, haven't needed to yet but may need to include these blocks in the fork config mapping:

HomesteadGasRepriceBlock *big.Int
DiehardBlock             *big.Int
ExplosionBlock           *big.Int

Reason I hadn't is because those gas calculations haven't mattered for the tests we are using/ functionality we are implementing. I haven't looked too in depth, but we may want to chat about what exactly the configuration should be to make sure tests function as intended.

@austinabell
Copy link
Contributor Author

austinabell commented May 7, 2019

Hold on for a second before reviewing, I need to change how Frontier is mapped since it throws an exception when a test file with that fork subtest is called. (I am not sure in go how to create the struct without any values defined but looking into it now)

Edit: My guess was not the problem, it was the previous implementation of those methods assuming their hard coded config was always set properly

@noot
Copy link
Contributor

noot commented May 8, 2019

getting an error when running tests:

# github.com/eth-classic/go-ethereum/core/vm/runtime [github.com/eth-classic/go-ethereum/core/vm/runtime.test]
core/vm/runtime/runtime.go:70:15: cannot use ruleSet literal (type ruleSet) as type vm.RuleSet in assignment:
	ruleSet does not implement vm.RuleSet (missing IsAtlantis method)

looks like you need to implement IsAtlantis somewhere else?

@austinabell
Copy link
Contributor Author

getting an error when running tests:

# github.com/eth-classic/go-ethereum/core/vm/runtime [github.com/eth-classic/go-ethereum/core/vm/runtime.test]
core/vm/runtime/runtime.go:70:15: cannot use ruleSet literal (type ruleSet) as type vm.RuleSet in assignment:
	ruleSet does not implement vm.RuleSet (missing IsAtlantis method)

looks like you need to implement IsAtlantis somewhere else?

Ah yes, my bad. Hadn't noticed the vm runtime one since I hadn't run the full test suite since I had added that function to the interface. I'll commit that fix right now.

@austinabell austinabell merged commit 6011a28 into development May 10, 2019
@austinabell austinabell deleted the austin/refactor branch May 10, 2019 16:11
noot pushed a commit that referenced this pull request Jun 6, 2019
* Removed research and moved to wiki (#2)

* changed import paths from ethereumproject to eth-classic (#4)

* changed import paths from ethereumproject to eth-classic

* add bn256 package; begin adding bn256add

* fix syntax errors; tests package passes

* fix import path

* change all import paths to eth-classic after forking needed repos

* go: initialized modules (#10)

* init gomodules

* remove vendor

* update modules

* Fixed dependency references to allow build to run without sputnikvm (#14)

* Testing framework (#12)

* Removed coverage file accidentally commited

* Set up testing framework for eth tests

* go: initialized modules (#10)

* init gomodules

* remove vendor

* update modules

* Updated struct formatting for unmarshalling

* Updated format of eth test struct and updated test files (were replaced with generated files)

* Using ethereum tests submodule and updated framework for testing

* Updated hashing of logs comparison and logging of tests

* Removed error checking on state execution because expected error in some tests

* Updated testing structure into subtests for better reporting and so that all test cases are tested even when one fails

* Changed subtest name from full filepath to just the json file

* Restructured and added light documentation

* Added homestead specific state test

* Updated framework to be able to delete empty objects in trie for tests>EIP158

* Changed conditional for when state objects are deleted and removed logging statement

* Changed folder back to intended from testing

* Changed conditional to not skip EIP158 fork tests

* Added functionality to skip tests

* Removed commented out code

* Create CODEOWNERS (#17)

* Config and refactor (#21)

* Refactor and add config for Atlantis chain config

* Typo fix

* Refactor jump table setup

* Changed fork config skipping functionality and removed unused configuration mappings

* Fixed null pointer error with test configs

* Added definitions of other blocks for correctly mapping gas table

* Implemented IsAtlantis interface for vm runtime

* Added fix for testing some fork subtests EIP150 and Frontier (#27)

* ci: create basic circle-ci config (#26)

* ci: create basic circle-ci config

* ci: lower parallelism

* ci: rename jobs

* ci: rename jobs

* EIP161, State Trie Clearing (#28)

* implemented EIP 161 logic

* implemented EIP 161 logic

* fixed bug

* no more segfaults

* Byzantium Tests Passing. Certain Homestead Failing

* Fixed implementation to pass (almost) all tests

* Updated testing framework to run all ETH directories

* Reimpl EIP161 SUICIDE and CALL edge cases

* Skip unimplemented functionality tests

* proper indentation

* Elizabeth/fix bindings test (#30)

* add go mods to bind package

* attempt to fix mods

* revert some dependencies

* fixed trimToImportPath for outside of go path (#33)

* fixed trimToImportPath for outside of go path

* is this how working_directory works?

* is this how working_directory works?

* is this how working_directory works?

* is THIS how working_directory works?

* is THIS how working_directory works?

* working_directory

* working_directory

* EIP 140 REVERT (#34)

* Implemented EIP 140 op code framework to be tested

* Added required parameters and moved protocol parameters into their own file

* Removed coverage file accidentally commited

* Set up testing framework for eth tests

* Updated struct formatting for unmarshalling

* Updated format of eth test struct and updated test files (were replaced with generated files)

* Using ethereum tests submodule and updated framework for testing

* Updated testing structure into subtests for better reporting and so that all test cases are tested even when one fails

* Fix merge error

* Removed indirect reference to ethereum/go-ethereum during rebase

* Implemented EIP 140 op code framework to be tested

* Added required parameters and moved protocol parameters into their own file

* Removed coverage file accidentally commited

* Set up testing framework for eth tests

* Updated struct formatting for unmarshalling

* Updated format of eth test struct and updated test files (were replaced with generated files)

* Using ethereum tests submodule and updated framework for testing

* Updated testing structure into subtests for better reporting and so that all test cases are tested even when one fails

* Fix merge error

* Removed indirect reference to ethereum/go-ethereum during rebase

* WIP fixed some implementations of REVERT

* Fixed more implementation details

* Skipped unrelated and unimplemented tests

* Implemented EIP 140 op code framework to be tested

* Added required parameters and moved protocol parameters into their own file

* Removed coverage file accidentally commited

* Set up testing framework for eth tests

* Updated struct formatting for unmarshalling

* Updated format of eth test struct and updated test files (were replaced with generated files)

* Using ethereum tests submodule and updated framework for testing

* Updated testing structure into subtests for better reporting and so that all test cases are tested even when one fails

* Fix merge error

* Removed indirect reference to ethereum/go-ethereum during rebase

* Implemented EIP 140 op code framework to be tested

* Added required parameters and moved protocol parameters into their own file

* Removed coverage file accidentally commited

* Set up testing framework for eth tests

* Updated struct formatting for unmarshalling

* Updated format of eth test struct and updated test files (were replaced with generated files)

* Using ethereum tests submodule and updated framework for testing

* Updated testing structure into subtests for better reporting and so that all test cases are tested even when one fails

* Fix merge error

* Removed indirect reference to ethereum/go-ethereum during rebase

* WIP fixed some implementations of REVERT

* Fixed more implementation details

* Skipped unrelated and unimplemented tests

* Revert modules changes from development

* Removed last gas cost variable used previously to save recalculation

* EIP 170, contract size limit (#23)

* added contract size limit

* added maxCodeSizeExceeded error

* fixed some tests failing due to not checking for creation of contract in the OR

* added IsAtlantis condition for max code size to apply. We now fail tests

* removed TestETHCodeSizeLimit

* EIP 100 Difficulty adjustment and testing (#36)

* Set up testing framework for difficulty

* Set up framework for testing difficulty

* Implemented EIP 100 and set up testing config

* Set up testing framework for difficulty

* Set up framework for testing difficulty

* Implemented EIP 100 and set up testing config

* Cleaned up and moved params to file

* Fixed usages of CalcDifficulty

* Moved parsing of hex or decimal strings functions to common package

* EIP 211 and refactor (#37)

* set up framework for returndata and refactor

* Refactored pc operation

* Refactored nil function jumptable lookups (why was it like that to begin with)

* Finished refactoring jump operations

* Implemented 211 functionality, but state tests not passing

* Fixed returndatasize

* Refactor memory and gas stack accesses

* Fixed a few small details for the implementation

* Fixed incorrect implementation of returndatacopy and revert edge case

* Removed unused instruction parameter since refactor

* Removed commented out printing from debugging

* EIP 196, 197, 198 (#24)

* implement bn256 precompiles

* implement bigModExp

* add comments and test

* run precompile tests

* skip failing tests for now

* add distinction between atlantis and pre-atlantis precompiles

* refactor precompiles to separate pre and post atlantis

* implement bn256 precompiles

* implement bigModExp

* add comments and test

* run precompile tests

* skip failing tests for now

* add distinction between atlantis and pre-atlantis precompiles

* refactor precompiles to separate pre and post atlantis

* fix ecrecover edge case

* implement bn256 precompiles

* implement bigModExp

* add comments and test

* run precompile tests

* skip failing tests for now

* add distinction between atlantis and pre-atlantis precompiles

* refactor precompiles to separate pre and post atlantis

* implement bn256 precompiles

* implement bigModExp

* add comments and test

* run precompile tests

* fix ecrecover edge case

* update go.mod

* remove skip for previously failing tests

* attempt to fix go.mod

* attempt to fix go.mod

* fix go.mod termiu version

* EIP 214 STATICCALL (#40)

* Cherry pick STATICALL commit

* Removed implemented skipped tests

* Removed implemented tests
soc1c added a commit that referenced this pull request Aug 7, 2019
* Fixed state transition logic for edge case (#17)

* Update morden bootnodes (#16)

* Updates bootnodes

* what a fantastic test :)

* Core execution refactor, EIP 684, edge case fixes, starting nonce for morden (#19)

* Refactored Call

* Refactored CallCode

* Refactored DelegateCall

* Refactored StaticCall

* Added create before contract collision check

* Refactored Call

* Refactored CallCode

* Refactored DelegateCall

* Refactored StaticCall

* Added create before contract collision check

* Fixed state transition logic for edge case

* Added create collision logic

* Fix for edge case tests

* Removed outdated contract collision tests and changed format of test output to be consistent

* Rename exec function

* utilize StartingNonce from state instead of explicit 0 nonce checks for contract collision and empty objects

* Fixes morden seg fault edge case

* adding starting nonce to created contracts
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants