From 4d4e2586af4c2ccd5a6281b18e2ac96fde99fda5 Mon Sep 17 00:00:00 2001 From: "Aljaz S." <117018081+aljazs-flare@users.noreply.github.com> Date: Wed, 22 Nov 2023 14:17:04 +0000 Subject: [PATCH 01/14] Add support for fallback bootstrap endpoints --- README-docker.md | 1 + entrypoint.sh | 43 +++++++++++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 10 deletions(-) mode change 100644 => 100755 entrypoint.sh diff --git a/README-docker.md b/README-docker.md index f4364fe8..f785bb88 100644 --- a/README-docker.md +++ b/README-docker.md @@ -54,6 +54,7 @@ These are the environment variables you can edit and their default values: | `AUTOCONFIGURE_PUBLIC_IP` | `0` | Set to `1` to autoconfigure `PUBLIC_IP`, skipped if PUBLIC_IP is set | | `AUTOCONFIGURE_BOOTSTRAP` | `0` | Set to `1` to autoconfigure `BOOTSTRAP_IPS` and `BOOTSTRAP_IDS` | | `AUTOCONFIGURE_BOOTSTRAP_ENDPOINT` | `https://coston2.flare.network/ext/info` | Endpoint used for [bootstrapping](https://docs.avax.network/nodes/maintain/avalanchego-config-flags#bootstrapping) when `AUTOCONFIGURE_BOOTSTRAP` is enabled. Possible values are `https://coston2.flare.network/ext/info` or `https://flare.flare.network/ext/info`. | +| `AUTOCONFIGURE_FALLBACK_ENDPOINTS` | _(empty)_ | Comma-divided fallback bootstrap endpoints, used if `AUTOCONFIGURE_BOOTSTRAP_ENDPOINT` is not valid (not whitelisted / unreachable / etc), tested from first-to-last until one is valid | | `BOOTSTRAP_BEACON_CONNECTION_TIMEOUT` | `1m` | Set the duration value (eg. `45s` / `5m` / `1h`) for [--bootstrap-beacon-connection-timeout](https://docs.avax.network/nodes/maintain/avalanchego-config-flags#--bootstrap-beacon-connection-timeout-duration) AvalancheGo flag. | | `EXTRA_ARGUMENTS` | | Extra arguments passed to flare binary | diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755 index 260197a9..da28dfca --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,27 +7,50 @@ then if [ "$PUBLIC_IP" = "" ]; then echo "Autoconfiguring public IP" - PUBLIC_IP=$(curl https://api.ipify.org/) + PUBLIC_IP=$(curl -s https://api.ipify.org/) + echo " Got public address '${PUBLIC_IP}'" else echo "/!\\ AUTOCONFIGURE_PUBLIC_IP is enabled, but PUBLIC_IP is already set to '$PUBLIC_IP'! Skipping autoconfigure and using current PUBLIC_IP value!" fi fi -# Check if we can connect to the bootstrap endpoint (whitelisting) -BOOTSTRAP_STATUS=$(curl -m 10 -s -w %{http_code} -X POST --data '{ "jsonrpc":"2.0", "id":1, "method":"info.getNodeIP" }' -H 'content-type:application/json;' "$AUTOCONFIGURE_BOOTSTRAP_ENDPOINT" -o /dev/null) -if [ "$BOOTSTRAP_STATUS" != "200" ]; then - echo "Could not connect to bootstrap endpoint. Is your IP whitelisted?" - exit 1 -fi - if [ "$AUTOCONFIGURE_BOOTSTRAP" = "1" ]; then + + + __BOOTSTRAP_ENDPOINTS=("${AUTOCONFIGURE_BOOTSTRAP_ENDPOINT}" ${AUTOCONFIGURE_FALLBACK_ENDPOINTS//,/ }) + + echo "Trying provided bootstrap endpoints" + for __ENDPOINT in "${__BOOTSTRAP_ENDPOINTS[@]}"; do + echo " Trying endpoint $__ENDPOINT" + + RESPONSE_CODE=$(curl -X POST -m 5 -s -o /dev/null -w '%{http_code}' "$__ENDPOINT" -H 'Content-Type: application/json' --data '{ "jsonrpc":"2.0", "id":1, "method":"info.getNodeIP" }' || true) + if [ "$RESPONSE_CODE" = "200" ]; then + __BOOTSTRAP_ENDPOINT="$__ENDPOINT" + break + else + echo " Failed! The endpoint is unreachable or your IP is not whitelisted." + continue + fi + done + + if [ -z "$__BOOTSTRAP_ENDPOINT" ]; then + echo " None of provided bootstrap endpoints worked!" + exit 1 + fi + + echo "Autoconfiguring bootstrap IPs and IDs" - BOOTSTRAP_IPS=$(curl -m 10 -sX POST --data '{ "jsonrpc":"2.0", "id":1, "method":"info.getNodeIP" }' -H 'content-type:application/json;' "$AUTOCONFIGURE_BOOTSTRAP_ENDPOINT" | jq -r ".result.ip") - BOOTSTRAP_IDS=$(curl -m 10 -sX POST --data '{ "jsonrpc":"2.0", "id":1, "method":"info.getNodeID" }' -H 'content-type:application/json;' "$AUTOCONFIGURE_BOOTSTRAP_ENDPOINT" | jq -r ".result.nodeID") + BOOTSTRAP_IPS=$(curl -m 10 -sX POST --data '{ "jsonrpc":"2.0", "id":1, "method":"info.getNodeIP" }' -H 'content-type:application/json;' "$__BOOTSTRAP_ENDPOINT" | jq -r ".result.ip") + BOOTSTRAP_IDS=$(curl -m 10 -sX POST --data '{ "jsonrpc":"2.0", "id":1, "method":"info.getNodeID" }' -H 'content-type:application/json;' "$__BOOTSTRAP_ENDPOINT" | jq -r ".result.nodeID") + + echo " Got bootstrap ips: '${BOOTSTRAP_IPS}'" + echo " Got bootstrap ids: '${BOOTSTRAP_IDS}'" fi +exit 0 + /app/build/avalanchego \ --http-host=$HTTP_HOST \ --http-port=$HTTP_PORT \ From 407b8850275ea9371a450b0be305a3bc0b3afd67 Mon Sep 17 00:00:00 2001 From: "Aljaz S." <117018081+aljazs-flare@users.noreply.github.com> Date: Fri, 1 Dec 2023 15:36:32 +0000 Subject: [PATCH 02/14] removed a stray "exit 0" --- entrypoint.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index da28dfca..51f7cea0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -49,8 +49,6 @@ then echo " Got bootstrap ids: '${BOOTSTRAP_IDS}'" fi -exit 0 - /app/build/avalanchego \ --http-host=$HTTP_HOST \ --http-port=$HTTP_PORT \ From 1ae4958191fb1889794a555b4148f820cf4c0ad8 Mon Sep 17 00:00:00 2001 From: "Aljaz S." <117018081+aljazs-flare@users.noreply.github.com> Date: Fri, 1 Dec 2023 15:37:07 +0000 Subject: [PATCH 03/14] Removed unnecesary "not whitelisted" error message text --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 51f7cea0..f5d7305a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -29,7 +29,7 @@ then __BOOTSTRAP_ENDPOINT="$__ENDPOINT" break else - echo " Failed! The endpoint is unreachable or your IP is not whitelisted." + echo " Failed! The endpoint is unreachable." continue fi done From 731e227b9e03764e3b4b212b902ba2d208bb984e Mon Sep 17 00:00:00 2001 From: morris-kamau Date: Tue, 9 Jan 2024 16:51:39 +0300 Subject: [PATCH 04/14] modify the autocofig public IP to use flr DNS instead of ipfy --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index f5d7305a..0e69109b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,7 +7,7 @@ then if [ "$PUBLIC_IP" = "" ]; then echo "Autoconfiguring public IP" - PUBLIC_IP=$(curl -s https://api.ipify.org/) + PUBLIC_IP=$(curl -s -m 10 https://flare.network/cdn-cgi/trace | grep 'ip=' | cut -d'=' -f2) echo " Got public address '${PUBLIC_IP}'" else echo "/!\\ AUTOCONFIGURE_PUBLIC_IP is enabled, but PUBLIC_IP is already set to '$PUBLIC_IP'! Skipping autoconfigure and using current PUBLIC_IP value!" @@ -49,7 +49,7 @@ then echo " Got bootstrap ids: '${BOOTSTRAP_IDS}'" fi -/app/build/avalanchego \ +exec /app/build/avalanchego \ --http-host=$HTTP_HOST \ --http-port=$HTTP_PORT \ --staking-port=$STAKING_PORT \ From 7052634c8b7216fb3fab67716156c094d81d9a02 Mon Sep 17 00:00:00 2001 From: morris-kamau Date: Tue, 9 Jan 2024 16:59:07 +0300 Subject: [PATCH 05/14] change empty var check for publicIP --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 0e69109b..4dfc5707 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,7 +4,7 @@ set -eo pipefail if [ "$AUTOCONFIGURE_PUBLIC_IP" = "1" ]; then - if [ "$PUBLIC_IP" = "" ]; + if [ -z "$PUBLIC_IP" ]; then echo "Autoconfiguring public IP" PUBLIC_IP=$(curl -s -m 10 https://flare.network/cdn-cgi/trace | grep 'ip=' | cut -d'=' -f2) From b710862003e1699797e20ac806d0d4b6369ef8e1 Mon Sep 17 00:00:00 2001 From: Marko Boben Date: Tue, 23 Jan 2024 17:57:15 +0100 Subject: [PATCH 06/14] Added prioritised handling of submitter contract --- coreth/core/daemon.go | 29 +++++++++++++++++++++++++++++ coreth/core/state_transition.go | 23 +++++++++++++---------- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/coreth/core/daemon.go b/coreth/core/daemon.go index 90bd8cc7..d6652c73 100644 --- a/coreth/core/daemon.go +++ b/coreth/core/daemon.go @@ -80,6 +80,26 @@ func GetPrioritisedFTSOContract(blockTime *big.Int) string { } } +func GetPrioritisedSubmitterContract(blockTime *big.Int) string { + switch { + default: + return "0xEC1C93A9f6a9e18E97784c76aC52053587FcDB89" + } +} + +func IsPrioritisedContractCall(to *common.Address, ret []byte, blockTime *big.Int) bool { + switch { + case to == nil: + return false + case *to == common.HexToAddress(GetPrioritisedFTSOContract(blockTime)): + return true + case *to == common.HexToAddress(GetPrioritisedSubmitterContract(blockTime)): + return !isZeroSlice(ret) + default: + return false + } +} + func GetMaximumMintRequest(blockTime *big.Int) *big.Int { switch { default: @@ -157,3 +177,12 @@ func atomicDaemonAndMint(evm EVMCaller, log log.Logger) { log.Warn("Daemon error", "error", daemonErr) } } + +func isZeroSlice(s []byte) bool { + for i := len(s) - 1; i >= 0; i-- { + if s[i] != 0 { + return false + } + } + return true +} diff --git a/coreth/core/state_transition.go b/coreth/core/state_transition.go index d6a49bb2..337fc450 100644 --- a/coreth/core/state_transition.go +++ b/coreth/core/state_transition.go @@ -56,8 +56,10 @@ The state transitioning model does all the necessary work to work out a valid ne 3) Create a new state object if the recipient is \0*32 4) Value transfer == If contract creation == - 4a) Attempt to run transaction data - 4b) If valid, use result as code for the new state object + + 4a) Attempt to run transaction data + 4b) If valid, use result as code for the new state object + == end == 5) Run Script section 6) Derive new state root @@ -300,13 +302,13 @@ func (st *StateTransition) preCheck() error { // TransitionDb will transition the state by applying the current message and // returning the evm execution result with following fields. // -// - used gas: -// total gas used (including gas being refunded) -// - returndata: -// the returned data from evm -// - concrete execution error: -// various **EVM** error which aborts the execution, -// e.g. ErrOutOfGas, ErrExecutionReverted +// - used gas: +// total gas used (including gas being refunded) +// - returndata: +// the returned data from evm +// - concrete execution error: +// various **EVM** error which aborts the execution, +// e.g. ErrOutOfGas, ErrExecutionReverted // // However if any consensus issue encountered, return the error directly with // nil evm execution result. @@ -417,7 +419,8 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { } st.refundGas(rules.IsApricotPhase1) - if vmerr == nil && msg.To() != nil && *msg.To() == common.HexToAddress(GetPrioritisedFTSOContract(timestamp)) && st.initialGas <= GetMaxFTSOGasLimit(timestamp) { + // if vmerr == nil && msg.To() != nil && *msg.To() == common.HexToAddress(GetPrioritisedFTSOContract(timestamp)) && st.initialGas <= GetMaxFTSOGasLimit(timestamp) { + if vmerr == nil && IsPrioritisedContractCall(msg.To(), ret, timestamp) && st.initialGas <= GetMaxFTSOGasLimit(timestamp) { nominalGasUsed := uint64(params.TxGas) // 21000 nominalGasPrice := uint64(params.ApricotPhase4MinBaseFee) // 25_000_000_000; the max base fee is 1_000_000_000_000 nominalFee := new(big.Int).Mul(new(big.Int).SetUint64(nominalGasUsed), new(big.Int).SetUint64(nominalGasPrice)) From 1048112b09f213e8ec0d611cfad82419fd9f81cb Mon Sep 17 00:00:00 2001 From: Marko Boben Date: Thu, 25 Jan 2024 00:17:54 +0100 Subject: [PATCH 07/14] Fork times for submitter contract --- coreth/core/daemon.go | 40 ++++++++++++++++++++++++++------- coreth/core/daemon_test.go | 30 +++++++++++++++++++++++++ coreth/core/state_transition.go | 3 +-- 3 files changed, 63 insertions(+), 10 deletions(-) diff --git a/coreth/core/daemon.go b/coreth/core/daemon.go index d6652c73..8a8c2376 100644 --- a/coreth/core/daemon.go +++ b/coreth/core/daemon.go @@ -6,11 +6,27 @@ package core import ( "fmt" "math/big" + "os" + "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" "github.com/ava-labs/coreth/core/vm" + "github.com/ava-labs/coreth/params" +) + +var ( + // Define activation times for submitter contract + submitterContractActivationTimeFlare = big.NewInt(time.Date(2024, time.March, 1, 12, 0, 0, 0, time.UTC).Unix()) + submitterContractActivationTimeCostwo = big.NewInt(time.Date(2024, time.January, 31, 12, 0, 0, 0, time.UTC).Unix()) + + // Define ftso and submitter contract addresses + prioritisedFTSOContractAddress = common.HexToAddress("0x1000000000000000000000000000000000000003") + + prioritisedSubmitterContractAddressFlare = common.HexToAddress("0xEC1C93A9f6a9e18E97784c76aC52053587FcDB89") + prioritisedSubmitterContractAddressCostwo = common.HexToAddress("0xEC1C93A9f6a9e18E97784c76aC52053587FcDB89") + prioritisedSubmitterContractAddressEnv = common.HexToAddress(os.Getenv("SUBMITTER_CONTRACT_ADDRESS")) // for local and staging chains ) // Define errors @@ -73,27 +89,35 @@ func GetDaemonSelector(blockTime *big.Int) []byte { } } -func GetPrioritisedFTSOContract(blockTime *big.Int) string { +func isPrioritisedFTSOContract(to *common.Address, blockTime *big.Int) bool { switch { default: - return "0x1000000000000000000000000000000000000003" + return *to == prioritisedFTSOContractAddress } } -func GetPrioritisedSubmitterContract(blockTime *big.Int) string { +func isPrioritisedSubmitterContract(chainID *big.Int, to *common.Address, blockTime *big.Int) bool { switch { + case chainID.Cmp(params.FlareChainID) == 0: + return *to == prioritisedSubmitterContractAddressFlare && + blockTime.Cmp(submitterContractActivationTimeFlare) >= 0 + case chainID.Cmp(params.CostwoChainID) == 0: + return *to == prioritisedSubmitterContractAddressCostwo && + blockTime.Cmp(submitterContractActivationTimeCostwo) >= 0 + case chainID.Cmp(params.LocalFlareChainID) == 0 || chainID.Cmp(params.StagingChainID) == 0: + return *to == prioritisedSubmitterContractAddressEnv default: - return "0xEC1C93A9f6a9e18E97784c76aC52053587FcDB89" + return false } } -func IsPrioritisedContractCall(to *common.Address, ret []byte, blockTime *big.Int) bool { +func IsPrioritisedContractCall(chainID *big.Int, to *common.Address, ret []byte, blockTime *big.Int) bool { switch { - case to == nil: + case to == nil || chainID == nil || blockTime == nil: return false - case *to == common.HexToAddress(GetPrioritisedFTSOContract(blockTime)): + case isPrioritisedFTSOContract(to, blockTime): return true - case *to == common.HexToAddress(GetPrioritisedSubmitterContract(blockTime)): + case isPrioritisedSubmitterContract(chainID, to, blockTime): return !isZeroSlice(ret) default: return false diff --git a/coreth/core/daemon_test.go b/coreth/core/daemon_test.go index 88d224da..8d316780 100644 --- a/coreth/core/daemon_test.go +++ b/coreth/core/daemon_test.go @@ -7,11 +7,13 @@ import ( "errors" "math/big" "testing" + "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" "github.com/ava-labs/coreth/core/vm" + "github.com/ava-labs/coreth/params" ) // Define a mock structure to spy and mock values for daemon calls @@ -476,3 +478,31 @@ func TestDaemonShouldNotMintMoreThanLimit(t *testing.T) { t.Errorf("Add balance call count not as expected. got %d want 1", defaultEVMMock.mockEVMCallerData.addBalanceCalls) } } + +func TestPrioritisedContract(t *testing.T) { + address := common.HexToAddress("0x123456789aBCdEF123456789aBCdef123456789A") + preForkTime := big.NewInt(time.Date(2024, time.February, 1, 12, 0, 0, 0, time.UTC).Unix()) + postForkTime := big.NewInt(time.Date(2024, time.March, 2, 12, 0, 0, 0, time.UTC).Unix()) + ret0 := [32]byte{} + ret1 := [32]byte{} + ret1[31] = 1 + + if IsPrioritisedContractCall(params.FlareChainID, &address, nil, preForkTime) { + t.Errorf("Expected false for wrong address") + } + if !IsPrioritisedContractCall(params.FlareChainID, &prioritisedFTSOContractAddress, nil, preForkTime) { + t.Errorf("Expected true for FTSO contract") + } + if IsPrioritisedContractCall(params.FlareChainID, &prioritisedSubmitterContractAddressFlare, ret1[:], preForkTime) { + t.Errorf("Expected false for submitter contract before activation") + } + if !IsPrioritisedContractCall(params.FlareChainID, &prioritisedSubmitterContractAddressFlare, ret1[:], postForkTime) { + t.Errorf("Expected true for submitter contract after activation") + } + if IsPrioritisedContractCall(params.FlareChainID, &prioritisedSubmitterContractAddressFlare, ret0[:], postForkTime) { + t.Errorf("Expected false for submitter contract with wrong return value") + } + if IsPrioritisedContractCall(params.FlareChainID, &prioritisedSubmitterContractAddressFlare, nil, postForkTime) { + t.Errorf("Expected false for submitter contract with no return value") + } +} diff --git a/coreth/core/state_transition.go b/coreth/core/state_transition.go index 337fc450..f5f5f9b4 100644 --- a/coreth/core/state_transition.go +++ b/coreth/core/state_transition.go @@ -419,8 +419,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { } st.refundGas(rules.IsApricotPhase1) - // if vmerr == nil && msg.To() != nil && *msg.To() == common.HexToAddress(GetPrioritisedFTSOContract(timestamp)) && st.initialGas <= GetMaxFTSOGasLimit(timestamp) { - if vmerr == nil && IsPrioritisedContractCall(msg.To(), ret, timestamp) && st.initialGas <= GetMaxFTSOGasLimit(timestamp) { + if vmerr == nil && IsPrioritisedContractCall(chainID, msg.To(), ret, timestamp) && st.initialGas <= GetMaxFTSOGasLimit(timestamp) { nominalGasUsed := uint64(params.TxGas) // 21000 nominalGasPrice := uint64(params.ApricotPhase4MinBaseFee) // 25_000_000_000; the max base fee is 1_000_000_000_000 nominalFee := new(big.Int).Mul(new(big.Int).SetUint64(nominalGasUsed), new(big.Int).SetUint64(nominalGasPrice)) From d6d641d6ea3f848face4b04da0ec1a4a7f6cda6e Mon Sep 17 00:00:00 2001 From: Marko Boben Date: Thu, 25 Jan 2024 11:23:56 +0100 Subject: [PATCH 08/14] Simplified function for checking ftso prioritised contract --- coreth/core/daemon.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/coreth/core/daemon.go b/coreth/core/daemon.go index 8a8c2376..17d9d5d0 100644 --- a/coreth/core/daemon.go +++ b/coreth/core/daemon.go @@ -24,8 +24,8 @@ var ( // Define ftso and submitter contract addresses prioritisedFTSOContractAddress = common.HexToAddress("0x1000000000000000000000000000000000000003") - prioritisedSubmitterContractAddressFlare = common.HexToAddress("0xEC1C93A9f6a9e18E97784c76aC52053587FcDB89") - prioritisedSubmitterContractAddressCostwo = common.HexToAddress("0xEC1C93A9f6a9e18E97784c76aC52053587FcDB89") + prioritisedSubmitterContractAddressFlare = common.HexToAddress("0x200000000000000000000000000000000000000a") + prioritisedSubmitterContractAddressCostwo = common.HexToAddress("0x300000000000000000000000000000000000000b") prioritisedSubmitterContractAddressEnv = common.HexToAddress(os.Getenv("SUBMITTER_CONTRACT_ADDRESS")) // for local and staging chains ) @@ -89,15 +89,14 @@ func GetDaemonSelector(blockTime *big.Int) []byte { } } -func isPrioritisedFTSOContract(to *common.Address, blockTime *big.Int) bool { - switch { - default: - return *to == prioritisedFTSOContractAddress - } +func isPrioritisedFTSOContract(to *common.Address) bool { + return to != nil && *to == prioritisedFTSOContractAddress } func isPrioritisedSubmitterContract(chainID *big.Int, to *common.Address, blockTime *big.Int) bool { switch { + case to == nil || chainID == nil || blockTime == nil: + return false case chainID.Cmp(params.FlareChainID) == 0: return *to == prioritisedSubmitterContractAddressFlare && blockTime.Cmp(submitterContractActivationTimeFlare) >= 0 @@ -113,9 +112,7 @@ func isPrioritisedSubmitterContract(chainID *big.Int, to *common.Address, blockT func IsPrioritisedContractCall(chainID *big.Int, to *common.Address, ret []byte, blockTime *big.Int) bool { switch { - case to == nil || chainID == nil || blockTime == nil: - return false - case isPrioritisedFTSOContract(to, blockTime): + case isPrioritisedFTSOContract(to): return true case isPrioritisedSubmitterContract(chainID, to, blockTime): return !isZeroSlice(ret) From 18a7aeede908ab216db9677e138e0fc825aba633 Mon Sep 17 00:00:00 2001 From: Marko Boben Date: Mon, 12 Feb 2024 16:58:10 +0100 Subject: [PATCH 09/14] Change of default attestors addresses --- coreth/core/daemon.go | 4 ++-- coreth/core/state_connector.go | 34 ++++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/coreth/core/daemon.go b/coreth/core/daemon.go index 17d9d5d0..0bb4a06b 100644 --- a/coreth/core/daemon.go +++ b/coreth/core/daemon.go @@ -99,10 +99,10 @@ func isPrioritisedSubmitterContract(chainID *big.Int, to *common.Address, blockT return false case chainID.Cmp(params.FlareChainID) == 0: return *to == prioritisedSubmitterContractAddressFlare && - blockTime.Cmp(submitterContractActivationTimeFlare) >= 0 + blockTime.Cmp(submitterContractActivationTimeFlare) > 0 case chainID.Cmp(params.CostwoChainID) == 0: return *to == prioritisedSubmitterContractAddressCostwo && - blockTime.Cmp(submitterContractActivationTimeCostwo) >= 0 + blockTime.Cmp(submitterContractActivationTimeCostwo) > 0 case chainID.Cmp(params.LocalFlareChainID) == 0 || chainID.Cmp(params.StagingChainID) == 0: return *to == prioritisedSubmitterContractAddressEnv default: diff --git a/coreth/core/state_connector.go b/coreth/core/state_connector.go index 06993612..23196169 100644 --- a/coreth/core/state_connector.go +++ b/coreth/core/state_connector.go @@ -115,16 +115,30 @@ func FinaliseRoundSelector(chainID *big.Int, blockTime *big.Int) []byte { func GetDefaultAttestors(chainID *big.Int, blockTime *big.Int) []common.Address { switch { case chainID.Cmp(params.FlareChainID) == 0: - return []common.Address{ - common.HexToAddress("0x0988Cf4828F4e4eD0cE7c07467E70e19095Ee152"), - common.HexToAddress("0x6BC7DCa62010D418eB72CCdc58561e00C5868Ef1"), - common.HexToAddress("0xE34Bb361536610a9DCcEa5292262e36AfF65c06c"), - common.HexToAddress("0x8A3D627D86A81F5D21683F4963565C63DB5e1309"), - common.HexToAddress("0x2D3e7e4b19bDc920fd9C57BD3072A31F5a59FeC8"), - common.HexToAddress("0x6455dC38fdF739b6fE021b30C7D9672C1c6DEb5c"), - common.HexToAddress("0x49893c5Dfc035F4eE4E46faC014f6D4bC80F7f92"), - common.HexToAddress("0x08e8b2Af4874e920de27723576A13d66008Af523"), - common.HexToAddress("0x5D2f75392DdDa69a2818021dd6a64937904c8352"), + if blockTime.Cmp(submitterContractActivationTimeFlare) > 0 { + return []common.Address{ + common.HexToAddress("0x0988Cf4828F4e4eD0cE7c07467E70e19095Ee152"), + common.HexToAddress("0x6BC7DCa62010D418eB72CCdc58561e00C5868Ef1"), + common.HexToAddress("0xE34Bb361536610a9DCcEa5292262e36AfF65c06c"), + common.HexToAddress("0x8A3D627D86A81F5D21683F4963565C63DB5e1309"), + common.HexToAddress("0x2D3e7e4b19bDc920fd9C57BD3072A31F5a59FeC8"), + common.HexToAddress("0x6455dC38fdF739b6fE021b30C7D9672C1c6DEb5c"), + common.HexToAddress("0x49893c5Dfc035F4eE4E46faC014f6D4bC80F7f92"), + common.HexToAddress("0x08e8b2Af4874e920de27723576A13d66008Af523"), + common.HexToAddress("0x5D2f75392DdDa69a2818021dd6a64937904c8352"), + } + } else { + return []common.Address{ + common.HexToAddress("0x0988Cf4828F4e4eD0cE7c07467E70e19095Ee152"), + common.HexToAddress("0x6BC7DCa62010D418eB72CCdc58561e00C5868Ef1"), + common.HexToAddress("0xE34Bb361536610a9DCcEa5292262e36AfF65c06c"), + common.HexToAddress("0x8A3D627D86A81F5D21683F4963565C63DB5e1309"), + common.HexToAddress("0x2D3e7e4b19bDc920fd9C57BD3072A31F5a59FeC8"), + common.HexToAddress("0x6455dC38fdF739b6fE021b30C7D9672C1c6DEb5c"), + common.HexToAddress("0x49893c5Dfc035F4eE4E46faC014f6D4bC80F7f92"), + common.HexToAddress("0x08e8b2Af4874e920de27723576A13d66008Af523"), + common.HexToAddress("0x5D2f75392DdDa69a2818021dd6a64937904c8352"), + } } case chainID.Cmp(params.SongbirdChainID) == 0: return []common.Address{ From f15d6d2cfacc87aca874707fa9fe6c953a7f4a43 Mon Sep 17 00:00:00 2001 From: Marko Boben Date: Tue, 20 Feb 2024 14:17:47 +0100 Subject: [PATCH 10/14] Updated submitter fork addresses --- coreth/core/daemon.go | 13 ++++++------- coreth/core/daemon_test.go | 8 ++++---- coreth/core/state_connector.go | 18 +++++++++--------- coreth/core/state_transition.go | 2 +- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/coreth/core/daemon.go b/coreth/core/daemon.go index 0bb4a06b..f6f416e9 100644 --- a/coreth/core/daemon.go +++ b/coreth/core/daemon.go @@ -18,15 +18,14 @@ import ( var ( // Define activation times for submitter contract - submitterContractActivationTimeFlare = big.NewInt(time.Date(2024, time.March, 1, 12, 0, 0, 0, time.UTC).Unix()) - submitterContractActivationTimeCostwo = big.NewInt(time.Date(2024, time.January, 31, 12, 0, 0, 0, time.UTC).Unix()) + submitterContractActivationTimeFlare = big.NewInt(time.Date(2024, time.March, 26, 12, 0, 0, 0, time.UTC).Unix()) + submitterContractActivationTimeCostwo = big.NewInt(time.Date(2024, time.February, 21, 12, 0, 0, 0, time.UTC).Unix()) // Define ftso and submitter contract addresses prioritisedFTSOContractAddress = common.HexToAddress("0x1000000000000000000000000000000000000003") - prioritisedSubmitterContractAddressFlare = common.HexToAddress("0x200000000000000000000000000000000000000a") - prioritisedSubmitterContractAddressCostwo = common.HexToAddress("0x300000000000000000000000000000000000000b") - prioritisedSubmitterContractAddressEnv = common.HexToAddress(os.Getenv("SUBMITTER_CONTRACT_ADDRESS")) // for local and staging chains + prioritisedSubmitterContractAddress = common.HexToAddress("0x2cA6571Daa15ce734Bbd0Bf27D5C9D16787fc33f") + prioritisedSubmitterContractAddressEnv = common.HexToAddress(os.Getenv("SUBMITTER_CONTRACT_ADDRESS")) // for local and staging chains ) // Define errors @@ -98,10 +97,10 @@ func isPrioritisedSubmitterContract(chainID *big.Int, to *common.Address, blockT case to == nil || chainID == nil || blockTime == nil: return false case chainID.Cmp(params.FlareChainID) == 0: - return *to == prioritisedSubmitterContractAddressFlare && + return *to == prioritisedSubmitterContractAddress && blockTime.Cmp(submitterContractActivationTimeFlare) > 0 case chainID.Cmp(params.CostwoChainID) == 0: - return *to == prioritisedSubmitterContractAddressCostwo && + return *to == prioritisedSubmitterContractAddress && blockTime.Cmp(submitterContractActivationTimeCostwo) > 0 case chainID.Cmp(params.LocalFlareChainID) == 0 || chainID.Cmp(params.StagingChainID) == 0: return *to == prioritisedSubmitterContractAddressEnv diff --git a/coreth/core/daemon_test.go b/coreth/core/daemon_test.go index 8d316780..dafafcd3 100644 --- a/coreth/core/daemon_test.go +++ b/coreth/core/daemon_test.go @@ -493,16 +493,16 @@ func TestPrioritisedContract(t *testing.T) { if !IsPrioritisedContractCall(params.FlareChainID, &prioritisedFTSOContractAddress, nil, preForkTime) { t.Errorf("Expected true for FTSO contract") } - if IsPrioritisedContractCall(params.FlareChainID, &prioritisedSubmitterContractAddressFlare, ret1[:], preForkTime) { + if IsPrioritisedContractCall(params.FlareChainID, &prioritisedSubmitterContractAddress, ret1[:], preForkTime) { t.Errorf("Expected false for submitter contract before activation") } - if !IsPrioritisedContractCall(params.FlareChainID, &prioritisedSubmitterContractAddressFlare, ret1[:], postForkTime) { + if !IsPrioritisedContractCall(params.FlareChainID, &prioritisedSubmitterContractAddress, ret1[:], postForkTime) { t.Errorf("Expected true for submitter contract after activation") } - if IsPrioritisedContractCall(params.FlareChainID, &prioritisedSubmitterContractAddressFlare, ret0[:], postForkTime) { + if IsPrioritisedContractCall(params.FlareChainID, &prioritisedSubmitterContractAddress, ret0[:], postForkTime) { t.Errorf("Expected false for submitter contract with wrong return value") } - if IsPrioritisedContractCall(params.FlareChainID, &prioritisedSubmitterContractAddressFlare, nil, postForkTime) { + if IsPrioritisedContractCall(params.FlareChainID, &prioritisedSubmitterContractAddress, nil, postForkTime) { t.Errorf("Expected false for submitter contract with no return value") } } diff --git a/coreth/core/state_connector.go b/coreth/core/state_connector.go index 23196169..2792735b 100644 --- a/coreth/core/state_connector.go +++ b/coreth/core/state_connector.go @@ -117,15 +117,15 @@ func GetDefaultAttestors(chainID *big.Int, blockTime *big.Int) []common.Address case chainID.Cmp(params.FlareChainID) == 0: if blockTime.Cmp(submitterContractActivationTimeFlare) > 0 { return []common.Address{ - common.HexToAddress("0x0988Cf4828F4e4eD0cE7c07467E70e19095Ee152"), - common.HexToAddress("0x6BC7DCa62010D418eB72CCdc58561e00C5868Ef1"), - common.HexToAddress("0xE34Bb361536610a9DCcEa5292262e36AfF65c06c"), - common.HexToAddress("0x8A3D627D86A81F5D21683F4963565C63DB5e1309"), - common.HexToAddress("0x2D3e7e4b19bDc920fd9C57BD3072A31F5a59FeC8"), - common.HexToAddress("0x6455dC38fdF739b6fE021b30C7D9672C1c6DEb5c"), - common.HexToAddress("0x49893c5Dfc035F4eE4E46faC014f6D4bC80F7f92"), - common.HexToAddress("0x08e8b2Af4874e920de27723576A13d66008Af523"), - common.HexToAddress("0x5D2f75392DdDa69a2818021dd6a64937904c8352"), + common.HexToAddress("0x4E07E1F3DB3Dc9BAd56Cc829747cc0148234329F"), + common.HexToAddress("0xB264Fad6Fdc65767998f93501945aB8F9108809d"), + common.HexToAddress("0x366BeC54195bfD45DBB34b79Ad2dEC4010598947"), + common.HexToAddress("0x2665B179d5fCE1118f06e23B5d6E7617c5Ff733A"), + common.HexToAddress("0x65cBaFaDD7C914179aabcE9C35f918a4E36AfFf9"), + common.HexToAddress("0x7eC6a7C7c4Ef003A75DC6c06352B48B37Ac2191B"), + common.HexToAddress("0xEa9bC2F98eFFC6A27E2C31733c1905961826f73B"), + common.HexToAddress("0xA4aA75a9B49c7f2B4be62b2999d7103E78D004C7"), + common.HexToAddress("0x4DF8436D7578C2d3bc73d33B6644913e131B70FC"), } } else { return []common.Address{ diff --git a/coreth/core/state_transition.go b/coreth/core/state_transition.go index f5f5f9b4..77d815d3 100644 --- a/coreth/core/state_transition.go +++ b/coreth/core/state_transition.go @@ -420,7 +420,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { st.refundGas(rules.IsApricotPhase1) if vmerr == nil && IsPrioritisedContractCall(chainID, msg.To(), ret, timestamp) && st.initialGas <= GetMaxFTSOGasLimit(timestamp) { - nominalGasUsed := uint64(params.TxGas) // 21000 + nominalGasUsed := params.TxGas // 21000 nominalGasPrice := uint64(params.ApricotPhase4MinBaseFee) // 25_000_000_000; the max base fee is 1_000_000_000_000 nominalFee := new(big.Int).Mul(new(big.Int).SetUint64(nominalGasUsed), new(big.Int).SetUint64(nominalGasPrice)) actualGasUsed := st.gasUsed() From b55e073e46915e2b9dd9a9a72046a3d087cea9ca Mon Sep 17 00:00:00 2001 From: Marko Boben Date: Tue, 20 Feb 2024 14:28:15 +0100 Subject: [PATCH 11/14] Updated submitter fork test date --- coreth/core/daemon.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreth/core/daemon.go b/coreth/core/daemon.go index f6f416e9..e69a799d 100644 --- a/coreth/core/daemon.go +++ b/coreth/core/daemon.go @@ -19,7 +19,7 @@ import ( var ( // Define activation times for submitter contract submitterContractActivationTimeFlare = big.NewInt(time.Date(2024, time.March, 26, 12, 0, 0, 0, time.UTC).Unix()) - submitterContractActivationTimeCostwo = big.NewInt(time.Date(2024, time.February, 21, 12, 0, 0, 0, time.UTC).Unix()) + submitterContractActivationTimeCostwo = big.NewInt(time.Date(2024, time.February, 21, 14, 0, 0, 0, time.UTC).Unix()) // Define ftso and submitter contract addresses prioritisedFTSOContractAddress = common.HexToAddress("0x1000000000000000000000000000000000000003") From 6f85d4bafc17eca44aa63e4d31d3b00dbc881977 Mon Sep 17 00:00:00 2001 From: Marko Boben Date: Tue, 20 Feb 2024 14:53:56 +0100 Subject: [PATCH 12/14] Fixed failing test --- coreth/core/daemon_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coreth/core/daemon_test.go b/coreth/core/daemon_test.go index dafafcd3..7be96a2f 100644 --- a/coreth/core/daemon_test.go +++ b/coreth/core/daemon_test.go @@ -481,8 +481,8 @@ func TestDaemonShouldNotMintMoreThanLimit(t *testing.T) { func TestPrioritisedContract(t *testing.T) { address := common.HexToAddress("0x123456789aBCdEF123456789aBCdef123456789A") - preForkTime := big.NewInt(time.Date(2024, time.February, 1, 12, 0, 0, 0, time.UTC).Unix()) - postForkTime := big.NewInt(time.Date(2024, time.March, 2, 12, 0, 0, 0, time.UTC).Unix()) + preForkTime := big.NewInt(time.Date(2024, time.March, 20, 12, 0, 0, 0, time.UTC).Unix()) + postForkTime := big.NewInt(time.Date(2024, time.March, 27, 12, 0, 0, 0, time.UTC).Unix()) ret0 := [32]byte{} ret1 := [32]byte{} ret1[31] = 1 From a986263d8375e2146832b12acc896cd3b0b8abfb Mon Sep 17 00:00:00 2001 From: Marko Boben Date: Wed, 21 Feb 2024 12:20:14 +0100 Subject: [PATCH 13/14] Updated patch version --- avalanchego/version/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avalanchego/version/constants.go b/avalanchego/version/constants.go index ab2809fd..57654a75 100644 --- a/avalanchego/version/constants.go +++ b/avalanchego/version/constants.go @@ -14,7 +14,7 @@ var ( Current = &Semantic{ Major: 1, Minor: 7, - Patch: 1806, + Patch: 1807, } CurrentApp = &Application{ Major: Current.Major, From 24bf021cd372de5ae243c7aae62c198567bc0869 Mon Sep 17 00:00:00 2001 From: Marko Boben Date: Mon, 4 Mar 2024 11:28:38 +0100 Subject: [PATCH 14/14] Changed submitter fork time for coston 2 --- coreth/core/daemon.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreth/core/daemon.go b/coreth/core/daemon.go index e69a799d..acf55eb3 100644 --- a/coreth/core/daemon.go +++ b/coreth/core/daemon.go @@ -19,7 +19,7 @@ import ( var ( // Define activation times for submitter contract submitterContractActivationTimeFlare = big.NewInt(time.Date(2024, time.March, 26, 12, 0, 0, 0, time.UTC).Unix()) - submitterContractActivationTimeCostwo = big.NewInt(time.Date(2024, time.February, 21, 14, 0, 0, 0, time.UTC).Unix()) + submitterContractActivationTimeCostwo = big.NewInt(time.Date(2024, time.March, 7, 12, 0, 0, 0, time.UTC).Unix()) // Define ftso and submitter contract addresses prioritisedFTSOContractAddress = common.HexToAddress("0x1000000000000000000000000000000000000003")