Skip to content

Commit

Permalink
Merge pull request #5527 from onflow/ramtin/5459-add-testnet-chainID
Browse files Browse the repository at this point in the history
[Flow EVM] add testnet chainID
  • Loading branch information
ramtinms authored Mar 12, 2024
2 parents fe758fc + 27372df commit 87494ce
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion fvm/evm/emulator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (c *Config) ChainRules() gethParams.Rules {
// and set a proper height for the specific release based on the Flow EVM heights
// so it could gets activated at a desired time.
var DefaultChainConfig = &gethParams.ChainConfig{
ChainID: types.FlowEVMTestnetChainID, // default is testnet
ChainID: types.FlowEVMPreviewNetChainID,

// Fork scheduling based on block heights
HomesteadBlock: bigZero,
Expand Down
4 changes: 2 additions & 2 deletions fvm/evm/emulator/emulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func TestContractInteraction(t *testing.T) {
nonce += 1

ret := new(big.Int).SetBytes(res.ReturnedValue)
require.Equal(t, types.FlowEVMTestnetChainID, ret)
require.Equal(t, types.FlowEVMPreviewNetChainID, ret)
})
})

Expand Down Expand Up @@ -328,7 +328,7 @@ func TestContractInteraction(t *testing.T) {
tx := account.SignTx(
t,
gethTypes.NewTx(&gethTypes.DynamicFeeTx{
ChainID: types.FlowEVMTestnetChainID,
ChainID: types.FlowEVMPreviewNetChainID,
Nonce: account.Nonce(),
GasTipCap: big.NewInt(2),
GasFeeCap: big.NewInt(3),
Expand Down
18 changes: 11 additions & 7 deletions fvm/evm/types/chainIDs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ import (
)

var (
FlowEVMTestnetChainID = big.NewInt(646)
FlowEVMMainnetChainID = big.NewInt(747)
FlowEVMPreviewNetChainID = big.NewInt(646)
FlowEVMTestNetChainID = big.NewInt(545)
FlowEVMMainNetChainID = big.NewInt(747)
)

func EVMChainIDFromFlowChainID(flowChainID flow.ChainID) *big.Int {
// default evm chain ID is testnet
chainID := FlowEVMTestnetChainID
if flowChainID == flow.Mainnet {
chainID = FlowEVMMainnetChainID
// default evm chain ID is previewNet
switch flowChainID {
case flow.Mainnet:
return FlowEVMMainNetChainID
case flow.Testnet:
return FlowEVMTestNetChainID
default:
return FlowEVMPreviewNetChainID
}
return chainID
}
2 changes: 1 addition & 1 deletion fvm/evm/types/emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type BlockContext struct {
// NewDefaultBlockContext returns a new default block context
func NewDefaultBlockContext(BlockNumber uint64) BlockContext {
return BlockContext{
ChainID: FlowEVMTestnetChainID,
ChainID: FlowEVMPreviewNetChainID,
BlockNumber: BlockNumber,
DirectCallBaseGasUsage: DefaultDirectCallBaseGasUsage,
DirectCallGasPrice: DefaultDirectCallGasPrice,
Expand Down

0 comments on commit 87494ce

Please sign in to comment.