Skip to content

Commit

Permalink
Merge branch 'dev' into feat/enable_7702_test
Browse files Browse the repository at this point in the history
  • Loading branch information
ulbqb committed Dec 4, 2024
2 parents 68cf02e + bcb8faf commit 35888bf
Show file tree
Hide file tree
Showing 68 changed files with 1,148 additions and 2,448 deletions.
14 changes: 7 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,31 @@ executors:
working_directory: ~/go/src/github.com/kaiachain/kaia
resource_class: medium
docker:
- image: kaiachain/build_base:1.12-go.1.22.1-solc0.8.13-ubuntu-20.04
- image: kaiachain/build_base:go1.23.3-solc0.8.13-ubuntu-22.04
auth:
username: $DOCKER_LOGIN
password: $DOCKER_PASSWORD
tar-linux-arm64-executor: # this executor is for linux-arm64 tar packaging
working_directory: ~/go/src/github.com/kaiachain/kaia
resource_class: arm.medium
docker:
- image: kaiachain/build_base:1.12-go.1.22.1-solc0.8.13-ubuntu-20.04-arm
- image: kaiachain/build_base:go1.23.3-solc0.8.13-ubuntu-22.04-arm
auth:
username: $DOCKER_LOGIN
password: $DOCKER_PASSWORD
rpm-linux-amd64-executor: # this executor is for linux-amd64 rpm packaging
working_directory: /go/src/github.com/kaiachain/kaia
resource_class: medium
docker:
- image: kaiachain/circleci-rpmbuild:1.22.1-gcc7
- image: kaiachain/circleci-rpmbuild:1.23.3-gcc11
auth:
username: $DOCKER_LOGIN
password: $DOCKER_PASSWORD
rpm-linux-arm64-executor: # this executor is for linux-arm64 rpm packaging
working_directory: /go/src/github.com/kaiachain/kaia
resource_class: arm.medium
docker:
- image: kaiachain/circleci-rpmbuild:1.22.1-gcc7-arm
- image: kaiachain/circleci-rpmbuild:1.23.3-gcc11-arm
auth:
username: $DOCKER_LOGIN
password: $DOCKER_PASSWORD
Expand All @@ -60,15 +60,15 @@ executors:
working_directory: ~/go/src/github.com/kaiachain/kaia
resource_class: medium
docker:
- image: kaiachain/build_base:1.12-go.1.22.1-solc0.8.13-ubuntu-20.04
- image: kaiachain/build_base:go1.23-solc0.8.13-ubuntu-22.04
auth:
username: $DOCKER_LOGIN
password: $DOCKER_PASSWORD
test-others-executor: # this executor is for test-others job
working_directory: /go/src/github.com/kaiachain/kaia
resource_class: xlarge
docker:
- image: kaiachain/build_base:1.12-go.1.22.1-solc0.8.13-ubuntu-20.04
- image: kaiachain/build_base:go1.23-solc0.8.13-ubuntu-22.04
auth:
username: $DOCKER_LOGIN
password: $DOCKER_PASSWORD
Expand Down Expand Up @@ -107,7 +107,7 @@ commands:
name: "set variables"
command: |
export GOPATH=~/go
export PATH=$HOME/go1.22.1/go/bin:$PATH
export PATH=$HOME/go1.23.3/go/bin:$PATH
pat="^v[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+.*"
if [[ $CIRCLE_TAG =~ $pat ]]; then
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
#* @global-owner1 @global-owner2
* @aidan-kwon @blukat29 @yoomee1313 @ian0371
* @blukat29 @yoomee1313 @ian0371

# Order is important; the last matching pattern takes the most
# precedence. When someone opens a pull request that only
Expand Down
13 changes: 5 additions & 8 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ const (
)

