Skip to content

Commit 92e7be8

Browse files
StephenButtolphmichaelkaplan13
authored andcommitted
update versions
1 parent f70113e commit 92e7be8

File tree

8 files changed

+140
-78
lines changed

8 files changed

+140
-78
lines changed

go.mod

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ require (
3838
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
3939
github.com/dlclark/regexp2 v1.7.0 // indirect
4040
github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 // indirect
41+
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
4142
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
4243
github.com/fsnotify/fsnotify v1.9.0 // indirect
4344
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
@@ -46,16 +47,23 @@ require (
4647
github.com/go-logr/logr v1.4.3 // indirect
4748
github.com/go-logr/stdr v1.2.2 // indirect
4849
github.com/go-ole/go-ole v1.3.0 // indirect
50+
github.com/go-openapi/jsonpointer v0.19.6 // indirect
51+
github.com/go-openapi/jsonreference v0.20.2 // indirect
52+
github.com/go-openapi/swag v0.22.3 // indirect
4953
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
5054
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
5155
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
5256
github.com/gofrs/flock v0.8.1 // indirect
5357
github.com/gogo/protobuf v1.3.2 // indirect
58+
github.com/golang/protobuf v1.5.4 // indirect
5459
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
60+
github.com/google/btree v1.1.2 // indirect
61+
github.com/google/gnostic-models v0.6.8 // indirect
5562
github.com/google/go-cmp v0.7.0 // indirect
5663
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
5764
github.com/google/renameio/v2 v2.0.0 // indirect
5865
github.com/google/uuid v1.6.0 // indirect
66+
github.com/gorilla/mux v1.8.0 // indirect
5967
github.com/gorilla/rpc v1.2.0 // indirect
6068
github.com/gorilla/websocket v1.5.0 // indirect
6169
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
@@ -66,17 +74,22 @@ require (
6674
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
6775
github.com/holiman/uint256 v1.2.4 // indirect
6876
github.com/huin/goupnp v1.3.0 // indirect
77+
github.com/imdario/mergo v0.3.16 // indirect
6978
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
79+
github.com/josharian/intern v1.0.0 // indirect
80+
github.com/json-iterator/go v1.1.12 // indirect
7081
github.com/klauspost/compress v1.18.0 // indirect
7182
github.com/kr/pretty v0.3.1 // indirect
7283
github.com/kr/text v0.2.0 // indirect
84+
github.com/mailru/easyjson v0.7.7 // indirect
7385
github.com/mattn/go-colorable v0.1.13 // indirect
7486
github.com/mattn/go-isatty v0.0.17 // indirect
7587
github.com/mattn/go-runewidth v0.0.13 // indirect
7688
github.com/mitchellh/mapstructure v1.5.0 // indirect
7789
github.com/mitchellh/pointerstructure v1.2.0 // indirect
7890
github.com/mr-tron/base58 v1.2.0 // indirect
7991
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
92+
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
8093
github.com/olekukonko/tablewriter v0.0.5 // indirect
8194
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
8295
github.com/pkg/errors v0.9.1 // indirect
@@ -135,5 +148,6 @@ require (
135148
google.golang.org/grpc v1.75.0 // indirect
136149
google.golang.org/protobuf v1.36.8 // indirect
137150
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
151+
gopkg.in/yaml.v2 v2.4.0 // indirect
138152
gopkg.in/yaml.v3 v3.0.1 // indirect
139153
)

go.sum

Lines changed: 60 additions & 2 deletions
Large diffs are not rendered by default.

helloworld/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/ava-labs/subnet-evm/precompile/allowlist"
99
"github.com/ava-labs/subnet-evm/precompile/precompileconfig"
1010

11-
"github.com/ethereum/go-ethereum/common"
11+
"github.com/ava-labs/libevm/common"
1212
)
1313

1414
var _ precompileconfig.Config = &Config{}

helloworld/config_test.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@ package helloworld
77
import (
88
"testing"
99

10-
"github.com/ava-labs/subnet-evm/precompile/allowlist"
10+
"github.com/ava-labs/libevm/common"
11+
"github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest"
1112
"github.com/ava-labs/subnet-evm/precompile/precompileconfig"
12-
"github.com/ava-labs/subnet-evm/precompile/testutils"
13+
"github.com/ava-labs/subnet-evm/precompile/precompiletest"
1314
"github.com/ava-labs/subnet-evm/utils"
14-
15-
"github.com/ethereum/go-ethereum/common"
1615
"go.uber.org/mock/gomock"
1716
)
1817

1918
// TestVerify tests the verification of Config.
2019
func TestVerify(t *testing.T) {
21-
admins := []common.Address{allowlist.TestAdminAddr}
22-
enableds := []common.Address{allowlist.TestEnabledAddr}
23-
managers := []common.Address{allowlist.TestManagerAddr}
24-
tests := map[string]testutils.ConfigVerifyTest{
20+
admins := []common.Address{allowlisttest.TestAdminAddr}
21+
enableds := []common.Address{allowlisttest.TestEnabledAddr}
22+
managers := []common.Address{allowlisttest.TestManagerAddr}
23+
tests := map[string]precompiletest.ConfigVerifyTest{
2524
"valid config": {
2625
Config: NewConfig(utils.NewUint64(3), admins, enableds, managers),
2726
ChainConfig: func() precompileconfig.ChainConfig {
@@ -47,15 +46,15 @@ func TestVerify(t *testing.T) {
4746
// and runs them all together.
4847
// Even if you don't add any custom tests, keep this. This will still
4948
// run the default allowlist verify tests.
50-
allowlist.VerifyPrecompileWithAllowListTests(t, Module, tests)
49+
allowlisttest.VerifyPrecompileWithAllowListTests(t, Module, tests)
5150
}
5251

5352
// TestEqual tests the equality of Config with other precompile configs.
5453
func TestEqual(t *testing.T) {
55-
admins := []common.Address{allowlist.TestAdminAddr}
56-
enableds := []common.Address{allowlist.TestEnabledAddr}
57-
managers := []common.Address{allowlist.TestManagerAddr}
58-
tests := map[string]testutils.ConfigEqualTest{
54+
admins := []common.Address{allowlisttest.TestAdminAddr}
55+
enableds := []common.Address{allowlisttest.TestEnabledAddr}
56+
managers := []common.Address{allowlisttest.TestManagerAddr}
57+
tests := map[string]precompiletest.ConfigEqualTest{
5958
"non-nil config and nil other": {
6059
Config: NewConfig(utils.NewUint64(3), admins, enableds, managers),
6160
Other: nil,
@@ -84,5 +83,5 @@ func TestEqual(t *testing.T) {
8483
// and runs them all together.
8584
// Even if you don't add any custom tests, keep this. This will still
8685
// run the default allowlist equal tests.
87-
allowlist.EqualPrecompileWithAllowListTests(t, Module, tests)
86+
allowlisttest.EqualPrecompileWithAllowListTests(t, Module, tests)
8887
}

helloworld/contract.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ import (
88
"errors"
99
"fmt"
1010

11+
"github.com/ava-labs/libevm/core/vm"
1112
"github.com/ava-labs/subnet-evm/accounts/abi"
1213
"github.com/ava-labs/subnet-evm/precompile/allowlist"
1314
"github.com/ava-labs/subnet-evm/precompile/contract"
14-
"github.com/ava-labs/subnet-evm/vmerrs"
1515

1616
_ "embed"
1717

18-
"github.com/ethereum/go-ethereum/common"
18+
"github.com/ava-labs/libevm/common"
19+
"github.com/ava-labs/libevm/core/types"
1920
)
2021

2122
const (
@@ -154,7 +155,7 @@ func setGreeting(accessibleState contract.AccessibleState, caller common.Address
154155
return nil, 0, err
155156
}
156157
if readOnly {
157-
return nil, remainingGas, vmerrs.ErrWriteProtection
158+
return nil, remainingGas, vm.ErrWriteProtection
158159
}
159160
// do not use strict mode after Durango
160161
useStrictMode := !contract.IsDurangoActivated(accessibleState)
@@ -206,12 +207,12 @@ func setGreeting(accessibleState contract.AccessibleState, caller common.Address
206207
}
207208

208209
// Emit the event
209-
stateDB.AddLog(
210-
ContractAddress,
211-
topics,
212-
data,
213-
accessibleState.GetBlockContext().Number().Uint64(),
214-
)
210+
stateDB.AddLog(&types.Log{
211+
Address: ContractAddress,
212+
Topics: topics,
213+
Data: data,
214+
BlockNumber: accessibleState.GetBlockContext().Number().Uint64(),
215+
})
215216
}
216217

217218
// setGreeting is the execution function

helloworld/contract_test.go

Lines changed: 40 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ package helloworld
77
import (
88
"testing"
99

10-
"github.com/ava-labs/subnet-evm/core/state"
11-
"github.com/ava-labs/subnet-evm/precompile/allowlist"
10+
"github.com/ava-labs/libevm/common"
11+
"github.com/ava-labs/libevm/core/vm"
12+
"github.com/ava-labs/subnet-evm/core/extstate"
13+
"github.com/ava-labs/subnet-evm/precompile/allowlist/allowlisttest"
1214
"github.com/ava-labs/subnet-evm/precompile/contract"
1315
"github.com/ava-labs/subnet-evm/precompile/precompileconfig"
14-
"github.com/ava-labs/subnet-evm/precompile/testutils"
16+
"github.com/ava-labs/subnet-evm/precompile/precompiletest"
1517
"github.com/ava-labs/subnet-evm/utils"
16-
"github.com/ava-labs/subnet-evm/vmerrs"
17-
"github.com/ethereum/go-ethereum/common"
1818
"github.com/stretchr/testify/require"
1919
"go.uber.org/mock/gomock"
2020
)
@@ -28,10 +28,10 @@ const testGreeting = "test"
2828
const longString = "a very long string that is longer than 32 bytes and will cause an error"
2929

3030
var (
31-
tests = map[string]testutils.PrecompileTest{
31+
tests = map[string]precompiletest.PrecompileTest{
3232
"calling sayHello from NoRole should succeed": {
33-
Caller: allowlist.TestNoRoleAddr,
34-
BeforeHook: allowlist.SetDefaultRoles(Module.Address),
33+
Caller: allowlisttest.TestNoRoleAddr,
34+
BeforeHook: allowlisttest.SetDefaultRoles(Module.Address),
3535
InputFn: func(t testing.TB) []byte {
3636
input, err := PackSayHello()
3737
require.NoError(t, err)
@@ -54,8 +54,8 @@ var (
5454
ExpectedErr: "",
5555
},
5656
"calling sayHello from Enabled should succeed": {
57-
Caller: allowlist.TestEnabledAddr,
58-
BeforeHook: allowlist.SetDefaultRoles(Module.Address),
57+
Caller: allowlisttest.TestEnabledAddr,
58+
BeforeHook: allowlisttest.SetDefaultRoles(Module.Address),
5959
InputFn: func(t testing.TB) []byte {
6060
input, err := PackSayHello()
6161
require.NoError(t, err)
@@ -78,8 +78,8 @@ var (
7878
ExpectedErr: "",
7979
},
8080
"calling sayHello from Manager should succeed": {
81-
Caller: allowlist.TestManagerAddr,
82-
BeforeHook: allowlist.SetDefaultRoles(Module.Address),
81+
Caller: allowlisttest.TestManagerAddr,
82+
BeforeHook: allowlisttest.SetDefaultRoles(Module.Address),
8383
InputFn: func(t testing.TB) []byte {
8484
input, err := PackSayHello()
8585
require.NoError(t, err)
@@ -102,8 +102,8 @@ var (
102102
ExpectedErr: "",
103103
},
104104
"calling sayHello from Admin should succeed": {
105-
Caller: allowlist.TestAdminAddr,
106-
BeforeHook: allowlist.SetDefaultRoles(Module.Address),
105+
Caller: allowlisttest.TestAdminAddr,
106+
BeforeHook: allowlisttest.SetDefaultRoles(Module.Address),
107107
InputFn: func(t testing.TB) []byte {
108108
input, err := PackSayHello()
109109
require.NoError(t, err)
@@ -126,8 +126,8 @@ var (
126126
ExpectedErr: "",
127127
},
128128
"calling sayHello from NoRole with a config should return default greeting": {
129-
Caller: allowlist.TestNoRoleAddr,
130-
BeforeHook: allowlist.SetDefaultRoles(Module.Address),
129+
Caller: allowlisttest.TestNoRoleAddr,
130+
BeforeHook: allowlisttest.SetDefaultRoles(Module.Address),
131131
Config: NewConfig(utils.NewUint64(0), nil, nil, nil),
132132
InputFn: func(t testing.TB) []byte {
133133
input, err := PackSayHello()
@@ -156,11 +156,11 @@ var (
156156
},
157157
SuppliedGas: SayHelloGasCost - 1,
158158
ReadOnly: false,
159-
ExpectedErr: vmerrs.ErrOutOfGas.Error(),
159+
ExpectedErr: vm.ErrOutOfGas.Error(),
160160
},
161161
"calling setGreeting from NoRole should fail": {
162-
Caller: allowlist.TestNoRoleAddr,
163-
BeforeHook: allowlist.SetDefaultRoles(Module.Address),
162+
Caller: allowlisttest.TestNoRoleAddr,
163+
BeforeHook: allowlisttest.SetDefaultRoles(Module.Address),
164164
InputFn: func(t testing.TB) []byte {
165165
// CUSTOM CODE STARTS HERE
166166
// set test input to a value here
@@ -173,8 +173,8 @@ var (
173173
ExpectedErr: ErrCannotSetGreeting.Error(),
174174
},
175175
"calling setGreeting from Enabled should succeed": {
176-
Caller: allowlist.TestEnabledAddr,
177-
BeforeHook: allowlist.SetDefaultRoles(Module.Address),
176+
Caller: allowlisttest.TestEnabledAddr,
177+
BeforeHook: allowlisttest.SetDefaultRoles(Module.Address),
178178
InputFn: func(t testing.TB) []byte {
179179
// CUSTOM CODE STARTS HERE
180180
// set test input to a value here
@@ -191,14 +191,14 @@ var (
191191
}),
192192
ReadOnly: false,
193193
ExpectedErr: "",
194-
AfterHook: func(t testing.TB, state contract.StateDB) {
194+
AfterHook: func(t testing.TB, state *extstate.StateDB) {
195195
greeting := GetGreeting(state)
196196
require.Equal(t, greeting, testGreeting)
197197
},
198198
},
199199
"calling setGreeting from Manager should succeed": {
200-
Caller: allowlist.TestManagerAddr,
201-
BeforeHook: allowlist.SetDefaultRoles(Module.Address),
200+
Caller: allowlisttest.TestManagerAddr,
201+
BeforeHook: allowlisttest.SetDefaultRoles(Module.Address),
202202
InputFn: func(t testing.TB) []byte {
203203
// CUSTOM CODE STARTS HERE
204204
// set test input to a value here
@@ -215,14 +215,14 @@ var (
215215
}),
216216
ReadOnly: false,
217217
ExpectedErr: "",
218-
AfterHook: func(t testing.TB, state contract.StateDB) {
218+
AfterHook: func(t testing.TB, state *extstate.StateDB) {
219219
greeting := GetGreeting(state)
220220
require.Equal(t, greeting, testGreeting)
221221
},
222222
},
223223
"calling setGreeting from Admin should succeed": {
224-
Caller: allowlist.TestAdminAddr,
225-
BeforeHook: allowlist.SetDefaultRoles(Module.Address),
224+
Caller: allowlisttest.TestAdminAddr,
225+
BeforeHook: allowlisttest.SetDefaultRoles(Module.Address),
226226
InputFn: func(t testing.TB) []byte {
227227
// CUSTOM CODE STARTS HERE
228228
// set test input to a value here
@@ -239,7 +239,7 @@ var (
239239
}),
240240
ReadOnly: false,
241241
ExpectedErr: "",
242-
AfterHook: func(t testing.TB, state contract.StateDB) {
242+
AfterHook: func(t testing.TB, state *extstate.StateDB) {
243243
greeting := GetGreeting(state)
244244
require.Equal(t, greeting, testGreeting)
245245
},
@@ -256,11 +256,11 @@ var (
256256
},
257257
SuppliedGas: SetGreetingGasCost,
258258
ReadOnly: true,
259-
ExpectedErr: vmerrs.ErrWriteProtection.Error(),
259+
ExpectedErr: vm.ErrWriteProtection.Error(),
260260
},
261261
"insufficient gas for setGreeting should fail": {
262-
Caller: allowlist.TestEnabledAddr,
263-
BeforeHook: allowlist.SetDefaultRoles(Module.Address),
262+
Caller: allowlisttest.TestEnabledAddr,
263+
BeforeHook: allowlisttest.SetDefaultRoles(Module.Address),
264264
InputFn: func(t testing.TB) []byte {
265265
// CUSTOM CODE STARTS HERE
266266
// set test input to a value here
@@ -273,13 +273,13 @@ var (
273273
NewGreeting: testGreeting,
274274
}) - 1,
275275
ReadOnly: false,
276-
ExpectedErr: vmerrs.ErrOutOfGas.Error(),
276+
ExpectedErr: vm.ErrOutOfGas.Error(),
277277
},
278278
// more custom tests
279279
"store greeting then say hello from non-enabled address": {
280-
Caller: allowlist.TestNoRoleAddr,
281-
BeforeHook: func(t testing.TB, state contract.StateDB) {
282-
allowlist.SetDefaultRoles(Module.Address)(t, state)
280+
Caller: allowlisttest.TestNoRoleAddr,
281+
BeforeHook: func(t testing.TB, state *extstate.StateDB) {
282+
allowlisttest.SetDefaultRoles(Module.Address)(t, state)
283283
StoreGreeting(state, testGreeting)
284284
},
285285
InputFn: func(t testing.TB) []byte {
@@ -298,8 +298,8 @@ var (
298298
}(),
299299
},
300300
"set a very long greeting from enabled address before Durango": {
301-
Caller: allowlist.TestEnabledAddr,
302-
BeforeHook: allowlist.SetDefaultRoles(Module.Address),
301+
Caller: allowlisttest.TestEnabledAddr,
302+
BeforeHook: allowlisttest.SetDefaultRoles(Module.Address),
303303
// By default Durango is enabled in the tests.
304304
ChainConfigFn: func(ctrl *gomock.Controller) precompileconfig.ChainConfig {
305305
config := precompileconfig.NewMockChainConfig(ctrl)
@@ -318,8 +318,8 @@ var (
318318
ExpectedErr: ErrInputExceedsLimit.Error(),
319319
},
320320
"set a very long greeting from enabled address after Durango": {
321-
Caller: allowlist.TestEnabledAddr,
322-
BeforeHook: allowlist.SetDefaultRoles(Module.Address),
321+
Caller: allowlisttest.TestEnabledAddr,
322+
BeforeHook: allowlisttest.SetDefaultRoles(Module.Address),
323323
InputFn: func(t testing.TB) []byte {
324324
input, err := PackSetGreeting(longString)
325325
require.NoError(t, err)
@@ -344,7 +344,7 @@ func TestHelloWorldRun(t *testing.T) {
344344
// and runs them all together.
345345
// Even if you don't add any custom tests, keep this. This will still
346346
// run the default allowlist tests.
347-
allowlist.RunPrecompileWithAllowListTests(t, Module, state.NewTestStateDB, tests)
347+
allowlisttest.RunPrecompileWithAllowListTests(t, Module, tests)
348348
}
349349

350350
// TestPackUnpackGreetingChangedEventData tests the Pack/UnpackGreetingChangedEventData.
@@ -368,12 +368,3 @@ func TestPackUnpackGreetingChangedEventData(t *testing.T) {
368368
require.NoError(t, err)
369369
require.Equal(t, dataInput, unpacked)
370370
}
371-
372-
func BenchmarkHelloWorld(b *testing.B) {
373-
// Benchmark tests with allowlist tests.
374-
// This adds allowlist run tests to your custom tests
375-
// and benchmarks them all together.
376-
// Even if you don't add any custom tests, keep this. This will still
377-
// run the default allowlist tests.
378-
allowlist.BenchPrecompileWithAllowList(b, Module, state.NewTestStateDB, tests)
379-
}

0 commit comments

Comments
 (0)