Skip to content

Commit d7e9d59

Browse files
authored
Merge branch 'master' into ceyonur/acp-226-verify-min-delay-excess
2 parents 9625295 + 0a1d401 commit d7e9d59

32 files changed

+987
-409
lines changed

RELEASES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Implement ACP-226: Set expected block gas cost to 0 in Granite network upgrade, removing block gas cost requirements for block building.
88
- Implement ACP-226: Add `timeMilliseconds` (Unix uint64) timestamp to block header for Granite upgrade.
99
- Implement ACP-226: Add `minDelayExcess` (uint64) to block header for Granite upgrade.
10+
- Update go version to 1.24.7
1011

1112
## [v0.15.3](https://github.com/ava-labs/coreth/releases/tag/v0.15.3)
1213

core/state_manager.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,13 @@ package core
2929

3030
import (
3131
"fmt"
32-
"math/rand"
33-
"time"
3432

3533
"github.com/ava-labs/coreth/plugin/evm/customrawdb"
3634
"github.com/ava-labs/libevm/common"
3735
"github.com/ava-labs/libevm/core/types"
3836
"github.com/ava-labs/libevm/ethdb"
3937
)
4038

41-
func init() {
42-
rand.Seed(time.Now().UnixNano())
43-
}
44-
4539
// flushWindow is the distance to the [commitInterval] when we start
4640
// optimistically flushing trie nodes to disk (only applicable in [pruning]
4741
// mode).

go.mod

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/ava-labs/coreth
22

3-
go 1.23.9
3+
go 1.24.7
44