const (
DefaultTriesInMemory = 128
DefaultBlockInterval = 128
DefaultLivePruningRetention = 172800 // 2*params.DefaultStakeUpdateInterval
MaxPrefetchTxs = 20000
DefaultTriesInMemory = 128
DefaultBlockInterval = 128
DefaultPruningRetention = 172800 // 2*params.DefaultStakeUpdateInterval
MaxPrefetchTxs = 20000

// BlockChainVersion ensures that an incompatible database forces a resync from scratch.
// Changelog:
Expand Down Expand Up @@ -239,7 +239,7 @@ func NewBlockChain(db database.DBManager, cacheConfig *CacheConfig, chainConfig
CacheSize: 512,
BlockInterval: DefaultBlockInterval,
TriesInMemory: DefaultTriesInMemory,
LivePruningRetention: DefaultLivePruningRetention,
LivePruningRetention: DefaultPruningRetention,
TrieNodeCacheConfig: statedb.GetEmptyTrieNodeCacheConfig(),
SnapshotCacheSize: 512,
SnapshotAsyncGen: true,
Expand Down Expand Up @@ -638,9 +638,6 @@ func (bc *BlockChain) setHeadBeyondRoot(head uint64, root common.Hash, repair bo
if params.IsCheckpointInterval(num) {
bc.db.DeleteIstanbulSnapshot(hash)
}
if bc.Config().Istanbul.ProposerPolicy == params.WeightedRandom && !bc.Config().IsKaiaForkEnabled(new(big.Int).SetUint64(num)) && params.IsStakingUpdateInterval(num) {
bc.db.DeleteStakingInfo(num)
}

for _, module := range bc.rewindableModules {
module.RewindDelete(hash, num)
Expand Down
233 changes: 121 additions & 112 deletions blockchain/types/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,119 +756,128 @@ func TestTransactionCoding(t *testing.T) {
t.Fatalf("could not generate key: %v", err)
}
var (
signer = LatestSignerForChainID(common.Big1)
addr = common.HexToAddress("0x0000000000000000000000000000000000000001")
recipient = common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87")
accesses = AccessList{{Address: addr, StorageKeys: []common.Hash{{0}}}}
)
for i := uint64(0); i < 500; i++ {
var txData TxInternalData
switch i % 5 {
case 0:
// Legacy tx.
txData = &TxInternalDataLegacy{
AccountNonce: i,
Recipient: &recipient,
GasLimit: 1,
Price: big.NewInt(2),
Payload: []byte("abcdef"),
}
case 1:
// Legacy tx contract creation.
txData = &TxInternalDataLegacy{
AccountNonce: i,
GasLimit: 1,
Price: big.NewInt(2),
Payload: []byte("abcdef"),
}
case 2:
// Tx with non-zero access list.
txData = &TxInternalDataEthereumAccessList{
ChainID: big.NewInt(1),
AccountNonce: i,
Recipient: &recipient,
GasLimit: 123457,
Price: big.NewInt(10),
AccessList: accesses,
Payload: []byte("abcdef"),
}
case 3:
// Tx with empty access list.
txData = &TxInternalDataEthereumAccessList{
ChainID: big.NewInt(1),
AccountNonce: i,
Recipient: &recipient,
GasLimit: 123457,
Price: big.NewInt(10),
Payload: []byte("abcdef"),
}
case 4:
// Contract creation with access list.
txData = &TxInternalDataEthereumAccessList{
ChainID: big.NewInt(1),
AccountNonce: i,
GasLimit: 123457,
Price: big.NewInt(10),
AccessList: accesses,
}
case 5:
// Tx with non-zero access list.
txData = &TxInternalDataEthereumDynamicFee{
ChainID: big.NewInt(1),
AccountNonce: i,
Recipient: &recipient,
GasLimit: 123457,
GasFeeCap: big.NewInt(10),
GasTipCap: big.NewInt(10),
AccessList: accesses,
Payload: []byte("abcdef"),
}
case 6:
// Tx with dynamic fee.
txData = &TxInternalDataEthereumDynamicFee{
ChainID: big.NewInt(1),
AccountNonce: i,
Recipient: &recipient,
GasLimit: 123457,
GasFeeCap: big.NewInt(10),
GasTipCap: big.NewInt(10),
Payload: []byte("abcdef"),
}
case 7:
// Contract creation with dynamic fee tx.
txData = &TxInternalDataEthereumDynamicFee{
ChainID: big.NewInt(1),
AccountNonce: i,
GasLimit: 123457,
GasFeeCap: big.NewInt(10),
GasTipCap: big.NewInt(10),
AccessList: accesses,
}
case 8:
// Tx with non-zero access list.
txData = &TxInternalDataEthereumSetCode{
ChainID: big.NewInt(1),
AccountNonce: i,
Recipient: recipient,
GasLimit: 123457,
GasFeeCap: big.NewInt(10),
GasTipCap: big.NewInt(10),
AccessList: accesses,
AuthorizationList: authorizations,
}
case 9:
// Tx with set code.
txData = &TxInternalDataEthereumSetCode{
ChainID: big.NewInt(1),
AccountNonce: i,
Recipient: recipient,
GasLimit: 123457,
GasFeeCap: big.NewInt(10),
GasTipCap: big.NewInt(10),
AuthorizationList: authorizations,
}
signer = LatestSignerForChainID(common.Big1)
addr = common.HexToAddress("0x0000000000000000000000000000000000000001")
recipient = common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87")
accesses = AccessList{{Address: addr, StorageKeys: []common.Hash{{0}}}}
txDataList = []func(uint64) TxInternalData{
func(i uint64) TxInternalData {
// Legacy tx.
return &TxInternalDataLegacy{
AccountNonce: i,
Recipient: &recipient,
GasLimit: 1,
Price: big.NewInt(2),
Payload: []byte("abcdef"),
}
},
func(i uint64) TxInternalData {
// Legacy tx contract creation.
return &TxInternalDataLegacy{
AccountNonce: i,
GasLimit: 1,
Price: big.NewInt(2),
Payload: []byte("abcdef"),
}
},
func(i uint64) TxInternalData {
// Tx with non-zero access list.
return &TxInternalDataEthereumAccessList{
ChainID: big.NewInt(1),
AccountNonce: i,
Recipient: &recipient,
GasLimit: 123457,
Price: big.NewInt(10),
AccessList: accesses,
Payload: []byte("abcdef"),
}
},
func(i uint64) TxInternalData {
// Tx with empty access list.
return &TxInternalDataEthereumAccessList{
ChainID: big.NewInt(1),
AccountNonce: i,
Recipient: &recipient,
GasLimit: 123457,
Price: big.NewInt(10),
Payload: []byte("abcdef"),
}
},
func(i uint64) TxInternalData {
// Contract creation with access list.
return &TxInternalDataEthereumAccessList{
ChainID: big.NewInt(1),
AccountNonce: i,
GasLimit: 123457,
Price: big.NewInt(10),
AccessList: accesses,
}
},
func(i uint64) TxInternalData {
// Tx with non-zero access list.
return &TxInternalDataEthereumDynamicFee{
ChainID: big.NewInt(1),
AccountNonce: i,
Recipient: &recipient,
GasLimit: 123457,
GasFeeCap: big.NewInt(10),
GasTipCap: big.NewInt(10),
AccessList: accesses,
Payload: []byte("abcdef"),
}
},
func(i uint64) TxInternalData {
// Tx with dynamic fee.
return &TxInternalDataEthereumDynamicFee{
ChainID: big.NewInt(1),
AccountNonce: i,
Recipient: &recipient,
GasLimit: 123457,
GasFeeCap: big.NewInt(10),
GasTipCap: big.NewInt(10),
Payload: []byte("abcdef"),
}
},
func(i uint64) TxInternalData {
// Contract creation with dynamic fee tx.
return &TxInternalDataEthereumDynamicFee{
ChainID: big.NewInt(1),
AccountNonce: i,
GasLimit: 123457,
GasFeeCap: big.NewInt(10),
GasTipCap: big.NewInt(10),
AccessList: accesses,
}
},
func(i uint64) TxInternalData {
// Tx with non-zero access list.
return &TxInternalDataEthereumSetCode{
ChainID: big.NewInt(1),
AccountNonce: i,
Recipient: recipient,
GasLimit: 123457,
GasFeeCap: big.NewInt(10),
GasTipCap: big.NewInt(10),
AccessList: accesses,
AuthorizationList: authorizations,
}
},
func(i uint64) TxInternalData {
// Tx with set code.
return &TxInternalDataEthereumSetCode{
ChainID: big.NewInt(1),
AccountNonce: i,
Recipient: recipient,
GasLimit: 123457,
GasFeeCap: big.NewInt(10),
GasTipCap: big.NewInt(10),
AuthorizationList: authorizations,
}
},
}

)
for i := 0; i < 500; i++ {
txData := txDataList[i%len(txDataList)](uint64(i))
transaction := Transaction{data: txData}
tx, err := SignTx(&transaction, signer, key)
if err != nil {
Expand Down
26 changes: 26 additions & 0 deletions blockchain/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package vm

import (
"bytes"
"crypto/ecdsa"
"crypto/sha256"
"encoding/binary"
Expand Down Expand Up @@ -216,6 +217,31 @@ func ActivePrecompiles(rules params.Rules) []common.Address {
}
}

// IsPrecompiledContractAddress returns true if this is used for TestExecutionSpecState and the input address is one of precompiled contract addresses.
func IsPrecompiledContractAddress(addr common.Address, rules params.Rules) bool {
if relaxPrecompileRangeForTest {
activePrecompiles := ActivePrecompiles(rules)
for _, pre := range activePrecompiles {
// skip 0x0a and 0x0b if before Prague
if !rules.IsPrague && (bytes.Compare(pre.Bytes(), []byte{10}) == 0 || bytes.Compare(pre.Bytes(), []byte{11}) == 0) {
continue
}
if bytes.Compare(pre.Bytes(), addr.Bytes()) == 0 {
return true
}
}
return false
}
return common.IsPrecompiledContractAddress(addr)
}

var relaxPrecompileRangeForTest bool

// Only for testing. Make sure to reset (false) after test.
func RelaxPrecompileRangeForTest(enable bool) {
relaxPrecompileRangeForTest = enable
}

// RunPrecompiledContract runs and evaluates the output of a precompiled contract.
func RunPrecompiledContract(p PrecompiledContract, input []byte, contract *Contract, evm *EVM) (ret []byte, computationCost uint64, err error) {
gas, computationCost := p.GetRequiredGasAndComputationCost(input)
Expand Down
Loading

0 comments on commit 35888bf

Please sign in to comment.