@@ -34,6 +34,7 @@ import (
34
34
"github.com/ethereum/go-ethereum/consensus"
35
35
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
36
36
"github.com/ethereum/go-ethereum/core"
37
+ "github.com/ethereum/go-ethereum/core/forkid"
37
38
"github.com/ethereum/go-ethereum/core/state"
38
39
"github.com/ethereum/go-ethereum/core/types"
39
40
"github.com/ethereum/go-ethereum/core/vm"
@@ -1139,28 +1140,60 @@ type config struct {
1139
1140
ActivationTime uint64 `json:"activationTime"`
1140
1141
BlobSchedule * params.BlobConfig `json:"blobSchedule"`
1141
1142
ChainId * hexutil.Big `json:"chainId"`
1143
+ ForkId hexutil.Bytes `json:"forkId"`
1142
1144
Precompiles map [common.Address ]string `json:"precompiles"`
1143
1145
SystemContracts map [string ]common.Address `json:"systemContracts"`
1144
1146
}
1145
1147
1148
+ type configResponse struct {
1149
+ Current * config `json:"current"`
1150
+ Next * config `json:"next"`
1151
+ Last * config `json:"last"`
1152
+ }
1153
+
1146
1154
// Config implements the EIP-7910 eth_config method.
1147
- func (api * BlockChainAPI ) Config (ctx context.Context ) config {
1155
+ func (api * BlockChainAPI ) Config (ctx context.Context ) (* configResponse , error ) {
1156
+ genesis , err := api .b .BlockByNumber (ctx , 0 )
1157
+ if err != nil {
1158
+ return nil , fmt .Errorf ("unable to load genesis: %w" , err )
1159
+ }
1160
+ assemble := func (c * params.ChainConfig , ts * uint64 ) * config {
1161
+ if ts == nil {
1162
+ return nil
1163
+ }
1164
+ t := * ts
1165
+
1166
+ var (
1167
+ rules = c .Rules (c .LondonBlock , true , t )
1168
+ precompiles = make (map [common.Address ]string )
1169
+ )
1170
+ for addr , c := range vm .ActivePrecompiledContracts (rules ) {
1171
+ precompiles [addr ] = c .Name ()
1172
+ }
1173
+ forkid := forkid .NewID (c , genesis , ^ uint64 (0 ), t ).Hash
1174
+ return & config {
1175
+ ActivationTime : t ,
1176
+ BlobSchedule : c .BlobConfig (c .LatestFork (t )),
1177
+ ChainId : (* hexutil .Big )(c .ChainID ),
1178
+ ForkId : forkid [:],
1179
+ Precompiles : precompiles ,
1180
+ SystemContracts : c .ActiveSystemContracts (t ),
1181
+ }
1182
+ }
1148
1183
var (
1149
- c = api .b .ChainConfig ()
1150
- h = api .b .CurrentBlock ()
1151
- rules = c .Rules (h .Number , true , h .Time )
1152
- precompiles = make (map [common.Address ]string )
1184
+ c = api .b .ChainConfig ()
1185
+ t = api .b .CurrentHeader ().Time
1153
1186
)
1154
- for addr , c := range vm .ActivePrecompiledContracts (rules ) {
1155
- precompiles [addr ] = c .Name ()
1187
+ resp := configResponse {
1188
+ Next : assemble (c , c .Timestamp (c .LatestFork (t )+ 1 )),
1189
+ Current : assemble (c , c .Timestamp (c .LatestFork (t ))),
1190
+ Last : assemble (c , c .Timestamp (c .LatestFork (^ uint64 (0 )))),
1156
1191
}
1157
- return config {
1158
- ActivationTime : c .NextForkTime (h .Time ),
1159
- BlobSchedule : c .BlobConfig (c .LatestFork (h .Time )),
1160
- ChainId : (* hexutil .Big )(c .ChainID ),
1161
- Precompiles : precompiles ,
1162
- SystemContracts : c .ActiveSystemContracts (h .Time ),
1192
+ // Nil out last if no future-fork is configured.
1193
+ if resp .Next == nil {
1194
+ resp .Last = nil
1163
1195
}
1196
+ return & resp , nil
1164
1197
}
1165
1198
1166
1199
// AccessList creates an access list for the given transaction.
0 commit comments