-
Notifications
You must be signed in to change notification settings - Fork 30
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
[WIP] Enable blockchain EEST #223
base: dev
Are you sure you want to change the base?
Conversation
test: Enable Shanghai and Cancun EIPs blockchain test by Cancun and Prague forks
test: Enable prague's EIP7623
* Enable eip 2935 on blockchain EEST * Fix cyclic import * Fix for lint
test: EETS Set precompile correctly
* Enable old forks other than frontier and byzantium * Restore all old fork tests
if CreateContractWithCodeFormatInExecutionSpecTest { | ||
stateDB.CreateSmartContractAccount(addr, params.CodeFormatEVM, g.Config.Rules(new(big.Int).SetUint64(g.Number))) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a code has delegation prefix, SetCodeToEOA should be used for 7702.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be done in test code. Or this is bug.
"github.com/kaiachain/kaia/blockchain/types" | ||
"github.com/kaiachain/kaia/common" | ||
"github.com/kaiachain/kaia/consensus/gxhash" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
func TestBlockchain(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok to remove this.
@@ -223,7 +224,7 @@ func (tm *testMatcher) runTestFile(t *testing.T, path, name string, runTest inte | |||
t.Skip("Skipped by whitelist") | |||
} | |||
} | |||
t.Parallel() | |||
// t.Parallel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to have: Enable this
@@ -159,11 +199,13 @@ See https://github.com/ethereum/tests/wiki/Blockchain-Tests-II | |||
expected we are expected to ignore it and continue processing and then validate the | |||
post state. | |||
*/ | |||
func (t *BlockTest) insertBlocks(blockchain *blockchain.BlockChain) ([]btBlock, error) { | |||
func (t *BlockTest) insertBlocks(bc *blockchain.BlockChain, preBlock *types.Block) ([]btBlock, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may not need to change insertBlock since it is no longer used.
We can also consider deleting it.
|
||
// Because it is a eth test, we don't have to think about fee payer | ||
// Because the baseFee is set to 0, Kaia's gas fee may be 0 if the transaction has a dynamic fee. | ||
senderMap[tx.ValidatedSender()] = new(big.Int).Sub( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If tx.ValidatedSender() is already present in the map, you must add it to it.
} | ||
|
||
// Modify the decode function | ||
func (bb *btBlock) decode(latestParentHash common.Hash, latestRoot common.Hash) (*types.Block, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that decode is no longer necessary.
} | ||
|
||
// Decode header | ||
var header TestHeader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we use btHeader?
if GasLimitInExecutionSpecTest != 0 { | ||
blockContext.GasLimit = GasLimitInExecutionSpecTest | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, it's correct that Kaia's GasLimit is zero?
|
||
// when execution spec test, we can insert test GasLimit to blockContext. | ||
if UseKaiaCancunExtCodeHashFee && chainConfig.Rules(header.Number).IsCancun { | ||
// EIP-1052 must be activated for backward compatibility on Kaia. But EIP-2929 is activated instead of it on Ethereum | ||
vm.ChangeGasCostForTest(&vmenv.Config.JumpTable, vm.EXTCODEHASH, params.WarmStorageReadCostEIP2929) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be implemented in test code.
@@ -316,7 +317,7 @@ func (t *TxInternalDataFeeDelegatedValueTransfer) SenderTxHash() common.Hash { | |||
} | |||
|
|||
func (t *TxInternalDataFeeDelegatedValueTransfer) Validate(stateDB StateDB, currentBlockNumber uint64) error { | |||
if common.IsPrecompiledContractAddress(t.Recipient) { | |||
if common.IsPrecompiledContractAddress(t.Recipient, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed, executing test for each fork?
func (suite *ExecutionSpecBlockTestSuite) TearDownSuite() { | ||
// Reset global variables for test | ||
common.IsPrecompiledContractAddress = suite.originalIsPrecompiledContractAddress | ||
blockchain.UseKaiaCancunExtCodeHashFee = false | ||
blockchain.GasLimitInExecutionSpecTest = 0 | ||
blockchain.CreateContractWithCodeFormatInExecutionSpecTest = false | ||
types.IsPragueInExecutionSpecTest = false | ||
gxhash.CustomInitialize = nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using build tag, can these be switched?
if gblock.Hash() != t.json.Genesis.Hash { | ||
return fmt.Errorf("genesis block hash doesn't match test: computed=%x, test=%x", gblock.Hash().Bytes()[:6], t.json.Genesis.Hash[:6]) | ||
|
||
st := MakePreState(db, t.json.Pre, true, config.Rules(gblock.Number())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this, can we overwrite pre state?
config.SetDefaults() | ||
// Since we calculate the baseFee differently than eth, we will set it to 0 to turn off the gas fee. | ||
config.Governance.KIP71 = ¶ms.KIP71Config{ | ||
LowerBoundBaseFee: 0, | ||
UpperBoundBaseFee: 0, | ||
GasTarget: 0, | ||
MaxBlockGasUsedForBaseFee: 0, | ||
BaseFeeDenominator: 0, | ||
} | ||
blockchain.InitDeriveSha(config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to know how config is. Description of blockchain config is needed.
ethReward: ethReward, | ||
} | ||
|
||
i, err := bc.InsertChain(blocks) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the same block executed twice?
if rewardList, exist := rewardMap[addr]; exist { | ||
// In the case of rewardBaseAddress, the Kaia reward will be deducted once. | ||
statedb.SubBalance(addr, rewardList.kaiaReward) | ||
statedb.AddBalance(addr, rewardList.ethReward) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be run before loop.
This PR is under refactoring.
refactoring Tasks: