Skip to content

Commit

Permalink
merged with develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemmsilva committed Sep 6, 2023
2 parents b3d5949 + fb0b3fe commit 91c2d76
Show file tree
Hide file tree
Showing 53 changed files with 1,074 additions and 1,105 deletions.
3 changes: 2 additions & 1 deletion components/chains/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ func provide(c *dig.Container) error {
ParamsStateManager.StateManagerTimerTickPeriod,
ParamsStateManager.PruningMinStatesToKeep,
ParamsStateManager.PruningMaxStatesToDelete,
ParamsSnapshotManager.SnapshotsToLoad,
ParamsSnapshotManager.Period,
ParamsSnapshotManager.Delay,
ParamsSnapshotManager.LocalPath,
ParamsSnapshotManager.NetworkPaths,
ParamsSnapshotManager.UpdatePeriod,
deps.ChainRecordRegistryProvider,
deps.DKShareRegistryProvider,
deps.NodeIdentityProvider,
Expand Down
9 changes: 5 additions & 4 deletions components/chains/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ type ParametersStateManager struct {
}

type ParametersSnapshotManager struct {
Period uint32 `default:"0" usage:"how often state snapshots should be made: 1000 meaning \"every 1000th state\", 0 meaning \"making snapshots is disabled\""`
LocalPath string `default:"waspdb/snap" usage:"the path to the snapshots folder in this node's disk"`
NetworkPaths []string `default:"" usage:"the list of paths to the remote (http(s)) snapshot locations; each of listed locations must contain 'INDEX' file with list of snapshot files"`
UpdatePeriod time.Duration `default:"5m" usage:"how often known snapshots list should be updated"`
SnapshotsToLoad []string `default:"0" usage:"list of snapshots to load; can be either single block hash of a snapshot (if a single chain has to be configured) or list of '<chainID>:<blockHash>' to configure many chains"`
Period uint32 `default:"0" usage:"how often state snapshots should be made: 1000 meaning \"every 1000th state\", 0 meaning \"making snapshots is disabled\""`
Delay uint32 `default:"20" usage:"how many states should pass before snapshot is produced"`
LocalPath string `default:"waspdb/snap" usage:"the path to the snapshots folder in this node's disk"`
NetworkPaths []string `default:"" usage:"the list of paths to the remote (http(s)) snapshot locations; each of listed locations must contain 'INDEX' file with list of snapshot files"`
}

var (
Expand Down
17 changes: 10 additions & 7 deletions contracts/wasm/corecontracts/test/core_blocklog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ func TestGetRequestReceipt(t *testing.T) {
require.Equal(t, blockIndex, f.Results.BlockIndex().Value())
require.Equal(t, reqIndex, f.Results.RequestIndex().Value())

receipt, err := blocklog.RequestReceiptFromBytes(f.Results.RequestReceipt().Value())
receipt, err := blocklog.RequestReceiptFromBytes(
f.Results.RequestReceipt().Value(),
f.Results.BlockIndex().Value(),
f.Results.RequestIndex().Value(),
)
require.NoError(t, err)
soloreceipt, err := ctx.Chain.GetRequestReceipt(reqs[0])
require.NoError(t, err)

// note: this is what ctx.Chain.GetRequestReceipt() does as well,
// so we better make sure they are equal before comparing
receipt.BlockIndex = f.Results.BlockIndex().Value()
receipt.RequestIndex = f.Results.RequestIndex().Value()
require.Equal(t, soloreceipt, receipt)
}

Expand All @@ -136,9 +136,12 @@ func TestGetRequestReceiptsForBlock(t *testing.T) {
receipts := f.Results.RequestReceipts()
recNum := receipts.Length()
for j := uint32(0); j < recNum; j++ {
receipt, err := blocklog.RequestReceiptFromBytes(receipts.GetBytes(j).Value())
receipt, err := blocklog.RequestReceiptFromBytes(
receipts.GetBytes(j).Value(),
soloreceipts[j].BlockIndex,
soloreceipts[j].RequestIndex,
)
require.NoError(t, err)
receipt.BlockIndex = soloreceipts[j].BlockIndex
require.Equal(t, soloreceipts[j], receipt)
}
}
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ require (
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.16.0
github.com/samber/lo v1.38.1
github.com/second-state/WasmEdge-go v0.13.2
github.com/second-state/WasmEdge-go v0.13.3
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
github.com/wasmerio/wasmer-go v1.0.4
go.dedis.ch/kyber/v3 v3.1.0
go.uber.org/atomic v1.11.0
go.uber.org/dig v1.17.0
go.uber.org/zap v1.25.0
golang.org/x/crypto v0.12.0
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
golang.org/x/net v0.14.0
golang.org/x/crypto v0.13.0
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
golang.org/x/net v0.15.0
gopkg.in/yaml.v3 v3.0.1
nhooyr.io/websocket v1.8.7
pgregory.net/rapid v1.0.0
Expand Down Expand Up @@ -197,10 +197,10 @@ require (
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
golang.org/x/tools v0.13.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/grpc v1.57.0 // indirect
Expand Down
27 changes: 14 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@ github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXn
github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0=
github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/second-state/WasmEdge-go v0.13.2 h1:MVCdV03OEMKku+4FMwq4gNQhPTiNhlFSe5RNy7ujvzo=
github.com/second-state/WasmEdge-go v0.13.2/go.mod h1:HyBf9hVj1sRAjklsjc1Yvs9b5RcmthPG9z99dY78TKg=
github.com/second-state/WasmEdge-go v0.13.3 h1:ZUPMQKJH0FHVGvBiobuEkNOKMfIL20fP0H5aaqG1JtY=
github.com/second-state/WasmEdge-go v0.13.3/go.mod h1:HyBf9hVj1sRAjklsjc1Yvs9b5RcmthPG9z99dY78TKg=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
Expand Down Expand Up @@ -799,11 +799,11 @@ golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
Expand Down Expand Up @@ -843,8 +843,8 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down Expand Up @@ -916,8 +916,9 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -926,8 +927,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand All @@ -952,8 +953,8 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 h1:Vve/L0v7CXXuxUmaMGIEK/dEeq7uiqb5qBgQrZzIE7E=
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
4 changes: 0 additions & 4 deletions packages/chain/statemanager/sm_gpa/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ import (

type StateManagerOutput interface {
addBlockCommitted(uint32, *state.L1Commitment)
addSnapshotToLoad(uint32, *state.L1Commitment)
setUpdateSnapshots()
TakeBlocksCommitted() []sm_snapshots.SnapshotInfo
TakeSnapshotToLoad() sm_snapshots.SnapshotInfo
TakeUpdateSnapshots() bool
}

type SnapshotExistsFun func(uint32, *state.L1Commitment) bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func NewReadOnlyStore(store state.Store) state.Store {
return &readOnlyStore{store: store}
}

func (ros *readOnlyStore) IsEmpty() bool {
return ros.store.IsEmpty()
}

func (ros *readOnlyStore) HasTrieRoot(trieRoot trie.Hash) bool {
return ros.store.HasTrieRoot(trieRoot)
}
Expand Down Expand Up @@ -75,6 +79,10 @@ func (ros *readOnlyStore) Prune(trie.Hash) (trie.PruneStats, error) {
panic("Cannot prune read-only store")
}

func (ros *readOnlyStore) LargestPrunedBlockIndex() (uint32, error) {
return ros.store.LargestPrunedBlockIndex()
}

func (ros *readOnlyStore) TakeSnapshot(trieRoot trie.Hash, w io.Writer) error {
return ros.store.TakeSnapshot(trieRoot, w)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type BlockFactory struct {
t require.TestingT
store state.Store
chainID isc.ChainID
chainInitParams dict.Dict
lastBlockCommitment *state.L1Commitment
aliasOutputs map[state.BlockHash]*isc.AliasOutputWithID
}
Expand Down Expand Up @@ -65,6 +66,7 @@ func NewBlockFactory(t require.TestingT, chainInitParamsOpt ...dict.Dict) *Block
t: t,
store: chainStore,
chainID: chainID,
chainInitParams: chainInitParams,
lastBlockCommitment: originCommitment,
aliasOutputs: aliasOutputs,
}
Expand All @@ -74,6 +76,10 @@ func (bfT *BlockFactory) GetChainID() isc.ChainID {
return bfT.chainID
}

func (bfT *BlockFactory) GetChainInitParameters() dict.Dict {
return bfT.chainInitParams
}

func (bfT *BlockFactory) GetOriginOutput() *isc.AliasOutputWithID {
return bfT.GetAliasOutput(origin.L1Commitment(nil, 0))
}
Expand Down

This file was deleted.

Loading

0 comments on commit 91c2d76

Please sign in to comment.