55
require (
66
github.com/VictoriaMetrics/fastcache v1.12.1
@@ -32,11 +32,11 @@ require (
3232
go.uber.org/goleak v1.3.0
3333
go.uber.org/mock v0.5.0
3434
go.uber.org/zap v1.26.0
35-
golang.org/x/crypto v0.36.0
35+
golang.org/x/crypto v0.42.0
3636
golang.org/x/exp v0.0.0-20241215155358-4a5509556b9e
37-
golang.org/x/sync v0.12.0
37+
golang.org/x/sync v0.17.0
3838
golang.org/x/time v0.3.0
39-
golang.org/x/tools v0.29.0
39+
golang.org/x/tools v0.37.0
4040
google.golang.org/protobuf v1.36.5
4141
gopkg.in/natefinch/lumberjack.v2 v2.0.0
4242
)
@@ -69,7 +69,7 @@ require (
6969
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
7070
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
7171
github.com/fsnotify/fsnotify v1.6.0 // indirect
72-
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 // indirect
72+
github.com/garslo/gogen v0.0.0-20230926014519-f497ca02dd4c // indirect
7373
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
7474
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
7575
github.com/getsentry/sentry-go v0.18.0 // indirect
@@ -148,12 +148,12 @@ require (
148148
go.opentelemetry.io/otel/trace v1.22.0 // indirect
149149
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
150150
go.uber.org/multierr v1.11.0 // indirect
151-
golang.org/x/mod v0.22.0 // indirect
152-
golang.org/x/net v0.38.0 // indirect
151+
golang.org/x/mod v0.28.0 // indirect
152+
golang.org/x/net v0.44.0 // indirect
153153
golang.org/x/oauth2 v0.27.0 // indirect
154-
golang.org/x/sys v0.31.0 // indirect
155-
golang.org/x/term v0.30.0 // indirect
156-
golang.org/x/text v0.23.0 // indirect
154+
golang.org/x/sys v0.36.0 // indirect
155+
golang.org/x/term v0.35.0 // indirect
156+
golang.org/x/text v0.29.0 // indirect
157157
gonum.org/v1/gonum v0.11.0 // indirect
158158
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect
159159
google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect

go.sum

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4
190190
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
191191
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
192192
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
193-
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 h1:IZqZOB2fydHte3kUgxrzK5E1fW7RQGeDwE8F/ZZnUYc=
194-
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61/go.mod h1:Q0X6pkwTILDlzrGEckF6HKjXe48EgsY/l7K7vhY4MW8=
193+
github.com/garslo/gogen v0.0.0-20230926014519-f497ca02dd4c h1:40KPNY+PW1YryU4J3aX9kNAgjXIXXyfloGA732AnOQc=
194+
github.com/garslo/gogen v0.0.0-20230926014519-f497ca02dd4c/go.mod h1:Q0X6pkwTILDlzrGEckF6HKjXe48EgsY/l7K7vhY4MW8=
195195
github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc=
196196
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays=
197197
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
@@ -669,8 +669,8 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm
669669
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
670670
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
671671
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
672-
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
673-
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
672+
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
673+
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
674674
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
675675
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
676676
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -709,8 +709,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
709709
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
710710
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
711711
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
712-
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
713-
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
712+
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
713+
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
714714
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
715715
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
716716
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -755,8 +755,8 @@ golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qx
755755
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
756756
golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
757757
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
758-
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
759-
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
758+
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
759+
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
760760
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
761761
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
762762
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -780,8 +780,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
780780
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
781781
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
782782
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
783-
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
784-
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
783+
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
784+
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
785785
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
786786
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
787787
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -848,12 +848,12 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
848848
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
849849
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
850850
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
851-
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
852-
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
851+
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
852+
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
853853
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
854854
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
855-
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
856-
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
855+
golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ=
856+
golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA=
857857
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
858858
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
859859
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -864,8 +864,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
864864
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
865865
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
866866
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
867-
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
868-
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
867+
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
868+
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
869869
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
870870
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
871871
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -927,8 +927,8 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f
927927
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
928928
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
929929
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
930-
golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE=
931-
golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588=
930+
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
931+
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
932932
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
933933
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
934934
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

miner/worker.go

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -144,42 +144,35 @@ func (w *worker) commitNewWork(predicateContext *precompileconfig.PredicateConte
144144
w.mu.RLock()
145145
defer w.mu.RUnlock()
146146
var (
147-
parent = w.chain.CurrentBlock()
148-
tstart = w.clock.Time()
149-
timestamp = uint64(tstart.Unix())
150-
timestampMS = uint64(tstart.UnixMilli())
151-
chainExtra = params.GetExtra(w.chainConfig)
147+
parent = w.chain.CurrentBlock()
148+
tstart = w.clock.Time()
149+
chainExtra = params.GetExtra(w.chainConfig)
152150
)
153-
// Note: in order to support asynchronous block production, blocks are allowed to have
154-
// the same timestamp as their parent. This allows more than one block to be produced
155-
// per second.
156-
if parent.Time >= timestamp {
157-
timestamp = parent.Time
158-
// If the parent has a TimeMilliseconds, use it. Otherwise, use the parent time * 1000.
159-
parentExtra := customtypes.GetHeaderExtra(parent)
160-
if parentExtra.TimeMilliseconds != nil {
161-
timestampMS = *parentExtra.TimeMilliseconds
162-
} else {
163-
timestampMS = parent.Time * 1000 // TODO: establish minimum time
164-
}
151+
152+
timestamp, timestampMS := customheader.GetNextTimestamp(parent, tstart)
153+
154+
header := &types.Header{
155+
ParentHash: parent.Hash(),
156+
Number: new(big.Int).Add(parent.Number, common.Big1),
157+
Time: timestamp,
158+
}
159+
160+
if chainExtra.IsGranite(timestamp) {
161+
headerExtra := customtypes.GetHeaderExtra(header)
162+
headerExtra.TimeMilliseconds = &timestampMS
165163
}
166164

167-
gasLimit, err := customheader.GasLimit(chainExtra, parent, timestamp)
165+
gasLimit, err := customheader.GasLimit(chainExtra, parent, header.Time)
168166
if err != nil {
169167
return nil, fmt.Errorf("calculating new gas limit: %w", err)
170168
}
171-
baseFee, err := customheader.BaseFee(chainExtra, parent, timestamp)
169+
header.GasLimit = gasLimit
170+
171+
baseFee, err := customheader.BaseFee(chainExtra, parent, header.Time)
172172
if err != nil {
173173
return nil, fmt.Errorf("failed to calculate new base fee: %w", err)
174174
}
175-
176-
header := &types.Header{
177-
ParentHash: parent.Hash(),
178-
Number: new(big.Int).Add(parent.Number, common.Big1),
179-
GasLimit: gasLimit,
180-
Time: timestamp,
181-
BaseFee: baseFee,
182-
}
175+
header.BaseFee = baseFee
183176

184177
// Apply EIP-4844, EIP-4788.
185178
if w.chainConfig.IsCancun(header.Number, header.Time) {
@@ -195,12 +188,6 @@ func (w *worker) commitNewWork(predicateContext *precompileconfig.PredicateConte
195188
header.ParentBeaconRoot = w.beaconRoot
196189
}
197190

198-
// Add TimeMilliseconds if Granite is active.
199-
if chainExtra.IsGranite(header.Time) {
200-
headerExtra := customtypes.GetHeaderExtra(header)
201-
headerExtra.TimeMilliseconds = &timestampMS
202-
}
203-
204191
if w.coinbase == (common.Address{}) {
205192
return nil, errors.New("cannot mine without etherbase")
206193
}

params/hooks_libevm.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ func makePrecompile(contract contract.StatefulPrecompiledContract) libevm.Precom
149149
// Otherwise, we allow the precompile to be called
150150
}
151151

152-
// EVM semantic addresses are used here to maintain consistency with prior behavior as present in AvalancheGo 1.13.0.
153152
return contract.Run(accessibleState, env.Addresses().EVMSemantic.Caller, env.Addresses().EVMSemantic.Self, input, suppliedGas, env.ReadOnly())
154153
}
155154
return vm.NewStatefulPrecompile(legacy.PrecompiledStatefulContract(run).Upgrade())

plugin/evm/atomic/sync/syncer.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ var (
4040
_ syncclient.LeafSyncTask = (*syncerLeafTask)(nil)
4141
)
4242

43+
// Name returns the human-readable name for this sync task.
44+
func (*syncer) Name() string { return "Atomic State Syncer" }
45+
46+
// ID returns the stable identifier for this sync task.
47+
func (*syncer) ID() string { return "state_atomic_sync" }
48+
4349
// Config holds the configuration for creating a new atomic syncer.
4450
type Config struct {
4551
// TargetHeight is the target block height to sync to.

plugin/evm/atomic/sync/syncer_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ func TestSyncerScenarios(t *testing.T) {
6868

6969
for _, tt := range tests {
7070
t.Run(tt.name, func(t *testing.T) {
71-
rand.Seed(1)
71+
r := rand.New(rand.NewSource(1))
7272
targetHeight := 10 * uint64(testCommitInterval)
7373
serverTrieDB := triedb.NewDatabase(rawdb.NewMemoryDatabase(), nil)
74-
root, _, _ := statesynctest.GenerateTrie(t, serverTrieDB, int(targetHeight), state.TrieKeyLength)
74+
root, _, _ := statesynctest.GenerateTrie(t, r, serverTrieDB, int(targetHeight), state.TrieKeyLength)
7575

7676
testSyncer(t, serverTrieDB, targetHeight, root, nil, int64(targetHeight), tt.numWorkers)
7777
})
@@ -104,11 +104,11 @@ func TestSyncerResumeScenarios(t *testing.T) {
104104

105105
for _, tt := range tests {
106106
t.Run(tt.name, func(t *testing.T) {
107-
rand.Seed(1)
107+
r := rand.New(rand.NewSource(1))
108108
targetHeight := 10 * uint64(testCommitInterval)
109109
serverTrieDB := triedb.NewDatabase(rawdb.NewMemoryDatabase(), nil)
110110
numTrieKeys := int(targetHeight) - 1 // no atomic ops for genesis
111-
root, _, _ := statesynctest.GenerateTrie(t, serverTrieDB, numTrieKeys, state.TrieKeyLength)
111+
root, _, _ := statesynctest.GenerateTrie(t, r, serverTrieDB, numTrieKeys, state.TrieKeyLength)
112112

113113
testSyncer(t, serverTrieDB, targetHeight, root, []atomicSyncTestCheckpoint{
114114
{
@@ -148,16 +148,16 @@ func TestSyncerResumeNewRootCheckpointScenarios(t *testing.T) {
148148

149149
for _, tt := range tests {
150150
t.Run(tt.name, func(t *testing.T) {
151-
rand.Seed(1)
151+
r := rand.New(rand.NewSource(1))
152152
targetHeight1 := 10 * uint64(testCommitInterval)
153153
serverTrieDB := triedb.NewDatabase(rawdb.NewMemoryDatabase(), nil)
154154
numTrieKeys1 := int(targetHeight1) - 1 // no atomic ops for genesis
155-
root1, _, _ := statesynctest.GenerateTrie(t, serverTrieDB, numTrieKeys1, state.TrieKeyLength)
155+
root1, _, _ := statesynctest.GenerateTrie(t, r, serverTrieDB, numTrieKeys1, state.TrieKeyLength)
156156

157157
targetHeight2 := 20 * uint64(testCommitInterval)
158158
numTrieKeys2 := int(targetHeight2) - 1 // no atomic ops for genesis
159159
root2, _, _ := statesynctest.FillTrie(
160-
t, numTrieKeys1, numTrieKeys2, state.TrieKeyLength, serverTrieDB, root1,
160+
t, r, numTrieKeys1, numTrieKeys2, state.TrieKeyLength, serverTrieDB, root1,
161161
)
162162

163163
testSyncer(t, serverTrieDB, targetHeight1, root1, []atomicSyncTestCheckpoint{
@@ -222,8 +222,9 @@ func TestSyncerContextCancellation(t *testing.T) {
222222
// It returns the context, mock client, atomic backend, client DB, and root hash for testing.
223223
func setupParallelizationTest(t *testing.T, targetHeight uint64) (context.Context, *syncclient.TestClient, *state.AtomicBackend, *versiondb.Database, common.Hash) {
224224
// Create a simple test trie with some data.
225+
r := rand.New(rand.NewSource(1))
225226
serverTrieDB := triedb.NewDatabase(rawdb.NewMemoryDatabase(), nil)
226-
root, _, _ := statesynctest.GenerateTrie(t, serverTrieDB, int(targetHeight), state.TrieKeyLength)
227+
root, _, _ := statesynctest.GenerateTrie(t, r, serverTrieDB, int(targetHeight), state.TrieKeyLength)
227228

228229
ctx, mockClient, atomicBackend, clientDB := setupTestInfrastructure(t, serverTrieDB)
229230

plugin/evm/customheader/time.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,30 @@ var (
2626
ErrTimeMillisecondsBeforeGranite = errors.New("TimeMilliseconds should be nil before Granite activation")
2727
)
2828

29+
// GetNextTimestamp calculates the timestamp (in seconds and milliseconds) for the next child block based on the parent's timestamp and the current time.
30+
// First return value is the timestamp in seconds, second return value is the timestamp in milliseconds.
31+
func GetNextTimestamp(parent *types.Header, now time.Time) (uint64, uint64) {
32+
var (
33+
timestamp = uint64(now.Unix())
34+
timestampMS = uint64(now.UnixMilli())
35+
)
36+
// Note: in order to support asynchronous block production, blocks are allowed to have
37+
// the same timestamp as their parent. This allows more than one block to be produced
38+
// per second.
39+
parentExtra := customtypes.GetHeaderExtra(parent)
40+
if parent.Time >= timestamp ||
41+
(parentExtra.TimeMilliseconds != nil && *parentExtra.TimeMilliseconds >= timestampMS) {
42+
timestamp = parent.Time
43+
// If the parent has a TimeMilliseconds, use it. Otherwise, use the parent time * 1000.
44+
if parentExtra.TimeMilliseconds != nil {
45+
timestampMS = *parentExtra.TimeMilliseconds
46+
} else {
47+
timestampMS = parent.Time * 1000 // TODO: establish minimum time
48+
}
49+
}
50+
return timestamp, timestampMS
51+
}
52+
2953
// VerifyTime verifies that the header's Time and TimeMilliseconds fields are
3054
// consistent with the given rules and the current time.
3155
// This includes:

0 commit comments

Comments
 (0)