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

Release/6.0.0: Official Mainnet & Testnet #28

Merged
merged 13 commits into from
Feb 29, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
# In order:
# * Module download cache
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
# In order:
# * Module download cache
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
# In order:
# * Module download cache
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Electroneum Smart Chain supports cross-chain transfers between our legacy Electr

For prerequisites and detailed build instructions please read the [Installation Instructions](https://github.com/electroneum/electroneum-sc/wiki/Install-and-Build).

Building `etn-sc` requires both a Go (version 1.16 or later) and a C compiler. You can install
Building `etn-sc` requires both a Go (version 1.19 or later) and a C compiler. You can install
them using your favourite package manager. Once the dependencies are installed, run

```shell
Expand Down Expand Up @@ -135,7 +135,7 @@ Specifying the `--testnet` flag, however, will reconfigure your `etn-sc` instanc
*Note: Although there are some internal protective measures to prevent transactions from
crossing over between the main network and test network, you should make sure to always
use separate accounts for play-cryptocurrency and real-cryptocurrency. Unless you manually move
accounts, `ls etn-sc` will by default correctly separate the two networks and will not make any
accounts, `etn-sc` will by default correctly separate the two networks and will not make any
accounts available between them.*

### Configuration
Expand Down
4 changes: 2 additions & 2 deletions cmd/etn-sc/consolecmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestConsoleWelcome(t *testing.T) {
geth.SetTemplateFunc("gover", runtime.Version)
geth.SetTemplateFunc("gethver", func() string { return params.VersionWithCommit("", "") })
geth.SetTemplateFunc("niltime", func() string {
return time.Unix(1655988353, 0).Format("Mon Jan 02 2006 15:04:05 GMT-0700 (MST)")
return time.Unix(1707989393, 0).Format("Mon Jan 02 2006 15:04:05 GMT-0700 (MST)")
})
geth.SetTemplateFunc("apis", func() string { return ipcAPIs })

Expand Down Expand Up @@ -132,7 +132,7 @@ func testAttachWelcome(t *testing.T, geth *testgeth, endpoint, apis string) {
attach.SetTemplateFunc("gover", runtime.Version)
attach.SetTemplateFunc("gethver", func() string { return params.VersionWithCommit("", "") })
attach.SetTemplateFunc("niltime", func() string {
return time.Unix(1655988353, 0).Format("Mon Jan 02 2006 15:04:05 GMT-0700 (MST)")
return time.Unix(1707989393, 0).Format("Mon Jan 02 2006 15:04:05 GMT-0700 (MST)")
})
attach.SetTemplateFunc("ipc", func() bool { return strings.HasPrefix(endpoint, "ipc") })
attach.SetTemplateFunc("datadir", func() string { return geth.Datadir })
Expand Down
29 changes: 24 additions & 5 deletions consensus/istanbul/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,32 @@ func (c *core) newRoundChangeTimer() {
// set timeout based on the round number
baseTimeout := time.Duration(c.config.GetConfig(c.current.Sequence()).RequestTimeoutSeconds) * time.Second
round := c.current.Round().Uint64()

timeout := baseTimeout * time.Duration(math.Pow(2, float64(round)))

maxRequestTimeout := time.Duration(c.config.GetConfig(c.current.Sequence()).MaxRequestTimeoutSeconds) * time.Second

if maxRequestTimeout > time.Duration(0) && timeout > maxRequestTimeout {
timeout = maxRequestTimeout
// If the upper limit of the request timeout is capped by small maxRequestTimeout, round can be a quite large number,
// which leads to float64 overflow, making its value negative or zero forever after some point.
// In this case we cannot simply use math.Pow and have to implement a safeguard on our own, at the cost of performance (which is not important in this case).
var timeout time.Duration
if maxRequestTimeout > time.Duration(0) {
timeout = baseTimeout
for i := uint64(0); i < round; i++ {
timeout = timeout * 2
if timeout > maxRequestTimeout {
timeout = maxRequestTimeout
break
}
}
// prevent log storm when unexpected overflow happens
if timeout < baseTimeout {
c.currentLogger(true, nil).Error("QBFT: Possible request timeout overflow detected, setting timeout value to maxRequestTimeout",
"timeout", timeout.Seconds(),
"max_request_timeout", maxRequestTimeout.Seconds(),
)
timeout = maxRequestTimeout
}
} else {
// effectively impossible to observe overflow happen when maxRequestTimeout is disabled
timeout = baseTimeout * time.Duration(math.Pow(2, float64(round)))
}

c.currentLogger(true, nil).Trace("IBFT: start new ROUND-CHANGE timer", "timeout", timeout.Seconds())
Expand Down
16 changes: 8 additions & 8 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/electroneum/electroneum-sc/rlp"
"math/big"

"github.com/electroneum/electroneum-sc/rlp"

"github.com/electroneum/electroneum-sc/common"
"github.com/electroneum/electroneum-sc/common/hexutil"
"github.com/electroneum/electroneum-sc/common/math"
Expand Down Expand Up @@ -423,7 +424,6 @@ func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big
}

func GenerateGenesisExtraDataForIBFTValSet(valset []common.Address) []byte {

// Initialize a pointer to an instance of types.QBFTExtra
extra := &types.QBFTExtra{
VanityData: make([]byte, 32),
Expand All @@ -439,8 +439,8 @@ func GenerateGenesisExtraDataForIBFTValSet(valset []common.Address) []byte {
panic("RLP Encoding of genesis extra failed. Unable to create genesis block")
}

genesisExtraDataHex := hex.EncodeToString(extraBytes)
fmt.Println(genesisExtraDataHex)
//genesisExtraDataHex := hex.EncodeToString(extraBytes)
//fmt.Println(genesisExtraDataHex)

return extraBytes
}
Expand All @@ -463,16 +463,16 @@ func DefaultGenesisBlock() *Genesis {
Config: params.MainnetChainConfig,
Number: 0,
Nonce: 0,
Timestamp: 0,
Timestamp: 1709141867, // 28 Feb 2024
ExtraData: GenerateGenesisExtraDataForIBFTValSet(validatorSet),
GasLimit: 30000000,
GasUsed: 0, //ok unless we add a smart contract in the genesis state
Difficulty: big.NewInt(1),
Mixhash: common.HexToHash("0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365"),
ParentHash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
Coinbase: common.Address{},
Alloc: GenesisAlloc{ //TODO: get etn circulating supply allocated to the bridge address. the address is already correct
common.HexToAddress("0x7b56c6e6f53498e3e9332b180fe41f1add202f28"): {Balance: math.MustParseBig256("1000000000000000000000000000")},
Alloc: GenesisAlloc{
common.HexToAddress("0x7b56c6e6f53498e3e9332b180fe41f1add202f28"): {Balance: math.MustParseBig256("17964946965760000000000000000")}, // = terminal circulating supply for legacy mainnet [0,1806749}. Legacy emissions are burned from height 1806749 onwards
},
}
}
Expand All @@ -489,7 +489,7 @@ func DefaultTestnetGenesisBlock() *Genesis {
Config: params.TestnetChainConfig,
Number: 0,
Nonce: 0,
Timestamp: 1693335596, // tue 29 aug 2023
Timestamp: 1707989393, // feb 15 2024
ExtraData: GenerateGenesisExtraDataForIBFTValSet(validatorSet),
GasLimit: 30000000,
GasUsed: 0, //ok unless we add a smart contract in the genesis state
Expand Down
3 changes: 3 additions & 0 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
effectiveTip := st.gasPrice
if rules.IsLondon {
effectiveTip = cmath.BigMin(st.gasTipCap, new(big.Int).Sub(st.gasFeeCap, st.evm.Context.BaseFee)) // gastipcap is zero for priority tx with waiver, so this holds fine
if effectiveTip.Sign() < 0 {
effectiveTip = new(big.Int).SetUint64(0)
}
}
st.state.AddBalance(st.evm.Context.Coinbase, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), effectiveTip)) //this is where you do the coinbase payout of the miner tip

Expand Down
13 changes: 7 additions & 6 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (

// Genesis hashes to enforce below configs on.
var (
MainnetGenesisHash = common.HexToHash("0x4fda998638776057c8c27989bc021aed4b813fcebd483bf7a6b139f6efb324a6")
MainnetGenesisHash = common.HexToHash("0x9ec40a3c9e4165b0150331271abf47984ca2614ca11b08c29a5fdd547566401b")
StagenetGenesisHash = common.HexToHash("0x619e6f8fa6e99eb9829e1f0c7fa62a999d47bf8a7da51a72c2af3cd83cb6e4a3")
TestnetGenesisHash = common.HexToHash("0x31cf4b703626e42f9bded05754f4c6072986a02db46c9c6281a9924aea75a788")
TestnetGenesisHash = common.HexToHash("0x10e52a738c4546344d46c0f0b601476cc9a7ed28dfcd62ead9528fdd1fe56a93")
)

// TrustedCheckpoints associates each known checkpoint with the genesis hash of
Expand Down Expand Up @@ -68,10 +68,11 @@ var (
MaxRequestTimeoutSeconds: 60,
AllowedFutureBlockTime: 5,
},
GenesisETN: math.MustParseBig256("17000000000000000000000000000"), //TODO: Get the exact circulating supply at time of blockchain migration
LegacyV9ForkHeight: big.NewInt(0),
LegacyToSmartchainMigrationHeight: big.NewInt(0),
PriorityTransactorsContractAddress: common.Address{},
GenesisETN: math.MustParseBig256("17964946965760000000000000000"), // = terminal circulating supply for legacy mainnet [0,1806749}. Legacy emissions are burned from height 1806749 onwards
LegacyV9ForkHeight: big.NewInt(862866),
LegacyToSmartchainMigrationHeight: big.NewInt(1806749),
PriorityTransactorsContractAddress: common.HexToAddress("0x92cdf1fc0e54d3150f100265ae2717b0689660ee"),
Transitions: []Transition{},
}

// StagenetChainConfig is the chain parameters to run a node on the test network.
Expand Down
Loading