mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
Merge pull request #69 from berachain/update-main
Update main with latest upstream/master
This commit is contained in:
commit
87efec359f
74 changed files with 1291 additions and 885 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
|
@ -25,7 +25,7 @@ jobs:
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 1.24
|
go-version: 1.25
|
||||||
cache: false
|
cache: false
|
||||||
|
|
||||||
- name: Run linters
|
- name: Run linters
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ func ConvertType(in interface{}, proto interface{}) interface{} {
|
||||||
// indirect recursively dereferences the value until it either gets the value
|
// indirect recursively dereferences the value until it either gets the value
|
||||||
// or finds a big.Int
|
// or finds a big.Int
|
||||||
func indirect(v reflect.Value) reflect.Value {
|
func indirect(v reflect.Value) reflect.Value {
|
||||||
if v.Kind() == reflect.Ptr && v.Elem().Type() != reflect.TypeOf(big.Int{}) {
|
if v.Kind() == reflect.Ptr && v.Elem().Type() != reflect.TypeFor[big.Int]() {
|
||||||
return indirect(v.Elem())
|
return indirect(v.Elem())
|
||||||
}
|
}
|
||||||
return v
|
return v
|
||||||
|
|
@ -65,32 +65,32 @@ func reflectIntType(unsigned bool, size int) reflect.Type {
|
||||||
if unsigned {
|
if unsigned {
|
||||||
switch size {
|
switch size {
|
||||||
case 8:
|
case 8:
|
||||||
return reflect.TypeOf(uint8(0))
|
return reflect.TypeFor[uint8]()
|
||||||
case 16:
|
case 16:
|
||||||
return reflect.TypeOf(uint16(0))
|
return reflect.TypeFor[uint16]()
|
||||||
case 32:
|
case 32:
|
||||||
return reflect.TypeOf(uint32(0))
|
return reflect.TypeFor[uint32]()
|
||||||
case 64:
|
case 64:
|
||||||
return reflect.TypeOf(uint64(0))
|
return reflect.TypeFor[uint64]()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch size {
|
switch size {
|
||||||
case 8:
|
case 8:
|
||||||
return reflect.TypeOf(int8(0))
|
return reflect.TypeFor[int8]()
|
||||||
case 16:
|
case 16:
|
||||||
return reflect.TypeOf(int16(0))
|
return reflect.TypeFor[int16]()
|
||||||
case 32:
|
case 32:
|
||||||
return reflect.TypeOf(int32(0))
|
return reflect.TypeFor[int32]()
|
||||||
case 64:
|
case 64:
|
||||||
return reflect.TypeOf(int64(0))
|
return reflect.TypeFor[int64]()
|
||||||
}
|
}
|
||||||
return reflect.TypeOf(&big.Int{})
|
return reflect.TypeFor[*big.Int]()
|
||||||
}
|
}
|
||||||
|
|
||||||
// mustArrayToByteSlice creates a new byte slice with the exact same size as value
|
// mustArrayToByteSlice creates a new byte slice with the exact same size as value
|
||||||
// and copies the bytes in value to the new slice.
|
// and copies the bytes in value to the new slice.
|
||||||
func mustArrayToByteSlice(value reflect.Value) reflect.Value {
|
func mustArrayToByteSlice(value reflect.Value) reflect.Value {
|
||||||
slice := reflect.MakeSlice(reflect.TypeOf([]byte{}), value.Len(), value.Len())
|
slice := reflect.ValueOf(make([]byte, value.Len()))
|
||||||
reflect.Copy(slice, value)
|
reflect.Copy(slice, value)
|
||||||
return slice
|
return slice
|
||||||
}
|
}
|
||||||
|
|
@ -104,7 +104,7 @@ func set(dst, src reflect.Value) error {
|
||||||
switch {
|
switch {
|
||||||
case dstType.Kind() == reflect.Interface && dst.Elem().IsValid() && (dst.Elem().Type().Kind() == reflect.Ptr || dst.Elem().CanSet()):
|
case dstType.Kind() == reflect.Interface && dst.Elem().IsValid() && (dst.Elem().Type().Kind() == reflect.Ptr || dst.Elem().CanSet()):
|
||||||
return set(dst.Elem(), src)
|
return set(dst.Elem(), src)
|
||||||
case dstType.Kind() == reflect.Ptr && dstType.Elem() != reflect.TypeOf(big.Int{}):
|
case dstType.Kind() == reflect.Ptr && dstType.Elem() != reflect.TypeFor[big.Int]():
|
||||||
return set(dst.Elem(), src)
|
return set(dst.Elem(), src)
|
||||||
case srcType.AssignableTo(dstType) && dst.CanSet():
|
case srcType.AssignableTo(dstType) && dst.CanSet():
|
||||||
dst.Set(src)
|
dst.Set(src)
|
||||||
|
|
|
||||||
|
|
@ -204,12 +204,12 @@ func TestConvertType(t *testing.T) {
|
||||||
var fields []reflect.StructField
|
var fields []reflect.StructField
|
||||||
fields = append(fields, reflect.StructField{
|
fields = append(fields, reflect.StructField{
|
||||||
Name: "X",
|
Name: "X",
|
||||||
Type: reflect.TypeOf(new(big.Int)),
|
Type: reflect.TypeFor[*big.Int](),
|
||||||
Tag: "json:\"" + "x" + "\"",
|
Tag: "json:\"" + "x" + "\"",
|
||||||
})
|
})
|
||||||
fields = append(fields, reflect.StructField{
|
fields = append(fields, reflect.StructField{
|
||||||
Name: "Y",
|
Name: "Y",
|
||||||
Type: reflect.TypeOf(new(big.Int)),
|
Type: reflect.TypeFor[*big.Int](),
|
||||||
Tag: "json:\"" + "y" + "\"",
|
Tag: "json:\"" + "y" + "\"",
|
||||||
})
|
})
|
||||||
val := reflect.New(reflect.StructOf(fields))
|
val := reflect.New(reflect.StructOf(fields))
|
||||||
|
|
|
||||||
|
|
@ -238,9 +238,9 @@ func (t Type) GetType() reflect.Type {
|
||||||
case UintTy:
|
case UintTy:
|
||||||
return reflectIntType(true, t.Size)
|
return reflectIntType(true, t.Size)
|
||||||
case BoolTy:
|
case BoolTy:
|
||||||
return reflect.TypeOf(false)
|
return reflect.TypeFor[bool]()
|
||||||
case StringTy:
|
case StringTy:
|
||||||
return reflect.TypeOf("")
|
return reflect.TypeFor[string]()
|
||||||
case SliceTy:
|
case SliceTy:
|
||||||
return reflect.SliceOf(t.Elem.GetType())
|
return reflect.SliceOf(t.Elem.GetType())
|
||||||
case ArrayTy:
|
case ArrayTy:
|
||||||
|
|
@ -248,19 +248,15 @@ func (t Type) GetType() reflect.Type {
|
||||||
case TupleTy:
|
case TupleTy:
|
||||||
return t.TupleType
|
return t.TupleType
|
||||||
case AddressTy:
|
case AddressTy:
|
||||||
return reflect.TypeOf(common.Address{})
|
return reflect.TypeFor[common.Address]()
|
||||||
case FixedBytesTy:
|
case FixedBytesTy:
|
||||||
return reflect.ArrayOf(t.Size, reflect.TypeOf(byte(0)))
|
return reflect.ArrayOf(t.Size, reflect.TypeFor[byte]())
|
||||||
case BytesTy:
|
case BytesTy:
|
||||||
return reflect.SliceOf(reflect.TypeOf(byte(0)))
|
return reflect.TypeFor[[]byte]()
|
||||||
case HashTy:
|
case HashTy, FixedPointTy: // currently not used
|
||||||
// hashtype currently not used
|
return reflect.TypeFor[[32]byte]()
|
||||||
return reflect.ArrayOf(32, reflect.TypeOf(byte(0)))
|
|
||||||
case FixedPointTy:
|
|
||||||
// fixedpoint type currently not used
|
|
||||||
return reflect.ArrayOf(32, reflect.TypeOf(byte(0)))
|
|
||||||
case FunctionTy:
|
case FunctionTy:
|
||||||
return reflect.ArrayOf(24, reflect.TypeOf(byte(0)))
|
return reflect.TypeFor[[24]byte]()
|
||||||
default:
|
default:
|
||||||
panic("Invalid type")
|
panic("Invalid type")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// KeyStoreType is the reflect type of a keystore backend.
|
// KeyStoreType is the reflect type of a keystore backend.
|
||||||
var KeyStoreType = reflect.TypeOf(&KeyStore{})
|
var KeyStoreType = reflect.TypeFor[*KeyStore]()
|
||||||
|
|
||||||
// KeyStoreScheme is the protocol scheme prefixing account and wallet URLs.
|
// KeyStoreScheme is the protocol scheme prefixing account and wallet URLs.
|
||||||
const KeyStoreScheme = "keystore"
|
const KeyStoreScheme = "keystore"
|
||||||
|
|
|
||||||
|
|
@ -5,54 +5,54 @@
|
||||||
# https://github.com/ethereum/execution-spec-tests/releases/download/fusaka-devnet-3%40v1.0.0
|
# https://github.com/ethereum/execution-spec-tests/releases/download/fusaka-devnet-3%40v1.0.0
|
||||||
576261e1280e5300c458aa9b05eccb2fec5ff80a0005940dc52fa03fdd907249 fixtures_fusaka-devnet-3.tar.gz
|
576261e1280e5300c458aa9b05eccb2fec5ff80a0005940dc52fa03fdd907249 fixtures_fusaka-devnet-3.tar.gz
|
||||||
|
|
||||||
# version:golang 1.24.4
|
# version:golang 1.25.0
|
||||||
# https://go.dev/dl/
|
# https://go.dev/dl/
|
||||||
5a86a83a31f9fa81490b8c5420ac384fd3d95a3e71fba665c7b3f95d1dfef2b4 go1.24.4.src.tar.gz
|
4bd01e91297207bfa450ea40d4d5a93b1b531a5e438473b2a06e18e077227225 go1.25.0.src.tar.gz
|
||||||
0d2af78e3b6e08f8013dbbdb26ae33052697b6b72e03ec17d496739c2a1aed68 go1.24.4.aix-ppc64.tar.gz
|
e5234a7dac67bc86c528fe9752fc9d63557918627707a733ab4cac1a6faed2d4 go1.25.0.aix-ppc64.tar.gz
|
||||||
69bef555e114b4a2252452b6e7049afc31fbdf2d39790b669165e89525cd3f5c go1.24.4.darwin-amd64.tar.gz
|
5bd60e823037062c2307c71e8111809865116714d6f6b410597cf5075dfd80ef go1.25.0.darwin-amd64.tar.gz
|
||||||
c4d74453a26f488bdb4b0294da4840d9020806de4661785334eb6d1803ee5c27 go1.24.4.darwin-amd64.pkg
|
95e836238bcf8f9a71bffea43344cbd35ee1f16db3aaced2f98dbac045d102db go1.25.0.darwin-amd64.pkg
|
||||||
27973684b515eaf461065054e6b572d9390c05e69ba4a423076c160165336470 go1.24.4.darwin-arm64.tar.gz
|
544932844156d8172f7a28f77f2ac9c15a23046698b6243f633b0a0b00c0749c go1.25.0.darwin-arm64.tar.gz
|
||||||
2fe1f8746745c4bfebd494583aaef24cad42594f6d25ed67856879d567ee66e7 go1.24.4.darwin-arm64.pkg
|
202a0d8338c152cb4c9f04782429e9ba8bef31d9889272380837e4043c9d800a go1.25.0.darwin-arm64.pkg
|
||||||
70b2de9c1cafe5af7be3eb8f80753cce0501ef300db3f3bd59be7ccc464234e1 go1.24.4.dragonfly-amd64.tar.gz
|
5ed3cf9a810a1483822538674f1336c06b51aa1b94d6d545a1a0319a48177120 go1.25.0.dragonfly-amd64.tar.gz
|
||||||
8d529839db29ee171505b89dc9c3de76003a4ab56202d84bddbbecacbfb6d7c9 go1.24.4.freebsd-386.tar.gz
|
abea5d5c6697e6b5c224731f2158fe87c602996a2a233ac0c4730cd57bf8374e go1.25.0.freebsd-386.tar.gz
|
||||||
6cbc3ad6cc21bdcc7283824d3ac0e85512c02022f6a35eb2e844882ea6e8448c go1.24.4.freebsd-amd64.tar.gz
|
86e6fe0a29698d7601c4442052dac48bd58d532c51cccb8f1917df648138730b go1.25.0.freebsd-amd64.tar.gz
|
||||||
d49ae050c20aff646a7641dd903f03eb674570790b90ffb298076c4d41e36655 go1.24.4.freebsd-arm.tar.gz
|
d90b78e41921f72f30e8bbc81d9dec2cff7ff384a33d8d8debb24053e4336bfe go1.25.0.freebsd-arm.tar.gz
|
||||||
e31924abef2a28456b7103c0a5d333dcc11ecf19e76d5de1a383ad5fe0b42457 go1.24.4.freebsd-arm64.tar.gz
|
451d0da1affd886bfb291b7c63a6018527b269505db21ce6e14724f22ab0662e go1.25.0.freebsd-arm64.tar.gz
|
||||||
b5bca135eae8ebddf22972611ac1c58ae9fbb5979fd953cc5245c5b1b2517546 go1.24.4.freebsd-riscv64.tar.gz
|
7b565f76bd8bda46549eeaaefe0e53b251e644c230577290c0f66b1ecdb3cdbe go1.25.0.freebsd-riscv64.tar.gz
|
||||||
7d5efda511ff7e3114b130acee5d0bffbb078fedbfa9b2c1b6a807107e1ca23a go1.24.4.illumos-amd64.tar.gz
|
b1e1fdaab1ad25aa1c08d7a36c97d45d74b98b89c3f78c6d2145f77face54a2c go1.25.0.illumos-amd64.tar.gz
|
||||||
130c9b061082eca15513e595e9952a2ded32e737e609dd0e49f7dfa74eba026d go1.24.4.linux-386.tar.gz
|
8c602dd9d99bc9453b3995d20ce4baf382cc50855900a0ece5de9929df4a993a go1.25.0.linux-386.tar.gz
|
||||||
77e5da33bb72aeaef1ba4418b6fe511bc4d041873cbf82e5aa6318740df98717 go1.24.4.linux-amd64.tar.gz
|
2852af0cb20a13139b3448992e69b868e50ed0f8a1e5940ee1de9e19a123b613 go1.25.0.linux-amd64.tar.gz
|
||||||
d5501ee5aca0f258d5fe9bfaed401958445014495dc115f202d43d5210b45241 go1.24.4.linux-arm64.tar.gz
|
05de75d6994a2783699815ee553bd5a9327d8b79991de36e38b66862782f54ae go1.25.0.linux-arm64.tar.gz
|
||||||
6a554e32301cecae3162677e66d4264b81b3b1a89592dd1b7b5c552c7a49fe37 go1.24.4.linux-armv6l.tar.gz
|
a5a8f8198fcf00e1e485b8ecef9ee020778bf32a408a4e8873371bfce458cd09 go1.25.0.linux-armv6l.tar.gz
|
||||||
b208eb25fe244408cbe269ed426454bc46e59d0e0a749b6240d39e884e969875 go1.24.4.linux-loong64.tar.gz
|
cab86b1cf761b1cb3bac86a8877cfc92e7b036fc0d3084123d77013d61432afc go1.25.0.linux-loong64.tar.gz
|
||||||
fddfcb28fd36fe63d2ae181026798f86f3bbd3a7bb0f1e1f617dd3d604bf3fe4 go1.24.4.linux-mips.tar.gz
|
d66b6fb74c3d91b9829dc95ec10ca1f047ef5e89332152f92e136cf0e2da5be1 go1.25.0.linux-mips.tar.gz
|
||||||
7934b924d5ab8c8ae3134a09a6ae74d3c39f63f6c4322ec289364dbbf0bac3ca go1.24.4.linux-mips64.tar.gz
|
4082e4381a8661bc2a839ff94ba3daf4f6cde20f8fb771b5b3d4762dc84198a2 go1.25.0.linux-mips64.tar.gz
|
||||||
fa763d8673f94d6e534bb72c3cf675d4c2b8da4a6da42a89f08c5586106db39c go1.24.4.linux-mips64le.tar.gz
|
70002c299ec7f7175ac2ef673b1b347eecfa54ae11f34416a6053c17f855afcc go1.25.0.linux-mips64le.tar.gz
|
||||||
84363dbfe49b41d43df84420a09bd53a4770053d63bfa509868c46a5f8eb3ff7 go1.24.4.linux-mipsle.tar.gz
|
b00a3a39eff099f6df9f1c7355bf28e4589d0586f42d7d4a394efb763d145a73 go1.25.0.linux-mipsle.tar.gz
|
||||||
28fcbd5d3b56493606873c33f2b4bdd84ba93c633f37313613b5a1e6495c6fe5 go1.24.4.linux-ppc64.tar.gz
|
df166f33bd98160662560a72ff0b4ba731f969a80f088922bddcf566a88c1ec1 go1.25.0.linux-ppc64.tar.gz
|
||||||
9ca4afef813a2578c23843b640ae0290aa54b2e3c950a6cc4c99e16a57dec2ec go1.24.4.linux-ppc64le.tar.gz
|
0f18a89e7576cf2c5fa0b487a1635d9bcbf843df5f110e9982c64df52a983ad0 go1.25.0.linux-ppc64le.tar.gz
|
||||||
1d7034f98662d8f2c8abd7c700ada4093acb4f9c00e0e51a30344821d0785c77 go1.24.4.linux-riscv64.tar.gz
|
c018ff74a2c48d55c8ca9b07c8e24163558ffec8bea08b326d6336905d956b67 go1.25.0.linux-riscv64.tar.gz
|
||||||
0449f3203c39703ab27684be763e9bb78ca9a051e0e4176727aead9461b6deb5 go1.24.4.linux-s390x.tar.gz
|
34e5a2e19f2292fbaf8783e3a241e6e49689276aef6510a8060ea5ef54eee408 go1.25.0.linux-s390x.tar.gz
|
||||||
954b49ccc2cfcf4b5f7cd33ff662295e0d3b74e7590c8e25fc2abb30bce120ba go1.24.4.netbsd-386.tar.gz
|
f8586cdb7aa855657609a5c5f6dbf523efa00c2bbd7c76d3936bec80aa6c0aba go1.25.0.netbsd-386.tar.gz
|
||||||
370fabcdfee7c18857c96fdd5b706e025d4fb86a208da88ba56b1493b35498e9 go1.24.4.netbsd-amd64.tar.gz
|
ae8dc1469385b86a157a423bb56304ba45730de8a897615874f57dd096db2c2a go1.25.0.netbsd-amd64.tar.gz
|
||||||
7935ef95d4d1acc48587b1eb4acab98b0a7d9569736a32398b9c1d2e89026865 go1.24.4.netbsd-arm.tar.gz
|
1ff7e4cc764425fc9dd6825eaee79d02b3c7cafffbb3691687c8d672ade76cb7 go1.25.0.netbsd-arm.tar.gz
|
||||||
ead78fd0fa29fbb176cc83f1caa54032e1a44f842affa56a682c647e0759f237 go1.24.4.netbsd-arm64.tar.gz
|
e1b310739f26724216aa6d7d7208c4031f9ff54c9b5b9a796ddc8bebcb4a5f16 go1.25.0.netbsd-arm64.tar.gz
|
||||||
913e217394b851a636b99de175f0c2f9ab9938b41c557f047168f77ee485d776 go1.24.4.openbsd-386.tar.gz
|
4802a9b20e533da91adb84aab42e94aa56cfe3e5475d0550bed3385b182e69d8 go1.25.0.openbsd-386.tar.gz
|
||||||
24568da3dcbcdb24ec18b631f072faf0f3763e3d04f79032dc56ad9ec35379c4 go1.24.4.openbsd-amd64.tar.gz
|
c016cd984bebe317b19a4f297c4f50def120dc9788490540c89f28e42f1dabe1 go1.25.0.openbsd-amd64.tar.gz
|
||||||
45abf523f870632417ab007de3841f64dd906bde546ffc8c6380ccbe91c7fb73 go1.24.4.openbsd-arm.tar.gz
|
a1e31d0bf22172ddde42edf5ec811ef81be43433df0948ece52fecb247ccfd8d go1.25.0.openbsd-arm.tar.gz
|
||||||
7c57c69b5dd1e946b28a3034c285240a48e2861bdcb50b7d9c0ed61bcf89c879 go1.24.4.openbsd-arm64.tar.gz
|
343ea8edd8c218196e15a859c6072d0dd3246fbbb168481ab665eb4c4140458d go1.25.0.openbsd-arm64.tar.gz
|
||||||
91ed711f704829372d6931e1897631ef40288b8f9e3cd6ef4a24df7126d1066a go1.24.4.openbsd-ppc64.tar.gz
|
694c14da1bcaeb5e3332d49bdc2b6d155067648f8fe1540c5de8f3cf8e157154 go1.25.0.openbsd-ppc64.tar.gz
|
||||||
de5e270d971c8790e8880168d56a2ea103979927c10ded136d792bbdf9bce3d3 go1.24.4.openbsd-riscv64.tar.gz
|
aa510ad25cf54c06cd9c70b6d80ded69cb20188ac6e1735655eef29ff7e7885f go1.25.0.openbsd-riscv64.tar.gz
|
||||||
ff429d03f00bcd32a50f445320b8329d0fadb2a2fff899c11e95e0922a82c543 go1.24.4.plan9-386.tar.gz
|
46f8cef02086cf04bf186c5912776b56535178d4cb319cd19c9fdbdd29231986 go1.25.0.plan9-386.tar.gz
|
||||||
39d6363a43fd16b60ae9ad7346a264e982e4fa653dee3b45f83e03cd2f7a6647 go1.24.4.plan9-amd64.tar.gz
|
29b34391d84095e44608a228f63f2f88113a37b74a79781353ec043dfbcb427b go1.25.0.plan9-amd64.tar.gz
|
||||||
1964ae2571259de77b930e97f2891aa92706ff81aac9909d45bb107b0fab16c8 go1.24.4.plan9-arm.tar.gz
|
0a047107d13ebe7943aaa6d54b1d7bbd2e45e68ce449b52915a818da715799c2 go1.25.0.plan9-arm.tar.gz
|
||||||
a7f9af424e8fb87886664754badca459513f64f6a321d17f1d219b8edf519821 go1.24.4.solaris-amd64.tar.gz
|
9977f9e4351984364a3b2b78f8b88bfd1d339812356d5237678514594b7d3611 go1.25.0.solaris-amd64.tar.gz
|
||||||
d454d3cb144432f1726bf00e28c6017e78ccb256a8d01b8e3fb1b2e6b5650f28 go1.24.4.windows-386.zip
|
df9f39db82a803af0db639e3613a36681ab7a42866b1384b3f3a1045663961a7 go1.25.0.windows-386.zip
|
||||||
966ecace1cdbb3497a2b930bdb0f90c3ad32922fa1a7c655b2d4bbeb7e4ac308 go1.24.4.windows-386.msi
|
afd9e0a8d2665ff122c8302bb4a3ce4a5331e4e630ddc388be1f9238adfa8fe3 go1.25.0.windows-386.msi
|
||||||
b751a1136cb9d8a2e7ebb22c538c4f02c09b98138c7c8bfb78a54a4566c013b1 go1.24.4.windows-amd64.zip
|
89efb4f9b30812eee083cc1770fdd2913c14d301064f6454851428f9707d190b go1.25.0.windows-amd64.zip
|
||||||
0cbb6e83865747dbe69b3d4155f92e88fcf336ff5d70182dba145e9d7bd3d8f6 go1.24.4.windows-amd64.msi
|
936bd87109da515f79d80211de5bc6cbda071f2cc577f7e6af1a9e754ea34819 go1.25.0.windows-amd64.msi
|
||||||
d17da51bc85bd010754a4063215d15d2c033cc289d67ca9201a03c9041b2969d go1.24.4.windows-arm64.zip
|
27bab004c72b3d7bd05a69b6ec0fc54a309b4b78cc569dd963d8b3ec28bfdb8c go1.25.0.windows-arm64.zip
|
||||||
47dbe734b6a829de45654648a7abcf05bdceef5c80e03ea0b208eeebef75a852 go1.24.4.windows-arm64.msi
|
357d030b217ff68e700b6cfc56097bc21ad493bb45b79733a052d112f5031ed9 go1.25.0.windows-arm64.msi
|
||||||
|
|
||||||
# version:golangci 2.0.2
|
# version:golangci 2.0.2
|
||||||
# https://github.com/golangci/golangci-lint/releases/
|
# https://github.com/golangci/golangci-lint/releases/
|
||||||
|
|
|
||||||
|
|
@ -344,10 +344,6 @@ func downloadSpecTestFixtures(csdb *download.ChecksumDB, cachedir string) string
|
||||||
return filepath.Join(cachedir, base)
|
return filepath.Join(cachedir, base)
|
||||||
}
|
}
|
||||||
|
|
||||||
// doCheckTidy assets that the Go modules files are tidied already.
|
|
||||||
func doCheckTidy() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// doCheckGenerate ensures that re-generating generated files does not cause
|
// doCheckGenerate ensures that re-generating generated files does not cause
|
||||||
// any mutations in the source file tree.
|
// any mutations in the source file tree.
|
||||||
func doCheckGenerate() {
|
func doCheckGenerate() {
|
||||||
|
|
|
||||||
|
|
@ -720,7 +720,7 @@ func pruneHistory(ctx *cli.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// downladEra is the era1 file downloader tool.
|
// downloadEra is the era1 file downloader tool.
|
||||||
func downloadEra(ctx *cli.Context) error {
|
func downloadEra(ctx *cli.Context) error {
|
||||||
flags.CheckExclusive(ctx, eraBlockFlag, eraEpochFlag, eraAllFlag)
|
flags.CheckExclusive(ctx, eraBlockFlag, eraEpochFlag, eraAllFlag)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ func runBlockTest(ctx *cli.Context, fname string) ([]testResult, error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
result := &testResult{Name: name, Pass: true}
|
result := &testResult{Name: name, Pass: true}
|
||||||
if err := tests[name].Run(false, rawdb.HashScheme, ctx.Bool(WitnessCrossCheckFlag.Name), tracer, func(res error, chain *core.BlockChain) {
|
if err := tests[name].Run(false, rawdb.PathScheme, ctx.Bool(WitnessCrossCheckFlag.Name), tracer, func(res error, chain *core.BlockChain) {
|
||||||
if ctx.Bool(DumpFlag.Name) {
|
if ctx.Bool(DumpFlag.Name) {
|
||||||
if s, _ := chain.State(); s != nil {
|
if s, _ := chain.State(); s != nil {
|
||||||
result.State = dump(s)
|
result.State = dump(s)
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ func (s *filterTestSuite) filterShortRange(t *utesting.T) {
|
||||||
}, s.queryAndCheck)
|
}, s.queryAndCheck)
|
||||||
}
|
}
|
||||||
|
|
||||||
// filterShortRange runs all long-range filter tests.
|
// filterLongRange runs all long-range filter tests.
|
||||||
func (s *filterTestSuite) filterLongRange(t *utesting.T) {
|
func (s *filterTestSuite) filterLongRange(t *utesting.T) {
|
||||||
s.filterRange(t, func(query *filterQuery) bool {
|
s.filterRange(t, func(query *filterQuery) bool {
|
||||||
return query.ToBlock+1-query.FromBlock > filterRangeThreshold
|
return query.ToBlock+1-query.FromBlock > filterRangeThreshold
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package eip4844
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
|
@ -29,6 +30,66 @@ var (
|
||||||
minBlobGasPrice = big.NewInt(params.BlobTxMinBlobGasprice)
|
minBlobGasPrice = big.NewInt(params.BlobTxMinBlobGasprice)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// BlobConfig contains the parameters for blob-related formulas.
|
||||||
|
// These can be adjusted in a fork.
|
||||||
|
type BlobConfig struct {
|
||||||
|
Target int
|
||||||
|
Max int
|
||||||
|
UpdateFraction uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (bc *BlobConfig) maxBlobGas() uint64 {
|
||||||
|
return uint64(bc.Max) * params.BlobTxBlobGasPerBlob
|
||||||
|
}
|
||||||
|
|
||||||
|
// blobBaseFee computes the blob fee.
|
||||||
|
func (bc *BlobConfig) blobBaseFee(excessBlobGas uint64) *big.Int {
|
||||||
|
return fakeExponential(minBlobGasPrice, new(big.Int).SetUint64(excessBlobGas), new(big.Int).SetUint64(bc.UpdateFraction))
|
||||||
|
}
|
||||||
|
|
||||||
|
// blobPrice returns the price of one blob in Wei.
|
||||||
|
func (bc *BlobConfig) blobPrice(excessBlobGas uint64) *big.Int {
|
||||||
|
f := bc.blobBaseFee(excessBlobGas)
|
||||||
|
return new(big.Int).Mul(f, big.NewInt(params.BlobTxBlobGasPerBlob))
|
||||||
|
}
|
||||||
|
|
||||||
|
func latestBlobConfig(cfg *params.ChainConfig, time uint64) *BlobConfig {
|
||||||
|
if cfg.BlobScheduleConfig == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var (
|
||||||
|
london = cfg.LondonBlock
|
||||||
|
s = cfg.BlobScheduleConfig
|
||||||
|
bc *params.BlobConfig
|
||||||
|
)
|
||||||
|
switch {
|
||||||
|
case cfg.IsBPO5(london, time) && s.BPO5 != nil:
|
||||||
|
bc = s.BPO5
|
||||||
|
case cfg.IsBPO4(london, time) && s.BPO4 != nil:
|
||||||
|
bc = s.BPO4
|
||||||
|
case cfg.IsBPO3(london, time) && s.BPO3 != nil:
|
||||||
|
bc = s.BPO3
|
||||||
|
case cfg.IsBPO2(london, time) && s.BPO2 != nil:
|
||||||
|
bc = s.BPO2
|
||||||
|
case cfg.IsBPO1(london, time) && s.BPO1 != nil:
|
||||||
|
bc = s.BPO1
|
||||||
|
case cfg.IsOsaka(london, time) && s.Osaka != nil:
|
||||||
|
bc = s.Osaka
|
||||||
|
case cfg.IsPrague(london, time) && s.Prague != nil:
|
||||||
|
bc = s.Prague
|
||||||
|
case cfg.IsCancun(london, time) && s.Cancun != nil:
|
||||||
|
bc = s.Cancun
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &BlobConfig{
|
||||||
|
Target: bc.Target,
|
||||||
|
Max: bc.Max,
|
||||||
|
UpdateFraction: bc.UpdateFraction,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// VerifyEIP4844Header verifies the presence of the excessBlobGas field and that
|
// VerifyEIP4844Header verifies the presence of the excessBlobGas field and that
|
||||||
// if the current block contains no transactions, the excessBlobGas is updated
|
// if the current block contains no transactions, the excessBlobGas is updated
|
||||||
// accordingly.
|
// accordingly.
|
||||||
|
|
@ -36,21 +97,27 @@ func VerifyEIP4844Header(config *params.ChainConfig, parent, header *types.Heade
|
||||||
if header.Number.Uint64() != parent.Number.Uint64()+1 {
|
if header.Number.Uint64() != parent.Number.Uint64()+1 {
|
||||||
panic("bad header pair")
|
panic("bad header pair")
|
||||||
}
|
}
|
||||||
// Verify the header is not malformed
|
|
||||||
|
bcfg := latestBlobConfig(config, header.Time)
|
||||||
|
if bcfg == nil {
|
||||||
|
panic("called before EIP-4844 is active")
|
||||||
|
}
|
||||||
|
|
||||||
if header.ExcessBlobGas == nil {
|
if header.ExcessBlobGas == nil {
|
||||||
return errors.New("header is missing excessBlobGas")
|
return errors.New("header is missing excessBlobGas")
|
||||||
}
|
}
|
||||||
if header.BlobGasUsed == nil {
|
if header.BlobGasUsed == nil {
|
||||||
return errors.New("header is missing blobGasUsed")
|
return errors.New("header is missing blobGasUsed")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that the blob gas used remains within reasonable limits.
|
// Verify that the blob gas used remains within reasonable limits.
|
||||||
maxBlobGas := MaxBlobGasPerBlock(config, header.Time)
|
if *header.BlobGasUsed > bcfg.maxBlobGas() {
|
||||||
if *header.BlobGasUsed > maxBlobGas {
|
return fmt.Errorf("blob gas used %d exceeds maximum allowance %d", *header.BlobGasUsed, bcfg.maxBlobGas())
|
||||||
return fmt.Errorf("blob gas used %d exceeds maximum allowance %d", *header.BlobGasUsed, maxBlobGas)
|
|
||||||
}
|
}
|
||||||
if *header.BlobGasUsed%params.BlobTxBlobGasPerBlob != 0 {
|
if *header.BlobGasUsed%params.BlobTxBlobGasPerBlob != 0 {
|
||||||
return fmt.Errorf("blob gas used %d not a multiple of blob gas per blob %d", header.BlobGasUsed, params.BlobTxBlobGasPerBlob)
|
return fmt.Errorf("blob gas used %d not a multiple of blob gas per blob %d", header.BlobGasUsed, params.BlobTxBlobGasPerBlob)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the excessBlobGas is correct based on the parent header
|
// Verify the excessBlobGas is correct based on the parent header
|
||||||
expectedExcessBlobGas := CalcExcessBlobGas(config, parent, header.Time)
|
expectedExcessBlobGas := CalcExcessBlobGas(config, parent, header.Time)
|
||||||
if *header.ExcessBlobGas != expectedExcessBlobGas {
|
if *header.ExcessBlobGas != expectedExcessBlobGas {
|
||||||
|
|
@ -62,38 +129,41 @@ func VerifyEIP4844Header(config *params.ChainConfig, parent, header *types.Heade
|
||||||
// CalcExcessBlobGas calculates the excess blob gas after applying the set of
|
// CalcExcessBlobGas calculates the excess blob gas after applying the set of
|
||||||
// blobs on top of the excess blob gas.
|
// blobs on top of the excess blob gas.
|
||||||
func CalcExcessBlobGas(config *params.ChainConfig, parent *types.Header, headTimestamp uint64) uint64 {
|
func CalcExcessBlobGas(config *params.ChainConfig, parent *types.Header, headTimestamp uint64) uint64 {
|
||||||
var (
|
isOsaka := config.IsOsaka(config.LondonBlock, headTimestamp)
|
||||||
parentExcessBlobGas uint64
|
bcfg := latestBlobConfig(config, headTimestamp)
|
||||||
parentBlobGasUsed uint64
|
return calcExcessBlobGas(isOsaka, bcfg, parent)
|
||||||
)
|
}
|
||||||
|
|
||||||
|
func calcExcessBlobGas(isOsaka bool, bcfg *BlobConfig, parent *types.Header) uint64 {
|
||||||
|
var parentExcessBlobGas, parentBlobGasUsed uint64
|
||||||
if parent.ExcessBlobGas != nil {
|
if parent.ExcessBlobGas != nil {
|
||||||
parentExcessBlobGas = *parent.ExcessBlobGas
|
parentExcessBlobGas = *parent.ExcessBlobGas
|
||||||
parentBlobGasUsed = *parent.BlobGasUsed
|
parentBlobGasUsed = *parent.BlobGasUsed
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
excessBlobGas = parentExcessBlobGas + parentBlobGasUsed
|
excessBlobGas = parentExcessBlobGas + parentBlobGasUsed
|
||||||
target = targetBlobsPerBlock(config, headTimestamp)
|
targetGas = uint64(bcfg.Target) * params.BlobTxBlobGasPerBlob
|
||||||
targetGas = uint64(target) * params.BlobTxBlobGasPerBlob
|
|
||||||
)
|
)
|
||||||
if excessBlobGas < targetGas {
|
if excessBlobGas < targetGas {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if !config.IsOsaka(config.LondonBlock, headTimestamp) {
|
|
||||||
// Pre-Osaka, we use the formula defined by EIP-4844.
|
|
||||||
return excessBlobGas - targetGas
|
|
||||||
}
|
|
||||||
|
|
||||||
// EIP-7918 (post-Osaka) introduces a different formula for computing excess.
|
// EIP-7918 (post-Osaka) introduces a different formula for computing excess,
|
||||||
|
// in cases where the price is lower than a 'reserve price'.
|
||||||
|
if isOsaka {
|
||||||
var (
|
var (
|
||||||
baseCost = big.NewInt(params.BlobBaseCost)
|
baseCost = big.NewInt(params.BlobBaseCost)
|
||||||
reservePrice = baseCost.Mul(baseCost, parent.BaseFee)
|
reservePrice = baseCost.Mul(baseCost, parent.BaseFee)
|
||||||
blobPrice = calcBlobPrice(config, parent)
|
blobPrice = bcfg.blobPrice(parentExcessBlobGas)
|
||||||
)
|
)
|
||||||
if reservePrice.Cmp(blobPrice) > 0 {
|
if reservePrice.Cmp(blobPrice) > 0 {
|
||||||
max := MaxBlobsPerBlock(config, headTimestamp)
|
scaledExcess := parentBlobGasUsed * uint64(bcfg.Max-bcfg.Target) / uint64(bcfg.Max)
|
||||||
scaledExcess := parentBlobGasUsed * uint64(max-target) / uint64(max)
|
|
||||||
return parentExcessBlobGas + scaledExcess
|
return parentExcessBlobGas + scaledExcess
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Original EIP-4844 formula.
|
||||||
return excessBlobGas - targetGas
|
return excessBlobGas - targetGas
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,7 +173,7 @@ func CalcBlobFee(config *params.ChainConfig, header *types.Header) *big.Int {
|
||||||
if blobConfig == nil {
|
if blobConfig == nil {
|
||||||
panic("calculating blob fee on unsupported fork")
|
panic("calculating blob fee on unsupported fork")
|
||||||
}
|
}
|
||||||
return fakeExponential(minBlobGasPrice, new(big.Int).SetUint64(*header.ExcessBlobGas), new(big.Int).SetUint64(blobConfig.UpdateFraction))
|
return blobConfig.blobBaseFee(*header.ExcessBlobGas)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxBlobsPerBlock returns the max blobs per block for a block at the given timestamp.
|
// MaxBlobsPerBlock returns the max blobs per block for a block at the given timestamp.
|
||||||
|
|
@ -115,36 +185,6 @@ func MaxBlobsPerBlock(cfg *params.ChainConfig, time uint64) int {
|
||||||
return blobConfig.Max
|
return blobConfig.Max
|
||||||
}
|
}
|
||||||
|
|
||||||
func latestBlobConfig(cfg *params.ChainConfig, time uint64) *params.BlobConfig {
|
|
||||||
if cfg.BlobScheduleConfig == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
var (
|
|
||||||
london = cfg.LondonBlock
|
|
||||||
s = cfg.BlobScheduleConfig
|
|
||||||
)
|
|
||||||
switch {
|
|
||||||
case cfg.IsBPO5(london, time) && s.BPO5 != nil:
|
|
||||||
return s.BPO5
|
|
||||||
case cfg.IsBPO4(london, time) && s.BPO4 != nil:
|
|
||||||
return s.BPO4
|
|
||||||
case cfg.IsBPO3(london, time) && s.BPO3 != nil:
|
|
||||||
return s.BPO3
|
|
||||||
case cfg.IsBPO2(london, time) && s.BPO2 != nil:
|
|
||||||
return s.BPO2
|
|
||||||
case cfg.IsBPO1(london, time) && s.BPO1 != nil:
|
|
||||||
return s.BPO1
|
|
||||||
case cfg.IsOsaka(london, time) && s.Osaka != nil:
|
|
||||||
return s.Osaka
|
|
||||||
case cfg.IsPrague(london, time) && s.Prague != nil:
|
|
||||||
return s.Prague
|
|
||||||
case cfg.IsCancun(london, time) && s.Cancun != nil:
|
|
||||||
return s.Cancun
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MaxBlobGasPerBlock returns the maximum blob gas that can be spent in a block at the given timestamp.
|
// MaxBlobGasPerBlock returns the maximum blob gas that can be spent in a block at the given timestamp.
|
||||||
func MaxBlobGasPerBlock(cfg *params.ChainConfig, time uint64) uint64 {
|
func MaxBlobGasPerBlock(cfg *params.ChainConfig, time uint64) uint64 {
|
||||||
return uint64(MaxBlobsPerBlock(cfg, time)) * params.BlobTxBlobGasPerBlob
|
return uint64(MaxBlobsPerBlock(cfg, time)) * params.BlobTxBlobGasPerBlob
|
||||||
|
|
@ -153,39 +193,11 @@ func MaxBlobGasPerBlock(cfg *params.ChainConfig, time uint64) uint64 {
|
||||||
// LatestMaxBlobsPerBlock returns the latest max blobs per block defined by the
|
// LatestMaxBlobsPerBlock returns the latest max blobs per block defined by the
|
||||||
// configuration, regardless of the currently active fork.
|
// configuration, regardless of the currently active fork.
|
||||||
func LatestMaxBlobsPerBlock(cfg *params.ChainConfig) int {
|
func LatestMaxBlobsPerBlock(cfg *params.ChainConfig) int {
|
||||||
s := cfg.BlobScheduleConfig
|
bcfg := latestBlobConfig(cfg, math.MaxUint64)
|
||||||
if s == nil {
|
if bcfg == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
switch {
|
return bcfg.Max
|
||||||
case s.BPO5 != nil:
|
|
||||||
return s.BPO5.Max
|
|
||||||
case s.BPO4 != nil:
|
|
||||||
return s.BPO4.Max
|
|
||||||
case s.BPO3 != nil:
|
|
||||||
return s.BPO3.Max
|
|
||||||
case s.BPO2 != nil:
|
|
||||||
return s.BPO2.Max
|
|
||||||
case s.BPO1 != nil:
|
|
||||||
return s.BPO1.Max
|
|
||||||
case s.Osaka != nil:
|
|
||||||
return s.Osaka.Max
|
|
||||||
case s.Prague != nil:
|
|
||||||
return s.Prague.Max
|
|
||||||
case s.Cancun != nil:
|
|
||||||
return s.Cancun.Max
|
|
||||||
default:
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// targetBlobsPerBlock returns the target number of blobs in a block at the given timestamp.
|
|
||||||
func targetBlobsPerBlock(cfg *params.ChainConfig, time uint64) int {
|
|
||||||
blobConfig := latestBlobConfig(cfg, time)
|
|
||||||
if blobConfig == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
return blobConfig.Target
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fakeExponential approximates factor * e ** (numerator / denominator) using
|
// fakeExponential approximates factor * e ** (numerator / denominator) using
|
||||||
|
|
@ -204,9 +216,3 @@ func fakeExponential(factor, numerator, denominator *big.Int) *big.Int {
|
||||||
}
|
}
|
||||||
return output.Div(output, denominator)
|
return output.Div(output, denominator)
|
||||||
}
|
}
|
||||||
|
|
||||||
// calcBlobPrice calculates the blob price for a block.
|
|
||||||
func calcBlobPrice(config *params.ChainConfig, header *types.Header) *big.Int {
|
|
||||||
blobBaseFee := CalcBlobFee(config, header)
|
|
||||||
return new(big.Int).Mul(blobBaseFee, big.NewInt(params.BlobTxBlobGasPerBlob))
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,10 @@ import (
|
||||||
func TestCalcExcessBlobGas(t *testing.T) {
|
func TestCalcExcessBlobGas(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
config = params.MainnetChainConfig
|
config = params.MainnetChainConfig
|
||||||
targetBlobs = targetBlobsPerBlock(config, *config.CancunTime)
|
targetBlobs = config.BlobScheduleConfig.Cancun.Target
|
||||||
targetBlobGas = uint64(targetBlobs) * params.BlobTxBlobGasPerBlob
|
targetBlobGas = uint64(targetBlobs) * params.BlobTxBlobGasPerBlob
|
||||||
)
|
)
|
||||||
|
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
excess uint64
|
excess uint64
|
||||||
blobs int
|
blobs int
|
||||||
|
|
@ -90,6 +91,65 @@ func TestCalcBlobFee(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCalcBlobFeePostOsaka(t *testing.T) {
|
||||||
|
zero := uint64(0)
|
||||||
|
bpo1 := uint64(1754836608)
|
||||||
|
bpo2 := uint64(1754934912)
|
||||||
|
bpo3 := uint64(1755033216)
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
excessBlobGas uint64
|
||||||
|
blobGasUsed uint64
|
||||||
|
blobfee uint64
|
||||||
|
basefee uint64
|
||||||
|
parenttime uint64
|
||||||
|
headertime uint64
|
||||||
|
}{
|
||||||
|
{5149252, 1310720, 5617366, 30, 1754904516, 1754904528},
|
||||||
|
{19251039, 2490368, 20107103, 50, 1755033204, 1755033216},
|
||||||
|
}
|
||||||
|
for i, tt := range tests {
|
||||||
|
config := ¶ms.ChainConfig{
|
||||||
|
LondonBlock: big.NewInt(0),
|
||||||
|
CancunTime: &zero,
|
||||||
|
PragueTime: &zero,
|
||||||
|
OsakaTime: &zero,
|
||||||
|
BPO1Time: &bpo1,
|
||||||
|
BPO2Time: &bpo2,
|
||||||
|
BPO3Time: &bpo3,
|
||||||
|
BlobScheduleConfig: ¶ms.BlobScheduleConfig{
|
||||||
|
Cancun: params.DefaultCancunBlobConfig,
|
||||||
|
Prague: params.DefaultPragueBlobConfig,
|
||||||
|
Osaka: params.DefaultOsakaBlobConfig,
|
||||||
|
BPO1: ¶ms.BlobConfig{
|
||||||
|
Target: 9,
|
||||||
|
Max: 14,
|
||||||
|
UpdateFraction: 8832827,
|
||||||
|
},
|
||||||
|
BPO2: ¶ms.BlobConfig{
|
||||||
|
Target: 14,
|
||||||
|
Max: 21,
|
||||||
|
UpdateFraction: 13739630,
|
||||||
|
},
|
||||||
|
BPO3: ¶ms.BlobConfig{
|
||||||
|
Target: 21,
|
||||||
|
Max: 32,
|
||||||
|
UpdateFraction: 20609697,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
parent := &types.Header{
|
||||||
|
ExcessBlobGas: &tt.excessBlobGas,
|
||||||
|
BlobGasUsed: &tt.blobGasUsed,
|
||||||
|
BaseFee: big.NewInt(int64(tt.basefee)),
|
||||||
|
Time: tt.parenttime,
|
||||||
|
}
|
||||||
|
have := CalcExcessBlobGas(config, parent, tt.headertime)
|
||||||
|
if have != tt.blobfee {
|
||||||
|
t.Errorf("test %d: blobfee mismatch: have %v want %v", i, have, tt.blobfee)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestFakeExponential(t *testing.T) {
|
func TestFakeExponential(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
factor int64
|
factor int64
|
||||||
|
|
@ -131,9 +191,10 @@ func TestFakeExponential(t *testing.T) {
|
||||||
func TestCalcExcessBlobGasEIP7918(t *testing.T) {
|
func TestCalcExcessBlobGasEIP7918(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
cfg = params.MergedTestChainConfig
|
cfg = params.MergedTestChainConfig
|
||||||
targetBlobs = targetBlobsPerBlock(cfg, *cfg.CancunTime)
|
targetBlobs = cfg.BlobScheduleConfig.Osaka.Target
|
||||||
blobGasTarget = uint64(targetBlobs) * params.BlobTxBlobGasPerBlob
|
blobGasTarget = uint64(targetBlobs) * params.BlobTxBlobGasPerBlob
|
||||||
)
|
)
|
||||||
|
|
||||||
makeHeader := func(parentExcess, parentBaseFee uint64, blobsUsed int) *types.Header {
|
makeHeader := func(parentExcess, parentBaseFee uint64, blobsUsed int) *types.Header {
|
||||||
blobGasUsed := uint64(blobsUsed) * params.BlobTxBlobGasPerBlob
|
blobGasUsed := uint64(blobsUsed) * params.BlobTxBlobGasPerBlob
|
||||||
return &types.Header{
|
return &types.Header{
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ func VerifyGaslimit(parentGasLimit, headerGasLimit uint64) error {
|
||||||
}
|
}
|
||||||
limit := parentGasLimit / params.GasLimitBoundDivisor
|
limit := parentGasLimit / params.GasLimitBoundDivisor
|
||||||
if uint64(diff) >= limit {
|
if uint64(diff) >= limit {
|
||||||
return fmt.Errorf("invalid gas limit: have %d, want %d +-= %d", headerGasLimit, parentGasLimit, limit-1)
|
return fmt.Errorf("invalid gas limit: have %d, want %d +/- %d", headerGasLimit, parentGasLimit, limit-1)
|
||||||
}
|
}
|
||||||
if headerGasLimit < params.MinGasLimit {
|
if headerGasLimit < params.MinGasLimit {
|
||||||
return fmt.Errorf("invalid gas limit below %d", params.MinGasLimit)
|
return fmt.Errorf("invalid gas limit below %d", params.MinGasLimit)
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import (
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/lru"
|
"github.com/ethereum/go-ethereum/common/lru"
|
||||||
|
"github.com/ethereum/go-ethereum/core/overlay"
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
|
@ -241,8 +242,19 @@ func newTrieReader(root common.Hash, db *triedb.Database, cache *utils.PointCach
|
||||||
if !db.IsVerkle() {
|
if !db.IsVerkle() {
|
||||||
tr, err = trie.NewStateTrie(trie.StateTrieID(root), db)
|
tr, err = trie.NewStateTrie(trie.StateTrieID(root), db)
|
||||||
} else {
|
} else {
|
||||||
// TODO @gballet determine the trie type (verkle or overlay) by transition state
|
|
||||||
tr, err = trie.NewVerkleTrie(root, db, cache)
|
tr, err = trie.NewVerkleTrie(root, db, cache)
|
||||||
|
|
||||||
|
// Based on the transition status, determine if the overlay
|
||||||
|
// tree needs to be created, or if a single, target tree is
|
||||||
|
// to be picked.
|
||||||
|
ts := overlay.LoadTransitionState(db.Disk(), root, true)
|
||||||
|
if ts.InTransition() {
|
||||||
|
mpt, err := trie.NewStateTrie(trie.StateTrieID(ts.BaseRoot), db)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
tr = trie.NewTransitionTree(mpt, tr.(*trie.VerkleTrie), false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -977,7 +977,7 @@ func (s *StateDB) fastDeleteStorage(snaps *snapshot.Tree, addrHash common.Hash,
|
||||||
storageOrigins = make(map[common.Hash][]byte) // the set for tracking the original value of slot
|
storageOrigins = make(map[common.Hash][]byte) // the set for tracking the original value of slot
|
||||||
)
|
)
|
||||||
stack := trie.NewStackTrie(func(path []byte, hash common.Hash, blob []byte) {
|
stack := trie.NewStackTrie(func(path []byte, hash common.Hash, blob []byte) {
|
||||||
nodes.AddNode(path, trienode.NewDeleted())
|
nodes.AddNode(path, trienode.NewDeletedWithPrev(blob))
|
||||||
})
|
})
|
||||||
for iter.Next() {
|
for iter.Next() {
|
||||||
slot := common.CopyBytes(iter.Slot())
|
slot := common.CopyBytes(iter.Slot())
|
||||||
|
|
@ -1028,7 +1028,7 @@ func (s *StateDB) slowDeleteStorage(addr common.Address, addrHash common.Hash, r
|
||||||
if it.Hash() == (common.Hash{}) {
|
if it.Hash() == (common.Hash{}) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
nodes.AddNode(it.Path(), trienode.NewDeleted())
|
nodes.AddNode(it.Path(), trienode.NewDeletedWithPrev(it.NodeBlob()))
|
||||||
}
|
}
|
||||||
if err := it.Error(); err != nil {
|
if err := it.Error(); err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
|
|
@ -1160,7 +1160,7 @@ func (s *StateDB) commit(deleteEmptyObjects bool, noStorageWiping bool) (*stateU
|
||||||
//
|
//
|
||||||
// Given that some accounts may be destroyed and then recreated within
|
// Given that some accounts may be destroyed and then recreated within
|
||||||
// the same block, it's possible that a node set with the same owner
|
// the same block, it's possible that a node set with the same owner
|
||||||
// may already exists. In such cases, these two sets are combined, with
|
// may already exist. In such cases, these two sets are combined, with
|
||||||
// the later one overwriting the previous one if any nodes are modified
|
// the later one overwriting the previous one if any nodes are modified
|
||||||
// or deleted in both sets.
|
// or deleted in both sets.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -84,12 +84,3 @@ func toWordSize(size uint64) uint64 {
|
||||||
|
|
||||||
return (size + 31) / 32
|
return (size + 31) / 32
|
||||||
}
|
}
|
||||||
|
|
||||||
func allZero(b []byte) bool {
|
|
||||||
for _, byte := range b {
|
|
||||||
if byte != 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import (
|
||||||
"github.com/consensys/gnark-crypto/ecc/bls12-381/fp"
|
"github.com/consensys/gnark-crypto/ecc/bls12-381/fp"
|
||||||
"github.com/consensys/gnark-crypto/ecc/bls12-381/fr"
|
"github.com/consensys/gnark-crypto/ecc/bls12-381/fr"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/common/bitutil"
|
||||||
"github.com/ethereum/go-ethereum/core/tracing"
|
"github.com/ethereum/go-ethereum/core/tracing"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/crypto/blake2b"
|
"github.com/ethereum/go-ethereum/crypto/blake2b"
|
||||||
|
|
@ -289,7 +290,7 @@ func (c *ecrecover) Run(input []byte) ([]byte, error) {
|
||||||
v := input[63] - 27
|
v := input[63] - 27
|
||||||
|
|
||||||
// tighter sig s values input homestead only apply to tx sigs
|
// tighter sig s values input homestead only apply to tx sigs
|
||||||
if !allZero(input[32:63]) || !crypto.ValidateSignatureValues(v, r, s, false) {
|
if bitutil.TestBytes(input[32:63]) || !crypto.ValidateSignatureValues(v, r, s, false) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
// We must make sure not to modify the 'input', so placing the 'v' along with
|
// We must make sure not to modify the 'input', so placing the 'v' along with
|
||||||
|
|
@ -500,23 +501,28 @@ func (c *bigModExp) RequiredGas(input []byte) uint64 {
|
||||||
|
|
||||||
func (c *bigModExp) Run(input []byte) ([]byte, error) {
|
func (c *bigModExp) Run(input []byte) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
baseLen = new(big.Int).SetBytes(getData(input, 0, 32)).Uint64()
|
baseLenBig = new(big.Int).SetBytes(getData(input, 0, 32))
|
||||||
expLen = new(big.Int).SetBytes(getData(input, 32, 32)).Uint64()
|
expLenBig = new(big.Int).SetBytes(getData(input, 32, 32))
|
||||||
modLen = new(big.Int).SetBytes(getData(input, 64, 32)).Uint64()
|
modLenBig = new(big.Int).SetBytes(getData(input, 64, 32))
|
||||||
|
baseLen = baseLenBig.Uint64()
|
||||||
|
expLen = expLenBig.Uint64()
|
||||||
|
modLen = modLenBig.Uint64()
|
||||||
|
inputLenOverflow = max(baseLenBig.BitLen(), expLenBig.BitLen(), modLenBig.BitLen()) > 64
|
||||||
)
|
)
|
||||||
if len(input) > 96 {
|
if len(input) > 96 {
|
||||||
input = input[96:]
|
input = input[96:]
|
||||||
} else {
|
} else {
|
||||||
input = input[:0]
|
input = input[:0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// enforce size cap for inputs
|
||||||
|
if c.eip7823 && (inputLenOverflow || max(baseLen, expLen, modLen) > 1024) {
|
||||||
|
return nil, errors.New("one or more of base/exponent/modulus length exceeded 1024 bytes")
|
||||||
|
}
|
||||||
// Handle a special case when both the base and mod length is zero
|
// Handle a special case when both the base and mod length is zero
|
||||||
if baseLen == 0 && modLen == 0 {
|
if baseLen == 0 && modLen == 0 {
|
||||||
return []byte{}, nil
|
return []byte{}, nil
|
||||||
}
|
}
|
||||||
// enforce size cap for inputs
|
|
||||||
if c.eip7823 && max(baseLen, expLen, modLen) > 1024 {
|
|
||||||
return nil, errors.New("one or more of base/exponent/modulus length exceeded 1024 bytes")
|
|
||||||
}
|
|
||||||
// Retrieve the operands and execute the exponentiation
|
// Retrieve the operands and execute the exponentiation
|
||||||
var (
|
var (
|
||||||
base = new(big.Int).SetBytes(getData(input, 0, baseLen))
|
base = new(big.Int).SetBytes(getData(input, 0, baseLen))
|
||||||
|
|
|
||||||
|
|
@ -89,8 +89,8 @@ func enable1884(jt *JumpTable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSelfBalance(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSelfBalance(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
balance := interpreter.evm.StateDB.GetBalance(scope.Contract.Address())
|
balance := evm.StateDB.GetBalance(scope.Contract.Address())
|
||||||
scope.Stack.push(balance)
|
scope.Stack.push(balance)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
@ -108,8 +108,8 @@ func enable1344(jt *JumpTable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// opChainID implements CHAINID opcode
|
// opChainID implements CHAINID opcode
|
||||||
func opChainID(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opChainID(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
chainId, _ := uint256.FromBig(interpreter.evm.chainConfig.ChainID)
|
chainId, _ := uint256.FromBig(evm.chainConfig.ChainID)
|
||||||
scope.Stack.push(chainId)
|
scope.Stack.push(chainId)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
@ -199,28 +199,28 @@ func enable1153(jt *JumpTable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// opTload implements TLOAD opcode
|
// opTload implements TLOAD opcode
|
||||||
func opTload(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opTload(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
loc := scope.Stack.peek()
|
loc := scope.Stack.peek()
|
||||||
hash := common.Hash(loc.Bytes32())
|
hash := common.Hash(loc.Bytes32())
|
||||||
val := interpreter.evm.StateDB.GetTransientState(scope.Contract.Address(), hash)
|
val := evm.StateDB.GetTransientState(scope.Contract.Address(), hash)
|
||||||
loc.SetBytes(val.Bytes())
|
loc.SetBytes(val.Bytes())
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// opTstore implements TSTORE opcode
|
// opTstore implements TSTORE opcode
|
||||||
func opTstore(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opTstore(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
if interpreter.readOnly {
|
if evm.readOnly {
|
||||||
return nil, ErrWriteProtection
|
return nil, ErrWriteProtection
|
||||||
}
|
}
|
||||||
loc := scope.Stack.pop()
|
loc := scope.Stack.pop()
|
||||||
val := scope.Stack.pop()
|
val := scope.Stack.pop()
|
||||||
interpreter.evm.StateDB.SetTransientState(scope.Contract.Address(), loc.Bytes32(), val.Bytes32())
|
evm.StateDB.SetTransientState(scope.Contract.Address(), loc.Bytes32(), val.Bytes32())
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// opBaseFee implements BASEFEE opcode
|
// opBaseFee implements BASEFEE opcode
|
||||||
func opBaseFee(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opBaseFee(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
baseFee, _ := uint256.FromBig(interpreter.evm.Context.BaseFee)
|
baseFee, _ := uint256.FromBig(evm.Context.BaseFee)
|
||||||
scope.Stack.push(baseFee)
|
scope.Stack.push(baseFee)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
@ -237,7 +237,7 @@ func enable3855(jt *JumpTable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// opPush0 implements the PUSH0 opcode
|
// opPush0 implements the PUSH0 opcode
|
||||||
func opPush0(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opPush0(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.push(new(uint256.Int))
|
scope.Stack.push(new(uint256.Int))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
@ -263,7 +263,7 @@ func enable5656(jt *JumpTable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// opMcopy implements the MCOPY opcode (https://eips.ethereum.org/EIPS/eip-5656)
|
// opMcopy implements the MCOPY opcode (https://eips.ethereum.org/EIPS/eip-5656)
|
||||||
func opMcopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opMcopy(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
dst = scope.Stack.pop()
|
dst = scope.Stack.pop()
|
||||||
src = scope.Stack.pop()
|
src = scope.Stack.pop()
|
||||||
|
|
@ -276,10 +276,10 @@ func opMcopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by
|
||||||
}
|
}
|
||||||
|
|
||||||
// opBlobHash implements the BLOBHASH opcode
|
// opBlobHash implements the BLOBHASH opcode
|
||||||
func opBlobHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opBlobHash(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
index := scope.Stack.peek()
|
index := scope.Stack.peek()
|
||||||
if index.LtUint64(uint64(len(interpreter.evm.TxContext.BlobHashes))) {
|
if index.LtUint64(uint64(len(evm.TxContext.BlobHashes))) {
|
||||||
blobHash := interpreter.evm.TxContext.BlobHashes[index.Uint64()]
|
blobHash := evm.TxContext.BlobHashes[index.Uint64()]
|
||||||
index.SetBytes32(blobHash[:])
|
index.SetBytes32(blobHash[:])
|
||||||
} else {
|
} else {
|
||||||
index.Clear()
|
index.Clear()
|
||||||
|
|
@ -288,14 +288,14 @@ func opBlobHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([
|
||||||
}
|
}
|
||||||
|
|
||||||
// opBlobBaseFee implements BLOBBASEFEE opcode
|
// opBlobBaseFee implements BLOBBASEFEE opcode
|
||||||
func opBlobBaseFee(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opBlobBaseFee(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
blobBaseFee, _ := uint256.FromBig(interpreter.evm.Context.BlobBaseFee)
|
blobBaseFee, _ := uint256.FromBig(evm.Context.BlobBaseFee)
|
||||||
scope.Stack.push(blobBaseFee)
|
scope.Stack.push(blobBaseFee)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// opCLZ implements the CLZ opcode (count leading zero bytes)
|
// opCLZ implements the CLZ opcode (count leading zero bytes)
|
||||||
func opCLZ(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opCLZ(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x := scope.Stack.peek()
|
x := scope.Stack.peek()
|
||||||
x.SetUint64(256 - uint64(x.BitLen()))
|
x.SetUint64(256 - uint64(x.BitLen()))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
@ -342,7 +342,7 @@ func enable6780(jt *JumpTable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func opExtCodeCopyEIP4762(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opExtCodeCopyEIP4762(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
stack = scope.Stack
|
stack = scope.Stack
|
||||||
a = stack.pop()
|
a = stack.pop()
|
||||||
|
|
@ -355,10 +355,10 @@ func opExtCodeCopyEIP4762(pc *uint64, interpreter *EVMInterpreter, scope *ScopeC
|
||||||
uint64CodeOffset = math.MaxUint64
|
uint64CodeOffset = math.MaxUint64
|
||||||
}
|
}
|
||||||
addr := common.Address(a.Bytes20())
|
addr := common.Address(a.Bytes20())
|
||||||
code := interpreter.evm.StateDB.GetCode(addr)
|
code := evm.StateDB.GetCode(addr)
|
||||||
paddedCodeCopy, copyOffset, nonPaddedCopyLength := getDataAndAdjustedBounds(code, uint64CodeOffset, length.Uint64())
|
paddedCodeCopy, copyOffset, nonPaddedCopyLength := getDataAndAdjustedBounds(code, uint64CodeOffset, length.Uint64())
|
||||||
consumed, wanted := interpreter.evm.AccessEvents.CodeChunksRangeGas(addr, copyOffset, nonPaddedCopyLength, uint64(len(code)), false, scope.Contract.Gas)
|
consumed, wanted := evm.AccessEvents.CodeChunksRangeGas(addr, copyOffset, nonPaddedCopyLength, uint64(len(code)), false, scope.Contract.Gas)
|
||||||
scope.Contract.UseGas(consumed, interpreter.evm.Config.Tracer, tracing.GasChangeUnspecified)
|
scope.Contract.UseGas(consumed, evm.Config.Tracer, tracing.GasChangeUnspecified)
|
||||||
if consumed < wanted {
|
if consumed < wanted {
|
||||||
return nil, ErrOutOfGas
|
return nil, ErrOutOfGas
|
||||||
}
|
}
|
||||||
|
|
@ -370,7 +370,7 @@ func opExtCodeCopyEIP4762(pc *uint64, interpreter *EVMInterpreter, scope *ScopeC
|
||||||
// opPush1EIP4762 handles the special case of PUSH1 opcode for EIP-4762, which
|
// opPush1EIP4762 handles the special case of PUSH1 opcode for EIP-4762, which
|
||||||
// need not worry about the adjusted bound logic when adding the PUSHDATA to
|
// need not worry about the adjusted bound logic when adding the PUSHDATA to
|
||||||
// the list of access events.
|
// the list of access events.
|
||||||
func opPush1EIP4762(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opPush1EIP4762(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
codeLen = uint64(len(scope.Contract.Code))
|
codeLen = uint64(len(scope.Contract.Code))
|
||||||
integer = new(uint256.Int)
|
integer = new(uint256.Int)
|
||||||
|
|
@ -383,8 +383,8 @@ func opPush1EIP4762(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext
|
||||||
// touch next chunk if PUSH1 is at the boundary. if so, *pc has
|
// touch next chunk if PUSH1 is at the boundary. if so, *pc has
|
||||||
// advanced past this boundary.
|
// advanced past this boundary.
|
||||||
contractAddr := scope.Contract.Address()
|
contractAddr := scope.Contract.Address()
|
||||||
consumed, wanted := interpreter.evm.AccessEvents.CodeChunksRangeGas(contractAddr, *pc+1, uint64(1), uint64(len(scope.Contract.Code)), false, scope.Contract.Gas)
|
consumed, wanted := evm.AccessEvents.CodeChunksRangeGas(contractAddr, *pc+1, uint64(1), uint64(len(scope.Contract.Code)), false, scope.Contract.Gas)
|
||||||
scope.Contract.UseGas(wanted, interpreter.evm.Config.Tracer, tracing.GasChangeUnspecified)
|
scope.Contract.UseGas(wanted, evm.Config.Tracer, tracing.GasChangeUnspecified)
|
||||||
if consumed < wanted {
|
if consumed < wanted {
|
||||||
return nil, ErrOutOfGas
|
return nil, ErrOutOfGas
|
||||||
}
|
}
|
||||||
|
|
@ -396,7 +396,7 @@ func opPush1EIP4762(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext
|
||||||
}
|
}
|
||||||
|
|
||||||
func makePushEIP4762(size uint64, pushByteSize int) executionFunc {
|
func makePushEIP4762(size uint64, pushByteSize int) executionFunc {
|
||||||
return func(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
return func(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
codeLen = len(scope.Contract.Code)
|
codeLen = len(scope.Contract.Code)
|
||||||
start = min(codeLen, int(*pc+1))
|
start = min(codeLen, int(*pc+1))
|
||||||
|
|
@ -411,8 +411,8 @@ func makePushEIP4762(size uint64, pushByteSize int) executionFunc {
|
||||||
|
|
||||||
if !scope.Contract.IsDeployment && !scope.Contract.IsSystemCall {
|
if !scope.Contract.IsDeployment && !scope.Contract.IsSystemCall {
|
||||||
contractAddr := scope.Contract.Address()
|
contractAddr := scope.Contract.Address()
|
||||||
consumed, wanted := interpreter.evm.AccessEvents.CodeChunksRangeGas(contractAddr, uint64(start), uint64(pushByteSize), uint64(len(scope.Contract.Code)), false, scope.Contract.Gas)
|
consumed, wanted := evm.AccessEvents.CodeChunksRangeGas(contractAddr, uint64(start), uint64(pushByteSize), uint64(len(scope.Contract.Code)), false, scope.Contract.Gas)
|
||||||
scope.Contract.UseGas(consumed, interpreter.evm.Config.Tracer, tracing.GasChangeUnspecified)
|
scope.Contract.UseGas(consumed, evm.Config.Tracer, tracing.GasChangeUnspecified)
|
||||||
if consumed < wanted {
|
if consumed < wanted {
|
||||||
return nil, ErrOutOfGas
|
return nil, ErrOutOfGas
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core/tracing"
|
"github.com/ethereum/go-ethereum/core/tracing"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
)
|
)
|
||||||
|
|
@ -95,6 +96,9 @@ type EVM struct {
|
||||||
// StateDB gives access to the underlying state
|
// StateDB gives access to the underlying state
|
||||||
StateDB StateDB
|
StateDB StateDB
|
||||||
|
|
||||||
|
// table holds the opcode specific handlers
|
||||||
|
table *JumpTable
|
||||||
|
|
||||||
// depth is the current call stack
|
// depth is the current call stack
|
||||||
depth int
|
depth int
|
||||||
|
|
||||||
|
|
@ -107,10 +111,6 @@ type EVM struct {
|
||||||
// virtual machine configuration options used to initialise the evm
|
// virtual machine configuration options used to initialise the evm
|
||||||
Config Config
|
Config Config
|
||||||
|
|
||||||
// global (to this context) ethereum virtual machine used throughout
|
|
||||||
// the execution of the tx
|
|
||||||
interpreter *EVMInterpreter
|
|
||||||
|
|
||||||
// abort is used to abort the EVM calling operations
|
// abort is used to abort the EVM calling operations
|
||||||
abort atomic.Bool
|
abort atomic.Bool
|
||||||
|
|
||||||
|
|
@ -124,6 +124,12 @@ type EVM struct {
|
||||||
|
|
||||||
// jumpDests stores results of JUMPDEST analysis.
|
// jumpDests stores results of JUMPDEST analysis.
|
||||||
jumpDests JumpDestCache
|
jumpDests JumpDestCache
|
||||||
|
|
||||||
|
hasher crypto.KeccakState // Keccak256 hasher instance shared across opcodes
|
||||||
|
hasherBuf common.Hash // Keccak256 hasher result array shared across opcodes
|
||||||
|
|
||||||
|
readOnly bool // Whether to throw on stateful modifications
|
||||||
|
returnData []byte // Last CALL's return data for subsequent reuse
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewEVM constructs an EVM instance with the supplied block context, state
|
// NewEVM constructs an EVM instance with the supplied block context, state
|
||||||
|
|
@ -138,9 +144,57 @@ func NewEVM(blockCtx BlockContext, statedb StateDB, chainConfig *params.ChainCon
|
||||||
chainConfig: chainConfig,
|
chainConfig: chainConfig,
|
||||||
chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time),
|
chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time),
|
||||||
jumpDests: newMapJumpDests(),
|
jumpDests: newMapJumpDests(),
|
||||||
|
hasher: crypto.NewKeccakState(),
|
||||||
}
|
}
|
||||||
evm.precompiles = activePrecompiledContracts(evm.chainRules)
|
evm.precompiles = activePrecompiledContracts(evm.chainRules)
|
||||||
evm.interpreter = NewEVMInterpreter(evm)
|
|
||||||
|
switch {
|
||||||
|
case evm.chainRules.IsOsaka:
|
||||||
|
evm.table = &osakaInstructionSet
|
||||||
|
case evm.chainRules.IsVerkle:
|
||||||
|
// TODO replace with proper instruction set when fork is specified
|
||||||
|
evm.table = &verkleInstructionSet
|
||||||
|
case evm.chainRules.IsPrague:
|
||||||
|
evm.table = &pragueInstructionSet
|
||||||
|
case evm.chainRules.IsCancun:
|
||||||
|
evm.table = &cancunInstructionSet
|
||||||
|
case evm.chainRules.IsShanghai:
|
||||||
|
evm.table = &shanghaiInstructionSet
|
||||||
|
case evm.chainRules.IsMerge:
|
||||||
|
evm.table = &mergeInstructionSet
|
||||||
|
case evm.chainRules.IsLondon:
|
||||||
|
evm.table = &londonInstructionSet
|
||||||
|
case evm.chainRules.IsBerlin:
|
||||||
|
evm.table = &berlinInstructionSet
|
||||||
|
case evm.chainRules.IsIstanbul:
|
||||||
|
evm.table = &istanbulInstructionSet
|
||||||
|
case evm.chainRules.IsConstantinople:
|
||||||
|
evm.table = &constantinopleInstructionSet
|
||||||
|
case evm.chainRules.IsByzantium:
|
||||||
|
evm.table = &byzantiumInstructionSet
|
||||||
|
case evm.chainRules.IsEIP158:
|
||||||
|
evm.table = &spuriousDragonInstructionSet
|
||||||
|
case evm.chainRules.IsEIP150:
|
||||||
|
evm.table = &tangerineWhistleInstructionSet
|
||||||
|
case evm.chainRules.IsHomestead:
|
||||||
|
evm.table = &homesteadInstructionSet
|
||||||
|
default:
|
||||||
|
evm.table = &frontierInstructionSet
|
||||||
|
}
|
||||||
|
var extraEips []int
|
||||||
|
if len(evm.Config.ExtraEips) > 0 {
|
||||||
|
// Deep-copy jumptable to prevent modification of opcodes in other tables
|
||||||
|
evm.table = copyJumpTable(evm.table)
|
||||||
|
}
|
||||||
|
for _, eip := range evm.Config.ExtraEips {
|
||||||
|
if err := EnableEIP(eip, evm.table); err != nil {
|
||||||
|
// Disable it, so caller can check if it's activated or not
|
||||||
|
log.Error("EIP activation failed", "eip", eip, "error", err)
|
||||||
|
} else {
|
||||||
|
extraEips = append(extraEips, eip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
evm.Config.ExtraEips = extraEips
|
||||||
return evm
|
return evm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,11 +230,6 @@ func (evm *EVM) Cancelled() bool {
|
||||||
return evm.abort.Load()
|
return evm.abort.Load()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interpreter returns the current interpreter
|
|
||||||
func (evm *EVM) Interpreter() *EVMInterpreter {
|
|
||||||
return evm.interpreter
|
|
||||||
}
|
|
||||||
|
|
||||||
func isSystemCall(caller common.Address) bool {
|
func isSystemCall(caller common.Address) bool {
|
||||||
return caller == params.SystemAddress
|
return caller == params.SystemAddress
|
||||||
}
|
}
|
||||||
|
|
@ -245,7 +294,7 @@ func (evm *EVM) Call(caller common.Address, addr common.Address, input []byte, g
|
||||||
contract := NewContract(caller, addr, value, gas, evm.jumpDests)
|
contract := NewContract(caller, addr, value, gas, evm.jumpDests)
|
||||||
contract.IsSystemCall = isSystemCall(caller)
|
contract.IsSystemCall = isSystemCall(caller)
|
||||||
contract.SetCallCode(evm.resolveCodeHash(addr), code)
|
contract.SetCallCode(evm.resolveCodeHash(addr), code)
|
||||||
ret, err = evm.interpreter.Run(contract, input, false)
|
ret, err = evm.Run(contract, input, false)
|
||||||
gas = contract.Gas
|
gas = contract.Gas
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -304,7 +353,7 @@ func (evm *EVM) CallCode(caller common.Address, addr common.Address, input []byt
|
||||||
// The contract is a scoped environment for this execution context only.
|
// The contract is a scoped environment for this execution context only.
|
||||||
contract := NewContract(caller, caller, value, gas, evm.jumpDests)
|
contract := NewContract(caller, caller, value, gas, evm.jumpDests)
|
||||||
contract.SetCallCode(evm.resolveCodeHash(addr), evm.resolveCode(addr))
|
contract.SetCallCode(evm.resolveCodeHash(addr), evm.resolveCode(addr))
|
||||||
ret, err = evm.interpreter.Run(contract, input, false)
|
ret, err = evm.Run(contract, input, false)
|
||||||
gas = contract.Gas
|
gas = contract.Gas
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -348,7 +397,7 @@ func (evm *EVM) DelegateCall(originCaller common.Address, caller common.Address,
|
||||||
// Note: The value refers to the original value from the parent call.
|
// Note: The value refers to the original value from the parent call.
|
||||||
contract := NewContract(originCaller, caller, value, gas, evm.jumpDests)
|
contract := NewContract(originCaller, caller, value, gas, evm.jumpDests)
|
||||||
contract.SetCallCode(evm.resolveCodeHash(addr), evm.resolveCode(addr))
|
contract.SetCallCode(evm.resolveCodeHash(addr), evm.resolveCode(addr))
|
||||||
ret, err = evm.interpreter.Run(contract, input, false)
|
ret, err = evm.Run(contract, input, false)
|
||||||
gas = contract.Gas
|
gas = contract.Gas
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -403,7 +452,7 @@ func (evm *EVM) StaticCall(caller common.Address, addr common.Address, input []b
|
||||||
// When an error was returned by the EVM or when setting the creation code
|
// When an error was returned by the EVM or when setting the creation code
|
||||||
// above we revert to the snapshot and consume any gas remaining. Additionally
|
// above we revert to the snapshot and consume any gas remaining. Additionally
|
||||||
// when we're in Homestead this also counts for code storage gas errors.
|
// when we're in Homestead this also counts for code storage gas errors.
|
||||||
ret, err = evm.interpreter.Run(contract, input, true)
|
ret, err = evm.Run(contract, input, true)
|
||||||
gas = contract.Gas
|
gas = contract.Gas
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -524,7 +573,7 @@ func (evm *EVM) create(caller common.Address, code []byte, gas uint64, value *ui
|
||||||
// initNewContract runs a new contract's creation code, performs checks on the
|
// initNewContract runs a new contract's creation code, performs checks on the
|
||||||
// resulting code that is to be deployed, and consumes necessary gas.
|
// resulting code that is to be deployed, and consumes necessary gas.
|
||||||
func (evm *EVM) initNewContract(contract *Contract, address common.Address) ([]byte, error) {
|
func (evm *EVM) initNewContract(contract *Contract, address common.Address) ([]byte, error) {
|
||||||
ret, err := evm.interpreter.Run(contract, nil, false)
|
ret, err := evm.Run(contract, nil, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ret, err
|
return ret, err
|
||||||
}
|
}
|
||||||
|
|
@ -567,7 +616,7 @@ func (evm *EVM) Create(caller common.Address, code []byte, gas uint64, value *ui
|
||||||
// The different between Create2 with Create is Create2 uses keccak256(0xff ++ msg.sender ++ salt ++ keccak256(init_code))[12:]
|
// The different between Create2 with Create is Create2 uses keccak256(0xff ++ msg.sender ++ salt ++ keccak256(init_code))[12:]
|
||||||
// instead of the usual sender-and-nonce-hash as the address where the contract is initialized at.
|
// instead of the usual sender-and-nonce-hash as the address where the contract is initialized at.
|
||||||
func (evm *EVM) Create2(caller common.Address, code []byte, gas uint64, endowment *uint256.Int, salt *uint256.Int) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error) {
|
func (evm *EVM) Create2(caller common.Address, code []byte, gas uint64, endowment *uint256.Int, salt *uint256.Int) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error) {
|
||||||
inithash := crypto.HashData(evm.interpreter.hasher, code)
|
inithash := crypto.HashData(evm.hasher, code)
|
||||||
contractAddr = crypto.CreateAddress2(caller, salt.Bytes32(), inithash[:])
|
contractAddr = crypto.CreateAddress2(caller, salt.Bytes32(), inithash[:])
|
||||||
return evm.create(caller, code, gas, endowment, contractAddr, CREATE2)
|
return evm.create(caller, code, gas, endowment, contractAddr, CREATE2)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,67 +26,67 @@ import (
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
)
|
)
|
||||||
|
|
||||||
func opAdd(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opAdd(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y := scope.Stack.pop(), scope.Stack.peek()
|
x, y := scope.Stack.pop(), scope.Stack.peek()
|
||||||
y.Add(&x, y)
|
y.Add(&x, y)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSub(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSub(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y := scope.Stack.pop(), scope.Stack.peek()
|
x, y := scope.Stack.pop(), scope.Stack.peek()
|
||||||
y.Sub(&x, y)
|
y.Sub(&x, y)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opMul(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opMul(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y := scope.Stack.pop(), scope.Stack.peek()
|
x, y := scope.Stack.pop(), scope.Stack.peek()
|
||||||
y.Mul(&x, y)
|
y.Mul(&x, y)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opDiv(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opDiv(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y := scope.Stack.pop(), scope.Stack.peek()
|
x, y := scope.Stack.pop(), scope.Stack.peek()
|
||||||
y.Div(&x, y)
|
y.Div(&x, y)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSdiv(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSdiv(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y := scope.Stack.pop(), scope.Stack.peek()
|
x, y := scope.Stack.pop(), scope.Stack.peek()
|
||||||
y.SDiv(&x, y)
|
y.SDiv(&x, y)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opMod(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opMod(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y := scope.Stack.pop(), scope.Stack.peek()
|
x, y := scope.Stack.pop(), scope.Stack.peek()
|
||||||
y.Mod(&x, y)
|
y.Mod(&x, y)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSmod(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSmod(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y := scope.Stack.pop(), scope.Stack.peek()
|
x, y := scope.Stack.pop(), scope.Stack.peek()
|
||||||
y.SMod(&x, y)
|
y.SMod(&x, y)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opExp(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opExp(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
base, exponent := scope.Stack.pop(), scope.Stack.peek()
|
base, exponent := scope.Stack.pop(), scope.Stack.peek()
|
||||||
exponent.Exp(&base, exponent)
|
exponent.Exp(&base, exponent)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSignExtend(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSignExtend(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
back, num := scope.Stack.pop(), scope.Stack.peek()
|
back, num := scope.Stack.pop(), scope.Stack.peek()
|
||||||
num.ExtendSign(num, &back)
|
num.ExtendSign(num, &back)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opNot(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opNot(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x := scope.Stack.peek()
|
x := scope.Stack.peek()
|
||||||
x.Not(x)
|
x.Not(x)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opLt(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opLt(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y := scope.Stack.pop(), scope.Stack.peek()
|
x, y := scope.Stack.pop(), scope.Stack.peek()
|
||||||
if x.Lt(y) {
|
if x.Lt(y) {
|
||||||
y.SetOne()
|
y.SetOne()
|
||||||
|
|
@ -96,7 +96,7 @@ func opLt(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte,
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opGt(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opGt(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y := scope.Stack.pop(), scope.Stack.peek()
|
x, y := scope.Stack.pop(), scope.Stack.peek()
|
||||||
if x.Gt(y) {
|
if x.Gt(y) {
|
||||||
y.SetOne()
|
y.SetOne()
|
||||||
|
|
@ -106,7 +106,7 @@ func opGt(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte,
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSlt(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSlt(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y := scope.Stack.pop(), scope.Stack.peek()
|
x, y := scope.Stack.pop(), scope.Stack.peek()
|
||||||
if x.Slt(y) {
|
if x.Slt(y) {
|
||||||
y.SetOne()
|
y.SetOne()
|
||||||
|
|
@ -116,7 +116,7 @@ func opSlt(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSgt(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSgt(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y := scope.Stack.pop(), scope.Stack.peek()
|
x, y := scope.Stack.pop(), scope.Stack.peek()
|
||||||
if x.Sgt(y) {
|
if x.Sgt(y) {
|
||||||
y.SetOne()
|
y.SetOne()
|
||||||
|
|
@ -126,7 +126,7 @@ func opSgt(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opEq(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opEq(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y := scope.Stack.pop(), scope.Stack.peek()
|
x, y := scope.Stack.pop(), scope.Stack.peek()
|
||||||
if x.Eq(y) {
|
if x.Eq(y) {
|
||||||
y.SetOne()
|
y.SetOne()
|
||||||
|
|
@ -136,7 +136,7 @@ func opEq(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte,
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opIszero(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opIszero(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x := scope.Stack.peek()
|
x := scope.Stack.peek()
|
||||||
if x.IsZero() {
|
if x.IsZero() {
|
||||||
x.SetOne()
|
x.SetOne()
|
||||||
|
|
@ -146,37 +146,37 @@ func opIszero(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]b
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opAnd(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opAnd(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y := scope.Stack.pop(), scope.Stack.peek()
|
x, y := scope.Stack.pop(), scope.Stack.peek()
|
||||||
y.And(&x, y)
|
y.And(&x, y)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opOr(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opOr(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y := scope.Stack.pop(), scope.Stack.peek()
|
x, y := scope.Stack.pop(), scope.Stack.peek()
|
||||||
y.Or(&x, y)
|
y.Or(&x, y)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opXor(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opXor(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y := scope.Stack.pop(), scope.Stack.peek()
|
x, y := scope.Stack.pop(), scope.Stack.peek()
|
||||||
y.Xor(&x, y)
|
y.Xor(&x, y)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opByte(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opByte(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
th, val := scope.Stack.pop(), scope.Stack.peek()
|
th, val := scope.Stack.pop(), scope.Stack.peek()
|
||||||
val.Byte(&th)
|
val.Byte(&th)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opAddmod(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opAddmod(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y, z := scope.Stack.pop(), scope.Stack.pop(), scope.Stack.peek()
|
x, y, z := scope.Stack.pop(), scope.Stack.pop(), scope.Stack.peek()
|
||||||
z.AddMod(&x, &y, z)
|
z.AddMod(&x, &y, z)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opMulmod(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opMulmod(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x, y, z := scope.Stack.pop(), scope.Stack.pop(), scope.Stack.peek()
|
x, y, z := scope.Stack.pop(), scope.Stack.pop(), scope.Stack.peek()
|
||||||
z.MulMod(&x, &y, z)
|
z.MulMod(&x, &y, z)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
@ -185,7 +185,7 @@ func opMulmod(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]b
|
||||||
// opSHL implements Shift Left
|
// opSHL implements Shift Left
|
||||||
// The SHL instruction (shift left) pops 2 values from the stack, first arg1 and then arg2,
|
// The SHL instruction (shift left) pops 2 values from the stack, first arg1 and then arg2,
|
||||||
// and pushes on the stack arg2 shifted to the left by arg1 number of bits.
|
// and pushes on the stack arg2 shifted to the left by arg1 number of bits.
|
||||||
func opSHL(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSHL(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
// Note, second operand is left in the stack; accumulate result into it, and no need to push it afterwards
|
// Note, second operand is left in the stack; accumulate result into it, and no need to push it afterwards
|
||||||
shift, value := scope.Stack.pop(), scope.Stack.peek()
|
shift, value := scope.Stack.pop(), scope.Stack.peek()
|
||||||
if shift.LtUint64(256) {
|
if shift.LtUint64(256) {
|
||||||
|
|
@ -199,7 +199,7 @@ func opSHL(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte
|
||||||
// opSHR implements Logical Shift Right
|
// opSHR implements Logical Shift Right
|
||||||
// The SHR instruction (logical shift right) pops 2 values from the stack, first arg1 and then arg2,
|
// The SHR instruction (logical shift right) pops 2 values from the stack, first arg1 and then arg2,
|
||||||
// and pushes on the stack arg2 shifted to the right by arg1 number of bits with zero fill.
|
// and pushes on the stack arg2 shifted to the right by arg1 number of bits with zero fill.
|
||||||
func opSHR(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSHR(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
// Note, second operand is left in the stack; accumulate result into it, and no need to push it afterwards
|
// Note, second operand is left in the stack; accumulate result into it, and no need to push it afterwards
|
||||||
shift, value := scope.Stack.pop(), scope.Stack.peek()
|
shift, value := scope.Stack.pop(), scope.Stack.peek()
|
||||||
if shift.LtUint64(256) {
|
if shift.LtUint64(256) {
|
||||||
|
|
@ -213,7 +213,7 @@ func opSHR(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte
|
||||||
// opSAR implements Arithmetic Shift Right
|
// opSAR implements Arithmetic Shift Right
|
||||||
// The SAR instruction (arithmetic shift right) pops 2 values from the stack, first arg1 and then arg2,
|
// The SAR instruction (arithmetic shift right) pops 2 values from the stack, first arg1 and then arg2,
|
||||||
// and pushes on the stack arg2 shifted to the right by arg1 number of bits with sign extension.
|
// and pushes on the stack arg2 shifted to the right by arg1 number of bits with sign extension.
|
||||||
func opSAR(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSAR(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
shift, value := scope.Stack.pop(), scope.Stack.peek()
|
shift, value := scope.Stack.pop(), scope.Stack.peek()
|
||||||
if shift.GtUint64(256) {
|
if shift.GtUint64(256) {
|
||||||
if value.Sign() >= 0 {
|
if value.Sign() >= 0 {
|
||||||
|
|
@ -229,50 +229,49 @@ func opSAR(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opKeccak256(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opKeccak256(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
offset, size := scope.Stack.pop(), scope.Stack.peek()
|
offset, size := scope.Stack.pop(), scope.Stack.peek()
|
||||||
data := scope.Memory.GetPtr(offset.Uint64(), size.Uint64())
|
data := scope.Memory.GetPtr(offset.Uint64(), size.Uint64())
|
||||||
|
|
||||||
interpreter.hasher.Reset()
|
evm.hasher.Reset()
|
||||||
interpreter.hasher.Write(data)
|
evm.hasher.Write(data)
|
||||||
interpreter.hasher.Read(interpreter.hasherBuf[:])
|
evm.hasher.Read(evm.hasherBuf[:])
|
||||||
|
|
||||||
evm := interpreter.evm
|
|
||||||
if evm.Config.EnablePreimageRecording {
|
if evm.Config.EnablePreimageRecording {
|
||||||
evm.StateDB.AddPreimage(interpreter.hasherBuf, data)
|
evm.StateDB.AddPreimage(evm.hasherBuf, data)
|
||||||
}
|
}
|
||||||
size.SetBytes(interpreter.hasherBuf[:])
|
size.SetBytes(evm.hasherBuf[:])
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opAddress(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opAddress(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.push(new(uint256.Int).SetBytes(scope.Contract.Address().Bytes()))
|
scope.Stack.push(new(uint256.Int).SetBytes(scope.Contract.Address().Bytes()))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opBalance(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opBalance(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
slot := scope.Stack.peek()
|
slot := scope.Stack.peek()
|
||||||
address := common.Address(slot.Bytes20())
|
address := common.Address(slot.Bytes20())
|
||||||
slot.Set(interpreter.evm.StateDB.GetBalance(address))
|
slot.Set(evm.StateDB.GetBalance(address))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opOrigin(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opOrigin(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.push(new(uint256.Int).SetBytes(interpreter.evm.Origin.Bytes()))
|
scope.Stack.push(new(uint256.Int).SetBytes(evm.Origin.Bytes()))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opCaller(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opCaller(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.push(new(uint256.Int).SetBytes(scope.Contract.Caller().Bytes()))
|
scope.Stack.push(new(uint256.Int).SetBytes(scope.Contract.Caller().Bytes()))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opCallValue(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opCallValue(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.push(scope.Contract.value)
|
scope.Stack.push(scope.Contract.value)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opCallDataLoad(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opCallDataLoad(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
x := scope.Stack.peek()
|
x := scope.Stack.peek()
|
||||||
if offset, overflow := x.Uint64WithOverflow(); !overflow {
|
if offset, overflow := x.Uint64WithOverflow(); !overflow {
|
||||||
data := getData(scope.Contract.Input, offset, 32)
|
data := getData(scope.Contract.Input, offset, 32)
|
||||||
|
|
@ -283,12 +282,12 @@ func opCallDataLoad(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opCallDataSize(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opCallDataSize(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.push(new(uint256.Int).SetUint64(uint64(len(scope.Contract.Input))))
|
scope.Stack.push(new(uint256.Int).SetUint64(uint64(len(scope.Contract.Input))))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opCallDataCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opCallDataCopy(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
memOffset = scope.Stack.pop()
|
memOffset = scope.Stack.pop()
|
||||||
dataOffset = scope.Stack.pop()
|
dataOffset = scope.Stack.pop()
|
||||||
|
|
@ -306,12 +305,12 @@ func opCallDataCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opReturnDataSize(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opReturnDataSize(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.push(new(uint256.Int).SetUint64(uint64(len(interpreter.returnData))))
|
scope.Stack.push(new(uint256.Int).SetUint64(uint64(len(evm.returnData))))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opReturnDataCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opReturnDataCopy(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
memOffset = scope.Stack.pop()
|
memOffset = scope.Stack.pop()
|
||||||
dataOffset = scope.Stack.pop()
|
dataOffset = scope.Stack.pop()
|
||||||
|
|
@ -326,25 +325,25 @@ func opReturnDataCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeConte
|
||||||
var end = dataOffset
|
var end = dataOffset
|
||||||
end.Add(&dataOffset, &length)
|
end.Add(&dataOffset, &length)
|
||||||
end64, overflow := end.Uint64WithOverflow()
|
end64, overflow := end.Uint64WithOverflow()
|
||||||
if overflow || uint64(len(interpreter.returnData)) < end64 {
|
if overflow || uint64(len(evm.returnData)) < end64 {
|
||||||
return nil, ErrReturnDataOutOfBounds
|
return nil, ErrReturnDataOutOfBounds
|
||||||
}
|
}
|
||||||
scope.Memory.Set(memOffset.Uint64(), length.Uint64(), interpreter.returnData[offset64:end64])
|
scope.Memory.Set(memOffset.Uint64(), length.Uint64(), evm.returnData[offset64:end64])
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opExtCodeSize(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opExtCodeSize(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
slot := scope.Stack.peek()
|
slot := scope.Stack.peek()
|
||||||
slot.SetUint64(uint64(interpreter.evm.StateDB.GetCodeSize(slot.Bytes20())))
|
slot.SetUint64(uint64(evm.StateDB.GetCodeSize(slot.Bytes20())))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opCodeSize(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opCodeSize(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.push(new(uint256.Int).SetUint64(uint64(len(scope.Contract.Code))))
|
scope.Stack.push(new(uint256.Int).SetUint64(uint64(len(scope.Contract.Code))))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opCodeCopy(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
memOffset = scope.Stack.pop()
|
memOffset = scope.Stack.pop()
|
||||||
codeOffset = scope.Stack.pop()
|
codeOffset = scope.Stack.pop()
|
||||||
|
|
@ -360,7 +359,7 @@ func opCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opExtCodeCopy(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
stack = scope.Stack
|
stack = scope.Stack
|
||||||
a = stack.pop()
|
a = stack.pop()
|
||||||
|
|
@ -373,7 +372,7 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
|
||||||
uint64CodeOffset = math.MaxUint64
|
uint64CodeOffset = math.MaxUint64
|
||||||
}
|
}
|
||||||
addr := common.Address(a.Bytes20())
|
addr := common.Address(a.Bytes20())
|
||||||
code := interpreter.evm.StateDB.GetCode(addr)
|
code := evm.StateDB.GetCode(addr)
|
||||||
codeCopy := getData(code, uint64CodeOffset, length.Uint64())
|
codeCopy := getData(code, uint64CodeOffset, length.Uint64())
|
||||||
scope.Memory.Set(memOffset.Uint64(), length.Uint64(), codeCopy)
|
scope.Memory.Set(memOffset.Uint64(), length.Uint64(), codeCopy)
|
||||||
|
|
||||||
|
|
@ -406,24 +405,24 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
|
||||||
//
|
//
|
||||||
// 6. Caller tries to get the code hash for an account which is marked as deleted, this
|
// 6. Caller tries to get the code hash for an account which is marked as deleted, this
|
||||||
// account should be regarded as a non-existent account and zero should be returned.
|
// account should be regarded as a non-existent account and zero should be returned.
|
||||||
func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opExtCodeHash(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
slot := scope.Stack.peek()
|
slot := scope.Stack.peek()
|
||||||
address := common.Address(slot.Bytes20())
|
address := common.Address(slot.Bytes20())
|
||||||
if interpreter.evm.StateDB.Empty(address) {
|
if evm.StateDB.Empty(address) {
|
||||||
slot.Clear()
|
slot.Clear()
|
||||||
} else {
|
} else {
|
||||||
slot.SetBytes(interpreter.evm.StateDB.GetCodeHash(address).Bytes())
|
slot.SetBytes(evm.StateDB.GetCodeHash(address).Bytes())
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opGasprice(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opGasprice(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
v, _ := uint256.FromBig(interpreter.evm.GasPrice)
|
v, _ := uint256.FromBig(evm.GasPrice)
|
||||||
scope.Stack.push(v)
|
scope.Stack.push(v)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opBlockhash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opBlockhash(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
num := scope.Stack.peek()
|
num := scope.Stack.peek()
|
||||||
num64, overflow := num.Uint64WithOverflow()
|
num64, overflow := num.Uint64WithOverflow()
|
||||||
if overflow {
|
if overflow {
|
||||||
|
|
@ -432,18 +431,18 @@ func opBlockhash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) (
|
||||||
}
|
}
|
||||||
|
|
||||||
var upper, lower uint64
|
var upper, lower uint64
|
||||||
upper = interpreter.evm.Context.BlockNumber.Uint64()
|
upper = evm.Context.BlockNumber.Uint64()
|
||||||
if upper < 257 {
|
if upper < 257 {
|
||||||
lower = 0
|
lower = 0
|
||||||
} else {
|
} else {
|
||||||
lower = upper - 256
|
lower = upper - 256
|
||||||
}
|
}
|
||||||
if num64 >= lower && num64 < upper {
|
if num64 >= lower && num64 < upper {
|
||||||
res := interpreter.evm.Context.GetHash(num64)
|
res := evm.Context.GetHash(num64)
|
||||||
if witness := interpreter.evm.StateDB.Witness(); witness != nil {
|
if witness := evm.StateDB.Witness(); witness != nil {
|
||||||
witness.AddBlockHash(num64)
|
witness.AddBlockHash(num64)
|
||||||
}
|
}
|
||||||
if tracer := interpreter.evm.Config.Tracer; tracer != nil && tracer.OnBlockHashRead != nil {
|
if tracer := evm.Config.Tracer; tracer != nil && tracer.OnBlockHashRead != nil {
|
||||||
tracer.OnBlockHashRead(num64, res)
|
tracer.OnBlockHashRead(num64, res)
|
||||||
}
|
}
|
||||||
num.SetBytes(res[:])
|
num.SetBytes(res[:])
|
||||||
|
|
@ -453,83 +452,83 @@ func opBlockhash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) (
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opCoinbase(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opCoinbase(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.push(new(uint256.Int).SetBytes(interpreter.evm.Context.Coinbase.Bytes()))
|
scope.Stack.push(new(uint256.Int).SetBytes(evm.Context.Coinbase.Bytes()))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opTimestamp(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opTimestamp(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.push(new(uint256.Int).SetUint64(interpreter.evm.Context.Time))
|
scope.Stack.push(new(uint256.Int).SetUint64(evm.Context.Time))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opNumber(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opNumber(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
v, _ := uint256.FromBig(interpreter.evm.Context.BlockNumber)
|
v, _ := uint256.FromBig(evm.Context.BlockNumber)
|
||||||
scope.Stack.push(v)
|
scope.Stack.push(v)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opDifficulty(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opDifficulty(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
v, _ := uint256.FromBig(interpreter.evm.Context.Difficulty)
|
v, _ := uint256.FromBig(evm.Context.Difficulty)
|
||||||
scope.Stack.push(v)
|
scope.Stack.push(v)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opRandom(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opRandom(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
v := new(uint256.Int).SetBytes(interpreter.evm.Context.Random.Bytes())
|
v := new(uint256.Int).SetBytes(evm.Context.Random.Bytes())
|
||||||
scope.Stack.push(v)
|
scope.Stack.push(v)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opGasLimit(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opGasLimit(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.push(new(uint256.Int).SetUint64(interpreter.evm.Context.GasLimit))
|
scope.Stack.push(new(uint256.Int).SetUint64(evm.Context.GasLimit))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opPop(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opPop(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.pop()
|
scope.Stack.pop()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opMload(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opMload(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
v := scope.Stack.peek()
|
v := scope.Stack.peek()
|
||||||
offset := v.Uint64()
|
offset := v.Uint64()
|
||||||
v.SetBytes(scope.Memory.GetPtr(offset, 32))
|
v.SetBytes(scope.Memory.GetPtr(offset, 32))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opMstore(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opMstore(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
mStart, val := scope.Stack.pop(), scope.Stack.pop()
|
mStart, val := scope.Stack.pop(), scope.Stack.pop()
|
||||||
scope.Memory.Set32(mStart.Uint64(), &val)
|
scope.Memory.Set32(mStart.Uint64(), &val)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opMstore8(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opMstore8(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
off, val := scope.Stack.pop(), scope.Stack.pop()
|
off, val := scope.Stack.pop(), scope.Stack.pop()
|
||||||
scope.Memory.store[off.Uint64()] = byte(val.Uint64())
|
scope.Memory.store[off.Uint64()] = byte(val.Uint64())
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSload(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSload(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
loc := scope.Stack.peek()
|
loc := scope.Stack.peek()
|
||||||
hash := common.Hash(loc.Bytes32())
|
hash := common.Hash(loc.Bytes32())
|
||||||
val := interpreter.evm.StateDB.GetState(scope.Contract.Address(), hash)
|
val := evm.StateDB.GetState(scope.Contract.Address(), hash)
|
||||||
loc.SetBytes(val.Bytes())
|
loc.SetBytes(val.Bytes())
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSstore(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSstore(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
if interpreter.readOnly {
|
if evm.readOnly {
|
||||||
return nil, ErrWriteProtection
|
return nil, ErrWriteProtection
|
||||||
}
|
}
|
||||||
loc := scope.Stack.pop()
|
loc := scope.Stack.pop()
|
||||||
val := scope.Stack.pop()
|
val := scope.Stack.pop()
|
||||||
interpreter.evm.StateDB.SetState(scope.Contract.Address(), loc.Bytes32(), val.Bytes32())
|
evm.StateDB.SetState(scope.Contract.Address(), loc.Bytes32(), val.Bytes32())
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opJump(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opJump(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
if interpreter.evm.abort.Load() {
|
if evm.abort.Load() {
|
||||||
return nil, errStopToken
|
return nil, errStopToken
|
||||||
}
|
}
|
||||||
pos := scope.Stack.pop()
|
pos := scope.Stack.pop()
|
||||||
|
|
@ -540,8 +539,8 @@ func opJump(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opJumpi(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opJumpi(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
if interpreter.evm.abort.Load() {
|
if evm.abort.Load() {
|
||||||
return nil, errStopToken
|
return nil, errStopToken
|
||||||
}
|
}
|
||||||
pos, cond := scope.Stack.pop(), scope.Stack.pop()
|
pos, cond := scope.Stack.pop(), scope.Stack.pop()
|
||||||
|
|
@ -554,107 +553,107 @@ func opJumpi(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opJumpdest(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opJumpdest(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opPc(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opPc(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.push(new(uint256.Int).SetUint64(*pc))
|
scope.Stack.push(new(uint256.Int).SetUint64(*pc))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opMsize(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opMsize(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.push(new(uint256.Int).SetUint64(uint64(scope.Memory.Len())))
|
scope.Stack.push(new(uint256.Int).SetUint64(uint64(scope.Memory.Len())))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opGas(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opGas(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.push(new(uint256.Int).SetUint64(scope.Contract.Gas))
|
scope.Stack.push(new(uint256.Int).SetUint64(scope.Contract.Gas))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap1(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap1(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap1()
|
scope.Stack.swap1()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap2(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap2(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap2()
|
scope.Stack.swap2()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap3(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap3(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap3()
|
scope.Stack.swap3()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap4(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap4(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap4()
|
scope.Stack.swap4()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap5(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap5(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap5()
|
scope.Stack.swap5()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap6(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap6(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap6()
|
scope.Stack.swap6()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap7(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap7(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap7()
|
scope.Stack.swap7()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap8(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap8(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap8()
|
scope.Stack.swap8()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap9(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap9(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap9()
|
scope.Stack.swap9()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap10(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap10(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap10()
|
scope.Stack.swap10()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap11(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap11(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap11()
|
scope.Stack.swap11()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap12(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap12(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap12()
|
scope.Stack.swap12()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap13(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap13(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap13()
|
scope.Stack.swap13()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap14(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap14(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap14()
|
scope.Stack.swap14()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap15(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap15(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap15()
|
scope.Stack.swap15()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSwap16(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSwap16(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.swap16()
|
scope.Stack.swap16()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opCreate(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opCreate(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
if interpreter.readOnly {
|
if evm.readOnly {
|
||||||
return nil, ErrWriteProtection
|
return nil, ErrWriteProtection
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
|
|
@ -663,21 +662,21 @@ func opCreate(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]b
|
||||||
input = scope.Memory.GetCopy(offset.Uint64(), size.Uint64())
|
input = scope.Memory.GetCopy(offset.Uint64(), size.Uint64())
|
||||||
gas = scope.Contract.Gas
|
gas = scope.Contract.Gas
|
||||||
)
|
)
|
||||||
if interpreter.evm.chainRules.IsEIP150 {
|
if evm.chainRules.IsEIP150 {
|
||||||
gas -= gas / 64
|
gas -= gas / 64
|
||||||
}
|
}
|
||||||
|
|
||||||
// reuse size int for stackvalue
|
// reuse size int for stackvalue
|
||||||
stackvalue := size
|
stackvalue := size
|
||||||
|
|
||||||
scope.Contract.UseGas(gas, interpreter.evm.Config.Tracer, tracing.GasChangeCallContractCreation)
|
scope.Contract.UseGas(gas, evm.Config.Tracer, tracing.GasChangeCallContractCreation)
|
||||||
|
|
||||||
res, addr, returnGas, suberr := interpreter.evm.Create(scope.Contract.Address(), input, gas, &value)
|
res, addr, returnGas, suberr := evm.Create(scope.Contract.Address(), input, gas, &value)
|
||||||
// Push item on the stack based on the returned error. If the ruleset is
|
// Push item on the stack based on the returned error. If the ruleset is
|
||||||
// homestead we must check for CodeStoreOutOfGasError (homestead only
|
// homestead we must check for CodeStoreOutOfGasError (homestead only
|
||||||
// rule) and treat as an error, if the ruleset is frontier we must
|
// rule) and treat as an error, if the ruleset is frontier we must
|
||||||
// ignore this error and pretend the operation was successful.
|
// ignore this error and pretend the operation was successful.
|
||||||
if interpreter.evm.chainRules.IsHomestead && suberr == ErrCodeStoreOutOfGas {
|
if evm.chainRules.IsHomestead && suberr == ErrCodeStoreOutOfGas {
|
||||||
stackvalue.Clear()
|
stackvalue.Clear()
|
||||||
} else if suberr != nil && suberr != ErrCodeStoreOutOfGas {
|
} else if suberr != nil && suberr != ErrCodeStoreOutOfGas {
|
||||||
stackvalue.Clear()
|
stackvalue.Clear()
|
||||||
|
|
@ -686,18 +685,18 @@ func opCreate(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]b
|
||||||
}
|
}
|
||||||
scope.Stack.push(&stackvalue)
|
scope.Stack.push(&stackvalue)
|
||||||
|
|
||||||
scope.Contract.RefundGas(returnGas, interpreter.evm.Config.Tracer, tracing.GasChangeCallLeftOverRefunded)
|
scope.Contract.RefundGas(returnGas, evm.Config.Tracer, tracing.GasChangeCallLeftOverRefunded)
|
||||||
|
|
||||||
if suberr == ErrExecutionReverted {
|
if suberr == ErrExecutionReverted {
|
||||||
interpreter.returnData = res // set REVERT data to return data buffer
|
evm.returnData = res // set REVERT data to return data buffer
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
interpreter.returnData = nil // clear dirty return data buffer
|
evm.returnData = nil // clear dirty return data buffer
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opCreate2(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opCreate2(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
if interpreter.readOnly {
|
if evm.readOnly {
|
||||||
return nil, ErrWriteProtection
|
return nil, ErrWriteProtection
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
|
|
@ -710,10 +709,10 @@ func opCreate2(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]
|
||||||
|
|
||||||
// Apply EIP150
|
// Apply EIP150
|
||||||
gas -= gas / 64
|
gas -= gas / 64
|
||||||
scope.Contract.UseGas(gas, interpreter.evm.Config.Tracer, tracing.GasChangeCallContractCreation2)
|
scope.Contract.UseGas(gas, evm.Config.Tracer, tracing.GasChangeCallContractCreation2)
|
||||||
// reuse size int for stackvalue
|
// reuse size int for stackvalue
|
||||||
stackvalue := size
|
stackvalue := size
|
||||||
res, addr, returnGas, suberr := interpreter.evm.Create2(scope.Contract.Address(), input, gas,
|
res, addr, returnGas, suberr := evm.Create2(scope.Contract.Address(), input, gas,
|
||||||
&endowment, &salt)
|
&endowment, &salt)
|
||||||
// Push item on the stack based on the returned error.
|
// Push item on the stack based on the returned error.
|
||||||
if suberr != nil {
|
if suberr != nil {
|
||||||
|
|
@ -722,35 +721,35 @@ func opCreate2(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]
|
||||||
stackvalue.SetBytes(addr.Bytes())
|
stackvalue.SetBytes(addr.Bytes())
|
||||||
}
|
}
|
||||||
scope.Stack.push(&stackvalue)
|
scope.Stack.push(&stackvalue)
|
||||||
scope.Contract.RefundGas(returnGas, interpreter.evm.Config.Tracer, tracing.GasChangeCallLeftOverRefunded)
|
scope.Contract.RefundGas(returnGas, evm.Config.Tracer, tracing.GasChangeCallLeftOverRefunded)
|
||||||
|
|
||||||
if suberr == ErrExecutionReverted {
|
if suberr == ErrExecutionReverted {
|
||||||
interpreter.returnData = res // set REVERT data to return data buffer
|
evm.returnData = res // set REVERT data to return data buffer
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
interpreter.returnData = nil // clear dirty return data buffer
|
evm.returnData = nil // clear dirty return data buffer
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opCall(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
stack := scope.Stack
|
stack := scope.Stack
|
||||||
// Pop gas. The actual gas in interpreter.evm.callGasTemp.
|
// Pop gas. The actual gas in evm.callGasTemp.
|
||||||
// We can use this as a temporary value
|
// We can use this as a temporary value
|
||||||
temp := stack.pop()
|
temp := stack.pop()
|
||||||
gas := interpreter.evm.callGasTemp
|
gas := evm.callGasTemp
|
||||||
// Pop other call parameters.
|
// Pop other call parameters.
|
||||||
addr, value, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
addr, value, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
||||||
toAddr := common.Address(addr.Bytes20())
|
toAddr := common.Address(addr.Bytes20())
|
||||||
// Get the arguments from the memory.
|
// Get the arguments from the memory.
|
||||||
args := scope.Memory.GetPtr(inOffset.Uint64(), inSize.Uint64())
|
args := scope.Memory.GetPtr(inOffset.Uint64(), inSize.Uint64())
|
||||||
|
|
||||||
if interpreter.readOnly && !value.IsZero() {
|
if evm.readOnly && !value.IsZero() {
|
||||||
return nil, ErrWriteProtection
|
return nil, ErrWriteProtection
|
||||||
}
|
}
|
||||||
if !value.IsZero() {
|
if !value.IsZero() {
|
||||||
gas += params.CallStipend
|
gas += params.CallStipend
|
||||||
}
|
}
|
||||||
ret, returnGas, err := interpreter.evm.Call(scope.Contract.Address(), toAddr, args, gas, &value)
|
ret, returnGas, err := evm.Call(scope.Contract.Address(), toAddr, args, gas, &value)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
temp.Clear()
|
temp.Clear()
|
||||||
|
|
@ -762,18 +761,18 @@ func opCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt
|
||||||
scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
|
scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.Contract.RefundGas(returnGas, interpreter.evm.Config.Tracer, tracing.GasChangeCallLeftOverRefunded)
|
scope.Contract.RefundGas(returnGas, evm.Config.Tracer, tracing.GasChangeCallLeftOverRefunded)
|
||||||
|
|
||||||
interpreter.returnData = ret
|
evm.returnData = ret
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opCallCode(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opCallCode(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
// Pop gas. The actual gas is in interpreter.evm.callGasTemp.
|
// Pop gas. The actual gas is in evm.callGasTemp.
|
||||||
stack := scope.Stack
|
stack := scope.Stack
|
||||||
// We use it as a temporary value
|
// We use it as a temporary value
|
||||||
temp := stack.pop()
|
temp := stack.pop()
|
||||||
gas := interpreter.evm.callGasTemp
|
gas := evm.callGasTemp
|
||||||
// Pop other call parameters.
|
// Pop other call parameters.
|
||||||
addr, value, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
addr, value, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
||||||
toAddr := common.Address(addr.Bytes20())
|
toAddr := common.Address(addr.Bytes20())
|
||||||
|
|
@ -784,7 +783,7 @@ func opCallCode(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([
|
||||||
gas += params.CallStipend
|
gas += params.CallStipend
|
||||||
}
|
}
|
||||||
|
|
||||||
ret, returnGas, err := interpreter.evm.CallCode(scope.Contract.Address(), toAddr, args, gas, &value)
|
ret, returnGas, err := evm.CallCode(scope.Contract.Address(), toAddr, args, gas, &value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
temp.Clear()
|
temp.Clear()
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -795,25 +794,25 @@ func opCallCode(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([
|
||||||
scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
|
scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.Contract.RefundGas(returnGas, interpreter.evm.Config.Tracer, tracing.GasChangeCallLeftOverRefunded)
|
scope.Contract.RefundGas(returnGas, evm.Config.Tracer, tracing.GasChangeCallLeftOverRefunded)
|
||||||
|
|
||||||
interpreter.returnData = ret
|
evm.returnData = ret
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opDelegateCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opDelegateCall(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
stack := scope.Stack
|
stack := scope.Stack
|
||||||
// Pop gas. The actual gas is in interpreter.evm.callGasTemp.
|
// Pop gas. The actual gas is in evm.callGasTemp.
|
||||||
// We use it as a temporary value
|
// We use it as a temporary value
|
||||||
temp := stack.pop()
|
temp := stack.pop()
|
||||||
gas := interpreter.evm.callGasTemp
|
gas := evm.callGasTemp
|
||||||
// Pop other call parameters.
|
// Pop other call parameters.
|
||||||
addr, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
addr, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
||||||
toAddr := common.Address(addr.Bytes20())
|
toAddr := common.Address(addr.Bytes20())
|
||||||
// Get arguments from the memory.
|
// Get arguments from the memory.
|
||||||
args := scope.Memory.GetPtr(inOffset.Uint64(), inSize.Uint64())
|
args := scope.Memory.GetPtr(inOffset.Uint64(), inSize.Uint64())
|
||||||
|
|
||||||
ret, returnGas, err := interpreter.evm.DelegateCall(scope.Contract.Caller(), scope.Contract.Address(), toAddr, args, gas, scope.Contract.value)
|
ret, returnGas, err := evm.DelegateCall(scope.Contract.Caller(), scope.Contract.Address(), toAddr, args, gas, scope.Contract.value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
temp.Clear()
|
temp.Clear()
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -824,25 +823,25 @@ func opDelegateCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext
|
||||||
scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
|
scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.Contract.RefundGas(returnGas, interpreter.evm.Config.Tracer, tracing.GasChangeCallLeftOverRefunded)
|
scope.Contract.RefundGas(returnGas, evm.Config.Tracer, tracing.GasChangeCallLeftOverRefunded)
|
||||||
|
|
||||||
interpreter.returnData = ret
|
evm.returnData = ret
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opStaticCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opStaticCall(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
// Pop gas. The actual gas is in interpreter.evm.callGasTemp.
|
// Pop gas. The actual gas is in evm.callGasTemp.
|
||||||
stack := scope.Stack
|
stack := scope.Stack
|
||||||
// We use it as a temporary value
|
// We use it as a temporary value
|
||||||
temp := stack.pop()
|
temp := stack.pop()
|
||||||
gas := interpreter.evm.callGasTemp
|
gas := evm.callGasTemp
|
||||||
// Pop other call parameters.
|
// Pop other call parameters.
|
||||||
addr, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
addr, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
||||||
toAddr := common.Address(addr.Bytes20())
|
toAddr := common.Address(addr.Bytes20())
|
||||||
// Get arguments from the memory.
|
// Get arguments from the memory.
|
||||||
args := scope.Memory.GetPtr(inOffset.Uint64(), inSize.Uint64())
|
args := scope.Memory.GetPtr(inOffset.Uint64(), inSize.Uint64())
|
||||||
|
|
||||||
ret, returnGas, err := interpreter.evm.StaticCall(scope.Contract.Address(), toAddr, args, gas)
|
ret, returnGas, err := evm.StaticCall(scope.Contract.Address(), toAddr, args, gas)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
temp.Clear()
|
temp.Clear()
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -853,69 +852,69 @@ func opStaticCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
|
||||||
scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
|
scope.Memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.Contract.RefundGas(returnGas, interpreter.evm.Config.Tracer, tracing.GasChangeCallLeftOverRefunded)
|
scope.Contract.RefundGas(returnGas, evm.Config.Tracer, tracing.GasChangeCallLeftOverRefunded)
|
||||||
|
|
||||||
interpreter.returnData = ret
|
evm.returnData = ret
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func opReturn(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opReturn(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
offset, size := scope.Stack.pop(), scope.Stack.pop()
|
offset, size := scope.Stack.pop(), scope.Stack.pop()
|
||||||
ret := scope.Memory.GetCopy(offset.Uint64(), size.Uint64())
|
ret := scope.Memory.GetCopy(offset.Uint64(), size.Uint64())
|
||||||
|
|
||||||
return ret, errStopToken
|
return ret, errStopToken
|
||||||
}
|
}
|
||||||
|
|
||||||
func opRevert(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opRevert(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
offset, size := scope.Stack.pop(), scope.Stack.pop()
|
offset, size := scope.Stack.pop(), scope.Stack.pop()
|
||||||
ret := scope.Memory.GetCopy(offset.Uint64(), size.Uint64())
|
ret := scope.Memory.GetCopy(offset.Uint64(), size.Uint64())
|
||||||
|
|
||||||
interpreter.returnData = ret
|
evm.returnData = ret
|
||||||
return ret, ErrExecutionReverted
|
return ret, ErrExecutionReverted
|
||||||
}
|
}
|
||||||
|
|
||||||
func opUndefined(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opUndefined(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
return nil, &ErrInvalidOpCode{opcode: OpCode(scope.Contract.Code[*pc])}
|
return nil, &ErrInvalidOpCode{opcode: OpCode(scope.Contract.Code[*pc])}
|
||||||
}
|
}
|
||||||
|
|
||||||
func opStop(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opStop(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
return nil, errStopToken
|
return nil, errStopToken
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSelfdestruct(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSelfdestruct(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
if interpreter.readOnly {
|
if evm.readOnly {
|
||||||
return nil, ErrWriteProtection
|
return nil, ErrWriteProtection
|
||||||
}
|
}
|
||||||
beneficiary := scope.Stack.pop()
|
beneficiary := scope.Stack.pop()
|
||||||
balance := interpreter.evm.StateDB.GetBalance(scope.Contract.Address())
|
balance := evm.StateDB.GetBalance(scope.Contract.Address())
|
||||||
interpreter.evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct)
|
evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct)
|
||||||
interpreter.evm.StateDB.SelfDestruct(scope.Contract.Address())
|
evm.StateDB.SelfDestruct(scope.Contract.Address())
|
||||||
if tracer := interpreter.evm.Config.Tracer; tracer != nil {
|
if tracer := evm.Config.Tracer; tracer != nil {
|
||||||
if tracer.OnEnter != nil {
|
if tracer.OnEnter != nil {
|
||||||
tracer.OnEnter(interpreter.evm.depth, byte(SELFDESTRUCT), scope.Contract.Address(), beneficiary.Bytes20(), []byte{}, 0, balance.ToBig())
|
tracer.OnEnter(evm.depth, byte(SELFDESTRUCT), scope.Contract.Address(), beneficiary.Bytes20(), []byte{}, 0, balance.ToBig())
|
||||||
}
|
}
|
||||||
if tracer.OnExit != nil {
|
if tracer.OnExit != nil {
|
||||||
tracer.OnExit(interpreter.evm.depth, []byte{}, 0, nil, false)
|
tracer.OnExit(evm.depth, []byte{}, 0, nil, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, errStopToken
|
return nil, errStopToken
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSelfdestruct6780(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSelfdestruct6780(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
if interpreter.readOnly {
|
if evm.readOnly {
|
||||||
return nil, ErrWriteProtection
|
return nil, ErrWriteProtection
|
||||||
}
|
}
|
||||||
beneficiary := scope.Stack.pop()
|
beneficiary := scope.Stack.pop()
|
||||||
balance := interpreter.evm.StateDB.GetBalance(scope.Contract.Address())
|
balance := evm.StateDB.GetBalance(scope.Contract.Address())
|
||||||
interpreter.evm.StateDB.SubBalance(scope.Contract.Address(), balance, tracing.BalanceDecreaseSelfdestruct)
|
evm.StateDB.SubBalance(scope.Contract.Address(), balance, tracing.BalanceDecreaseSelfdestruct)
|
||||||
interpreter.evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct)
|
evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct)
|
||||||
interpreter.evm.StateDB.SelfDestruct6780(scope.Contract.Address())
|
evm.StateDB.SelfDestruct6780(scope.Contract.Address())
|
||||||
if tracer := interpreter.evm.Config.Tracer; tracer != nil {
|
if tracer := evm.Config.Tracer; tracer != nil {
|
||||||
if tracer.OnEnter != nil {
|
if tracer.OnEnter != nil {
|
||||||
tracer.OnEnter(interpreter.evm.depth, byte(SELFDESTRUCT), scope.Contract.Address(), beneficiary.Bytes20(), []byte{}, 0, balance.ToBig())
|
tracer.OnEnter(evm.depth, byte(SELFDESTRUCT), scope.Contract.Address(), beneficiary.Bytes20(), []byte{}, 0, balance.ToBig())
|
||||||
}
|
}
|
||||||
if tracer.OnExit != nil {
|
if tracer.OnExit != nil {
|
||||||
tracer.OnExit(interpreter.evm.depth, []byte{}, 0, nil, false)
|
tracer.OnExit(evm.depth, []byte{}, 0, nil, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, errStopToken
|
return nil, errStopToken
|
||||||
|
|
@ -925,8 +924,8 @@ func opSelfdestruct6780(pc *uint64, interpreter *EVMInterpreter, scope *ScopeCon
|
||||||
|
|
||||||
// make log instruction function
|
// make log instruction function
|
||||||
func makeLog(size int) executionFunc {
|
func makeLog(size int) executionFunc {
|
||||||
return func(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
return func(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
if interpreter.readOnly {
|
if evm.readOnly {
|
||||||
return nil, ErrWriteProtection
|
return nil, ErrWriteProtection
|
||||||
}
|
}
|
||||||
topics := make([]common.Hash, size)
|
topics := make([]common.Hash, size)
|
||||||
|
|
@ -938,13 +937,13 @@ func makeLog(size int) executionFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
d := scope.Memory.GetCopy(mStart.Uint64(), mSize.Uint64())
|
d := scope.Memory.GetCopy(mStart.Uint64(), mSize.Uint64())
|
||||||
interpreter.evm.StateDB.AddLog(&types.Log{
|
evm.StateDB.AddLog(&types.Log{
|
||||||
Address: scope.Contract.Address(),
|
Address: scope.Contract.Address(),
|
||||||
Topics: topics,
|
Topics: topics,
|
||||||
Data: d,
|
Data: d,
|
||||||
// This is a non-consensus field, but assigned here because
|
// This is a non-consensus field, but assigned here because
|
||||||
// core/state doesn't know the current block number.
|
// core/state doesn't know the current block number.
|
||||||
BlockNumber: interpreter.evm.Context.BlockNumber.Uint64(),
|
BlockNumber: evm.Context.BlockNumber.Uint64(),
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
@ -952,7 +951,7 @@ func makeLog(size int) executionFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
// opPush1 is a specialized version of pushN
|
// opPush1 is a specialized version of pushN
|
||||||
func opPush1(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opPush1(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
codeLen = uint64(len(scope.Contract.Code))
|
codeLen = uint64(len(scope.Contract.Code))
|
||||||
integer = new(uint256.Int)
|
integer = new(uint256.Int)
|
||||||
|
|
@ -967,7 +966,7 @@ func opPush1(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by
|
||||||
}
|
}
|
||||||
|
|
||||||
// opPush2 is a specialized version of pushN
|
// opPush2 is a specialized version of pushN
|
||||||
func opPush2(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opPush2(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
codeLen = uint64(len(scope.Contract.Code))
|
codeLen = uint64(len(scope.Contract.Code))
|
||||||
integer = new(uint256.Int)
|
integer = new(uint256.Int)
|
||||||
|
|
@ -985,7 +984,7 @@ func opPush2(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by
|
||||||
|
|
||||||
// make push instruction function
|
// make push instruction function
|
||||||
func makePush(size uint64, pushByteSize int) executionFunc {
|
func makePush(size uint64, pushByteSize int) executionFunc {
|
||||||
return func(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
return func(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
codeLen = len(scope.Contract.Code)
|
codeLen = len(scope.Contract.Code)
|
||||||
start = min(codeLen, int(*pc+1))
|
start = min(codeLen, int(*pc+1))
|
||||||
|
|
@ -1004,9 +1003,9 @@ func makePush(size uint64, pushByteSize int) executionFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
// make dup instruction function
|
// make dup instruction function
|
||||||
func makeDup(size int64) executionFunc {
|
func makeDup(size int) executionFunc {
|
||||||
return func(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
return func(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
||||||
scope.Stack.dup(int(size))
|
scope.Stack.dup(size)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ func testTwoOperandOp(t *testing.T, tests []TwoOperandTestcase, opFn executionFu
|
||||||
expected := new(uint256.Int).SetBytes(common.Hex2Bytes(test.Expected))
|
expected := new(uint256.Int).SetBytes(common.Hex2Bytes(test.Expected))
|
||||||
stack.push(x)
|
stack.push(x)
|
||||||
stack.push(y)
|
stack.push(y)
|
||||||
opFn(&pc, evm.interpreter, &ScopeContext{nil, stack, nil})
|
opFn(&pc, evm, &ScopeContext{nil, stack, nil})
|
||||||
if len(stack.data) != 1 {
|
if len(stack.data) != 1 {
|
||||||
t.Errorf("Expected one item on stack after %v, got %d: ", name, len(stack.data))
|
t.Errorf("Expected one item on stack after %v, got %d: ", name, len(stack.data))
|
||||||
}
|
}
|
||||||
|
|
@ -221,7 +221,7 @@ func TestAddMod(t *testing.T) {
|
||||||
stack.push(z)
|
stack.push(z)
|
||||||
stack.push(y)
|
stack.push(y)
|
||||||
stack.push(x)
|
stack.push(x)
|
||||||
opAddmod(&pc, evm.interpreter, &ScopeContext{nil, stack, nil})
|
opAddmod(&pc, evm, &ScopeContext{nil, stack, nil})
|
||||||
actual := stack.pop()
|
actual := stack.pop()
|
||||||
if actual.Cmp(expected) != 0 {
|
if actual.Cmp(expected) != 0 {
|
||||||
t.Errorf("Testcase %d, expected %x, got %x", i, expected, actual)
|
t.Errorf("Testcase %d, expected %x, got %x", i, expected, actual)
|
||||||
|
|
@ -247,7 +247,7 @@ func TestWriteExpectedValues(t *testing.T) {
|
||||||
y := new(uint256.Int).SetBytes(common.Hex2Bytes(param.y))
|
y := new(uint256.Int).SetBytes(common.Hex2Bytes(param.y))
|
||||||
stack.push(x)
|
stack.push(x)
|
||||||
stack.push(y)
|
stack.push(y)
|
||||||
opFn(&pc, evm.interpreter, &ScopeContext{nil, stack, nil})
|
opFn(&pc, evm, &ScopeContext{nil, stack, nil})
|
||||||
actual := stack.pop()
|
actual := stack.pop()
|
||||||
result[i] = TwoOperandTestcase{param.x, param.y, fmt.Sprintf("%064x", actual)}
|
result[i] = TwoOperandTestcase{param.x, param.y, fmt.Sprintf("%064x", actual)}
|
||||||
}
|
}
|
||||||
|
|
@ -296,7 +296,7 @@ func opBenchmark(bench *testing.B, op executionFunc, args ...string) {
|
||||||
for _, arg := range intArgs {
|
for _, arg := range intArgs {
|
||||||
stack.push(arg)
|
stack.push(arg)
|
||||||
}
|
}
|
||||||
op(&pc, evm.interpreter, scope)
|
op(&pc, evm, scope)
|
||||||
stack.pop()
|
stack.pop()
|
||||||
}
|
}
|
||||||
bench.StopTimer()
|
bench.StopTimer()
|
||||||
|
|
@ -528,13 +528,13 @@ func TestOpMstore(t *testing.T) {
|
||||||
v := "abcdef00000000000000abba000000000deaf000000c0de00100000000133700"
|
v := "abcdef00000000000000abba000000000deaf000000c0de00100000000133700"
|
||||||
stack.push(new(uint256.Int).SetBytes(common.Hex2Bytes(v)))
|
stack.push(new(uint256.Int).SetBytes(common.Hex2Bytes(v)))
|
||||||
stack.push(new(uint256.Int))
|
stack.push(new(uint256.Int))
|
||||||
opMstore(&pc, evm.interpreter, &ScopeContext{mem, stack, nil})
|
opMstore(&pc, evm, &ScopeContext{mem, stack, nil})
|
||||||
if got := common.Bytes2Hex(mem.GetCopy(0, 32)); got != v {
|
if got := common.Bytes2Hex(mem.GetCopy(0, 32)); got != v {
|
||||||
t.Fatalf("Mstore fail, got %v, expected %v", got, v)
|
t.Fatalf("Mstore fail, got %v, expected %v", got, v)
|
||||||
}
|
}
|
||||||
stack.push(new(uint256.Int).SetUint64(0x1))
|
stack.push(new(uint256.Int).SetUint64(0x1))
|
||||||
stack.push(new(uint256.Int))
|
stack.push(new(uint256.Int))
|
||||||
opMstore(&pc, evm.interpreter, &ScopeContext{mem, stack, nil})
|
opMstore(&pc, evm, &ScopeContext{mem, stack, nil})
|
||||||
if common.Bytes2Hex(mem.GetCopy(0, 32)) != "0000000000000000000000000000000000000000000000000000000000000001" {
|
if common.Bytes2Hex(mem.GetCopy(0, 32)) != "0000000000000000000000000000000000000000000000000000000000000001" {
|
||||||
t.Fatalf("Mstore failed to overwrite previous value")
|
t.Fatalf("Mstore failed to overwrite previous value")
|
||||||
}
|
}
|
||||||
|
|
@ -555,7 +555,7 @@ func BenchmarkOpMstore(bench *testing.B) {
|
||||||
for i := 0; i < bench.N; i++ {
|
for i := 0; i < bench.N; i++ {
|
||||||
stack.push(value)
|
stack.push(value)
|
||||||
stack.push(memStart)
|
stack.push(memStart)
|
||||||
opMstore(&pc, evm.interpreter, &ScopeContext{mem, stack, nil})
|
opMstore(&pc, evm, &ScopeContext{mem, stack, nil})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -581,14 +581,14 @@ func TestOpTstore(t *testing.T) {
|
||||||
stack.push(new(uint256.Int).SetBytes(value))
|
stack.push(new(uint256.Int).SetBytes(value))
|
||||||
// push the location to the stack
|
// push the location to the stack
|
||||||
stack.push(new(uint256.Int))
|
stack.push(new(uint256.Int))
|
||||||
opTstore(&pc, evm.interpreter, &scopeContext)
|
opTstore(&pc, evm, &scopeContext)
|
||||||
// there should be no elements on the stack after TSTORE
|
// there should be no elements on the stack after TSTORE
|
||||||
if stack.len() != 0 {
|
if stack.len() != 0 {
|
||||||
t.Fatal("stack wrong size")
|
t.Fatal("stack wrong size")
|
||||||
}
|
}
|
||||||
// push the location to the stack
|
// push the location to the stack
|
||||||
stack.push(new(uint256.Int))
|
stack.push(new(uint256.Int))
|
||||||
opTload(&pc, evm.interpreter, &scopeContext)
|
opTload(&pc, evm, &scopeContext)
|
||||||
// there should be one element on the stack after TLOAD
|
// there should be one element on the stack after TLOAD
|
||||||
if stack.len() != 1 {
|
if stack.len() != 1 {
|
||||||
t.Fatal("stack wrong size")
|
t.Fatal("stack wrong size")
|
||||||
|
|
@ -613,7 +613,7 @@ func BenchmarkOpKeccak256(bench *testing.B) {
|
||||||
for i := 0; i < bench.N; i++ {
|
for i := 0; i < bench.N; i++ {
|
||||||
stack.push(uint256.NewInt(32))
|
stack.push(uint256.NewInt(32))
|
||||||
stack.push(start)
|
stack.push(start)
|
||||||
opKeccak256(&pc, evm.interpreter, &ScopeContext{mem, stack, nil})
|
opKeccak256(&pc, evm, &ScopeContext{mem, stack, nil})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -707,7 +707,7 @@ func TestRandom(t *testing.T) {
|
||||||
stack = newstack()
|
stack = newstack()
|
||||||
pc = uint64(0)
|
pc = uint64(0)
|
||||||
)
|
)
|
||||||
opRandom(&pc, evm.interpreter, &ScopeContext{nil, stack, nil})
|
opRandom(&pc, evm, &ScopeContext{nil, stack, nil})
|
||||||
if len(stack.data) != 1 {
|
if len(stack.data) != 1 {
|
||||||
t.Errorf("Expected one item on stack after %v, got %d: ", tt.name, len(stack.data))
|
t.Errorf("Expected one item on stack after %v, got %d: ", tt.name, len(stack.data))
|
||||||
}
|
}
|
||||||
|
|
@ -749,7 +749,7 @@ func TestBlobHash(t *testing.T) {
|
||||||
)
|
)
|
||||||
evm.SetTxContext(TxContext{BlobHashes: tt.hashes})
|
evm.SetTxContext(TxContext{BlobHashes: tt.hashes})
|
||||||
stack.push(uint256.NewInt(tt.idx))
|
stack.push(uint256.NewInt(tt.idx))
|
||||||
opBlobHash(&pc, evm.interpreter, &ScopeContext{nil, stack, nil})
|
opBlobHash(&pc, evm, &ScopeContext{nil, stack, nil})
|
||||||
if len(stack.data) != 1 {
|
if len(stack.data) != 1 {
|
||||||
t.Errorf("Expected one item on stack after %v, got %d: ", tt.name, len(stack.data))
|
t.Errorf("Expected one item on stack after %v, got %d: ", tt.name, len(stack.data))
|
||||||
}
|
}
|
||||||
|
|
@ -889,7 +889,7 @@ func TestOpMCopy(t *testing.T) {
|
||||||
mem.Resize(memorySize)
|
mem.Resize(memorySize)
|
||||||
}
|
}
|
||||||
// Do the copy
|
// Do the copy
|
||||||
opMcopy(&pc, evm.interpreter, &ScopeContext{mem, stack, nil})
|
opMcopy(&pc, evm, &ScopeContext{mem, stack, nil})
|
||||||
want := common.FromHex(strings.ReplaceAll(tc.want, " ", ""))
|
want := common.FromHex(strings.ReplaceAll(tc.want, " ", ""))
|
||||||
if have := mem.store; !bytes.Equal(want, have) {
|
if have := mem.store; !bytes.Equal(want, have) {
|
||||||
t.Errorf("case %d: \nwant: %#x\nhave: %#x\n", i, want, have)
|
t.Errorf("case %d: \nwant: %#x\nhave: %#x\n", i, want, have)
|
||||||
|
|
@ -1001,7 +1001,7 @@ func TestOpCLZ(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
stack.push(val)
|
stack.push(val)
|
||||||
opCLZ(&pc, evm.interpreter, &ScopeContext{Stack: stack})
|
opCLZ(&pc, evm, &ScopeContext{Stack: stack})
|
||||||
|
|
||||||
if gotLen := stack.len(); gotLen != 1 {
|
if gotLen := stack.len(); gotLen != 1 {
|
||||||
t.Fatalf("stack length = %d; want 1", gotLen)
|
t.Fatalf("stack length = %d; want 1", gotLen)
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,6 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/math"
|
"github.com/ethereum/go-ethereum/common/math"
|
||||||
"github.com/ethereum/go-ethereum/core/tracing"
|
"github.com/ethereum/go-ethereum/core/tracing"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
|
||||||
"github.com/ethereum/go-ethereum/log"
|
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -89,93 +87,27 @@ func (ctx *ScopeContext) ContractCode() []byte {
|
||||||
return ctx.Contract.Code
|
return ctx.Contract.Code
|
||||||
}
|
}
|
||||||
|
|
||||||
// EVMInterpreter represents an EVM interpreter
|
|
||||||
type EVMInterpreter struct {
|
|
||||||
evm *EVM
|
|
||||||
table *JumpTable
|
|
||||||
|
|
||||||
hasher crypto.KeccakState // Keccak256 hasher instance shared across opcodes
|
|
||||||
hasherBuf common.Hash // Keccak256 hasher result array shared across opcodes
|
|
||||||
|
|
||||||
readOnly bool // Whether to throw on stateful modifications
|
|
||||||
returnData []byte // Last CALL's return data for subsequent reuse
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewEVMInterpreter returns a new instance of the Interpreter.
|
|
||||||
func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
|
|
||||||
// If jump table was not initialised we set the default one.
|
|
||||||
var table *JumpTable
|
|
||||||
switch {
|
|
||||||
case evm.chainRules.IsOsaka:
|
|
||||||
table = &osakaInstructionSet
|
|
||||||
case evm.chainRules.IsVerkle:
|
|
||||||
// TODO replace with proper instruction set when fork is specified
|
|
||||||
table = &verkleInstructionSet
|
|
||||||
case evm.chainRules.IsPrague:
|
|
||||||
table = &pragueInstructionSet
|
|
||||||
case evm.chainRules.IsCancun:
|
|
||||||
table = &cancunInstructionSet
|
|
||||||
case evm.chainRules.IsShanghai:
|
|
||||||
table = &shanghaiInstructionSet
|
|
||||||
case evm.chainRules.IsMerge:
|
|
||||||
table = &mergeInstructionSet
|
|
||||||
case evm.chainRules.IsLondon:
|
|
||||||
table = &londonInstructionSet
|
|
||||||
case evm.chainRules.IsBerlin:
|
|
||||||
table = &berlinInstructionSet
|
|
||||||
case evm.chainRules.IsIstanbul:
|
|
||||||
table = &istanbulInstructionSet
|
|
||||||
case evm.chainRules.IsConstantinople:
|
|
||||||
table = &constantinopleInstructionSet
|
|
||||||
case evm.chainRules.IsByzantium:
|
|
||||||
table = &byzantiumInstructionSet
|
|
||||||
case evm.chainRules.IsEIP158:
|
|
||||||
table = &spuriousDragonInstructionSet
|
|
||||||
case evm.chainRules.IsEIP150:
|
|
||||||
table = &tangerineWhistleInstructionSet
|
|
||||||
case evm.chainRules.IsHomestead:
|
|
||||||
table = &homesteadInstructionSet
|
|
||||||
default:
|
|
||||||
table = &frontierInstructionSet
|
|
||||||
}
|
|
||||||
var extraEips []int
|
|
||||||
if len(evm.Config.ExtraEips) > 0 {
|
|
||||||
// Deep-copy jumptable to prevent modification of opcodes in other tables
|
|
||||||
table = copyJumpTable(table)
|
|
||||||
}
|
|
||||||
for _, eip := range evm.Config.ExtraEips {
|
|
||||||
if err := EnableEIP(eip, table); err != nil {
|
|
||||||
// Disable it, so caller can check if it's activated or not
|
|
||||||
log.Error("EIP activation failed", "eip", eip, "error", err)
|
|
||||||
} else {
|
|
||||||
extraEips = append(extraEips, eip)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
evm.Config.ExtraEips = extraEips
|
|
||||||
return &EVMInterpreter{evm: evm, table: table, hasher: crypto.NewKeccakState()}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run loops and evaluates the contract's code with the given input data and returns
|
// Run loops and evaluates the contract's code with the given input data and returns
|
||||||
// the return byte-slice and an error if one occurred.
|
// the return byte-slice and an error if one occurred.
|
||||||
//
|
//
|
||||||
// It's important to note that any errors returned by the interpreter should be
|
// It's important to note that any errors returned by the interpreter should be
|
||||||
// considered a revert-and-consume-all-gas operation except for
|
// considered a revert-and-consume-all-gas operation except for
|
||||||
// ErrExecutionReverted which means revert-and-keep-gas-left.
|
// ErrExecutionReverted which means revert-and-keep-gas-left.
|
||||||
func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (ret []byte, err error) {
|
func (evm *EVM) Run(contract *Contract, input []byte, readOnly bool) (ret []byte, err error) {
|
||||||
// Increment the call depth which is restricted to 1024
|
// Increment the call depth which is restricted to 1024
|
||||||
in.evm.depth++
|
evm.depth++
|
||||||
defer func() { in.evm.depth-- }()
|
defer func() { evm.depth-- }()
|
||||||
|
|
||||||
// Make sure the readOnly is only set if we aren't in readOnly yet.
|
// Make sure the readOnly is only set if we aren't in readOnly yet.
|
||||||
// This also makes sure that the readOnly flag isn't removed for child calls.
|
// This also makes sure that the readOnly flag isn't removed for child calls.
|
||||||
if readOnly && !in.readOnly {
|
if readOnly && !evm.readOnly {
|
||||||
in.readOnly = true
|
evm.readOnly = true
|
||||||
defer func() { in.readOnly = false }()
|
defer func() { evm.readOnly = false }()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the previous call's return data. It's unimportant to preserve the old buffer
|
// Reset the previous call's return data. It's unimportant to preserve the old buffer
|
||||||
// as every returning call will return new data anyway.
|
// as every returning call will return new data anyway.
|
||||||
in.returnData = nil
|
evm.returnData = nil
|
||||||
|
|
||||||
// Don't bother with the execution if there's no code.
|
// Don't bother with the execution if there's no code.
|
||||||
if len(contract.Code) == 0 {
|
if len(contract.Code) == 0 {
|
||||||
|
|
@ -184,7 +116,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
op OpCode // current opcode
|
op OpCode // current opcode
|
||||||
jumpTable *JumpTable = in.table
|
jumpTable *JumpTable = evm.table
|
||||||
mem = NewMemory() // bound memory
|
mem = NewMemory() // bound memory
|
||||||
stack = newstack() // local stack
|
stack = newstack() // local stack
|
||||||
callContext = &ScopeContext{
|
callContext = &ScopeContext{
|
||||||
|
|
@ -202,7 +134,8 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
gasCopy uint64 // for EVMLogger to log gas remaining before execution
|
gasCopy uint64 // for EVMLogger to log gas remaining before execution
|
||||||
logged bool // deferred EVMLogger should ignore already logged steps
|
logged bool // deferred EVMLogger should ignore already logged steps
|
||||||
res []byte // result of the opcode execution function
|
res []byte // result of the opcode execution function
|
||||||
debug = in.evm.Config.Tracer != nil
|
debug = evm.Config.Tracer != nil
|
||||||
|
isEIP4762 = evm.chainRules.IsEIP4762
|
||||||
)
|
)
|
||||||
// Don't move this deferred function, it's placed before the OnOpcode-deferred method,
|
// Don't move this deferred function, it's placed before the OnOpcode-deferred method,
|
||||||
// so that it gets executed _after_: the OnOpcode needs the stacks before
|
// so that it gets executed _after_: the OnOpcode needs the stacks before
|
||||||
|
|
@ -218,11 +151,11 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !logged && in.evm.Config.Tracer.OnOpcode != nil {
|
if !logged && evm.Config.Tracer.OnOpcode != nil {
|
||||||
in.evm.Config.Tracer.OnOpcode(pcCopy, byte(op), gasCopy, cost, callContext, in.returnData, in.evm.depth, VMErrorFromErr(err))
|
evm.Config.Tracer.OnOpcode(pcCopy, byte(op), gasCopy, cost, callContext, evm.returnData, evm.depth, VMErrorFromErr(err))
|
||||||
}
|
}
|
||||||
if logged && in.evm.Config.Tracer.OnFault != nil {
|
if logged && evm.Config.Tracer.OnFault != nil {
|
||||||
in.evm.Config.Tracer.OnFault(pcCopy, byte(op), gasCopy, cost, callContext, in.evm.depth, VMErrorFromErr(err))
|
evm.Config.Tracer.OnFault(pcCopy, byte(op), gasCopy, cost, callContext, evm.depth, VMErrorFromErr(err))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
@ -237,12 +170,12 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
logged, pcCopy, gasCopy = false, pc, contract.Gas
|
logged, pcCopy, gasCopy = false, pc, contract.Gas
|
||||||
}
|
}
|
||||||
|
|
||||||
if in.evm.chainRules.IsEIP4762 && !contract.IsDeployment && !contract.IsSystemCall {
|
if isEIP4762 && !contract.IsDeployment && !contract.IsSystemCall {
|
||||||
// if the PC ends up in a new "chunk" of verkleized code, charge the
|
// if the PC ends up in a new "chunk" of verkleized code, charge the
|
||||||
// associated costs.
|
// associated costs.
|
||||||
contractAddr := contract.Address()
|
contractAddr := contract.Address()
|
||||||
consumed, wanted := in.evm.TxContext.AccessEvents.CodeChunksRangeGas(contractAddr, pc, 1, uint64(len(contract.Code)), false, contract.Gas)
|
consumed, wanted := evm.TxContext.AccessEvents.CodeChunksRangeGas(contractAddr, pc, 1, uint64(len(contract.Code)), false, contract.Gas)
|
||||||
contract.UseGas(consumed, in.evm.Config.Tracer, tracing.GasChangeWitnessCodeChunk)
|
contract.UseGas(consumed, evm.Config.Tracer, tracing.GasChangeWitnessCodeChunk)
|
||||||
if consumed < wanted {
|
if consumed < wanted {
|
||||||
return nil, ErrOutOfGas
|
return nil, ErrOutOfGas
|
||||||
}
|
}
|
||||||
|
|
@ -287,7 +220,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
// Consume the gas and return an error if not enough gas is available.
|
// Consume the gas and return an error if not enough gas is available.
|
||||||
// cost is explicitly set so that the capture state defer method can get the proper cost
|
// cost is explicitly set so that the capture state defer method can get the proper cost
|
||||||
var dynamicCost uint64
|
var dynamicCost uint64
|
||||||
dynamicCost, err = operation.dynamicGas(in.evm, contract, stack, mem, memorySize)
|
dynamicCost, err = operation.dynamicGas(evm, contract, stack, mem, memorySize)
|
||||||
cost += dynamicCost // for tracing
|
cost += dynamicCost // for tracing
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("%w: %v", ErrOutOfGas, err)
|
return nil, fmt.Errorf("%w: %v", ErrOutOfGas, err)
|
||||||
|
|
@ -302,11 +235,11 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
|
|
||||||
// Do tracing before potential memory expansion
|
// Do tracing before potential memory expansion
|
||||||
if debug {
|
if debug {
|
||||||
if in.evm.Config.Tracer.OnGasChange != nil {
|
if evm.Config.Tracer.OnGasChange != nil {
|
||||||
in.evm.Config.Tracer.OnGasChange(gasCopy, gasCopy-cost, tracing.GasChangeCallOpCode)
|
evm.Config.Tracer.OnGasChange(gasCopy, gasCopy-cost, tracing.GasChangeCallOpCode)
|
||||||
}
|
}
|
||||||
if in.evm.Config.Tracer.OnOpcode != nil {
|
if evm.Config.Tracer.OnOpcode != nil {
|
||||||
in.evm.Config.Tracer.OnOpcode(pc, byte(op), gasCopy, cost, callContext, in.returnData, in.evm.depth, VMErrorFromErr(err))
|
evm.Config.Tracer.OnOpcode(pc, byte(op), gasCopy, cost, callContext, evm.returnData, evm.depth, VMErrorFromErr(err))
|
||||||
logged = true
|
logged = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -315,7 +248,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
}
|
}
|
||||||
|
|
||||||
// execute the operation
|
// execute the operation
|
||||||
res, err = operation.execute(&pc, in, callContext)
|
res, err = operation.execute(&pc, evm, callContext)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
executionFunc func(pc *uint64, interpreter *EVMInterpreter, callContext *ScopeContext) ([]byte, error)
|
executionFunc func(pc *uint64, evm *EVM, callContext *ScopeContext) ([]byte, error)
|
||||||
gasFunc func(*EVM, *Contract, *Stack, *Memory, uint64) (uint64, error) // last parameter is the requested memory size as a uint64
|
gasFunc func(*EVM, *Contract, *Stack, *Memory, uint64) (uint64, error) // last parameter is the requested memory size as a uint64
|
||||||
// memorySizeFunc returns the required size, and whether the operation overflowed a uint64
|
// memorySizeFunc returns the required size, and whether the operation overflowed a uint64
|
||||||
memorySizeFunc func(*Stack) (size uint64, overflow bool)
|
memorySizeFunc func(*Stack) (size uint64, overflow bool)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/consensys/gnark-crypto/ecc/bn254"
|
"github.com/consensys/gnark-crypto/ecc/bn254"
|
||||||
|
"github.com/ethereum/go-ethereum/common/bitutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
// G1 is the affine representation of a G1 group element.
|
// G1 is the affine representation of a G1 group element.
|
||||||
|
|
@ -43,7 +44,7 @@ func (g *G1) Unmarshal(buf []byte) (int, error) {
|
||||||
return 0, errors.New("invalid G1 point size")
|
return 0, errors.New("invalid G1 point size")
|
||||||
}
|
}
|
||||||
|
|
||||||
if allZeroes(buf[:64]) {
|
if !bitutil.TestBytes(buf[:64]) {
|
||||||
// point at infinity
|
// point at infinity
|
||||||
g.inner.X.SetZero()
|
g.inner.X.SetZero()
|
||||||
g.inner.Y.SetZero()
|
g.inner.Y.SetZero()
|
||||||
|
|
@ -82,12 +83,3 @@ func (p *G1) Marshal() []byte {
|
||||||
|
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
func allZeroes(buf []byte) bool {
|
|
||||||
for i := range buf {
|
|
||||||
if buf[i] != 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/consensys/gnark-crypto/ecc/bn254"
|
"github.com/consensys/gnark-crypto/ecc/bn254"
|
||||||
|
"github.com/ethereum/go-ethereum/common/bitutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
// G2 is the affine representation of a G2 group element.
|
// G2 is the affine representation of a G2 group element.
|
||||||
|
|
@ -31,7 +32,7 @@ func (g *G2) Unmarshal(buf []byte) (int, error) {
|
||||||
return 0, errors.New("invalid G2 point size")
|
return 0, errors.New("invalid G2 point size")
|
||||||
}
|
}
|
||||||
|
|
||||||
if allZeroes(buf[:128]) {
|
if !bitutil.TestBytes(buf[:128]) {
|
||||||
// point at infinity
|
// point at infinity
|
||||||
g.inner.X.A0.SetZero()
|
g.inner.X.A0.SetZero()
|
||||||
g.inner.X.A1.SetZero()
|
g.inner.X.A1.SetZero()
|
||||||
|
|
|
||||||
|
|
@ -35,29 +35,10 @@ package secp256k1
|
||||||
import (
|
import (
|
||||||
"crypto/elliptic"
|
"crypto/elliptic"
|
||||||
"math/big"
|
"math/big"
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
"github.com/ethereum/go-ethereum/common/math"
|
||||||
// number of bits in a big.Word
|
|
||||||
wordBits = 32 << (uint64(^big.Word(0)) >> 63)
|
|
||||||
// number of bytes in a big.Word
|
|
||||||
wordBytes = wordBits / 8
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// readBits encodes the absolute value of bigint as big-endian bytes. Callers
|
|
||||||
// must ensure that buf has enough space. If buf is too short the result will
|
|
||||||
// be incomplete.
|
|
||||||
func readBits(bigint *big.Int, buf []byte) {
|
|
||||||
i := len(buf)
|
|
||||||
for _, d := range bigint.Bits() {
|
|
||||||
for j := 0; j < wordBytes && i > 0; j++ {
|
|
||||||
i--
|
|
||||||
buf[i] = byte(d)
|
|
||||||
d >>= 8
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This code is from https://github.com/ThePiachu/GoBit and implements
|
// This code is from https://github.com/ThePiachu/GoBit and implements
|
||||||
// several Koblitz elliptic curves over prime fields.
|
// several Koblitz elliptic curves over prime fields.
|
||||||
//
|
//
|
||||||
|
|
@ -257,8 +238,8 @@ func (bitCurve *BitCurve) Marshal(x, y *big.Int) []byte {
|
||||||
byteLen := (bitCurve.BitSize + 7) >> 3
|
byteLen := (bitCurve.BitSize + 7) >> 3
|
||||||
ret := make([]byte, 1+2*byteLen)
|
ret := make([]byte, 1+2*byteLen)
|
||||||
ret[0] = 4 // uncompressed point flag
|
ret[0] = 4 // uncompressed point flag
|
||||||
readBits(x, ret[1:1+byteLen])
|
math.ReadBits(x, ret[1:1+byteLen])
|
||||||
readBits(y, ret[1+byteLen:])
|
math.ReadBits(y, ret[1+byteLen:])
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ package secp256k1
|
||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common/math"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -34,8 +36,8 @@ func (bitCurve *BitCurve) ScalarMult(Bx, By *big.Int, scalar []byte) (*big.Int,
|
||||||
|
|
||||||
// Do the multiplication in C, updating point.
|
// Do the multiplication in C, updating point.
|
||||||
point := make([]byte, 64)
|
point := make([]byte, 64)
|
||||||
readBits(Bx, point[:32])
|
math.ReadBits(Bx, point[:32])
|
||||||
readBits(By, point[32:])
|
math.ReadBits(By, point[32:])
|
||||||
|
|
||||||
pointPtr := (*C.uchar)(unsafe.Pointer(&point[0]))
|
pointPtr := (*C.uchar)(unsafe.Pointer(&point[0]))
|
||||||
scalarPtr := (*C.uchar)(unsafe.Pointer(&scalar[0]))
|
scalarPtr := (*C.uchar)(unsafe.Pointer(&scalar[0]))
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,8 @@ func (d *Downloader) GetHeader(hash common.Hash) (*types.Header, error) {
|
||||||
|
|
||||||
for _, peer := range d.peers.peers {
|
for _, peer := range d.peers.peers {
|
||||||
if peer == nil {
|
if peer == nil {
|
||||||
return nil, errors.New("could not find peer")
|
log.Warn("Encountered nil peer while retrieving sync target", "hash", hash)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
// Found a peer, attempt to retrieve the header whilst blocking and
|
// Found a peer, attempt to retrieve the header whilst blocking and
|
||||||
// retry if it fails for whatever reason
|
// retry if it fails for whatever reason
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// makeChain creates a chain of n blocks starting at and including parent.
|
// makeChain creates a chain of n blocks starting at and including parent.
|
||||||
// the returned hash chain is ordered head->parent. In addition, every 3rd block
|
// The returned hash chain is ordered head->parent.
|
||||||
// contains a transaction and every 5th an uncle to allow testing correct block
|
// If empty is false, every second block (i%2==0) contains one transaction.
|
||||||
// reassembly.
|
// No uncles are added.
|
||||||
func makeChain(n int, seed byte, parent *types.Block, empty bool) ([]*types.Block, []types.Receipts) {
|
func makeChain(n int, seed byte, parent *types.Block, empty bool) ([]*types.Block, []types.Receipts) {
|
||||||
blocks, receipts := core.GenerateChain(params.TestChainConfig, parent, ethash.NewFaker(), testDB, n, func(i int, block *core.BlockGen) {
|
blocks, receipts := core.GenerateChain(params.TestChainConfig, parent, ethash.NewFaker(), testDB, n, func(i int, block *core.BlockGen) {
|
||||||
block.SetCoinbase(common.Address{seed})
|
block.SetCoinbase(common.Address{seed})
|
||||||
|
|
|
||||||
|
|
@ -352,6 +352,8 @@ func (h *handler) runEthPeer(peer *eth.Peer, handler eth.Handler) error {
|
||||||
case <-timeout.C:
|
case <-timeout.C:
|
||||||
peer.Log().Warn("Required block challenge timed out, dropping", "addr", peer.RemoteAddr(), "type", peer.Name())
|
peer.Log().Warn("Required block challenge timed out, dropping", "addr", peer.RemoteAddr(), "type", peer.Name())
|
||||||
h.removePeer(peer.ID())
|
h.removePeer(peer.ID())
|
||||||
|
case <-dead:
|
||||||
|
// Peer handler terminated, abort all goroutines
|
||||||
}
|
}
|
||||||
}(number, hash, req)
|
}(number, hash, req)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ func (s *Syncer) run() {
|
||||||
)
|
)
|
||||||
for {
|
for {
|
||||||
if retries >= 10 {
|
if retries >= 10 {
|
||||||
req.errc <- fmt.Errorf("sync target is not avaibale, %x", req.hash)
|
req.errc <- fmt.Errorf("sync target is not available, %x", req.hash)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
|
|
|
||||||
|
|
@ -321,7 +321,7 @@ func TestInternals(t *testing.T) {
|
||||||
byte(vm.LOG0),
|
byte(vm.LOG0),
|
||||||
},
|
},
|
||||||
tracer: mkTracer("prestateTracer", nil),
|
tracer: mkTracer("prestateTracer", nil),
|
||||||
want: fmt.Sprintf(`{"0x00000000000000000000000000000000deadbeef":{"balance":"0x0","code":"0x6001600052600164ffffffffff60016000f560ff6000a0"},"%s":{"balance":"0x1c6bf52634000"}}`, originHex),
|
want: fmt.Sprintf(`{"0x00000000000000000000000000000000deadbeef":{"balance":"0x0","code":"0x6001600052600164ffffffffff60016000f560ff6000a0","codeHash":"0x27be17a236425a9b513d736c4bb84eca4505a15564cae640e85558cf4d7ff7bb"},"%s":{"balance":"0x1c6bf52634000"}}`, originHex),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// CREATE2 which requires padding memory by prestate tracer
|
// CREATE2 which requires padding memory by prestate tracer
|
||||||
|
|
@ -340,7 +340,7 @@ func TestInternals(t *testing.T) {
|
||||||
byte(vm.LOG0),
|
byte(vm.LOG0),
|
||||||
},
|
},
|
||||||
tracer: mkTracer("prestateTracer", nil),
|
tracer: mkTracer("prestateTracer", nil),
|
||||||
want: fmt.Sprintf(`{"0x00000000000000000000000000000000deadbeef":{"balance":"0x0","code":"0x6001600052600160ff60016000f560ff6000a0"},"%s":{"balance":"0x1c6bf52634000"}}`, originHex),
|
want: fmt.Sprintf(`{"0x00000000000000000000000000000000deadbeef":{"balance":"0x0","code":"0x6001600052600160ff60016000f560ff6000a0","codeHash":"0x5544040a7fd107ba8164108904724a38fb9c664daae88a5cc53580841e648edf"},"%s":{"balance":"0x1c6bf52634000"}}`, originHex),
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,7 @@
|
||||||
"0x17816e9a858b161c3e37016d139cf618056cacd4": {
|
"0x17816e9a858b161c3e37016d139cf618056cacd4": {
|
||||||
"balance": "0x0",
|
"balance": "0x0",
|
||||||
"code": "0xef0100b684710e6d5914ad6e64493de2a3c424cc43e970",
|
"code": "0xef0100b684710e6d5914ad6e64493de2a3c424cc43e970",
|
||||||
|
"codeHash":"0xca4cab497827c53a640924e1f7ebb69c3280f8ce8cef2d1d2f9a3707def2a856",
|
||||||
"nonce": 15809
|
"nonce": 15809
|
||||||
},
|
},
|
||||||
"0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97": {
|
"0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97": {
|
||||||
|
|
@ -124,11 +125,13 @@
|
||||||
"0xb684710e6d5914ad6e64493de2a3c424cc43e970": {
|
"0xb684710e6d5914ad6e64493de2a3c424cc43e970": {
|
||||||
"balance": "0x0",
|
"balance": "0x0",
|
||||||
"code": "0x60806040525f4711156100b6575f3273ffffffffffffffffffffffffffffffffffffffff16476040516100319061048b565b5f6040518083038185875af1925050503d805f811461006b576040519150601f19603f3d011682016040523d82523d5f602084013e610070565b606091505b50509050806100b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100ab906104f9565b60405180910390fd5b505b73ffffffffffffffffffffffffffffffffffffffff80166001336100da9190610563565b73ffffffffffffffffffffffffffffffffffffffff161115610131576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610128906105f4565b60405180910390fd5b73b9df4a9ba45917e71d664d51462d46926e4798e873ffffffffffffffffffffffffffffffffffffffff166001336101699190610563565b73ffffffffffffffffffffffffffffffffffffffff160361045c575f8036906101929190610631565b5f1c90505f73cda6461f1a30c618373f5790a83e1569fb685cba73ffffffffffffffffffffffffffffffffffffffff16631f3a71ba306040518263ffffffff1660e01b81526004016101e491906106af565b602060405180830381865afa1580156101ff573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061022391906106ff565b90508181106104595773cda6461f1a30c618373f5790a83e1569fb685cba73ffffffffffffffffffffffffffffffffffffffff1663a9059cbb5f836040518363ffffffff1660e01b815260040161027b929190610739565b6020604051808303815f875af1158015610297573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102bb9190610795565b6102fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102f1906104f9565b60405180910390fd5b5f73236501327e701692a281934230af0b6be8df335373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161034891906106af565b602060405180830381865afa158015610363573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061038791906106ff565b905073236501327e701692a281934230af0b6be8df335373ffffffffffffffffffffffffffffffffffffffff1663a9059cbb32836040518363ffffffff1660e01b81526004016103d8929190610739565b6020604051808303815f875af11580156103f4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104189190610795565b610457576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161044e9061080a565b60405180910390fd5b505b50505b005b5f81905092915050565b50565b5f6104765f8361045e565b915061048182610468565b5f82019050919050565b5f6104958261046b565b9150819050919050565b5f82825260208201905092915050565b7f5472616e73666572206661696c656400000000000000000000000000000000005f82015250565b5f6104e3600f8361049f565b91506104ee826104af565b602082019050919050565b5f6020820190508181035f830152610510816104d7565b9050919050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61056d82610517565b915061057883610517565b9250828201905073ffffffffffffffffffffffffffffffffffffffff8111156105a4576105a3610536565b5b92915050565b7f50616e69632831372900000000000000000000000000000000000000000000005f82015250565b5f6105de60098361049f565b91506105e9826105aa565b602082019050919050565b5f6020820190508181035f83015261060b816105d2565b9050919050565b5f82905092915050565b5f819050919050565b5f82821b905092915050565b5f61063c8383610612565b82610647813561061c565b92506020821015610687576106827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83602003600802610625565b831692505b505092915050565b5f61069982610517565b9050919050565b6106a98161068f565b82525050565b5f6020820190506106c25f8301846106a0565b92915050565b5f80fd5b5f819050919050565b6106de816106cc565b81146106e8575f80fd5b50565b5f815190506106f9816106d5565b92915050565b5f60208284031215610714576107136106c8565b5b5f610721848285016106eb565b91505092915050565b610733816106cc565b82525050565b5f60408201905061074c5f8301856106a0565b610759602083018461072a565b9392505050565b5f8115159050919050565b61077481610760565b811461077e575f80fd5b50565b5f8151905061078f8161076b565b92915050565b5f602082840312156107aa576107a96106c8565b5b5f6107b784828501610781565b91505092915050565b7f546f6b656e207472616e73666572206661696c656400000000000000000000005f82015250565b5f6107f460158361049f565b91506107ff826107c0565b602082019050919050565b5f6020820190508181035f830152610821816107e8565b905091905056fea2646970667358221220b6a06cc7b930dc4e34352a145f3548d57ec5a60d0097c1979ef363376bf9a69164736f6c63430008140033",
|
"code": "0x60806040525f4711156100b6575f3273ffffffffffffffffffffffffffffffffffffffff16476040516100319061048b565b5f6040518083038185875af1925050503d805f811461006b576040519150601f19603f3d011682016040523d82523d5f602084013e610070565b606091505b50509050806100b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100ab906104f9565b60405180910390fd5b505b73ffffffffffffffffffffffffffffffffffffffff80166001336100da9190610563565b73ffffffffffffffffffffffffffffffffffffffff161115610131576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610128906105f4565b60405180910390fd5b73b9df4a9ba45917e71d664d51462d46926e4798e873ffffffffffffffffffffffffffffffffffffffff166001336101699190610563565b73ffffffffffffffffffffffffffffffffffffffff160361045c575f8036906101929190610631565b5f1c90505f73cda6461f1a30c618373f5790a83e1569fb685cba73ffffffffffffffffffffffffffffffffffffffff16631f3a71ba306040518263ffffffff1660e01b81526004016101e491906106af565b602060405180830381865afa1580156101ff573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061022391906106ff565b90508181106104595773cda6461f1a30c618373f5790a83e1569fb685cba73ffffffffffffffffffffffffffffffffffffffff1663a9059cbb5f836040518363ffffffff1660e01b815260040161027b929190610739565b6020604051808303815f875af1158015610297573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102bb9190610795565b6102fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102f1906104f9565b60405180910390fd5b5f73236501327e701692a281934230af0b6be8df335373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161034891906106af565b602060405180830381865afa158015610363573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061038791906106ff565b905073236501327e701692a281934230af0b6be8df335373ffffffffffffffffffffffffffffffffffffffff1663a9059cbb32836040518363ffffffff1660e01b81526004016103d8929190610739565b6020604051808303815f875af11580156103f4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104189190610795565b610457576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161044e9061080a565b60405180910390fd5b505b50505b005b5f81905092915050565b50565b5f6104765f8361045e565b915061048182610468565b5f82019050919050565b5f6104958261046b565b9150819050919050565b5f82825260208201905092915050565b7f5472616e73666572206661696c656400000000000000000000000000000000005f82015250565b5f6104e3600f8361049f565b91506104ee826104af565b602082019050919050565b5f6020820190508181035f830152610510816104d7565b9050919050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61056d82610517565b915061057883610517565b9250828201905073ffffffffffffffffffffffffffffffffffffffff8111156105a4576105a3610536565b5b92915050565b7f50616e69632831372900000000000000000000000000000000000000000000005f82015250565b5f6105de60098361049f565b91506105e9826105aa565b602082019050919050565b5f6020820190508181035f83015261060b816105d2565b9050919050565b5f82905092915050565b5f819050919050565b5f82821b905092915050565b5f61063c8383610612565b82610647813561061c565b92506020821015610687576106827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83602003600802610625565b831692505b505092915050565b5f61069982610517565b9050919050565b6106a98161068f565b82525050565b5f6020820190506106c25f8301846106a0565b92915050565b5f80fd5b5f819050919050565b6106de816106cc565b81146106e8575f80fd5b50565b5f815190506106f9816106d5565b92915050565b5f60208284031215610714576107136106c8565b5b5f610721848285016106eb565b91505092915050565b610733816106cc565b82525050565b5f60408201905061074c5f8301856106a0565b610759602083018461072a565b9392505050565b5f8115159050919050565b61077481610760565b811461077e575f80fd5b50565b5f8151905061078f8161076b565b92915050565b5f602082840312156107aa576107a96106c8565b5b5f6107b784828501610781565b91505092915050565b7f546f6b656e207472616e73666572206661696c656400000000000000000000005f82015250565b5f6107f460158361049f565b91506107ff826107c0565b602082019050919050565b5f6020820190508181035f830152610821816107e8565b905091905056fea2646970667358221220b6a06cc7b930dc4e34352a145f3548d57ec5a60d0097c1979ef363376bf9a69164736f6c63430008140033",
|
||||||
|
"codeHash":"0x710e40f71ebfefb907b9970505d085952d073dedc9a67e7ce2db450194c9ad04",
|
||||||
"nonce": 1
|
"nonce": 1
|
||||||
},
|
},
|
||||||
"0xb9df4a9ba45917e71d664d51462d46926e4798e7": {
|
"0xb9df4a9ba45917e71d664d51462d46926e4798e7": {
|
||||||
"balance": "0x597af049b190a724",
|
"balance": "0x597af049b190a724",
|
||||||
"code": "0xef0100000000009b1d0af20d8c6d0a44e162d11f9b8f00",
|
"code": "0xef0100000000009b1d0af20d8c6d0a44e162d11f9b8f00",
|
||||||
|
"codeHash":"0xbb1a21a37f4391e14c4817bca5df4ed60b84e372053b367731ccd8ab0fb6daf1",
|
||||||
"nonce": 1887
|
"nonce": 1887
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@
|
||||||
"0x3b873a919aa0512d5a0f09e6dcceaa4a6727fafe": {
|
"0x3b873a919aa0512d5a0f09e6dcceaa4a6727fafe": {
|
||||||
"balance": "0x4d87094125a369d9bd5",
|
"balance": "0x4d87094125a369d9bd5",
|
||||||
"nonce": 1,
|
"nonce": 1,
|
||||||
|
"codeHash": "0xec0ba40983fafc34be1bda1b3a3c6eabdd60fa4ce6eab345be1e51bda01d0d4f",
|
||||||
"storage": {
|
"storage": {
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000001b436ba50d378d4bbc8660d312a13df6af6e89dfb",
|
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000001b436ba50d378d4bbc8660d312a13df6af6e89dfb",
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x00000000000000000000000000000000000000000000000006f05b59d3b20000",
|
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x00000000000000000000000000000000000000000000000006f05b59d3b20000",
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,8 @@
|
||||||
},
|
},
|
||||||
"0x3b873a919aa0512d5a0f09e6dcceaa4a6727fafe": {
|
"0x3b873a919aa0512d5a0f09e6dcceaa4a6727fafe": {
|
||||||
"balance": "0x4d87094125a369d9bd5",
|
"balance": "0x4d87094125a369d9bd5",
|
||||||
"nonce": 1
|
"nonce": 1,
|
||||||
|
"codeHash": "0xec0ba40983fafc34be1bda1b3a3c6eabdd60fa4ce6eab345be1e51bda01d0d4f"
|
||||||
},
|
},
|
||||||
"0xb436ba50d378d4bbc8660d312a13df6af6e89dfb": {
|
"0xb436ba50d378d4bbc8660d312a13df6af6e89dfb": {
|
||||||
"balance": "0x1780d77678137ac1b775",
|
"balance": "0x1780d77678137ac1b775",
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,8 @@
|
||||||
"0x3b873a919aa0512d5a0f09e6dcceaa4a6727fafe": {
|
"0x3b873a919aa0512d5a0f09e6dcceaa4a6727fafe": {
|
||||||
"balance": "0x4d87094125a369d9bd5",
|
"balance": "0x4d87094125a369d9bd5",
|
||||||
"nonce": 1,
|
"nonce": 1,
|
||||||
"code": "0x606060405236156100935763ffffffff60e060020a60003504166311ee8382811461009c57806313af4035146100be5780631f5e8f4c146100ee57806324daddc5146101125780634921a91a1461013b57806363e4bff414610157578063764978f91461017f578063893d20e8146101a1578063ba40aaa1146101cd578063cebc9a82146101f4578063e177246e14610216575b61009a5b5b565b005b34156100a457fe5b6100ac61023d565b60408051918252519081900360200190f35b34156100c657fe5b6100da600160a060020a0360043516610244565b604080519115158252519081900360200190f35b34156100f657fe5b6100da610307565b604080519115158252519081900360200190f35b341561011a57fe5b6100da6004351515610318565b604080519115158252519081900360200190f35b6100da6103d6565b604080519115158252519081900360200190f35b6100da600160a060020a0360043516610420565b604080519115158252519081900360200190f35b341561018757fe5b6100ac61046c565b60408051918252519081900360200190f35b34156101a957fe5b6101b1610473565b60408051600160a060020a039092168252519081900360200190f35b34156101d557fe5b6100da600435610483565b604080519115158252519081900360200190f35b34156101fc57fe5b6100ac61050d565b60408051918252519081900360200190f35b341561021e57fe5b6100da600435610514565b604080519115158252519081900360200190f35b6003545b90565b60006000610250610473565b600160a060020a031633600160a060020a03161415156102705760006000fd5b600160a060020a03831615156102865760006000fd5b50600054600160a060020a0390811690831681146102fb57604051600160a060020a0380851691908316907ffcf23a92150d56e85e3a3d33b357493246e55783095eb6a733eb8439ffc752c890600090a360008054600160a060020a031916600160a060020a03851617905560019150610300565b600091505b5b50919050565b60005460a060020a900460ff165b90565b60006000610324610473565b600160a060020a031633600160a060020a03161415156103445760006000fd5b5060005460a060020a900460ff16801515831515146102fb576000546040805160a060020a90920460ff1615158252841515602083015280517fe6cd46a119083b86efc6884b970bfa30c1708f53ba57b86716f15b2f4551a9539281900390910190a16000805460a060020a60ff02191660a060020a8515150217905560019150610300565b600091505b5b50919050565b60006103e0610307565b801561040557506103ef610473565b600160a060020a031633600160a060020a031614155b156104105760006000fd5b610419336105a0565b90505b5b90565b600061042a610307565b801561044f5750610439610473565b600160a060020a031633600160a060020a031614155b1561045a5760006000fd5b610463826105a0565b90505b5b919050565b6001545b90565b600054600160a060020a03165b90565b6000600061048f610473565b600160a060020a031633600160a060020a03161415156104af5760006000fd5b506001548281146102fb57604080518281526020810185905281517f79a3746dde45672c9e8ab3644b8bb9c399a103da2dc94b56ba09777330a83509929181900390910190a160018381559150610300565b600091505b5b50919050565b6002545b90565b60006000610520610473565b600160a060020a031633600160a060020a03161415156105405760006000fd5b506002548281146102fb57604080518281526020810185905281517ff6991a728965fedd6e927fdf16bdad42d8995970b4b31b8a2bf88767516e2494929181900390910190a1600283905560019150610300565b600091505b5b50919050565b60006000426105ad61023d565b116102fb576105c46105bd61050d565b4201610652565b6105cc61046c565b604051909150600160a060020a038416908290600081818185876187965a03f1925050501561063d57604080518281529051600160a060020a038516917f9bca65ce52fdef8a470977b51f247a2295123a4807dfa9e502edf0d30722da3b919081900360200190a260019150610300565b6102fb42610652565b5b600091505b50919050565b60038190555b505600a165627a7a72305820f3c973c8b7ed1f62000b6701bd5b708469e19d0f1d73fde378a56c07fd0b19090029"
|
"code": "0x606060405236156100935763ffffffff60e060020a60003504166311ee8382811461009c57806313af4035146100be5780631f5e8f4c146100ee57806324daddc5146101125780634921a91a1461013b57806363e4bff414610157578063764978f91461017f578063893d20e8146101a1578063ba40aaa1146101cd578063cebc9a82146101f4578063e177246e14610216575b61009a5b5b565b005b34156100a457fe5b6100ac61023d565b60408051918252519081900360200190f35b34156100c657fe5b6100da600160a060020a0360043516610244565b604080519115158252519081900360200190f35b34156100f657fe5b6100da610307565b604080519115158252519081900360200190f35b341561011a57fe5b6100da6004351515610318565b604080519115158252519081900360200190f35b6100da6103d6565b604080519115158252519081900360200190f35b6100da600160a060020a0360043516610420565b604080519115158252519081900360200190f35b341561018757fe5b6100ac61046c565b60408051918252519081900360200190f35b34156101a957fe5b6101b1610473565b60408051600160a060020a039092168252519081900360200190f35b34156101d557fe5b6100da600435610483565b604080519115158252519081900360200190f35b34156101fc57fe5b6100ac61050d565b60408051918252519081900360200190f35b341561021e57fe5b6100da600435610514565b604080519115158252519081900360200190f35b6003545b90565b60006000610250610473565b600160a060020a031633600160a060020a03161415156102705760006000fd5b600160a060020a03831615156102865760006000fd5b50600054600160a060020a0390811690831681146102fb57604051600160a060020a0380851691908316907ffcf23a92150d56e85e3a3d33b357493246e55783095eb6a733eb8439ffc752c890600090a360008054600160a060020a031916600160a060020a03851617905560019150610300565b600091505b5b50919050565b60005460a060020a900460ff165b90565b60006000610324610473565b600160a060020a031633600160a060020a03161415156103445760006000fd5b5060005460a060020a900460ff16801515831515146102fb576000546040805160a060020a90920460ff1615158252841515602083015280517fe6cd46a119083b86efc6884b970bfa30c1708f53ba57b86716f15b2f4551a9539281900390910190a16000805460a060020a60ff02191660a060020a8515150217905560019150610300565b600091505b5b50919050565b60006103e0610307565b801561040557506103ef610473565b600160a060020a031633600160a060020a031614155b156104105760006000fd5b610419336105a0565b90505b5b90565b600061042a610307565b801561044f5750610439610473565b600160a060020a031633600160a060020a031614155b1561045a5760006000fd5b610463826105a0565b90505b5b919050565b6001545b90565b600054600160a060020a03165b90565b6000600061048f610473565b600160a060020a031633600160a060020a03161415156104af5760006000fd5b506001548281146102fb57604080518281526020810185905281517f79a3746dde45672c9e8ab3644b8bb9c399a103da2dc94b56ba09777330a83509929181900390910190a160018381559150610300565b600091505b5b50919050565b6002545b90565b60006000610520610473565b600160a060020a031633600160a060020a03161415156105405760006000fd5b506002548281146102fb57604080518281526020810185905281517ff6991a728965fedd6e927fdf16bdad42d8995970b4b31b8a2bf88767516e2494929181900390910190a1600283905560019150610300565b600091505b5b50919050565b60006000426105ad61023d565b116102fb576105c46105bd61050d565b4201610652565b6105cc61046c565b604051909150600160a060020a038416908290600081818185876187965a03f1925050501561063d57604080518281529051600160a060020a038516917f9bca65ce52fdef8a470977b51f247a2295123a4807dfa9e502edf0d30722da3b919081900360200190a260019150610300565b6102fb42610652565b5b600091505b50919050565b60038190555b505600a165627a7a72305820f3c973c8b7ed1f62000b6701bd5b708469e19d0f1d73fde378a56c07fd0b19090029",
|
||||||
|
"codeHash": "0xec0ba40983fafc34be1bda1b3a3c6eabdd60fa4ce6eab345be1e51bda01d0d4f"
|
||||||
},
|
},
|
||||||
"0xb436ba50d378d4bbc8660d312a13df6af6e89dfb": {
|
"0xb436ba50d378d4bbc8660d312a13df6af6e89dfb": {
|
||||||
"balance": "0x1780d77678137ac1b775",
|
"balance": "0x1780d77678137ac1b775",
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,8 @@
|
||||||
},
|
},
|
||||||
"0x000000000000000000000000000000000000bbbb": {
|
"0x000000000000000000000000000000000000bbbb": {
|
||||||
"balance": "0x0",
|
"balance": "0x0",
|
||||||
"code": "0x6042604255"
|
"code": "0x6042604255",
|
||||||
|
"codeHash":"0xfa2f0a459fb0004c3c79afe1ab7612a23f1e649b3b352242f8c7c45a0e3585b6"
|
||||||
},
|
},
|
||||||
"0x703c4b2bd70c169f5717101caee543299fc946c7": {
|
"0x703c4b2bd70c169f5717101caee543299fc946c7": {
|
||||||
"balance": "0xde0b6b3a7640000",
|
"balance": "0xde0b6b3a7640000",
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@
|
||||||
"balance": "0x4d87094125a369d9bd5",
|
"balance": "0x4d87094125a369d9bd5",
|
||||||
"nonce": 1,
|
"nonce": 1,
|
||||||
"code": "0x606060405236156100935763ffffffff60e060020a60003504166311ee8382811461009c57806313af4035146100be5780631f5e8f4c146100ee57806324daddc5146101125780634921a91a1461013b57806363e4bff414610157578063764978f91461017f578063893d20e8146101a1578063ba40aaa1146101cd578063cebc9a82146101f4578063e177246e14610216575b61009a5b5b565b005b34156100a457fe5b6100ac61023d565b60408051918252519081900360200190f35b34156100c657fe5b6100da600160a060020a0360043516610244565b604080519115158252519081900360200190f35b34156100f657fe5b6100da610307565b604080519115158252519081900360200190f35b341561011a57fe5b6100da6004351515610318565b604080519115158252519081900360200190f35b6100da6103d6565b604080519115158252519081900360200190f35b6100da600160a060020a0360043516610420565b604080519115158252519081900360200190f35b341561018757fe5b6100ac61046c565b60408051918252519081900360200190f35b34156101a957fe5b6101b1610473565b60408051600160a060020a039092168252519081900360200190f35b34156101d557fe5b6100da600435610483565b604080519115158252519081900360200190f35b34156101fc57fe5b6100ac61050d565b60408051918252519081900360200190f35b341561021e57fe5b6100da600435610514565b604080519115158252519081900360200190f35b6003545b90565b60006000610250610473565b600160a060020a031633600160a060020a03161415156102705760006000fd5b600160a060020a03831615156102865760006000fd5b50600054600160a060020a0390811690831681146102fb57604051600160a060020a0380851691908316907ffcf23a92150d56e85e3a3d33b357493246e55783095eb6a733eb8439ffc752c890600090a360008054600160a060020a031916600160a060020a03851617905560019150610300565b600091505b5b50919050565b60005460a060020a900460ff165b90565b60006000610324610473565b600160a060020a031633600160a060020a03161415156103445760006000fd5b5060005460a060020a900460ff16801515831515146102fb576000546040805160a060020a90920460ff1615158252841515602083015280517fe6cd46a119083b86efc6884b970bfa30c1708f53ba57b86716f15b2f4551a9539281900390910190a16000805460a060020a60ff02191660a060020a8515150217905560019150610300565b600091505b5b50919050565b60006103e0610307565b801561040557506103ef610473565b600160a060020a031633600160a060020a031614155b156104105760006000fd5b610419336105a0565b90505b5b90565b600061042a610307565b801561044f5750610439610473565b600160a060020a031633600160a060020a031614155b1561045a5760006000fd5b610463826105a0565b90505b5b919050565b6001545b90565b600054600160a060020a03165b90565b6000600061048f610473565b600160a060020a031633600160a060020a03161415156104af5760006000fd5b506001548281146102fb57604080518281526020810185905281517f79a3746dde45672c9e8ab3644b8bb9c399a103da2dc94b56ba09777330a83509929181900390910190a160018381559150610300565b600091505b5b50919050565b6002545b90565b60006000610520610473565b600160a060020a031633600160a060020a03161415156105405760006000fd5b506002548281146102fb57604080518281526020810185905281517ff6991a728965fedd6e927fdf16bdad42d8995970b4b31b8a2bf88767516e2494929181900390910190a1600283905560019150610300565b600091505b5b50919050565b60006000426105ad61023d565b116102fb576105c46105bd61050d565b4201610652565b6105cc61046c565b604051909150600160a060020a038416908290600081818185876187965a03f1925050501561063d57604080518281529051600160a060020a038516917f9bca65ce52fdef8a470977b51f247a2295123a4807dfa9e502edf0d30722da3b919081900360200190a260019150610300565b6102fb42610652565b5b600091505b50919050565b60038190555b505600a165627a7a72305820f3c973c8b7ed1f62000b6701bd5b708469e19d0f1d73fde378a56c07fd0b19090029",
|
"code": "0x606060405236156100935763ffffffff60e060020a60003504166311ee8382811461009c57806313af4035146100be5780631f5e8f4c146100ee57806324daddc5146101125780634921a91a1461013b57806363e4bff414610157578063764978f91461017f578063893d20e8146101a1578063ba40aaa1146101cd578063cebc9a82146101f4578063e177246e14610216575b61009a5b5b565b005b34156100a457fe5b6100ac61023d565b60408051918252519081900360200190f35b34156100c657fe5b6100da600160a060020a0360043516610244565b604080519115158252519081900360200190f35b34156100f657fe5b6100da610307565b604080519115158252519081900360200190f35b341561011a57fe5b6100da6004351515610318565b604080519115158252519081900360200190f35b6100da6103d6565b604080519115158252519081900360200190f35b6100da600160a060020a0360043516610420565b604080519115158252519081900360200190f35b341561018757fe5b6100ac61046c565b60408051918252519081900360200190f35b34156101a957fe5b6101b1610473565b60408051600160a060020a039092168252519081900360200190f35b34156101d557fe5b6100da600435610483565b604080519115158252519081900360200190f35b34156101fc57fe5b6100ac61050d565b60408051918252519081900360200190f35b341561021e57fe5b6100da600435610514565b604080519115158252519081900360200190f35b6003545b90565b60006000610250610473565b600160a060020a031633600160a060020a03161415156102705760006000fd5b600160a060020a03831615156102865760006000fd5b50600054600160a060020a0390811690831681146102fb57604051600160a060020a0380851691908316907ffcf23a92150d56e85e3a3d33b357493246e55783095eb6a733eb8439ffc752c890600090a360008054600160a060020a031916600160a060020a03851617905560019150610300565b600091505b5b50919050565b60005460a060020a900460ff165b90565b60006000610324610473565b600160a060020a031633600160a060020a03161415156103445760006000fd5b5060005460a060020a900460ff16801515831515146102fb576000546040805160a060020a90920460ff1615158252841515602083015280517fe6cd46a119083b86efc6884b970bfa30c1708f53ba57b86716f15b2f4551a9539281900390910190a16000805460a060020a60ff02191660a060020a8515150217905560019150610300565b600091505b5b50919050565b60006103e0610307565b801561040557506103ef610473565b600160a060020a031633600160a060020a031614155b156104105760006000fd5b610419336105a0565b90505b5b90565b600061042a610307565b801561044f5750610439610473565b600160a060020a031633600160a060020a031614155b1561045a5760006000fd5b610463826105a0565b90505b5b919050565b6001545b90565b600054600160a060020a03165b90565b6000600061048f610473565b600160a060020a031633600160a060020a03161415156104af5760006000fd5b506001548281146102fb57604080518281526020810185905281517f79a3746dde45672c9e8ab3644b8bb9c399a103da2dc94b56ba09777330a83509929181900390910190a160018381559150610300565b600091505b5b50919050565b6002545b90565b60006000610520610473565b600160a060020a031633600160a060020a03161415156105405760006000fd5b506002548281146102fb57604080518281526020810185905281517ff6991a728965fedd6e927fdf16bdad42d8995970b4b31b8a2bf88767516e2494929181900390910190a1600283905560019150610300565b600091505b5b50919050565b60006000426105ad61023d565b116102fb576105c46105bd61050d565b4201610652565b6105cc61046c565b604051909150600160a060020a038416908290600081818185876187965a03f1925050501561063d57604080518281529051600160a060020a038516917f9bca65ce52fdef8a470977b51f247a2295123a4807dfa9e502edf0d30722da3b919081900360200190a260019150610300565b6102fb42610652565b5b600091505b50919050565b60038190555b505600a165627a7a72305820f3c973c8b7ed1f62000b6701bd5b708469e19d0f1d73fde378a56c07fd0b19090029",
|
||||||
|
"codeHash": "0xec0ba40983fafc34be1bda1b3a3c6eabdd60fa4ce6eab345be1e51bda01d0d4f",
|
||||||
"storage": {
|
"storage": {
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000001b436ba50d378d4bbc8660d312a13df6af6e89dfb",
|
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000001b436ba50d378d4bbc8660d312a13df6af6e89dfb",
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x00000000000000000000000000000000000000000000000006f05b59d3b20000",
|
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x00000000000000000000000000000000000000000000000006f05b59d3b20000",
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@
|
||||||
},
|
},
|
||||||
"0x40f2f445da6c9047554683fb382fba6769717116": {
|
"0x40f2f445da6c9047554683fb382fba6769717116": {
|
||||||
"code": "0x60606040526000357c01000000000000000000000000000000000000000000000000000000009004806341c0e1b514610044578063cfae32171461005157610042565b005b61004f6004506100ca565b005b61005c60045061015e565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156100bc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561015b57600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b5b565b60206040519081016040528060008152602001506001600050805480601f016020809104026020016040519081016040528092919081815260200182805480156101cd57820191906000526020600020905b8154815290600101906020018083116101b057829003601f168201915b505050505090506101d9565b9056",
|
"code": "0x60606040526000357c01000000000000000000000000000000000000000000000000000000009004806341c0e1b514610044578063cfae32171461005157610042565b005b61004f6004506100ca565b005b61005c60045061015e565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156100bc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561015b57600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b5b565b60206040519081016040528060008152602001506001600050805480601f016020809104026020016040519081016040528092919081815260200182805480156101cd57820191906000526020600020905b8154815290600101906020018083116101b057829003601f168201915b505050505090506101d9565b9056",
|
||||||
|
"codeHash": "0x19463d2ef23c9fcb3f853199279ecc9b21fa4147112bfe85664141ffbffd1a37",
|
||||||
"storage": {
|
"storage": {
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000f0c5cef39b17c213cfe090a46b8c7760ffb7928a",
|
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000f0c5cef39b17c213cfe090a46b8c7760ffb7928a",
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x00000000000000000000000000000000000000000000000000000000000001ee",
|
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x00000000000000000000000000000000000000000000000000000000000001ee",
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@
|
||||||
"balance": "0x9fb71abdd2621d8886"
|
"balance": "0x9fb71abdd2621d8886"
|
||||||
},
|
},
|
||||||
"0x40f2f445da6c9047554683fb382fba6769717116": {
|
"0x40f2f445da6c9047554683fb382fba6769717116": {
|
||||||
|
"codeHash":"0x19463d2ef23c9fcb3f853199279ecc9b21fa4147112bfe85664141ffbffd1a37",
|
||||||
"storage": {
|
"storage": {
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000f0c5cef39b17c213cfe090a46b8c7760ffb7928a",
|
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000f0c5cef39b17c213cfe090a46b8c7760ffb7928a",
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x00000000000000000000000000000000000000000000000000000000000001ee",
|
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x00000000000000000000000000000000000000000000000000000000000001ee",
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,8 @@
|
||||||
"balance": "0x9fb71abdd2621d8886"
|
"balance": "0x9fb71abdd2621d8886"
|
||||||
},
|
},
|
||||||
"0x40f2f445da6c9047554683fb382fba6769717116": {
|
"0x40f2f445da6c9047554683fb382fba6769717116": {
|
||||||
"code": "0x60606040526000357c01000000000000000000000000000000000000000000000000000000009004806341c0e1b514610044578063cfae32171461005157610042565b005b61004f6004506100ca565b005b61005c60045061015e565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156100bc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561015b57600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b5b565b60206040519081016040528060008152602001506001600050805480601f016020809104026020016040519081016040528092919081815260200182805480156101cd57820191906000526020600020905b8154815290600101906020018083116101b057829003601f168201915b505050505090506101d9565b9056"
|
"code": "0x60606040526000357c01000000000000000000000000000000000000000000000000000000009004806341c0e1b514610044578063cfae32171461005157610042565b005b61004f6004506100ca565b005b61005c60045061015e565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156100bc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561015b57600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b5b565b60206040519081016040528060008152602001506001600050805480601f016020809104026020016040519081016040528092919081815260200182805480156101cd57820191906000526020600020905b8154815290600101906020018083116101b057829003601f168201915b505050505090506101d9565b9056",
|
||||||
|
"codeHash": "0x19463d2ef23c9fcb3f853199279ecc9b21fa4147112bfe85664141ffbffd1a37"
|
||||||
},
|
},
|
||||||
"0xf0c5cef39b17c213cfe090a46b8c7760ffb7928a": {
|
"0xf0c5cef39b17c213cfe090a46b8c7760ffb7928a": {
|
||||||
"balance": "0x15b058920efcc5188",
|
"balance": "0x15b058920efcc5188",
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,9 @@
|
||||||
"result": {
|
"result": {
|
||||||
"post": {
|
"post": {
|
||||||
"0x1bda2f8e4735507930bd6cfe873bf0bf0f4ab1de": {
|
"0x1bda2f8e4735507930bd6cfe873bf0bf0f4ab1de": {
|
||||||
|
"nonce": 1,
|
||||||
"code": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c806309ce9ccb1461003b5780633fb5c1cb14610059575b600080fd5b610043610075565b60405161005091906100e2565b60405180910390f35b610073600480360381019061006e919061012e565b61007b565b005b60005481565b80600081905550600a8111156100c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd906101de565b60405180910390fd5b50565b6000819050919050565b6100dc816100c9565b82525050565b60006020820190506100f760008301846100d3565b92915050565b600080fd5b61010b816100c9565b811461011657600080fd5b50565b60008135905061012881610102565b92915050565b600060208284031215610144576101436100fd565b5b600061015284828501610119565b91505092915050565b600082825260208201905092915050565b7f4e756d6265722069732067726561746572207468616e2031302c207472616e7360008201527f616374696f6e2072657665727465642e00000000000000000000000000000000602082015250565b60006101c860308361015b565b91506101d38261016c565b604082019050919050565b600060208201905081810360008301526101f7816101bb565b905091905056fea264697066735822122069018995fecf03bda91a88b6eafe41641709dee8b4a706fe301c8a569fe8c1b364736f6c63430008130033",
|
"code": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c806309ce9ccb1461003b5780633fb5c1cb14610059575b600080fd5b610043610075565b60405161005091906100e2565b60405180910390f35b610073600480360381019061006e919061012e565b61007b565b005b60005481565b80600081905550600a8111156100c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bd906101de565b60405180910390fd5b50565b6000819050919050565b6100dc816100c9565b82525050565b60006020820190506100f760008301846100d3565b92915050565b600080fd5b61010b816100c9565b811461011657600080fd5b50565b60008135905061012881610102565b92915050565b600060208284031215610144576101436100fd565b5b600061015284828501610119565b91505092915050565b600082825260208201905092915050565b7f4e756d6265722069732067726561746572207468616e2031302c207472616e7360008201527f616374696f6e2072657665727465642e00000000000000000000000000000000602082015250565b60006101c860308361015b565b91506101d38261016c565b604082019050919050565b600060208201905081810360008301526101f7816101bb565b905091905056fea264697066735822122069018995fecf03bda91a88b6eafe41641709dee8b4a706fe301c8a569fe8c1b364736f6c63430008130033",
|
||||||
"nonce": 1
|
"codeHash": "0xf6387add93966c115d42eb1ecd36a1fa28841703312943db753b88f890cc1666"
|
||||||
},
|
},
|
||||||
"0x2445e8c26a2bf3d1e59f1bb9b1d442caf90768e0": {
|
"0x2445e8c26a2bf3d1e59f1bb9b1d442caf90768e0": {
|
||||||
"balance": "0x10f0645688331eb5690"
|
"balance": "0x10f0645688331eb5690"
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -211,13 +211,16 @@
|
||||||
},
|
},
|
||||||
"0x6c8f2a135f6ed072de4503bd7c4999a1a17f824b": {
|
"0x6c8f2a135f6ed072de4503bd7c4999a1a17f824b": {
|
||||||
"balance": "0x0",
|
"balance": "0x0",
|
||||||
"nonce": 237
|
"nonce": 237,
|
||||||
|
"codeHash":"0x461e17b7ae561793f22843985fc6866a3395c1fcee8ebf2d7ed5f293aec1b473"
|
||||||
},
|
},
|
||||||
"0x741467b251fca923d6229c4b439078b55dca233b": {
|
"0x741467b251fca923d6229c4b439078b55dca233b": {
|
||||||
"balance": "0x29c613529e8218f8"
|
"balance": "0x29c613529e8218f8",
|
||||||
|
"codeHash":"0x7678943ba1f399d76abe8e77b6f899c193f72aaefb5c4bd47fffb63c7f57ad9e"
|
||||||
},
|
},
|
||||||
"0x7dd677b54fc954824a7bc49bd26cbdfa12c75adf": {
|
"0x7dd677b54fc954824a7bc49bd26cbdfa12c75adf": {
|
||||||
"balance": "0xd7a58f5b73b4b6c4"
|
"balance": "0xd7a58f5b73b4b6c4",
|
||||||
|
"codeHash":"0xd1255e5eabbe40c6e18c87b2ed2acf8157356103d1ca1df617f7b52811edefc4"
|
||||||
},
|
},
|
||||||
"0xb834e3edfc1a927bdcecb67a9d0eccbd752a5bb3": {
|
"0xb834e3edfc1a927bdcecb67a9d0eccbd752a5bb3": {
|
||||||
"balance": "0xffe9b09a5c474dca",
|
"balance": "0xffe9b09a5c474dca",
|
||||||
|
|
@ -233,7 +236,8 @@
|
||||||
"balance": "0x98e2b02f14529b1eb2"
|
"balance": "0x98e2b02f14529b1eb2"
|
||||||
},
|
},
|
||||||
"0x651913977e8140c323997fce5e03c19e0015eebf": {
|
"0x651913977e8140c323997fce5e03c19e0015eebf": {
|
||||||
"balance": "0x29a2241af62c0000"
|
"balance": "0x29a2241af62c0000",
|
||||||
|
"codeHash":"0x7678943ba1f399d76abe8e77b6f899c193f72aaefb5c4bd47fffb63c7f57ad9e"
|
||||||
},
|
},
|
||||||
"0x6c8f2a135f6ed072de4503bd7c4999a1a17f824b": {
|
"0x6c8f2a135f6ed072de4503bd7c4999a1a17f824b": {
|
||||||
"nonce": 238
|
"nonce": 238
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@
|
||||||
"balance": "0x4d87094125a369d9bd5",
|
"balance": "0x4d87094125a369d9bd5",
|
||||||
"nonce": 1,
|
"nonce": 1,
|
||||||
"code": "0x606060405236156100935763ffffffff60e060020a60003504166311ee8382811461009c57806313af4035146100be5780631f5e8f4c146100ee57806324daddc5146101125780634921a91a1461013b57806363e4bff414610157578063764978f91461017f578063893d20e8146101a1578063ba40aaa1146101cd578063cebc9a82146101f4578063e177246e14610216575b61009a5b5b565b005b34156100a457fe5b6100ac61023d565b60408051918252519081900360200190f35b34156100c657fe5b6100da600160a060020a0360043516610244565b604080519115158252519081900360200190f35b34156100f657fe5b6100da610307565b604080519115158252519081900360200190f35b341561011a57fe5b6100da6004351515610318565b604080519115158252519081900360200190f35b6100da6103d6565b604080519115158252519081900360200190f35b6100da600160a060020a0360043516610420565b604080519115158252519081900360200190f35b341561018757fe5b6100ac61046c565b60408051918252519081900360200190f35b34156101a957fe5b6101b1610473565b60408051600160a060020a039092168252519081900360200190f35b34156101d557fe5b6100da600435610483565b604080519115158252519081900360200190f35b34156101fc57fe5b6100ac61050d565b60408051918252519081900360200190f35b341561021e57fe5b6100da600435610514565b604080519115158252519081900360200190f35b6003545b90565b60006000610250610473565b600160a060020a031633600160a060020a03161415156102705760006000fd5b600160a060020a03831615156102865760006000fd5b50600054600160a060020a0390811690831681146102fb57604051600160a060020a0380851691908316907ffcf23a92150d56e85e3a3d33b357493246e55783095eb6a733eb8439ffc752c890600090a360008054600160a060020a031916600160a060020a03851617905560019150610300565b600091505b5b50919050565b60005460a060020a900460ff165b90565b60006000610324610473565b600160a060020a031633600160a060020a03161415156103445760006000fd5b5060005460a060020a900460ff16801515831515146102fb576000546040805160a060020a90920460ff1615158252841515602083015280517fe6cd46a119083b86efc6884b970bfa30c1708f53ba57b86716f15b2f4551a9539281900390910190a16000805460a060020a60ff02191660a060020a8515150217905560019150610300565b600091505b5b50919050565b60006103e0610307565b801561040557506103ef610473565b600160a060020a031633600160a060020a031614155b156104105760006000fd5b610419336105a0565b90505b5b90565b600061042a610307565b801561044f5750610439610473565b600160a060020a031633600160a060020a031614155b1561045a5760006000fd5b610463826105a0565b90505b5b919050565b6001545b90565b600054600160a060020a03165b90565b6000600061048f610473565b600160a060020a031633600160a060020a03161415156104af5760006000fd5b506001548281146102fb57604080518281526020810185905281517f79a3746dde45672c9e8ab3644b8bb9c399a103da2dc94b56ba09777330a83509929181900390910190a160018381559150610300565b600091505b5b50919050565b6002545b90565b60006000610520610473565b600160a060020a031633600160a060020a03161415156105405760006000fd5b506002548281146102fb57604080518281526020810185905281517ff6991a728965fedd6e927fdf16bdad42d8995970b4b31b8a2bf88767516e2494929181900390910190a1600283905560019150610300565b600091505b5b50919050565b60006000426105ad61023d565b116102fb576105c46105bd61050d565b4201610652565b6105cc61046c565b604051909150600160a060020a038416908290600081818185876187965a03f1925050501561063d57604080518281529051600160a060020a038516917f9bca65ce52fdef8a470977b51f247a2295123a4807dfa9e502edf0d30722da3b919081900360200190a260019150610300565b6102fb42610652565b5b600091505b50919050565b60038190555b505600a165627a7a72305820f3c973c8b7ed1f62000b6701bd5b708469e19d0f1d73fde378a56c07fd0b19090029",
|
"code": "0x606060405236156100935763ffffffff60e060020a60003504166311ee8382811461009c57806313af4035146100be5780631f5e8f4c146100ee57806324daddc5146101125780634921a91a1461013b57806363e4bff414610157578063764978f91461017f578063893d20e8146101a1578063ba40aaa1146101cd578063cebc9a82146101f4578063e177246e14610216575b61009a5b5b565b005b34156100a457fe5b6100ac61023d565b60408051918252519081900360200190f35b34156100c657fe5b6100da600160a060020a0360043516610244565b604080519115158252519081900360200190f35b34156100f657fe5b6100da610307565b604080519115158252519081900360200190f35b341561011a57fe5b6100da6004351515610318565b604080519115158252519081900360200190f35b6100da6103d6565b604080519115158252519081900360200190f35b6100da600160a060020a0360043516610420565b604080519115158252519081900360200190f35b341561018757fe5b6100ac61046c565b60408051918252519081900360200190f35b34156101a957fe5b6101b1610473565b60408051600160a060020a039092168252519081900360200190f35b34156101d557fe5b6100da600435610483565b604080519115158252519081900360200190f35b34156101fc57fe5b6100ac61050d565b60408051918252519081900360200190f35b341561021e57fe5b6100da600435610514565b604080519115158252519081900360200190f35b6003545b90565b60006000610250610473565b600160a060020a031633600160a060020a03161415156102705760006000fd5b600160a060020a03831615156102865760006000fd5b50600054600160a060020a0390811690831681146102fb57604051600160a060020a0380851691908316907ffcf23a92150d56e85e3a3d33b357493246e55783095eb6a733eb8439ffc752c890600090a360008054600160a060020a031916600160a060020a03851617905560019150610300565b600091505b5b50919050565b60005460a060020a900460ff165b90565b60006000610324610473565b600160a060020a031633600160a060020a03161415156103445760006000fd5b5060005460a060020a900460ff16801515831515146102fb576000546040805160a060020a90920460ff1615158252841515602083015280517fe6cd46a119083b86efc6884b970bfa30c1708f53ba57b86716f15b2f4551a9539281900390910190a16000805460a060020a60ff02191660a060020a8515150217905560019150610300565b600091505b5b50919050565b60006103e0610307565b801561040557506103ef610473565b600160a060020a031633600160a060020a031614155b156104105760006000fd5b610419336105a0565b90505b5b90565b600061042a610307565b801561044f5750610439610473565b600160a060020a031633600160a060020a031614155b1561045a5760006000fd5b610463826105a0565b90505b5b919050565b6001545b90565b600054600160a060020a03165b90565b6000600061048f610473565b600160a060020a031633600160a060020a03161415156104af5760006000fd5b506001548281146102fb57604080518281526020810185905281517f79a3746dde45672c9e8ab3644b8bb9c399a103da2dc94b56ba09777330a83509929181900390910190a160018381559150610300565b600091505b5b50919050565b6002545b90565b60006000610520610473565b600160a060020a031633600160a060020a03161415156105405760006000fd5b506002548281146102fb57604080518281526020810185905281517ff6991a728965fedd6e927fdf16bdad42d8995970b4b31b8a2bf88767516e2494929181900390910190a1600283905560019150610300565b600091505b5b50919050565b60006000426105ad61023d565b116102fb576105c46105bd61050d565b4201610652565b6105cc61046c565b604051909150600160a060020a038416908290600081818185876187965a03f1925050501561063d57604080518281529051600160a060020a038516917f9bca65ce52fdef8a470977b51f247a2295123a4807dfa9e502edf0d30722da3b919081900360200190a260019150610300565b6102fb42610652565b5b600091505b50919050565b60038190555b505600a165627a7a72305820f3c973c8b7ed1f62000b6701bd5b708469e19d0f1d73fde378a56c07fd0b19090029",
|
||||||
|
"codeHash": "0xec0ba40983fafc34be1bda1b3a3c6eabdd60fa4ce6eab345be1e51bda01d0d4f",
|
||||||
"storage": {
|
"storage": {
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x000000000000000000000000000000000000000000000000000000005a37b834"
|
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x000000000000000000000000000000000000000000000000000000005a37b834"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@
|
||||||
"balance": "0x4d87094125a369d9bd5",
|
"balance": "0x4d87094125a369d9bd5",
|
||||||
"nonce": 1,
|
"nonce": 1,
|
||||||
"code": "0x606060405236156100935763ffffffff60e060020a60003504166311ee8382811461009c57806313af4035146100be5780631f5e8f4c146100ee57806324daddc5146101125780634921a91a1461013b57806363e4bff414610157578063764978f91461017f578063893d20e8146101a1578063ba40aaa1146101cd578063cebc9a82146101f4578063e177246e14610216575b61009a5b5b565b005b34156100a457fe5b6100ac61023d565b60408051918252519081900360200190f35b34156100c657fe5b6100da600160a060020a0360043516610244565b604080519115158252519081900360200190f35b34156100f657fe5b6100da610307565b604080519115158252519081900360200190f35b341561011a57fe5b6100da6004351515610318565b604080519115158252519081900360200190f35b6100da6103d6565b604080519115158252519081900360200190f35b6100da600160a060020a0360043516610420565b604080519115158252519081900360200190f35b341561018757fe5b6100ac61046c565b60408051918252519081900360200190f35b34156101a957fe5b6101b1610473565b60408051600160a060020a039092168252519081900360200190f35b34156101d557fe5b6100da600435610483565b604080519115158252519081900360200190f35b34156101fc57fe5b6100ac61050d565b60408051918252519081900360200190f35b341561021e57fe5b6100da600435610514565b604080519115158252519081900360200190f35b6003545b90565b60006000610250610473565b600160a060020a031633600160a060020a03161415156102705760006000fd5b600160a060020a03831615156102865760006000fd5b50600054600160a060020a0390811690831681146102fb57604051600160a060020a0380851691908316907ffcf23a92150d56e85e3a3d33b357493246e55783095eb6a733eb8439ffc752c890600090a360008054600160a060020a031916600160a060020a03851617905560019150610300565b600091505b5b50919050565b60005460a060020a900460ff165b90565b60006000610324610473565b600160a060020a031633600160a060020a03161415156103445760006000fd5b5060005460a060020a900460ff16801515831515146102fb576000546040805160a060020a90920460ff1615158252841515602083015280517fe6cd46a119083b86efc6884b970bfa30c1708f53ba57b86716f15b2f4551a9539281900390910190a16000805460a060020a60ff02191660a060020a8515150217905560019150610300565b600091505b5b50919050565b60006103e0610307565b801561040557506103ef610473565b600160a060020a031633600160a060020a031614155b156104105760006000fd5b610419336105a0565b90505b5b90565b600061042a610307565b801561044f5750610439610473565b600160a060020a031633600160a060020a031614155b1561045a5760006000fd5b610463826105a0565b90505b5b919050565b6001545b90565b600054600160a060020a03165b90565b6000600061048f610473565b600160a060020a031633600160a060020a03161415156104af5760006000fd5b506001548281146102fb57604080518281526020810185905281517f79a3746dde45672c9e8ab3644b8bb9c399a103da2dc94b56ba09777330a83509929181900390910190a160018381559150610300565b600091505b5b50919050565b6002545b90565b60006000610520610473565b600160a060020a031633600160a060020a03161415156105405760006000fd5b506002548281146102fb57604080518281526020810185905281517ff6991a728965fedd6e927fdf16bdad42d8995970b4b31b8a2bf88767516e2494929181900390910190a1600283905560019150610300565b600091505b5b50919050565b60006000426105ad61023d565b116102fb576105c46105bd61050d565b4201610652565b6105cc61046c565b604051909150600160a060020a038416908290600081818185876187965a03f1925050501561063d57604080518281529051600160a060020a038516917f9bca65ce52fdef8a470977b51f247a2295123a4807dfa9e502edf0d30722da3b919081900360200190a260019150610300565b6102fb42610652565b5b600091505b50919050565b60038190555b505600a165627a7a72305820f3c973c8b7ed1f62000b6701bd5b708469e19d0f1d73fde378a56c07fd0b19090029",
|
"code": "0x606060405236156100935763ffffffff60e060020a60003504166311ee8382811461009c57806313af4035146100be5780631f5e8f4c146100ee57806324daddc5146101125780634921a91a1461013b57806363e4bff414610157578063764978f91461017f578063893d20e8146101a1578063ba40aaa1146101cd578063cebc9a82146101f4578063e177246e14610216575b61009a5b5b565b005b34156100a457fe5b6100ac61023d565b60408051918252519081900360200190f35b34156100c657fe5b6100da600160a060020a0360043516610244565b604080519115158252519081900360200190f35b34156100f657fe5b6100da610307565b604080519115158252519081900360200190f35b341561011a57fe5b6100da6004351515610318565b604080519115158252519081900360200190f35b6100da6103d6565b604080519115158252519081900360200190f35b6100da600160a060020a0360043516610420565b604080519115158252519081900360200190f35b341561018757fe5b6100ac61046c565b60408051918252519081900360200190f35b34156101a957fe5b6101b1610473565b60408051600160a060020a039092168252519081900360200190f35b34156101d557fe5b6100da600435610483565b604080519115158252519081900360200190f35b34156101fc57fe5b6100ac61050d565b60408051918252519081900360200190f35b341561021e57fe5b6100da600435610514565b604080519115158252519081900360200190f35b6003545b90565b60006000610250610473565b600160a060020a031633600160a060020a03161415156102705760006000fd5b600160a060020a03831615156102865760006000fd5b50600054600160a060020a0390811690831681146102fb57604051600160a060020a0380851691908316907ffcf23a92150d56e85e3a3d33b357493246e55783095eb6a733eb8439ffc752c890600090a360008054600160a060020a031916600160a060020a03851617905560019150610300565b600091505b5b50919050565b60005460a060020a900460ff165b90565b60006000610324610473565b600160a060020a031633600160a060020a03161415156103445760006000fd5b5060005460a060020a900460ff16801515831515146102fb576000546040805160a060020a90920460ff1615158252841515602083015280517fe6cd46a119083b86efc6884b970bfa30c1708f53ba57b86716f15b2f4551a9539281900390910190a16000805460a060020a60ff02191660a060020a8515150217905560019150610300565b600091505b5b50919050565b60006103e0610307565b801561040557506103ef610473565b600160a060020a031633600160a060020a031614155b156104105760006000fd5b610419336105a0565b90505b5b90565b600061042a610307565b801561044f5750610439610473565b600160a060020a031633600160a060020a031614155b1561045a5760006000fd5b610463826105a0565b90505b5b919050565b6001545b90565b600054600160a060020a03165b90565b6000600061048f610473565b600160a060020a031633600160a060020a03161415156104af5760006000fd5b506001548281146102fb57604080518281526020810185905281517f79a3746dde45672c9e8ab3644b8bb9c399a103da2dc94b56ba09777330a83509929181900390910190a160018381559150610300565b600091505b5b50919050565b6002545b90565b60006000610520610473565b600160a060020a031633600160a060020a03161415156105405760006000fd5b506002548281146102fb57604080518281526020810185905281517ff6991a728965fedd6e927fdf16bdad42d8995970b4b31b8a2bf88767516e2494929181900390910190a1600283905560019150610300565b600091505b5b50919050565b60006000426105ad61023d565b116102fb576105c46105bd61050d565b4201610652565b6105cc61046c565b604051909150600160a060020a038416908290600081818185876187965a03f1925050501561063d57604080518281529051600160a060020a038516917f9bca65ce52fdef8a470977b51f247a2295123a4807dfa9e502edf0d30722da3b919081900360200190a260019150610300565b6102fb42610652565b5b600091505b50919050565b60038190555b505600a165627a7a72305820f3c973c8b7ed1f62000b6701bd5b708469e19d0f1d73fde378a56c07fd0b19090029",
|
||||||
|
"codeHash": "0xec0ba40983fafc34be1bda1b3a3c6eabdd60fa4ce6eab345be1e51bda01d0d4f",
|
||||||
"storage": {
|
"storage": {
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x000000000000000000000000000000000000000000000000000000005a37b834"
|
"0x0000000000000000000000000000000000000000000000000000000000000003": "0x000000000000000000000000000000000000000000000000000000005a37b834"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@
|
||||||
"0x2861bf89b6c640c79040d357c1e9513693ef5d3f": {
|
"0x2861bf89b6c640c79040d357c1e9513693ef5d3f": {
|
||||||
"balance": "0x0",
|
"balance": "0x0",
|
||||||
"code": "0x606060405236156100825760e060020a600035046312055e8f8114610084578063185061da146100b157806322beb9b9146100d5578063245a03ec146101865780633fa4f245146102a657806341c0e1b5146102af578063890eba68146102cb578063b29f0835146102de578063d6b4485914610308578063dd012a15146103b9575b005b6001805474ff0000000000000000000000000000000000000000191660a060020a60043502179055610082565b6100826001805475ff00000000000000000000000000000000000000000019169055565b61008260043560015460e060020a6352afbc3302606090815230600160a060020a039081166064527fb29f0835000000000000000000000000000000000000000000000000000000006084527fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060a45243840160c490815260ff60a060020a85041660e452600061010481905291909316926352afbc339261012492918183876161da5a03f1156100025750505050565b6100826004356024356001547fb0f07e440000000000000000000000000000000000000000000000000000000060609081526064839052600160a060020a039091169063b0f07e449060849060009060248183876161da5a03f150604080516001547f73657449742875696e74323536290000000000000000000000000000000000008252825191829003600e018220878352835192839003602001832060e060020a6352afbc33028452600160a060020a03308116600486015260e060020a9283900490920260248501526044840152438901606484015260a060020a820460ff1694830194909452600060a483018190529251931694506352afbc33935060c48181019391829003018183876161da5a03f115610002575050505050565b6103c460025481565b61008260005433600160a060020a039081169116146103ce575b565b6103c460015460a860020a900460ff1681565b6100826001805475ff000000000000000000000000000000000000000000191660a860020a179055565b61008260043560015460e060020a6352afbc3302606090815230600160a060020a039081166064527f185061da000000000000000000000000000000000000000000000000000000006084527fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060a45243840160c490815260ff60a060020a85041660e452600061010481905291909316926352afbc339261012492918183876161da5a03f1156100025750505050565b600435600255610082565b6060908152602090f35b6001547f6ff96d17000000000000000000000000000000000000000000000000000000006060908152600160a060020a0330811660645290911690632e1a7d4d908290636ff96d17906084906020906024816000876161da5a03f1156100025750506040805180517f2e1a7d4d0000000000000000000000000000000000000000000000000000000082526004820152905160248281019350600092829003018183876161da5a03f115610002575050600054600160a060020a03169050ff",
|
"code": "0x606060405236156100825760e060020a600035046312055e8f8114610084578063185061da146100b157806322beb9b9146100d5578063245a03ec146101865780633fa4f245146102a657806341c0e1b5146102af578063890eba68146102cb578063b29f0835146102de578063d6b4485914610308578063dd012a15146103b9575b005b6001805474ff0000000000000000000000000000000000000000191660a060020a60043502179055610082565b6100826001805475ff00000000000000000000000000000000000000000019169055565b61008260043560015460e060020a6352afbc3302606090815230600160a060020a039081166064527fb29f0835000000000000000000000000000000000000000000000000000000006084527fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060a45243840160c490815260ff60a060020a85041660e452600061010481905291909316926352afbc339261012492918183876161da5a03f1156100025750505050565b6100826004356024356001547fb0f07e440000000000000000000000000000000000000000000000000000000060609081526064839052600160a060020a039091169063b0f07e449060849060009060248183876161da5a03f150604080516001547f73657449742875696e74323536290000000000000000000000000000000000008252825191829003600e018220878352835192839003602001832060e060020a6352afbc33028452600160a060020a03308116600486015260e060020a9283900490920260248501526044840152438901606484015260a060020a820460ff1694830194909452600060a483018190529251931694506352afbc33935060c48181019391829003018183876161da5a03f115610002575050505050565b6103c460025481565b61008260005433600160a060020a039081169116146103ce575b565b6103c460015460a860020a900460ff1681565b6100826001805475ff000000000000000000000000000000000000000000191660a860020a179055565b61008260043560015460e060020a6352afbc3302606090815230600160a060020a039081166064527f185061da000000000000000000000000000000000000000000000000000000006084527fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060a45243840160c490815260ff60a060020a85041660e452600061010481905291909316926352afbc339261012492918183876161da5a03f1156100025750505050565b600435600255610082565b6060908152602090f35b6001547f6ff96d17000000000000000000000000000000000000000000000000000000006060908152600160a060020a0330811660645290911690632e1a7d4d908290636ff96d17906084906020906024816000876161da5a03f1156100025750506040805180517f2e1a7d4d0000000000000000000000000000000000000000000000000000000082526004820152905160248281019350600092829003018183876161da5a03f115610002575050600054600160a060020a03169050ff",
|
||||||
|
"codeHash": "0xad3e5642a709b936c0eafdd1fbca08a9f5f5089ff2008efeee3eed3f110d83d3",
|
||||||
"storage": {
|
"storage": {
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000d3cda913deb6f67967b99d67acdfa1712c293601",
|
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000d3cda913deb6f67967b99d67acdfa1712c293601",
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000ff30c9e568f133adce1f1ea91e189613223fc461b9"
|
"0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000ff30c9e568f133adce1f1ea91e189613223fc461b9"
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ func runTrace(tracer *tracers.Tracer, vmctx *vmContext, chaincfg *params.ChainCo
|
||||||
|
|
||||||
tracer.OnTxStart(evm.GetVMContext(), types.NewTx(&types.LegacyTx{Gas: gasLimit, GasPrice: vmctx.txCtx.GasPrice}), contract.Caller())
|
tracer.OnTxStart(evm.GetVMContext(), types.NewTx(&types.LegacyTx{Gas: gasLimit, GasPrice: vmctx.txCtx.GasPrice}), contract.Caller())
|
||||||
tracer.OnEnter(0, byte(vm.CALL), contract.Caller(), contract.Address(), []byte{}, startGas, value.ToBig())
|
tracer.OnEnter(0, byte(vm.CALL), contract.Caller(), contract.Address(), []byte{}, startGas, value.ToBig())
|
||||||
ret, err := evm.Interpreter().Run(contract, []byte{}, false)
|
ret, err := evm.Run(contract, []byte{}, false)
|
||||||
tracer.OnExit(0, ret, startGas-contract.Gas, err, true)
|
tracer.OnExit(0, ret, startGas-contract.Gas, err, true)
|
||||||
// Rest gas assumes no refund
|
// Rest gas assumes no refund
|
||||||
tracer.OnTxEnd(&types.Receipt{GasUsed: gasLimit - contract.Gas}, nil)
|
tracer.OnTxEnd(&types.Receipt{GasUsed: gasLimit - contract.Gas}, nil)
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ func TestStoreCapture(t *testing.T) {
|
||||||
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x0, byte(vm.SSTORE)}
|
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x0, byte(vm.SSTORE)}
|
||||||
var index common.Hash
|
var index common.Hash
|
||||||
logger.OnTxStart(evm.GetVMContext(), nil, common.Address{})
|
logger.OnTxStart(evm.GetVMContext(), nil, common.Address{})
|
||||||
_, err := evm.Interpreter().Run(contract, []byte{}, false)
|
_, err := evm.Run(contract, []byte{}, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,14 @@ func (a account) MarshalJSON() ([]byte, error) {
|
||||||
type account struct {
|
type account struct {
|
||||||
Balance *hexutil.Big `json:"balance,omitempty"`
|
Balance *hexutil.Big `json:"balance,omitempty"`
|
||||||
Code hexutil.Bytes `json:"code,omitempty"`
|
Code hexutil.Bytes `json:"code,omitempty"`
|
||||||
|
CodeHash *common.Hash `json:"codeHash,omitempty"`
|
||||||
Nonce uint64 `json:"nonce,omitempty"`
|
Nonce uint64 `json:"nonce,omitempty"`
|
||||||
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
|
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
|
||||||
}
|
}
|
||||||
var enc account
|
var enc account
|
||||||
enc.Balance = (*hexutil.Big)(a.Balance)
|
enc.Balance = (*hexutil.Big)(a.Balance)
|
||||||
enc.Code = a.Code
|
enc.Code = a.Code
|
||||||
|
enc.CodeHash = a.CodeHash
|
||||||
enc.Nonce = a.Nonce
|
enc.Nonce = a.Nonce
|
||||||
enc.Storage = a.Storage
|
enc.Storage = a.Storage
|
||||||
return json.Marshal(&enc)
|
return json.Marshal(&enc)
|
||||||
|
|
@ -33,6 +35,7 @@ func (a *account) UnmarshalJSON(input []byte) error {
|
||||||
type account struct {
|
type account struct {
|
||||||
Balance *hexutil.Big `json:"balance,omitempty"`
|
Balance *hexutil.Big `json:"balance,omitempty"`
|
||||||
Code *hexutil.Bytes `json:"code,omitempty"`
|
Code *hexutil.Bytes `json:"code,omitempty"`
|
||||||
|
CodeHash *common.Hash `json:"codeHash,omitempty"`
|
||||||
Nonce *uint64 `json:"nonce,omitempty"`
|
Nonce *uint64 `json:"nonce,omitempty"`
|
||||||
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
|
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
@ -46,6 +49,9 @@ func (a *account) UnmarshalJSON(input []byte) error {
|
||||||
if dec.Code != nil {
|
if dec.Code != nil {
|
||||||
a.Code = *dec.Code
|
a.Code = *dec.Code
|
||||||
}
|
}
|
||||||
|
if dec.CodeHash != nil {
|
||||||
|
a.CodeHash = dec.CodeHash
|
||||||
|
}
|
||||||
if dec.Nonce != nil {
|
if dec.Nonce != nil {
|
||||||
a.Nonce = *dec.Nonce
|
a.Nonce = *dec.Nonce
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ type stateMap = map[common.Address]*account
|
||||||
type account struct {
|
type account struct {
|
||||||
Balance *big.Int `json:"balance,omitempty"`
|
Balance *big.Int `json:"balance,omitempty"`
|
||||||
Code []byte `json:"code,omitempty"`
|
Code []byte `json:"code,omitempty"`
|
||||||
|
CodeHash *common.Hash `json:"codeHash,omitempty"`
|
||||||
Nonce uint64 `json:"nonce,omitempty"`
|
Nonce uint64 `json:"nonce,omitempty"`
|
||||||
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
|
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
|
||||||
empty bool
|
empty bool
|
||||||
|
|
@ -247,6 +248,7 @@ func (t *prestateTracer) processDiffState() {
|
||||||
postAccount := &account{Storage: make(map[common.Hash]common.Hash)}
|
postAccount := &account{Storage: make(map[common.Hash]common.Hash)}
|
||||||
newBalance := t.env.StateDB.GetBalance(addr).ToBig()
|
newBalance := t.env.StateDB.GetBalance(addr).ToBig()
|
||||||
newNonce := t.env.StateDB.GetNonce(addr)
|
newNonce := t.env.StateDB.GetNonce(addr)
|
||||||
|
newCodeHash := t.env.StateDB.GetCodeHash(addr)
|
||||||
|
|
||||||
if newBalance.Cmp(t.pre[addr].Balance) != 0 {
|
if newBalance.Cmp(t.pre[addr].Balance) != 0 {
|
||||||
modified = true
|
modified = true
|
||||||
|
|
@ -256,6 +258,19 @@ func (t *prestateTracer) processDiffState() {
|
||||||
modified = true
|
modified = true
|
||||||
postAccount.Nonce = newNonce
|
postAccount.Nonce = newNonce
|
||||||
}
|
}
|
||||||
|
prevCodeHash := common.Hash{}
|
||||||
|
if t.pre[addr].CodeHash != nil {
|
||||||
|
prevCodeHash = *t.pre[addr].CodeHash
|
||||||
|
}
|
||||||
|
// Empty code hashes are excluded from the prestate. Normalize
|
||||||
|
// the empty code hash to a zero hash to make it comparable.
|
||||||
|
if newCodeHash == types.EmptyCodeHash {
|
||||||
|
newCodeHash = common.Hash{}
|
||||||
|
}
|
||||||
|
if newCodeHash != prevCodeHash {
|
||||||
|
modified = true
|
||||||
|
postAccount.CodeHash = &newCodeHash
|
||||||
|
}
|
||||||
if !t.config.DisableCode {
|
if !t.config.DisableCode {
|
||||||
newCode := t.env.StateDB.GetCode(addr)
|
newCode := t.env.StateDB.GetCode(addr)
|
||||||
if !bytes.Equal(newCode, t.pre[addr].Code) {
|
if !bytes.Equal(newCode, t.pre[addr].Code) {
|
||||||
|
|
@ -305,6 +320,11 @@ func (t *prestateTracer) lookupAccount(addr common.Address) {
|
||||||
Nonce: t.env.StateDB.GetNonce(addr),
|
Nonce: t.env.StateDB.GetNonce(addr),
|
||||||
Code: t.env.StateDB.GetCode(addr),
|
Code: t.env.StateDB.GetCode(addr),
|
||||||
}
|
}
|
||||||
|
codeHash := t.env.StateDB.GetCodeHash(addr)
|
||||||
|
// If the code is empty, we don't need to store it in the prestate.
|
||||||
|
if codeHash != (common.Hash{}) && codeHash != types.EmptyCodeHash {
|
||||||
|
acc.CodeHash = &codeHash
|
||||||
|
}
|
||||||
if !acc.exists() {
|
if !acc.exists() {
|
||||||
acc.empty = true
|
acc.empty = true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,12 @@ func newTestBackend(config *node.Config) (*node.Node, []*types.Block, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("can't create new ethereum service: %v", err)
|
return nil, nil, fmt.Errorf("can't create new ethereum service: %v", err)
|
||||||
}
|
}
|
||||||
|
// Ensure tx pool starts the background operation
|
||||||
|
txPool := ethservice.TxPool()
|
||||||
|
if err = txPool.Sync(); err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("can't sync transaction pool: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Import the test chain.
|
// Import the test chain.
|
||||||
if err := n.Start(); err != nil {
|
if err := n.Start(); err != nil {
|
||||||
return nil, nil, fmt.Errorf("can't start test node: %v", err)
|
return nil, nil, fmt.Errorf("can't start test node: %v", err)
|
||||||
|
|
@ -506,8 +512,9 @@ func testAtFunctions(t *testing.T, client *rpc.Client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// send a transaction for some interesting pending status
|
// send a transaction for some interesting pending status
|
||||||
// and wait for the transaction to be included in the pending block
|
if err := sendTransaction(ec); err != nil {
|
||||||
sendTransaction(ec)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// wait for the transaction to be included in the pending block
|
// wait for the transaction to be included in the pending block
|
||||||
for {
|
for {
|
||||||
|
|
|
||||||
|
|
@ -233,6 +233,9 @@ func (db *Database) DeleteRange(start, end []byte) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err := it.Error(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return batch.Write()
|
return batch.Write()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,23 +34,6 @@ func FileExist(path string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// HashFiles iterates the provided set of files, computing the hash of each.
|
|
||||||
func HashFiles(files []string) (map[string][32]byte, error) {
|
|
||||||
res := make(map[string][32]byte)
|
|
||||||
for _, filePath := range files {
|
|
||||||
f, err := os.OpenFile(filePath, os.O_RDONLY, 0666)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
hasher := sha256.New()
|
|
||||||
if _, err := io.Copy(hasher, f); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
res[filePath] = [32]byte(hasher.Sum(nil))
|
|
||||||
}
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// HashFolder iterates all files under the given directory, computing the hash
|
// HashFolder iterates all files under the given directory, computing the hash
|
||||||
// of each.
|
// of each.
|
||||||
func HashFolder(folder string, exlude []string) (map[string][32]byte, error) {
|
func HashFolder(folder string, exlude []string) (map[string][32]byte, error) {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ func getOrRegisterRuntimeHistogram(name string, scale float64, r Registry) *runt
|
||||||
|
|
||||||
// runtimeHistogram wraps a runtime/metrics histogram.
|
// runtimeHistogram wraps a runtime/metrics histogram.
|
||||||
type runtimeHistogram struct {
|
type runtimeHistogram struct {
|
||||||
v atomic.Value // v is a pointer to a metrics.Float64Histogram
|
v atomic.Pointer[metrics.Float64Histogram]
|
||||||
scaleFactor float64
|
scaleFactor float64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,7 +58,7 @@ func (h *runtimeHistogram) Update(int64) {
|
||||||
|
|
||||||
// Snapshot returns a non-changing copy of the histogram.
|
// Snapshot returns a non-changing copy of the histogram.
|
||||||
func (h *runtimeHistogram) Snapshot() HistogramSnapshot {
|
func (h *runtimeHistogram) Snapshot() HistogramSnapshot {
|
||||||
hist := h.v.Load().(*metrics.Float64Histogram)
|
hist := h.v.Load()
|
||||||
return newRuntimeHistogramSnapshot(hist)
|
return newRuntimeHistogramSnapshot(hist)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -579,7 +579,6 @@ func totalFees(block *types.Block, receipts []*types.Receipt) *big.Int {
|
||||||
for i, tx := range block.Transactions() {
|
for i, tx := range block.Transactions() {
|
||||||
minerFee, _ := tx.EffectiveGasTip(block.BaseFee())
|
minerFee, _ := tx.EffectiveGasTip(block.BaseFee())
|
||||||
feesWei.Add(feesWei, new(big.Int).Mul(new(big.Int).SetUint64(receipts[i].GasUsed), minerFee))
|
feesWei.Add(feesWei, new(big.Int).Mul(new(big.Int).SetUint64(receipts[i].GasUsed), minerFee))
|
||||||
// TODO (MariusVanDerWijden) add blob fees
|
|
||||||
}
|
}
|
||||||
return feesWei
|
return feesWei
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ var (
|
||||||
ErrDatadirUsed = errors.New("datadir already used by another process")
|
ErrDatadirUsed = errors.New("datadir already used by another process")
|
||||||
ErrNodeStopped = errors.New("node not started")
|
ErrNodeStopped = errors.New("node not started")
|
||||||
ErrNodeRunning = errors.New("node already running")
|
ErrNodeRunning = errors.New("node already running")
|
||||||
ErrServiceUnknown = errors.New("unknown service")
|
|
||||||
|
|
||||||
datadirInUseErrnos = map[uint]bool{11: true, 32: true, 35: true}
|
datadirInUseErrnos = map[uint]bool{11: true, 32: true, 35: true}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -305,12 +305,3 @@ func (ln *LocalNode) bumpSeq() {
|
||||||
ln.seq++
|
ln.seq++
|
||||||
ln.db.storeLocalSeq(ln.id, ln.seq)
|
ln.db.storeLocalSeq(ln.id, ln.seq)
|
||||||
}
|
}
|
||||||
|
|
||||||
// nowMilliseconds gives the current timestamp at millisecond precision.
|
|
||||||
func nowMilliseconds() uint64 {
|
|
||||||
ns := time.Now().UnixNano()
|
|
||||||
if ns < 0 {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
return uint64(ns / 1000 / 1000)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/p2p/enr"
|
"github.com/ethereum/go-ethereum/p2p/enr"
|
||||||
|
|
@ -53,7 +54,7 @@ func TestLocalNode(t *testing.T) {
|
||||||
|
|
||||||
// This test checks that the sequence number is persisted between restarts.
|
// This test checks that the sequence number is persisted between restarts.
|
||||||
func TestLocalNodeSeqPersist(t *testing.T) {
|
func TestLocalNodeSeqPersist(t *testing.T) {
|
||||||
timestamp := nowMilliseconds()
|
timestamp := uint64(time.Now().UnixMilli())
|
||||||
|
|
||||||
ln, db := newLocalNodeForTesting()
|
ln, db := newLocalNodeForTesting()
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
|
||||||
|
|
@ -434,7 +434,7 @@ func (db *DB) localSeq(id ID) uint64 {
|
||||||
if seq := db.fetchUint64(localItemKey(id, dbLocalSeq)); seq > 0 {
|
if seq := db.fetchUint64(localItemKey(id, dbLocalSeq)); seq > 0 {
|
||||||
return seq
|
return seq
|
||||||
}
|
}
|
||||||
return nowMilliseconds()
|
return uint64(time.Now().UnixMilli())
|
||||||
}
|
}
|
||||||
|
|
||||||
// storeLocalSeq stores the local record sequence counter.
|
// storeLocalSeq stores the local record sequence counter.
|
||||||
|
|
|
||||||
|
|
@ -371,7 +371,7 @@ func decodeByteArray(s *Stream, val reflect.Value) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
slice := byteArrayBytes(val, val.Len())
|
slice := val.Bytes()
|
||||||
switch kind {
|
switch kind {
|
||||||
case Byte:
|
case Byte:
|
||||||
if len(slice) == 0 {
|
if len(slice) == 0 {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"math/bits"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/rlp/internal/rlpstruct"
|
"github.com/ethereum/go-ethereum/rlp/internal/rlpstruct"
|
||||||
|
|
@ -239,7 +240,6 @@ func makeByteArrayWriter(typ reflect.Type) writer {
|
||||||
case 1:
|
case 1:
|
||||||
return writeLengthOneByteArray
|
return writeLengthOneByteArray
|
||||||
default:
|
default:
|
||||||
length := typ.Len()
|
|
||||||
return func(val reflect.Value, w *encBuffer) error {
|
return func(val reflect.Value, w *encBuffer) error {
|
||||||
if !val.CanAddr() {
|
if !val.CanAddr() {
|
||||||
// Getting the byte slice of val requires it to be addressable. Make it
|
// Getting the byte slice of val requires it to be addressable. Make it
|
||||||
|
|
@ -248,7 +248,7 @@ func makeByteArrayWriter(typ reflect.Type) writer {
|
||||||
copy.Set(val)
|
copy.Set(val)
|
||||||
val = copy
|
val = copy
|
||||||
}
|
}
|
||||||
slice := byteArrayBytes(val, length)
|
slice := val.Bytes()
|
||||||
w.encodeStringHeader(len(slice))
|
w.encodeStringHeader(len(slice))
|
||||||
w.str = append(w.str, slice...)
|
w.str = append(w.str, slice...)
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -487,9 +487,8 @@ func putint(b []byte, i uint64) (size int) {
|
||||||
|
|
||||||
// intsize computes the minimum number of bytes required to store i.
|
// intsize computes the minimum number of bytes required to store i.
|
||||||
func intsize(i uint64) (size int) {
|
func intsize(i uint64) (size int) {
|
||||||
for size = 1; ; size++ {
|
if i == 0 {
|
||||||
if i >>= 8; i == 0 {
|
return 1
|
||||||
return size
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return (bits.Len64(i) + 7) / 8
|
||||||
}
|
}
|
||||||
|
|
|
||||||
27
rlp/safe.go
27
rlp/safe.go
|
|
@ -1,27 +0,0 @@
|
||||||
// Copyright 2021 The go-ethereum Authors
|
|
||||||
// This file is part of the go-ethereum library.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
//go:build nacl || js || !cgo
|
|
||||||
// +build nacl js !cgo
|
|
||||||
|
|
||||||
package rlp
|
|
||||||
|
|
||||||
import "reflect"
|
|
||||||
|
|
||||||
// byteArrayBytes returns a slice of the byte array v.
|
|
||||||
func byteArrayBytes(v reflect.Value, length int) []byte {
|
|
||||||
return v.Slice(0, length).Bytes()
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
// Copyright 2021 The go-ethereum Authors
|
|
||||||
// This file is part of the go-ethereum library.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
//go:build !nacl && !js && cgo
|
|
||||||
// +build !nacl,!js,cgo
|
|
||||||
|
|
||||||
package rlp
|
|
||||||
|
|
||||||
import (
|
|
||||||
"reflect"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
// byteArrayBytes returns a slice of the byte array v.
|
|
||||||
func byteArrayBytes(v reflect.Value, length int) []byte {
|
|
||||||
return unsafe.Slice((*byte)(unsafe.Pointer(v.UnsafeAddr())), length)
|
|
||||||
}
|
|
||||||
|
|
@ -29,12 +29,12 @@ import (
|
||||||
// insertion order.
|
// insertion order.
|
||||||
type committer struct {
|
type committer struct {
|
||||||
nodes *trienode.NodeSet
|
nodes *trienode.NodeSet
|
||||||
tracer *tracer
|
tracer *prevalueTracer
|
||||||
collectLeaf bool
|
collectLeaf bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// newCommitter creates a new committer or picks one from the pool.
|
// newCommitter creates a new committer or picks one from the pool.
|
||||||
func newCommitter(nodeset *trienode.NodeSet, tracer *tracer, collectLeaf bool) *committer {
|
func newCommitter(nodeset *trienode.NodeSet, tracer *prevalueTracer, collectLeaf bool) *committer {
|
||||||
return &committer{
|
return &committer{
|
||||||
nodes: nodeset,
|
nodes: nodeset,
|
||||||
tracer: tracer,
|
tracer: tracer,
|
||||||
|
|
@ -110,14 +110,16 @@ func (c *committer) commitChildren(path []byte, n *fullNode, parallel bool) {
|
||||||
} else {
|
} else {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(index int) {
|
go func(index int) {
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
p := append(path, byte(index))
|
p := append(path, byte(index))
|
||||||
childSet := trienode.NewNodeSet(c.nodes.Owner)
|
childSet := trienode.NewNodeSet(c.nodes.Owner)
|
||||||
childCommitter := newCommitter(childSet, c.tracer, c.collectLeaf)
|
childCommitter := newCommitter(childSet, c.tracer, c.collectLeaf)
|
||||||
n.Children[index] = childCommitter.commit(p, child, false)
|
n.Children[index] = childCommitter.commit(p, child, false)
|
||||||
|
|
||||||
nodesMu.Lock()
|
nodesMu.Lock()
|
||||||
c.nodes.MergeSet(childSet)
|
c.nodes.MergeDisjoint(childSet)
|
||||||
nodesMu.Unlock()
|
nodesMu.Unlock()
|
||||||
wg.Done()
|
|
||||||
}(i)
|
}(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -140,15 +142,15 @@ func (c *committer) store(path []byte, n node) node {
|
||||||
// The node is embedded in its parent, in other words, this node
|
// The node is embedded in its parent, in other words, this node
|
||||||
// will not be stored in the database independently, mark it as
|
// will not be stored in the database independently, mark it as
|
||||||
// deleted only if the node was existent in database before.
|
// deleted only if the node was existent in database before.
|
||||||
_, ok := c.tracer.accessList[string(path)]
|
origin := c.tracer.get(path)
|
||||||
if ok {
|
if len(origin) != 0 {
|
||||||
c.nodes.AddNode(path, trienode.NewDeleted())
|
c.nodes.AddNode(path, trienode.NewDeletedWithPrev(origin))
|
||||||
}
|
}
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
// Collect the dirty node to nodeset for return.
|
// Collect the dirty node to nodeset for return.
|
||||||
nhash := common.BytesToHash(hash)
|
nhash := common.BytesToHash(hash)
|
||||||
c.nodes.AddNode(path, trienode.New(nhash, nodeToBytes(n)))
|
c.nodes.AddNode(path, trienode.NewNodeWithPrev(nhash, nodeToBytes(n), c.tracer.get(path)))
|
||||||
|
|
||||||
// Collect the corresponding leaf node if it's required. We don't check
|
// Collect the corresponding leaf node if it's required. We don't check
|
||||||
// full node since it's impossible to store value in fullNode. The key
|
// full node since it's impossible to store value in fullNode. The key
|
||||||
|
|
|
||||||
|
|
@ -567,7 +567,12 @@ func VerifyRangeProof(rootHash common.Hash, firstKey []byte, keys [][]byte, valu
|
||||||
}
|
}
|
||||||
// Rebuild the trie with the leaf stream, the shape of trie
|
// Rebuild the trie with the leaf stream, the shape of trie
|
||||||
// should be same with the original one.
|
// should be same with the original one.
|
||||||
tr := &Trie{root: root, reader: newEmptyReader(), tracer: newTracer()}
|
tr := &Trie{
|
||||||
|
root: root,
|
||||||
|
reader: newEmptyReader(),
|
||||||
|
opTracer: newOpTracer(),
|
||||||
|
prevalueTracer: newPrevalueTracer(),
|
||||||
|
}
|
||||||
if empty {
|
if empty {
|
||||||
tr.root = nil
|
tr.root = nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
124
trie/tracer.go
124
trie/tracer.go
|
|
@ -18,14 +18,13 @@ package trie
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"maps"
|
"maps"
|
||||||
|
"slices"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// tracer tracks the changes of trie nodes. During the trie operations,
|
// opTracer tracks the changes of trie nodes. During the trie operations,
|
||||||
// some nodes can be deleted from the trie, while these deleted nodes
|
// some nodes can be deleted from the trie, while these deleted nodes
|
||||||
// won't be captured by trie.Hasher or trie.Committer. Thus, these deleted
|
// won't be captured by trie.Hasher or trie.Committer. Thus, these deleted
|
||||||
// nodes won't be removed from the disk at all. Tracer is an auxiliary tool
|
// nodes won't be removed from the disk at all. opTracer is an auxiliary tool
|
||||||
// used to track all insert and delete operations of trie and capture all
|
// used to track all insert and delete operations of trie and capture all
|
||||||
// deleted nodes eventually.
|
// deleted nodes eventually.
|
||||||
//
|
//
|
||||||
|
|
@ -35,38 +34,25 @@ import (
|
||||||
// This tool can track all of them no matter the node is embedded in its
|
// This tool can track all of them no matter the node is embedded in its
|
||||||
// parent or not, but valueNode is never tracked.
|
// parent or not, but valueNode is never tracked.
|
||||||
//
|
//
|
||||||
// Besides, it's also used for recording the original value of the nodes
|
// Note opTracer is not thread-safe, callers should be responsible for handling
|
||||||
// when they are resolved from the disk. The pre-value of the nodes will
|
|
||||||
// be used to construct trie history in the future.
|
|
||||||
//
|
|
||||||
// Note tracer is not thread-safe, callers should be responsible for handling
|
|
||||||
// the concurrency issues by themselves.
|
// the concurrency issues by themselves.
|
||||||
type tracer struct {
|
type opTracer struct {
|
||||||
inserts map[string]struct{}
|
inserts map[string]struct{}
|
||||||
deletes map[string]struct{}
|
deletes map[string]struct{}
|
||||||
accessList map[string][]byte
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// newTracer initializes the tracer for capturing trie changes.
|
// newOpTracer initializes the tracer for capturing trie changes.
|
||||||
func newTracer() *tracer {
|
func newOpTracer() *opTracer {
|
||||||
return &tracer{
|
return &opTracer{
|
||||||
inserts: make(map[string]struct{}),
|
inserts: make(map[string]struct{}),
|
||||||
deletes: make(map[string]struct{}),
|
deletes: make(map[string]struct{}),
|
||||||
accessList: make(map[string][]byte),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// onRead tracks the newly loaded trie node and caches the rlp-encoded
|
|
||||||
// blob internally. Don't change the value outside of function since
|
|
||||||
// it's not deep-copied.
|
|
||||||
func (t *tracer) onRead(path []byte, val []byte) {
|
|
||||||
t.accessList[string(path)] = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// onInsert tracks the newly inserted trie node. If it's already
|
// onInsert tracks the newly inserted trie node. If it's already
|
||||||
// in the deletion set (resurrected node), then just wipe it from
|
// in the deletion set (resurrected node), then just wipe it from
|
||||||
// the deletion set as it's "untouched".
|
// the deletion set as it's "untouched".
|
||||||
func (t *tracer) onInsert(path []byte) {
|
func (t *opTracer) onInsert(path []byte) {
|
||||||
if _, present := t.deletes[string(path)]; present {
|
if _, present := t.deletes[string(path)]; present {
|
||||||
delete(t.deletes, string(path))
|
delete(t.deletes, string(path))
|
||||||
return
|
return
|
||||||
|
|
@ -77,7 +63,7 @@ func (t *tracer) onInsert(path []byte) {
|
||||||
// onDelete tracks the newly deleted trie node. If it's already
|
// onDelete tracks the newly deleted trie node. If it's already
|
||||||
// in the addition set, then just wipe it from the addition set
|
// in the addition set, then just wipe it from the addition set
|
||||||
// as it's untouched.
|
// as it's untouched.
|
||||||
func (t *tracer) onDelete(path []byte) {
|
func (t *opTracer) onDelete(path []byte) {
|
||||||
if _, present := t.inserts[string(path)]; present {
|
if _, present := t.inserts[string(path)]; present {
|
||||||
delete(t.inserts, string(path))
|
delete(t.inserts, string(path))
|
||||||
return
|
return
|
||||||
|
|
@ -86,37 +72,83 @@ func (t *tracer) onDelete(path []byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset clears the content tracked by tracer.
|
// reset clears the content tracked by tracer.
|
||||||
func (t *tracer) reset() {
|
func (t *opTracer) reset() {
|
||||||
t.inserts = make(map[string]struct{})
|
clear(t.inserts)
|
||||||
t.deletes = make(map[string]struct{})
|
clear(t.deletes)
|
||||||
t.accessList = make(map[string][]byte)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy returns a deep copied tracer instance.
|
// copy returns a deep copied tracer instance.
|
||||||
func (t *tracer) copy() *tracer {
|
func (t *opTracer) copy() *opTracer {
|
||||||
accessList := make(map[string][]byte, len(t.accessList))
|
return &opTracer{
|
||||||
for path, blob := range t.accessList {
|
|
||||||
accessList[path] = common.CopyBytes(blob)
|
|
||||||
}
|
|
||||||
return &tracer{
|
|
||||||
inserts: maps.Clone(t.inserts),
|
inserts: maps.Clone(t.inserts),
|
||||||
deletes: maps.Clone(t.deletes),
|
deletes: maps.Clone(t.deletes),
|
||||||
accessList: accessList,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// deletedNodes returns a list of node paths which are deleted from the trie.
|
// deletedList returns a list of node paths which are deleted from the trie.
|
||||||
func (t *tracer) deletedNodes() []string {
|
func (t *opTracer) deletedList() [][]byte {
|
||||||
var paths []string
|
paths := make([][]byte, 0, len(t.deletes))
|
||||||
for path := range t.deletes {
|
for path := range t.deletes {
|
||||||
// It's possible a few deleted nodes were embedded
|
paths = append(paths, []byte(path))
|
||||||
// in their parent before, the deletions can be no
|
|
||||||
// effect by deleting nothing, filter them out.
|
|
||||||
_, ok := t.accessList[path]
|
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
paths = append(paths, path)
|
|
||||||
}
|
}
|
||||||
return paths
|
return paths
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prevalueTracer tracks the original values of resolved trie nodes. Cached trie
|
||||||
|
// node values are expected to be immutable. A zero-size node value is treated as
|
||||||
|
// non-existent and should not occur in practice.
|
||||||
|
//
|
||||||
|
// Note prevalueTracer is not thread-safe, callers should be responsible for
|
||||||
|
// handling the concurrency issues by themselves.
|
||||||
|
type prevalueTracer struct {
|
||||||
|
data map[string][]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// newPrevalueTracer initializes the tracer for capturing resolved trie nodes.
|
||||||
|
func newPrevalueTracer() *prevalueTracer {
|
||||||
|
return &prevalueTracer{
|
||||||
|
data: make(map[string][]byte),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// put tracks the newly loaded trie node and caches its RLP-encoded
|
||||||
|
// blob internally. Do not modify the value outside this function,
|
||||||
|
// as it is not deep-copied.
|
||||||
|
func (t *prevalueTracer) put(path []byte, val []byte) {
|
||||||
|
t.data[string(path)] = val
|
||||||
|
}
|
||||||
|
|
||||||
|
// get returns the cached trie node value. If the node is not found, nil will
|
||||||
|
// be returned.
|
||||||
|
func (t *prevalueTracer) get(path []byte) []byte {
|
||||||
|
return t.data[string(path)]
|
||||||
|
}
|
||||||
|
|
||||||
|
// hasList returns a list of flags indicating whether the corresponding trie nodes
|
||||||
|
// specified by the path exist in the trie.
|
||||||
|
func (t *prevalueTracer) hasList(list [][]byte) []bool {
|
||||||
|
exists := make([]bool, 0, len(list))
|
||||||
|
for _, path := range list {
|
||||||
|
_, ok := t.data[string(path)]
|
||||||
|
exists = append(exists, ok)
|
||||||
|
}
|
||||||
|
return exists
|
||||||
|
}
|
||||||
|
|
||||||
|
// values returns a list of values of the cached trie nodes.
|
||||||
|
func (t *prevalueTracer) values() [][]byte {
|
||||||
|
return slices.Collect(maps.Values(t.data))
|
||||||
|
}
|
||||||
|
|
||||||
|
// reset resets the cached content in the prevalueTracer.
|
||||||
|
func (t *prevalueTracer) reset() {
|
||||||
|
clear(t.data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy returns a copied prevalueTracer instance.
|
||||||
|
func (t *prevalueTracer) copy() *prevalueTracer {
|
||||||
|
// Shadow clone is used, as the cached trie node values are immutable
|
||||||
|
return &prevalueTracer{
|
||||||
|
data: maps.Clone(t.data),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,15 +52,15 @@ var (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestTrieTracer(t *testing.T) {
|
func TestTrieOpTracer(t *testing.T) {
|
||||||
testTrieTracer(t, tiny)
|
testTrieOpTracer(t, tiny)
|
||||||
testTrieTracer(t, nonAligned)
|
testTrieOpTracer(t, nonAligned)
|
||||||
testTrieTracer(t, standard)
|
testTrieOpTracer(t, standard)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests if the trie diffs are tracked correctly. Tracer should capture
|
// Tests if the trie diffs are tracked correctly. Tracer should capture
|
||||||
// all non-leaf dirty nodes, no matter the node is embedded or not.
|
// all non-leaf dirty nodes, no matter the node is embedded or not.
|
||||||
func testTrieTracer(t *testing.T, vals []struct{ k, v string }) {
|
func testTrieOpTracer(t *testing.T, vals []struct{ k, v string }) {
|
||||||
db := newTestDatabase(rawdb.NewMemoryDatabase(), rawdb.HashScheme)
|
db := newTestDatabase(rawdb.NewMemoryDatabase(), rawdb.HashScheme)
|
||||||
trie := NewEmpty(db)
|
trie := NewEmpty(db)
|
||||||
|
|
||||||
|
|
@ -68,8 +68,9 @@ func testTrieTracer(t *testing.T, vals []struct{ k, v string }) {
|
||||||
for _, val := range vals {
|
for _, val := range vals {
|
||||||
trie.MustUpdate([]byte(val.k), []byte(val.v))
|
trie.MustUpdate([]byte(val.k), []byte(val.v))
|
||||||
}
|
}
|
||||||
insertSet := copySet(trie.tracer.inserts) // copy before commit
|
insertSet := copySet(trie.opTracer.inserts) // copy before commit
|
||||||
deleteSet := copySet(trie.tracer.deletes) // copy before commit
|
deleteSet := copySet(trie.opTracer.deletes) // copy before commit
|
||||||
|
|
||||||
root, nodes := trie.Commit(false)
|
root, nodes := trie.Commit(false)
|
||||||
db.Update(root, types.EmptyRootHash, trienode.NewWithNodeSet(nodes))
|
db.Update(root, types.EmptyRootHash, trienode.NewWithNodeSet(nodes))
|
||||||
|
|
||||||
|
|
@ -86,7 +87,7 @@ func testTrieTracer(t *testing.T, vals []struct{ k, v string }) {
|
||||||
for _, val := range vals {
|
for _, val := range vals {
|
||||||
trie.MustDelete([]byte(val.k))
|
trie.MustDelete([]byte(val.k))
|
||||||
}
|
}
|
||||||
insertSet, deleteSet = copySet(trie.tracer.inserts), copySet(trie.tracer.deletes)
|
insertSet, deleteSet = copySet(trie.opTracer.inserts), copySet(trie.opTracer.deletes)
|
||||||
if !compareSet(insertSet, nil) {
|
if !compareSet(insertSet, nil) {
|
||||||
t.Fatal("Unexpected insertion set")
|
t.Fatal("Unexpected insertion set")
|
||||||
}
|
}
|
||||||
|
|
@ -97,13 +98,13 @@ func testTrieTracer(t *testing.T, vals []struct{ k, v string }) {
|
||||||
|
|
||||||
// Test that after inserting a new batch of nodes and deleting them immediately,
|
// Test that after inserting a new batch of nodes and deleting them immediately,
|
||||||
// the trie tracer should be cleared normally as no operation happened.
|
// the trie tracer should be cleared normally as no operation happened.
|
||||||
func TestTrieTracerNoop(t *testing.T) {
|
func TestTrieOpTracerNoop(t *testing.T) {
|
||||||
testTrieTracerNoop(t, tiny)
|
testTrieOpTracerNoop(t, tiny)
|
||||||
testTrieTracerNoop(t, nonAligned)
|
testTrieOpTracerNoop(t, nonAligned)
|
||||||
testTrieTracerNoop(t, standard)
|
testTrieOpTracerNoop(t, standard)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testTrieTracerNoop(t *testing.T, vals []struct{ k, v string }) {
|
func testTrieOpTracerNoop(t *testing.T, vals []struct{ k, v string }) {
|
||||||
db := newTestDatabase(rawdb.NewMemoryDatabase(), rawdb.HashScheme)
|
db := newTestDatabase(rawdb.NewMemoryDatabase(), rawdb.HashScheme)
|
||||||
trie := NewEmpty(db)
|
trie := NewEmpty(db)
|
||||||
for _, val := range vals {
|
for _, val := range vals {
|
||||||
|
|
@ -112,22 +113,22 @@ func testTrieTracerNoop(t *testing.T, vals []struct{ k, v string }) {
|
||||||
for _, val := range vals {
|
for _, val := range vals {
|
||||||
trie.MustDelete([]byte(val.k))
|
trie.MustDelete([]byte(val.k))
|
||||||
}
|
}
|
||||||
if len(trie.tracer.inserts) != 0 {
|
if len(trie.opTracer.inserts) != 0 {
|
||||||
t.Fatal("Unexpected insertion set")
|
t.Fatal("Unexpected insertion set")
|
||||||
}
|
}
|
||||||
if len(trie.tracer.deletes) != 0 {
|
if len(trie.opTracer.deletes) != 0 {
|
||||||
t.Fatal("Unexpected deletion set")
|
t.Fatal("Unexpected deletion set")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests if the accessList is correctly tracked.
|
// Tests if the original value of trie nodes are correctly tracked.
|
||||||
func TestAccessList(t *testing.T) {
|
func TestPrevalueTracer(t *testing.T) {
|
||||||
testAccessList(t, tiny)
|
testPrevalueTracer(t, tiny)
|
||||||
testAccessList(t, nonAligned)
|
testPrevalueTracer(t, nonAligned)
|
||||||
testAccessList(t, standard)
|
testPrevalueTracer(t, standard)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccessList(t *testing.T, vals []struct{ k, v string }) {
|
func testPrevalueTracer(t *testing.T, vals []struct{ k, v string }) {
|
||||||
var (
|
var (
|
||||||
db = newTestDatabase(rawdb.NewMemoryDatabase(), rawdb.HashScheme)
|
db = newTestDatabase(rawdb.NewMemoryDatabase(), rawdb.HashScheme)
|
||||||
trie = NewEmpty(db)
|
trie = NewEmpty(db)
|
||||||
|
|
@ -210,7 +211,7 @@ func testAccessList(t *testing.T, vals []struct{ k, v string }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests origin values won't be tracked in Iterator or Prover
|
// Tests origin values won't be tracked in Iterator or Prover
|
||||||
func TestAccessListLeak(t *testing.T) {
|
func TestPrevalueTracerLeak(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
db = newTestDatabase(rawdb.NewMemoryDatabase(), rawdb.HashScheme)
|
db = newTestDatabase(rawdb.NewMemoryDatabase(), rawdb.HashScheme)
|
||||||
trie = NewEmpty(db)
|
trie = NewEmpty(db)
|
||||||
|
|
@ -249,9 +250,9 @@ func TestAccessListLeak(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
trie, _ = New(TrieID(root), db)
|
trie, _ = New(TrieID(root), db)
|
||||||
n1 := len(trie.tracer.accessList)
|
n1 := len(trie.prevalueTracer.data)
|
||||||
c.op(trie)
|
c.op(trie)
|
||||||
n2 := len(trie.tracer.accessList)
|
n2 := len(trie.prevalueTracer.data)
|
||||||
|
|
||||||
if n1 != n2 {
|
if n1 != n2 {
|
||||||
t.Fatalf("AccessList is leaked, prev %d after %d", n1, n2)
|
t.Fatalf("AccessList is leaked, prev %d after %d", n1, n2)
|
||||||
|
|
|
||||||
205
trie/transition.go
Normal file
205
trie/transition.go
Normal file
|
|
@ -0,0 +1,205 @@
|
||||||
|
// Copyright 2025 go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package trie
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/ethdb"
|
||||||
|
"github.com/ethereum/go-ethereum/trie/trienode"
|
||||||
|
"github.com/ethereum/go-verkle"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TransitionTrie is a trie that implements a façade design pattern, presenting
|
||||||
|
// a single interface to the old MPT trie and the new verkle/binary trie. Reads
|
||||||
|
// first from the overlay trie, and falls back to the base trie if the key isn't
|
||||||
|
// found. All writes go to the overlay trie.
|
||||||
|
type TransitionTrie struct {
|
||||||
|
overlay *VerkleTrie
|
||||||
|
base *SecureTrie
|
||||||
|
storage bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewTransitionTrie creates a new TransitionTrie.
|
||||||
|
func NewTransitionTree(base *SecureTrie, overlay *VerkleTrie, st bool) *TransitionTrie {
|
||||||
|
return &TransitionTrie{
|
||||||
|
overlay: overlay,
|
||||||
|
base: base,
|
||||||
|
storage: st,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Base returns the base trie.
|
||||||
|
func (t *TransitionTrie) Base() *SecureTrie {
|
||||||
|
return t.base
|
||||||
|
}
|
||||||
|
|
||||||
|
// Overlay returns the overlay trie.
|
||||||
|
func (t *TransitionTrie) Overlay() *VerkleTrie {
|
||||||
|
return t.overlay
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetKey returns the sha3 preimage of a hashed key that was previously used
|
||||||
|
// to store a value.
|
||||||
|
func (t *TransitionTrie) GetKey(key []byte) []byte {
|
||||||
|
if key := t.overlay.GetKey(key); key != nil {
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
return t.base.GetKey(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetStorage returns the value for key stored in the trie. The value bytes must
|
||||||
|
// not be modified by the caller.
|
||||||
|
func (t *TransitionTrie) GetStorage(addr common.Address, key []byte) ([]byte, error) {
|
||||||
|
val, err := t.overlay.GetStorage(addr, key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("get storage from overlay: %s", err)
|
||||||
|
}
|
||||||
|
if len(val) != 0 {
|
||||||
|
return val, nil
|
||||||
|
}
|
||||||
|
// TODO also insert value into overlay
|
||||||
|
return t.base.GetStorage(addr, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAccount abstract an account read from the trie.
|
||||||
|
func (t *TransitionTrie) GetAccount(address common.Address) (*types.StateAccount, error) {
|
||||||
|
data, err := t.overlay.GetAccount(address)
|
||||||
|
if err != nil {
|
||||||
|
// Post cancun, no indicator needs to be used to indicate that
|
||||||
|
// an account was deleted in the overlay tree. If an error is
|
||||||
|
// returned, then it's a genuine error, and not an indicator
|
||||||
|
// that a tombstone was found.
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if data != nil {
|
||||||
|
return data, nil
|
||||||
|
}
|
||||||
|
return t.base.GetAccount(address)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStorage associates key with value in the trie. If value has length zero, any
|
||||||
|
// existing value is deleted from the trie. The value bytes must not be modified
|
||||||
|
// by the caller while they are stored in the trie.
|
||||||
|
func (t *TransitionTrie) UpdateStorage(address common.Address, key []byte, value []byte) error {
|
||||||
|
var v []byte
|
||||||
|
if len(value) >= 32 {
|
||||||
|
v = value[:32]
|
||||||
|
} else {
|
||||||
|
var val [32]byte
|
||||||
|
copy(val[32-len(value):], value[:])
|
||||||
|
v = val[:]
|
||||||
|
}
|
||||||
|
return t.overlay.UpdateStorage(address, key, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateAccount abstract an account write to the trie.
|
||||||
|
func (t *TransitionTrie) UpdateAccount(addr common.Address, account *types.StateAccount, codeLen int) error {
|
||||||
|
// NOTE: before the rebase, this was saving the state root, so that OpenStorageTrie
|
||||||
|
// could still work during a replay. This is no longer needed, as OpenStorageTrie
|
||||||
|
// only needs to know what the account trie does now.
|
||||||
|
return t.overlay.UpdateAccount(addr, account, codeLen)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteStorage removes any existing value for key from the trie. If a node was not
|
||||||
|
// found in the database, a trie.MissingNodeError is returned.
|
||||||
|
func (t *TransitionTrie) DeleteStorage(addr common.Address, key []byte) error {
|
||||||
|
return t.overlay.DeleteStorage(addr, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteAccount abstracts an account deletion from the trie.
|
||||||
|
func (t *TransitionTrie) DeleteAccount(key common.Address) error {
|
||||||
|
return t.overlay.DeleteAccount(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hash returns the root hash of the trie. It does not write to the database and
|
||||||
|
// can be used even if the trie doesn't have one.
|
||||||
|
func (t *TransitionTrie) Hash() common.Hash {
|
||||||
|
return t.overlay.Hash()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commit collects all dirty nodes in the trie and replace them with the
|
||||||
|
// corresponding node hash. All collected nodes(including dirty leaves if
|
||||||
|
// collectLeaf is true) will be encapsulated into a nodeset for return.
|
||||||
|
// The returned nodeset can be nil if the trie is clean(nothing to commit).
|
||||||
|
// Once the trie is committed, it's not usable anymore. A new trie must
|
||||||
|
// be created with new root and updated trie database for following usage
|
||||||
|
func (t *TransitionTrie) Commit(collectLeaf bool) (common.Hash, *trienode.NodeSet) {
|
||||||
|
// Just return if the trie is a storage trie: otherwise,
|
||||||
|
// the overlay trie will be committed as many times as
|
||||||
|
// there are storage tries. This would kill performance.
|
||||||
|
if t.storage {
|
||||||
|
return common.Hash{}, nil
|
||||||
|
}
|
||||||
|
return t.overlay.Commit(collectLeaf)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NodeIterator returns an iterator that returns nodes of the trie. Iteration
|
||||||
|
// starts at the key after the given start key.
|
||||||
|
func (t *TransitionTrie) NodeIterator(startKey []byte) (NodeIterator, error) {
|
||||||
|
panic("not implemented") // TODO: Implement
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prove constructs a Merkle proof for key. The result contains all encoded nodes
|
||||||
|
// on the path to the value at key. The value itself is also included in the last
|
||||||
|
// node and can be retrieved by verifying the proof.
|
||||||
|
//
|
||||||
|
// If the trie does not contain a value for key, the returned proof contains all
|
||||||
|
// nodes of the longest existing prefix of the key (at least the root), ending
|
||||||
|
// with the node that proves the absence of the key.
|
||||||
|
func (t *TransitionTrie) Prove(key []byte, proofDb ethdb.KeyValueWriter) error {
|
||||||
|
panic("not implemented") // TODO: Implement
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsVerkle returns true if the trie is verkle-tree based
|
||||||
|
func (t *TransitionTrie) IsVerkle() bool {
|
||||||
|
// For all intents and purposes, the calling code should treat this as a verkle trie
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStems updates a group of values, given the stem they are using. If
|
||||||
|
// a value already exists, it is overwritten.
|
||||||
|
func (t *TransitionTrie) UpdateStem(key []byte, values [][]byte) error {
|
||||||
|
trie := t.overlay
|
||||||
|
switch root := trie.root.(type) {
|
||||||
|
case *verkle.InternalNode:
|
||||||
|
return root.InsertValuesAtStem(key, values, t.overlay.nodeResolver)
|
||||||
|
default:
|
||||||
|
panic("invalid root type")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy creates a deep copy of the transition trie.
|
||||||
|
func (t *TransitionTrie) Copy() *TransitionTrie {
|
||||||
|
return &TransitionTrie{
|
||||||
|
overlay: t.overlay.Copy(),
|
||||||
|
base: t.base.Copy(),
|
||||||
|
storage: t.storage,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateContractCode updates the contract code for the given address.
|
||||||
|
func (t *TransitionTrie) UpdateContractCode(addr common.Address, codeHash common.Hash, code []byte) error {
|
||||||
|
return t.overlay.UpdateContractCode(addr, codeHash, code)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Witness returns a set containing all trie nodes that have been accessed.
|
||||||
|
func (t *TransitionTrie) Witness() map[string]struct{} {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
||||||
73
trie/trie.go
73
trie/trie.go
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
|
@ -55,8 +56,9 @@ type Trie struct {
|
||||||
// reader is the handler trie can retrieve nodes from.
|
// reader is the handler trie can retrieve nodes from.
|
||||||
reader *trieReader
|
reader *trieReader
|
||||||
|
|
||||||
// tracer is the tool to track the trie changes.
|
// Various tracers for capturing the modifications to trie
|
||||||
tracer *tracer
|
opTracer *opTracer
|
||||||
|
prevalueTracer *prevalueTracer
|
||||||
}
|
}
|
||||||
|
|
||||||
// newFlag returns the cache flag value for a newly created node.
|
// newFlag returns the cache flag value for a newly created node.
|
||||||
|
|
@ -73,7 +75,8 @@ func (t *Trie) Copy() *Trie {
|
||||||
unhashed: t.unhashed,
|
unhashed: t.unhashed,
|
||||||
uncommitted: t.uncommitted,
|
uncommitted: t.uncommitted,
|
||||||
reader: t.reader,
|
reader: t.reader,
|
||||||
tracer: t.tracer.copy(),
|
opTracer: t.opTracer.copy(),
|
||||||
|
prevalueTracer: t.prevalueTracer.copy(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,7 +94,8 @@ func New(id *ID, db database.NodeDatabase) (*Trie, error) {
|
||||||
trie := &Trie{
|
trie := &Trie{
|
||||||
owner: id.Owner,
|
owner: id.Owner,
|
||||||
reader: reader,
|
reader: reader,
|
||||||
tracer: newTracer(),
|
opTracer: newOpTracer(),
|
||||||
|
prevalueTracer: newPrevalueTracer(),
|
||||||
}
|
}
|
||||||
if id.Root != (common.Hash{}) && id.Root != types.EmptyRootHash {
|
if id.Root != (common.Hash{}) && id.Root != types.EmptyRootHash {
|
||||||
rootnode, err := trie.resolveAndTrack(id.Root[:], nil)
|
rootnode, err := trie.resolveAndTrack(id.Root[:], nil)
|
||||||
|
|
@ -361,7 +365,7 @@ func (t *Trie) insert(n node, prefix, key []byte, value node) (bool, node, error
|
||||||
// New branch node is created as a child of the original short node.
|
// New branch node is created as a child of the original short node.
|
||||||
// Track the newly inserted node in the tracer. The node identifier
|
// Track the newly inserted node in the tracer. The node identifier
|
||||||
// passed is the path from the root node.
|
// passed is the path from the root node.
|
||||||
t.tracer.onInsert(append(prefix, key[:matchlen]...))
|
t.opTracer.onInsert(append(prefix, key[:matchlen]...))
|
||||||
|
|
||||||
// Replace it with a short node leading up to the branch.
|
// Replace it with a short node leading up to the branch.
|
||||||
return true, &shortNode{key[:matchlen], branch, t.newFlag()}, nil
|
return true, &shortNode{key[:matchlen], branch, t.newFlag()}, nil
|
||||||
|
|
@ -379,7 +383,7 @@ func (t *Trie) insert(n node, prefix, key []byte, value node) (bool, node, error
|
||||||
// New short node is created and track it in the tracer. The node identifier
|
// New short node is created and track it in the tracer. The node identifier
|
||||||
// passed is the path from the root node. Note the valueNode won't be tracked
|
// passed is the path from the root node. Note the valueNode won't be tracked
|
||||||
// since it's always embedded in its parent.
|
// since it's always embedded in its parent.
|
||||||
t.tracer.onInsert(prefix)
|
t.opTracer.onInsert(prefix)
|
||||||
|
|
||||||
return true, &shortNode{key, value, t.newFlag()}, nil
|
return true, &shortNode{key, value, t.newFlag()}, nil
|
||||||
|
|
||||||
|
|
@ -444,7 +448,7 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
|
||||||
// The matched short node is deleted entirely and track
|
// The matched short node is deleted entirely and track
|
||||||
// it in the deletion set. The same the valueNode doesn't
|
// it in the deletion set. The same the valueNode doesn't
|
||||||
// need to be tracked at all since it's always embedded.
|
// need to be tracked at all since it's always embedded.
|
||||||
t.tracer.onDelete(prefix)
|
t.opTracer.onDelete(prefix)
|
||||||
|
|
||||||
return true, nil, nil // remove n entirely for whole matches
|
return true, nil, nil // remove n entirely for whole matches
|
||||||
}
|
}
|
||||||
|
|
@ -460,7 +464,7 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
|
||||||
case *shortNode:
|
case *shortNode:
|
||||||
// The child shortNode is merged into its parent, track
|
// The child shortNode is merged into its parent, track
|
||||||
// is deleted as well.
|
// is deleted as well.
|
||||||
t.tracer.onDelete(append(prefix, n.Key...))
|
t.opTracer.onDelete(append(prefix, n.Key...))
|
||||||
|
|
||||||
// Deleting from the subtrie reduced it to another
|
// Deleting from the subtrie reduced it to another
|
||||||
// short node. Merge the nodes to avoid creating a
|
// short node. Merge the nodes to avoid creating a
|
||||||
|
|
@ -468,7 +472,7 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
|
||||||
// always creates a new slice) instead of append to
|
// always creates a new slice) instead of append to
|
||||||
// avoid modifying n.Key since it might be shared with
|
// avoid modifying n.Key since it might be shared with
|
||||||
// other nodes.
|
// other nodes.
|
||||||
return true, &shortNode{concat(n.Key, child.Key...), child.Val, t.newFlag()}, nil
|
return true, &shortNode{slices.Concat(n.Key, child.Key), child.Val, t.newFlag()}, nil
|
||||||
default:
|
default:
|
||||||
return true, &shortNode{n.Key, child, t.newFlag()}, nil
|
return true, &shortNode{n.Key, child, t.newFlag()}, nil
|
||||||
}
|
}
|
||||||
|
|
@ -525,7 +529,7 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
|
||||||
// Replace the entire full node with the short node.
|
// Replace the entire full node with the short node.
|
||||||
// Mark the original short node as deleted since the
|
// Mark the original short node as deleted since the
|
||||||
// value is embedded into the parent now.
|
// value is embedded into the parent now.
|
||||||
t.tracer.onDelete(append(prefix, byte(pos)))
|
t.opTracer.onDelete(append(prefix, byte(pos)))
|
||||||
|
|
||||||
k := append([]byte{byte(pos)}, cnode.Key...)
|
k := append([]byte{byte(pos)}, cnode.Key...)
|
||||||
return true, &shortNode{k, cnode.Val, t.newFlag()}, nil
|
return true, &shortNode{k, cnode.Val, t.newFlag()}, nil
|
||||||
|
|
@ -563,13 +567,6 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func concat(s1 []byte, s2 ...byte) []byte {
|
|
||||||
r := make([]byte, len(s1)+len(s2))
|
|
||||||
copy(r, s1)
|
|
||||||
copy(r[len(s1):], s2)
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
// copyNode deep-copies the supplied node along with its children recursively.
|
// copyNode deep-copies the supplied node along with its children recursively.
|
||||||
func copyNode(n node) node {
|
func copyNode(n node) node {
|
||||||
switch n := (n).(type) {
|
switch n := (n).(type) {
|
||||||
|
|
@ -616,13 +613,31 @@ func (t *Trie) resolveAndTrack(n hashNode, prefix []byte) (node, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
t.tracer.onRead(prefix, blob)
|
t.prevalueTracer.put(prefix, blob)
|
||||||
|
|
||||||
// The returned node blob won't be changed afterward. No need to
|
// The returned node blob won't be changed afterward. No need to
|
||||||
// deep-copy the slice.
|
// deep-copy the slice.
|
||||||
return decodeNodeUnsafe(n, blob)
|
return decodeNodeUnsafe(n, blob)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// deletedNodes returns a list of node paths, referring the nodes being deleted
|
||||||
|
// from the trie. It's possible a few deleted nodes were embedded in their parent
|
||||||
|
// before, the deletions can be no effect by deleting nothing, filter them out.
|
||||||
|
func (t *Trie) deletedNodes() [][]byte {
|
||||||
|
var (
|
||||||
|
pos int
|
||||||
|
list = t.opTracer.deletedList()
|
||||||
|
flags = t.prevalueTracer.hasList(list)
|
||||||
|
)
|
||||||
|
for i := 0; i < len(list); i++ {
|
||||||
|
if flags[i] {
|
||||||
|
list[pos] = list[i]
|
||||||
|
pos++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list[:pos] // trim to the new length
|
||||||
|
}
|
||||||
|
|
||||||
// Hash returns the root hash of the trie. It does not write to the
|
// Hash returns the root hash of the trie. It does not write to the
|
||||||
// database and can be used even if the trie doesn't have one.
|
// database and can be used even if the trie doesn't have one.
|
||||||
func (t *Trie) Hash() common.Hash {
|
func (t *Trie) Hash() common.Hash {
|
||||||
|
|
@ -644,13 +659,13 @@ func (t *Trie) Commit(collectLeaf bool) (common.Hash, *trienode.NodeSet) {
|
||||||
// (b) The trie was non-empty and all nodes are dropped => return
|
// (b) The trie was non-empty and all nodes are dropped => return
|
||||||
// the node set includes all deleted nodes
|
// the node set includes all deleted nodes
|
||||||
if t.root == nil {
|
if t.root == nil {
|
||||||
paths := t.tracer.deletedNodes()
|
paths := t.deletedNodes()
|
||||||
if len(paths) == 0 {
|
if len(paths) == 0 {
|
||||||
return types.EmptyRootHash, nil // case (a)
|
return types.EmptyRootHash, nil // case (a)
|
||||||
}
|
}
|
||||||
nodes := trienode.NewNodeSet(t.owner)
|
nodes := trienode.NewNodeSet(t.owner)
|
||||||
for _, path := range paths {
|
for _, path := range paths {
|
||||||
nodes.AddNode([]byte(path), trienode.NewDeleted())
|
nodes.AddNode(path, trienode.NewDeletedWithPrev(t.prevalueTracer.get(path)))
|
||||||
}
|
}
|
||||||
return types.EmptyRootHash, nodes // case (b)
|
return types.EmptyRootHash, nodes // case (b)
|
||||||
}
|
}
|
||||||
|
|
@ -667,11 +682,11 @@ func (t *Trie) Commit(collectLeaf bool) (common.Hash, *trienode.NodeSet) {
|
||||||
return rootHash, nil
|
return rootHash, nil
|
||||||
}
|
}
|
||||||
nodes := trienode.NewNodeSet(t.owner)
|
nodes := trienode.NewNodeSet(t.owner)
|
||||||
for _, path := range t.tracer.deletedNodes() {
|
for _, path := range t.deletedNodes() {
|
||||||
nodes.AddNode([]byte(path), trienode.NewDeleted())
|
nodes.AddNode(path, trienode.NewDeletedWithPrev(t.prevalueTracer.get(path)))
|
||||||
}
|
}
|
||||||
// If the number of changes is below 100, we let one thread handle it
|
// If the number of changes is below 100, we let one thread handle it
|
||||||
t.root = newCommitter(nodes, t.tracer, collectLeaf).Commit(t.root, t.uncommitted > 100)
|
t.root = newCommitter(nodes, t.prevalueTracer, collectLeaf).Commit(t.root, t.uncommitted > 100)
|
||||||
t.uncommitted = 0
|
t.uncommitted = 0
|
||||||
return rootHash, nodes
|
return rootHash, nodes
|
||||||
}
|
}
|
||||||
|
|
@ -692,12 +707,13 @@ func (t *Trie) hashRoot() []byte {
|
||||||
|
|
||||||
// Witness returns a set containing all trie nodes that have been accessed.
|
// Witness returns a set containing all trie nodes that have been accessed.
|
||||||
func (t *Trie) Witness() map[string]struct{} {
|
func (t *Trie) Witness() map[string]struct{} {
|
||||||
if len(t.tracer.accessList) == 0 {
|
values := t.prevalueTracer.values()
|
||||||
|
if len(values) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
witness := make(map[string]struct{}, len(t.tracer.accessList))
|
witness := make(map[string]struct{}, len(values))
|
||||||
for _, node := range t.tracer.accessList {
|
for _, val := range values {
|
||||||
witness[string(node)] = struct{}{}
|
witness[string(val)] = struct{}{}
|
||||||
}
|
}
|
||||||
return witness
|
return witness
|
||||||
}
|
}
|
||||||
|
|
@ -708,6 +724,7 @@ func (t *Trie) Reset() {
|
||||||
t.owner = common.Hash{}
|
t.owner = common.Hash{}
|
||||||
t.unhashed = 0
|
t.unhashed = 0
|
||||||
t.uncommitted = 0
|
t.uncommitted = 0
|
||||||
t.tracer.reset()
|
t.opTracer.reset()
|
||||||
|
t.prevalueTracer.reset()
|
||||||
t.committed = false
|
t.committed = false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -449,35 +449,35 @@ func verifyAccessList(old *Trie, new *Trie, set *trienode.NodeSet) error {
|
||||||
if !ok || n.IsDeleted() {
|
if !ok || n.IsDeleted() {
|
||||||
return errors.New("expect new node")
|
return errors.New("expect new node")
|
||||||
}
|
}
|
||||||
//if len(n.Prev) > 0 {
|
if len(set.Origins[path]) > 0 {
|
||||||
// return errors.New("unexpected origin value")
|
return errors.New("unexpected origin value")
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
// Check deletion set
|
// Check deletion set
|
||||||
for path := range deletes {
|
for path, blob := range deletes {
|
||||||
n, ok := set.Nodes[path]
|
n, ok := set.Nodes[path]
|
||||||
if !ok || !n.IsDeleted() {
|
if !ok || !n.IsDeleted() {
|
||||||
return errors.New("expect deleted node")
|
return errors.New("expect deleted node")
|
||||||
}
|
}
|
||||||
//if len(n.Prev) == 0 {
|
if len(set.Origins[path]) == 0 {
|
||||||
// return errors.New("expect origin value")
|
return errors.New("expect origin value")
|
||||||
//}
|
}
|
||||||
//if !bytes.Equal(n.Prev, blob) {
|
if !bytes.Equal(set.Origins[path], blob) {
|
||||||
// return errors.New("invalid origin value")
|
return errors.New("invalid origin value")
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
// Check update set
|
// Check update set
|
||||||
for path := range updates {
|
for path, blob := range updates {
|
||||||
n, ok := set.Nodes[path]
|
n, ok := set.Nodes[path]
|
||||||
if !ok || n.IsDeleted() {
|
if !ok || n.IsDeleted() {
|
||||||
return errors.New("expect updated node")
|
return errors.New("expect updated node")
|
||||||
}
|
}
|
||||||
//if len(n.Prev) == 0 {
|
if len(set.Origins[path]) == 0 {
|
||||||
// return errors.New("expect origin value")
|
return errors.New("expect origin value")
|
||||||
//}
|
}
|
||||||
//if !bytes.Equal(n.Prev, blob) {
|
if !bytes.Equal(set.Origins[path], blob) {
|
||||||
// return errors.New("invalid origin value")
|
return errors.New("invalid origin value")
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -595,18 +595,18 @@ func runRandTest(rt randTest) error {
|
||||||
deleteExp[path] = struct{}{}
|
deleteExp[path] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(insertExp) != len(tr.tracer.inserts) {
|
if len(insertExp) != len(tr.opTracer.inserts) {
|
||||||
rt[i].err = errors.New("insert set mismatch")
|
rt[i].err = errors.New("insert set mismatch")
|
||||||
}
|
}
|
||||||
if len(deleteExp) != len(tr.tracer.deletes) {
|
if len(deleteExp) != len(tr.opTracer.deletes) {
|
||||||
rt[i].err = errors.New("delete set mismatch")
|
rt[i].err = errors.New("delete set mismatch")
|
||||||
}
|
}
|
||||||
for insert := range tr.tracer.inserts {
|
for insert := range tr.opTracer.inserts {
|
||||||
if _, present := insertExp[insert]; !present {
|
if _, present := insertExp[insert]; !present {
|
||||||
rt[i].err = errors.New("missing inserted node")
|
rt[i].err = errors.New("missing inserted node")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for del := range tr.tracer.deletes {
|
for del := range tr.opTracer.deletes {
|
||||||
if _, present := deleteExp[del]; !present {
|
if _, present := deleteExp[del]; !present {
|
||||||
rt[i].err = errors.New("missing deleted node")
|
rt[i].err = errors.New("missing deleted node")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,35 @@ func New(hash common.Hash, blob []byte) *Node {
|
||||||
// NewDeleted constructs a node which is deleted.
|
// NewDeleted constructs a node which is deleted.
|
||||||
func NewDeleted() *Node { return New(common.Hash{}, nil) }
|
func NewDeleted() *Node { return New(common.Hash{}, nil) }
|
||||||
|
|
||||||
|
// NodeWithPrev is a wrapper over Node by tracking the original value of node.
|
||||||
|
type NodeWithPrev struct {
|
||||||
|
*Node
|
||||||
|
Prev []byte // Nil means the node was not existent
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewNodeWithPrev constructs a node with the additional original value.
|
||||||
|
func NewNodeWithPrev(hash common.Hash, blob []byte, prev []byte) *NodeWithPrev {
|
||||||
|
return &NodeWithPrev{
|
||||||
|
Node: &Node{
|
||||||
|
Hash: hash,
|
||||||
|
Blob: blob,
|
||||||
|
},
|
||||||
|
Prev: prev,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDeletedWithPrev constructs a node which is deleted with the additional
|
||||||
|
// original value.
|
||||||
|
func NewDeletedWithPrev(prev []byte) *NodeWithPrev {
|
||||||
|
return &NodeWithPrev{
|
||||||
|
Node: &Node{
|
||||||
|
Hash: common.Hash{},
|
||||||
|
Blob: nil,
|
||||||
|
},
|
||||||
|
Prev: prev,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// leaf represents a trie leaf node
|
// leaf represents a trie leaf node
|
||||||
type leaf struct {
|
type leaf struct {
|
||||||
Blob []byte // raw blob of leaf
|
Blob []byte // raw blob of leaf
|
||||||
|
|
@ -63,6 +92,8 @@ type NodeSet struct {
|
||||||
Owner common.Hash
|
Owner common.Hash
|
||||||
Leaves []*leaf
|
Leaves []*leaf
|
||||||
Nodes map[string]*Node
|
Nodes map[string]*Node
|
||||||
|
Origins map[string][]byte
|
||||||
|
|
||||||
updates int // the count of updated and inserted nodes
|
updates int // the count of updated and inserted nodes
|
||||||
deletes int // the count of deleted nodes
|
deletes int // the count of deleted nodes
|
||||||
}
|
}
|
||||||
|
|
@ -73,6 +104,7 @@ func NewNodeSet(owner common.Hash) *NodeSet {
|
||||||
return &NodeSet{
|
return &NodeSet{
|
||||||
Owner: owner,
|
Owner: owner,
|
||||||
Nodes: make(map[string]*Node),
|
Nodes: make(map[string]*Node),
|
||||||
|
Origins: make(map[string][]byte),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,22 +123,25 @@ func (set *NodeSet) ForEachWithOrder(callback func(path string, n *Node)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddNode adds the provided node into set.
|
// AddNode adds the provided node into set.
|
||||||
func (set *NodeSet) AddNode(path []byte, n *Node) {
|
func (set *NodeSet) AddNode(path []byte, n *NodeWithPrev) {
|
||||||
if n.IsDeleted() {
|
if n.IsDeleted() {
|
||||||
set.deletes += 1
|
set.deletes += 1
|
||||||
} else {
|
} else {
|
||||||
set.updates += 1
|
set.updates += 1
|
||||||
}
|
}
|
||||||
set.Nodes[string(path)] = n
|
key := string(path)
|
||||||
|
set.Nodes[key] = n.Node
|
||||||
|
set.Origins[key] = n.Prev
|
||||||
}
|
}
|
||||||
|
|
||||||
// MergeSet merges this 'set' with 'other'. It assumes that the sets are disjoint,
|
// MergeDisjoint merges this 'set' with 'other'. It assumes that the sets are disjoint,
|
||||||
// and thus does not deduplicate data (count deletes, dedup leaves etc).
|
// and thus does not deduplicate data (count deletes, dedup leaves etc).
|
||||||
func (set *NodeSet) MergeSet(other *NodeSet) error {
|
func (set *NodeSet) MergeDisjoint(other *NodeSet) error {
|
||||||
if set.Owner != other.Owner {
|
if set.Owner != other.Owner {
|
||||||
return fmt.Errorf("nodesets belong to different owner are not mergeable %x-%x", set.Owner, other.Owner)
|
return fmt.Errorf("nodesets belong to different owner are not mergeable %x-%x", set.Owner, other.Owner)
|
||||||
}
|
}
|
||||||
maps.Copy(set.Nodes, other.Nodes)
|
maps.Copy(set.Nodes, other.Nodes)
|
||||||
|
maps.Copy(set.Origins, other.Origins)
|
||||||
|
|
||||||
set.deletes += other.deletes
|
set.deletes += other.deletes
|
||||||
set.updates += other.updates
|
set.updates += other.updates
|
||||||
|
|
@ -117,12 +152,13 @@ func (set *NodeSet) MergeSet(other *NodeSet) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge adds a set of nodes into the set.
|
// Merge adds a set of nodes to the current set. It assumes the sets may overlap,
|
||||||
func (set *NodeSet) Merge(owner common.Hash, nodes map[string]*Node) error {
|
// so deduplication is performed.
|
||||||
if set.Owner != owner {
|
func (set *NodeSet) Merge(other *NodeSet) error {
|
||||||
return fmt.Errorf("nodesets belong to different owner are not mergeable %x-%x", set.Owner, owner)
|
if set.Owner != other.Owner {
|
||||||
|
return fmt.Errorf("nodesets belong to different owner are not mergeable %x-%x", set.Owner, other.Owner)
|
||||||
}
|
}
|
||||||
for path, node := range nodes {
|
for path, node := range other.Nodes {
|
||||||
prev, ok := set.Nodes[path]
|
prev, ok := set.Nodes[path]
|
||||||
if ok {
|
if ok {
|
||||||
// overwrite happens, revoke the counter
|
// overwrite happens, revoke the counter
|
||||||
|
|
@ -137,8 +173,17 @@ func (set *NodeSet) Merge(owner common.Hash, nodes map[string]*Node) error {
|
||||||
} else {
|
} else {
|
||||||
set.updates += 1
|
set.updates += 1
|
||||||
}
|
}
|
||||||
set.Nodes[path] = node
|
set.Nodes[path] = node // overwrite the node with new value
|
||||||
|
|
||||||
|
// Add the original value only if it was previously non-existent.
|
||||||
|
// If multiple mutations are made to the same node, the first one
|
||||||
|
// is considered the true original value.
|
||||||
|
if _, exist := set.Origins[path]; !exist {
|
||||||
|
set.Origins[path] = other.Origins[path]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// TODO leaves are not aggregated, as they are not used in storage tries.
|
||||||
|
// TODO(rjl493456442) deprecate the leaves along with the legacy hash mode.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -169,11 +214,16 @@ func (set *NodeSet) Summary() string {
|
||||||
for path, n := range set.Nodes {
|
for path, n := range set.Nodes {
|
||||||
// Deletion
|
// Deletion
|
||||||
if n.IsDeleted() {
|
if n.IsDeleted() {
|
||||||
fmt.Fprintf(out, " [-]: %x\n", path)
|
fmt.Fprintf(out, " [-]: %x prev: %x\n", path, set.Origins[path])
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Insertion or update
|
// Insertion
|
||||||
fmt.Fprintf(out, " [+/*]: %x -> %v \n", path, n.Hash)
|
if len(set.Origins[path]) == 0 {
|
||||||
|
fmt.Fprintf(out, " [+]: %x -> %v\n", path, n.Hash)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// Update
|
||||||
|
fmt.Fprintf(out, " [*]: %x -> %v prev: %x\n", path, n.Hash, set.Origins[path])
|
||||||
}
|
}
|
||||||
for _, n := range set.Leaves {
|
for _, n := range set.Leaves {
|
||||||
fmt.Fprintf(out, "[leaf]: %v\n", n)
|
fmt.Fprintf(out, "[leaf]: %v\n", n)
|
||||||
|
|
@ -203,7 +253,7 @@ func NewWithNodeSet(set *NodeSet) *MergedNodeSet {
|
||||||
func (set *MergedNodeSet) Merge(other *NodeSet) error {
|
func (set *MergedNodeSet) Merge(other *NodeSet) error {
|
||||||
subset, present := set.Sets[other.Owner]
|
subset, present := set.Sets[other.Owner]
|
||||||
if present {
|
if present {
|
||||||
return subset.Merge(other.Owner, other.Nodes)
|
return subset.Merge(other)
|
||||||
}
|
}
|
||||||
set.Sets[other.Owner] = other
|
set.Sets[other.Owner] = other
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,100 @@
|
||||||
package trienode
|
package trienode
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
|
"maps"
|
||||||
|
"reflect"
|
||||||
|
"slices"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
"github.com/ethereum/go-ethereum/internal/testrand"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func makeTestSet(owner common.Hash, n int, paths [][]byte) *NodeSet {
|
||||||
|
set := NewNodeSet(owner)
|
||||||
|
for i := 0; i < n*3/4; i++ {
|
||||||
|
path := testrand.Bytes(10)
|
||||||
|
blob := testrand.Bytes(100)
|
||||||
|
set.AddNode(path, NewNodeWithPrev(crypto.Keccak256Hash(blob), blob, testrand.Bytes(100)))
|
||||||
|
}
|
||||||
|
for i := 0; i < n/4; i++ {
|
||||||
|
path := testrand.Bytes(10)
|
||||||
|
set.AddNode(path, NewDeletedWithPrev(testrand.Bytes(100)))
|
||||||
|
}
|
||||||
|
for i := 0; i < len(paths); i++ {
|
||||||
|
if i%3 == 0 {
|
||||||
|
set.AddNode(paths[i], NewDeletedWithPrev(testrand.Bytes(100)))
|
||||||
|
} else {
|
||||||
|
blob := testrand.Bytes(100)
|
||||||
|
set.AddNode(paths[i], NewNodeWithPrev(crypto.Keccak256Hash(blob), blob, testrand.Bytes(100)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return set
|
||||||
|
}
|
||||||
|
|
||||||
|
func copyNodeSet(set *NodeSet) *NodeSet {
|
||||||
|
cpy := &NodeSet{
|
||||||
|
Owner: set.Owner,
|
||||||
|
Leaves: slices.Clone(set.Leaves),
|
||||||
|
updates: set.updates,
|
||||||
|
deletes: set.deletes,
|
||||||
|
Nodes: maps.Clone(set.Nodes),
|
||||||
|
Origins: maps.Clone(set.Origins),
|
||||||
|
}
|
||||||
|
return cpy
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNodeSetMerge(t *testing.T) {
|
||||||
|
var shared [][]byte
|
||||||
|
for i := 0; i < 2; i++ {
|
||||||
|
shared = append(shared, testrand.Bytes(10))
|
||||||
|
}
|
||||||
|
owner := testrand.Hash()
|
||||||
|
setA := makeTestSet(owner, 20, shared)
|
||||||
|
cpyA := copyNodeSet(setA)
|
||||||
|
|
||||||
|
setB := makeTestSet(owner, 20, shared)
|
||||||
|
setA.Merge(setB)
|
||||||
|
|
||||||
|
for path, node := range setA.Nodes {
|
||||||
|
nA, inA := cpyA.Nodes[path]
|
||||||
|
nB, inB := setB.Nodes[path]
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case inA && inB:
|
||||||
|
origin := setA.Origins[path]
|
||||||
|
if !bytes.Equal(origin, cpyA.Origins[path]) {
|
||||||
|
t.Errorf("Unexpected origin, path %v: want: %v, got: %v", []byte(path), cpyA.Origins[path], origin)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(node, nB) {
|
||||||
|
t.Errorf("Unexpected node, path %v: want: %v, got: %v", []byte(path), spew.Sdump(nB), spew.Sdump(node))
|
||||||
|
}
|
||||||
|
case !inA && inB:
|
||||||
|
origin := setA.Origins[path]
|
||||||
|
if !bytes.Equal(origin, setB.Origins[path]) {
|
||||||
|
t.Errorf("Unexpected origin, path %v: want: %v, got: %v", []byte(path), setB.Origins[path], origin)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(node, nB) {
|
||||||
|
t.Errorf("Unexpected node, path %v: want: %v, got: %v", []byte(path), spew.Sdump(nB), spew.Sdump(node))
|
||||||
|
}
|
||||||
|
case inA && !inB:
|
||||||
|
origin := setA.Origins[path]
|
||||||
|
if !bytes.Equal(origin, cpyA.Origins[path]) {
|
||||||
|
t.Errorf("Unexpected origin, path %v: want: %v, got: %v", []byte(path), cpyA.Origins[path], origin)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(node, nA) {
|
||||||
|
t.Errorf("Unexpected node, path %v: want: %v, got: %v", []byte(path), spew.Sdump(nA), spew.Sdump(node))
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
t.Errorf("Unexpected node, %v", []byte(path))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkMerge(b *testing.B) {
|
func BenchmarkMerge(b *testing.B) {
|
||||||
b.Run("1K", func(b *testing.B) {
|
b.Run("1K", func(b *testing.B) {
|
||||||
benchmarkMerge(b, 1000)
|
benchmarkMerge(b, 1000)
|
||||||
|
|
@ -42,7 +129,7 @@ func benchmarkMerge(b *testing.B, count int) {
|
||||||
blob := make([]byte, 32)
|
blob := make([]byte, 32)
|
||||||
rand.Read(blob)
|
rand.Read(blob)
|
||||||
hash := crypto.Keccak256Hash(blob)
|
hash := crypto.Keccak256Hash(blob)
|
||||||
s.AddNode(path, New(hash, blob))
|
s.AddNode(path, NewNodeWithPrev(hash, blob, nil))
|
||||||
}
|
}
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
// Random path of 4 nibbles
|
// Random path of 4 nibbles
|
||||||
|
|
@ -53,9 +140,9 @@ func benchmarkMerge(b *testing.B, count int) {
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
// Store set x into a backup
|
// Store set x into a backup
|
||||||
z := NewNodeSet(common.Hash{})
|
z := NewNodeSet(common.Hash{})
|
||||||
z.Merge(common.Hash{}, x.Nodes)
|
z.Merge(x)
|
||||||
// Merge y into x
|
// Merge y into x
|
||||||
x.Merge(common.Hash{}, y.Nodes)
|
x.Merge(y)
|
||||||
x = z
|
x = z
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ type VerkleTrie struct {
|
||||||
root verkle.VerkleNode
|
root verkle.VerkleNode
|
||||||
cache *utils.PointCache
|
cache *utils.PointCache
|
||||||
reader *trieReader
|
reader *trieReader
|
||||||
|
tracer *prevalueTracer
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewVerkleTrie constructs a verkle tree based on the specified root hash.
|
// NewVerkleTrie constructs a verkle tree based on the specified root hash.
|
||||||
|
|
@ -50,27 +51,25 @@ func NewVerkleTrie(root common.Hash, db database.NodeDatabase, cache *utils.Poin
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Parse the root verkle node if it's not empty.
|
t := &VerkleTrie{
|
||||||
node := verkle.New()
|
root: verkle.New(),
|
||||||
if root != types.EmptyVerkleHash && root != types.EmptyRootHash {
|
|
||||||
blob, err := reader.node(nil, common.Hash{})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
node, err = verkle.ParseNode(blob, 0)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return &VerkleTrie{
|
|
||||||
root: node,
|
|
||||||
cache: cache,
|
cache: cache,
|
||||||
reader: reader,
|
reader: reader,
|
||||||
}, nil
|
tracer: newPrevalueTracer(),
|
||||||
}
|
}
|
||||||
|
// Parse the root verkle node if it's not empty.
|
||||||
func (t *VerkleTrie) FlatdbNodeResolver(path []byte) ([]byte, error) {
|
if root != types.EmptyVerkleHash && root != types.EmptyRootHash {
|
||||||
return t.reader.node(path, common.Hash{})
|
blob, err := t.nodeResolver(nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
node, err := verkle.ParseNode(blob, 0)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
t.root = node
|
||||||
|
}
|
||||||
|
return t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetKey returns the sha3 preimage of a hashed key that was previously used
|
// GetKey returns the sha3 preimage of a hashed key that was previously used
|
||||||
|
|
@ -268,7 +267,7 @@ func (t *VerkleTrie) Commit(_ bool) (common.Hash, *trienode.NodeSet) {
|
||||||
nodeset := trienode.NewNodeSet(common.Hash{})
|
nodeset := trienode.NewNodeSet(common.Hash{})
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
// Hash parameter is not used in pathdb
|
// Hash parameter is not used in pathdb
|
||||||
nodeset.AddNode(node.Path, trienode.New(common.Hash{}, node.SerializedBytes))
|
nodeset.AddNode(node.Path, trienode.NewNodeWithPrev(common.Hash{}, node.SerializedBytes, t.tracer.get(node.Path)))
|
||||||
}
|
}
|
||||||
// Serialize root commitment form
|
// Serialize root commitment form
|
||||||
return t.Hash(), nodeset
|
return t.Hash(), nodeset
|
||||||
|
|
@ -301,6 +300,7 @@ func (t *VerkleTrie) Copy() *VerkleTrie {
|
||||||
root: t.root.Copy(),
|
root: t.root.Copy(),
|
||||||
cache: t.cache,
|
cache: t.cache,
|
||||||
reader: t.reader,
|
reader: t.reader,
|
||||||
|
tracer: t.tracer.copy(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -317,7 +317,7 @@ func (t *VerkleTrie) Proof(posttrie *VerkleTrie, keys [][]byte) (*verkle.VerkleP
|
||||||
if posttrie != nil {
|
if posttrie != nil {
|
||||||
postroot = posttrie.root
|
postroot = posttrie.root
|
||||||
}
|
}
|
||||||
proof, _, _, _, err := verkle.MakeVerkleMultiProof(t.root, postroot, keys, t.FlatdbNodeResolver)
|
proof, _, _, _, err := verkle.MakeVerkleMultiProof(t.root, postroot, keys, t.nodeResolver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -421,7 +421,12 @@ func (t *VerkleTrie) ToDot() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *VerkleTrie) nodeResolver(path []byte) ([]byte, error) {
|
func (t *VerkleTrie) nodeResolver(path []byte) ([]byte, error) {
|
||||||
return t.reader.node(path, common.Hash{})
|
blob, err := t.reader.node(path, common.Hash{})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
t.tracer.put(path, blob)
|
||||||
|
return blob, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Witness returns a set containing all trie nodes that have been accessed.
|
// Witness returns a set containing all trie nodes that have been accessed.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue