Skip to content

Commit

Permalink
Merge branch 'master' into gh-workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
huancheng-trili committed Sep 6, 2024
2 parents 4bee367 + ddba573 commit fdb15f7
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 85 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v1.19.2
* Update Parisnet hash
* Update protocol history of ghostnet

## v1.19.1
* Update Paris protocol to [ParisB2](https://research-development.nomadic-labs.com/parisB2-announcement.html)

## v1.19.0

* BREAKING CHANGE: The cannonical import part has been changed from `blockwatch.cc` to `github.com/trilitech`
Expand Down
2 changes: 1 addition & 1 deletion examples/contract/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func balance_of(ctx context.Context, c *rpc.Client, addr, owner, id string) erro
return err
}
req := []contract.FA2BalanceRequest{
contract.FA2BalanceRequest{
{
Owner: own,
TokenId: tezos.NewZ(i),
},
Expand Down
2 changes: 1 addition & 1 deletion examples/tzgen/FA2NFT.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/tzgen/Hello.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/tzgen/Payable.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions micheline/primitives.go
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,9 @@ func (p *Prim) DecodeBuffer(buf *bytes.Buffer) error {
p.Args = append(p.Args, prim)
}
// annotation array byte size
if buf.Len() < 4 {
return io.ErrShortBuffer
}
size = int(binary.BigEndian.Uint32(buf.Next(4)))
if buf.Len() < size {
return io.ErrShortBuffer
Expand Down
12 changes: 9 additions & 3 deletions rpc/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ type BalanceUpdate struct {

// Oxford staking
Staker struct {
Contract tezos.Address `json:"contract"` // tz1/2/3 accounts (only stake, unstake)
Delegate tezos.Address `json:"delegate"` // baker
Baker tezos.Address `json:"baker"` // baker
Contract tezos.Address `json:"contract"` // tz1/2/3 accounts (only stake, unstake)
Delegate tezos.Address `json:"delegate"` // baker
Baker tezos.Address `json:"baker"` // baker
BakerOwnStake tezos.Address `json:"baker_own_stake"` // baker: replaced baker in v19
BakerEdge tezos.Address `json:"baker_edge"` // baker: new in v19
} `json:"staker"`
DelayedOp tezos.OpHash `json:"delayed_operation_hash"`
}
Expand Down Expand Up @@ -83,6 +85,10 @@ func (b BalanceUpdate) Address() tezos.Address {
return b.Staker.Delegate
case b.Staker.Baker.IsValid():
return b.Staker.Baker
case b.Staker.BakerOwnStake.IsValid():
return b.Staker.BakerOwnStake
case b.Staker.BakerEdge.IsValid():
return b.Staker.BakerEdge
}
return tezos.Address{}
}
Expand Down
5 changes: 5 additions & 0 deletions rpc/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ func (c Constants) MapToChainParams() *tezos.Params {
MinimalBlockDelay: time.Duration(c.MinimalBlockDelay) * time.Second,
}

// Paris blocks per snapshot
if p.BlocksPerSnapshot == 0 {
p.BlocksPerSnapshot = c.BlocksPerCycle
}

// backport preserved cycles
if p.ConsensusRightsDelay == 0 {
p.ConsensusRightsDelay = c.PreservedCycles
Expand Down
2 changes: 1 addition & 1 deletion rpc/delegates.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (c *Client) ListActiveDelegates(ctx context.Context, id BlockID) (DelegateL
}
selector := "active=true"
if p.Version >= 13 {
selector = "with_minimal_stake=true"
selector += "&with_minimal_stake=true"
}
delegates := make(DelegateList, 0)
u := fmt.Sprintf("chains/main/blocks/%s/context/delegates?%s", id, selector)
Expand Down
12 changes: 5 additions & 7 deletions tezos/param_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ func TestParamsStatic(t *testing.T) {

func TestDefaultParams(t *testing.T) {
for n, p := range map[string]*tezos.Params{
"main": tezos.DefaultParams,
"ghost": tezos.GhostnetParams,
"nairobi": tezos.NairobinetParams,
"oxford": tezos.OxfordnetParams,
"main": tezos.DefaultParams,
"ghost": tezos.GhostnetParams,
} {
if p.Network == "" {
t.Errorf("%s params: Empty network name", n)
Expand Down Expand Up @@ -756,7 +754,7 @@ var paramBlocks = []BlockMetadata{
LevelInfo: &LevelInfo{
Level: 3760128,
Cycle: 622,
CyclePosition: 8191,
CyclePosition: 16383,
ExpectedCommitment: true,
},
VotingPeriodInfo: &VotingPeriodInfo{
Expand Down Expand Up @@ -784,7 +782,7 @@ var paramBlocks = []BlockMetadata{
LevelInfo: &LevelInfo{
Level: 5070848,
Cycle: 702,
CyclePosition: 8191,
CyclePosition: 16383,
ExpectedCommitment: true,
},
VotingPeriodInfo: &VotingPeriodInfo{
Expand Down Expand Up @@ -812,7 +810,7 @@ var paramBlocks = []BlockMetadata{
LevelInfo: &LevelInfo{
Level: 5726208,
Cycle: 742,
CyclePosition: 8191,
CyclePosition: 16383,
ExpectedCommitment: true,
},
VotingPeriodInfo: &VotingPeriodInfo{
Expand Down
54 changes: 18 additions & 36 deletions tezos/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,36 +40,6 @@ var (
WithChainId(Ghostnet).
WithDeployment(Deployments[Ghostnet].AtProtocol(ProtoV019))

// NairobinetParams defines the blockchain configuration for Nairobi testnet.
// To produce compliant transactions, use these defaults in op.WithParams().
NairobinetParams = (&Params{
MinimalBlockDelay: 8 * time.Second,
CostPerByte: 250,
OriginationSize: 257,
HardGasLimitPerOperation: 1040000,
HardGasLimitPerBlock: 2600000,
HardStorageLimitPerOperation: 60000,
MaxOperationDataLength: 32768,
MaxOperationsTTL: 240,
}).
WithChainId(Nairobinet).
WithDeployment(Deployments[Nairobinet].AtProtocol(ProtoV017))

// OxfordnetParams defines the blockchain configuration for Oxford testnet.
// To produce compliant transactions, use these defaults in op.WithParams().
OxfordnetParams = (&Params{
MinimalBlockDelay: 8 * time.Second,
CostPerByte: 250,
OriginationSize: 257,
HardGasLimitPerOperation: 1040000,
HardGasLimitPerBlock: 2600000,
HardStorageLimitPerOperation: 60000,
MaxOperationDataLength: 32768,
MaxOperationsTTL: 240,
}).
WithChainId(Oxfordnet).
WithDeployment(Deployments[Oxfordnet].AtProtocol(ProtoV018))

// ParisnetParams defines the blockchain configuration for Paris testnet.
// To produce compliant transactions, use these defaults in op.WithParams().
ParisnetParams = (&Params{
Expand Down Expand Up @@ -141,12 +111,10 @@ func (p *Params) WithChainId(id ChainIdHash) *Params {
p.Network = "Mainnet"
case Ghostnet:
p.Network = "Ghostnet"
case Nairobinet:
p.Network = "Nairobinet"
case Oxfordnet:
p.Network = "Oxfordnet"
case Parisnet:
p.Network = "Parisnet"
case ParisCnet:
p.Network = "ParisCnet"
}
}
return p
Expand All @@ -155,7 +123,9 @@ func (p *Params) WithChainId(id ChainIdHash) *Params {
func (p *Params) WithProtocol(h ProtocolHash) *Params {
var ok bool
p.Protocol = h
versionsMtx.RLock()
p.Version, ok = Versions[h]
versionsMtx.RUnlock()
if !ok {
var max int
for _, v := range Versions {
Expand All @@ -165,6 +135,8 @@ func (p *Params) WithProtocol(h ProtocolHash) *Params {
max = v
}
p.Version = max + 1
versionsMtx.Lock()
defer versionsMtx.Unlock()
Versions[h] = p.Version
}
switch {
Expand Down Expand Up @@ -265,7 +237,8 @@ func (p *Params) CycleFromHeight(height int64) int64 {
func (p *Params) CycleStartHeight(c int64) int64 {
// adjust to target cycle
at := p.AtCycle(c)
return at.StartHeight - at.StartOffset + (c-at.StartCycle)*at.BlocksPerCycle
res := at.StartHeight - at.StartOffset + (c-at.StartCycle)*at.BlocksPerCycle
return res
}

func (p *Params) CycleEndHeight(c int64) int64 {
Expand Down Expand Up @@ -295,6 +268,11 @@ func (p *Params) IsCycleEnd(height int64) bool {
}

func (p *Params) IsSnapshotBlock(height int64) bool {
// no more snapshots in Paris
if p.Version > 18 && p.IsCycleEnd(height) {
return true
}

// adjust to target height
at := p.AtBlock(height)
pos := at.CyclePosition(height) + 1
Expand All @@ -308,7 +286,11 @@ func (p *Params) SnapshotBlock(cycle int64, index int) int64 {
if base < 0 {
return 0
}
return at.CycleStartHeight(base) + int64(index+1)*at.BlocksPerSnapshot - 1
offset := int64(index+1) * at.BlocksPerSnapshot
if offset > at.BlocksPerCycle {
offset = at.BlocksPerCycle
}
return at.CycleStartHeight(base) + offset - 1
}

func (p *Params) SnapshotIndex(height int64) int {
Expand Down
68 changes: 34 additions & 34 deletions tezos/protocols.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

package tezos

import "sync"

var (
ProtoAlpha = MustParseProtocolHash("ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK")
ProtoGenesis = MustParseProtocolHash("PrihK96nBAFSxVL1GLJTVhu9YnzkMFiBeuJRPA8NwuZVZCE1L6i")
Expand All @@ -25,7 +27,8 @@ var (
ProtoV016_2 = MustParseProtocolHash("PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1")
ProtoV017 = MustParseProtocolHash("PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf")
ProtoV018 = MustParseProtocolHash("ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH")
ProtoV019 = MustParseProtocolHash("PtParisBQscdCm6Cfow6ndeU6wKJyA3aV1j4D3gQBQMsTQyJCrz")
ProtoV019 = MustParseProtocolHash("PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ")
ProtoV020 = MustParseProtocolHash("PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi")

// aliases
PtAthens = ProtoV004
Expand All @@ -44,14 +47,15 @@ var (
PtNairobi = ProtoV017
Proxford = ProtoV018
PtParisB = ProtoV019
PsParisC = ProtoV020

Mainnet = MustParseChainIdHash("NetXdQprcVkpaWU")
Ghostnet = MustParseChainIdHash("NetXnHfVqm9iesp")
Nairobinet = MustParseChainIdHash("NetXyuzvDo2Ugzb")
Oxfordnet = MustParseChainIdHash("NetXxWsskGahzQB")
Parisnet = MustParseChainIdHash("NetXo8SqH1c38SS")
Mainnet = MustParseChainIdHash("NetXdQprcVkpaWU")
Ghostnet = MustParseChainIdHash("NetXnHfVqm9iesp")
Parisnet = MustParseChainIdHash("NetXR64bNAYkP4S")
ParisCnet = MustParseChainIdHash("NetXXWAHLEvre9b")

Versions = map[ProtocolHash]int{
versionsMtx = sync.RWMutex{}
Versions = map[ProtocolHash]int{
ProtoGenesis: 0,
ProtoBootstrap: 0,
ProtoV001: 1,
Expand All @@ -73,7 +77,8 @@ var (
ProtoV017: 17,
ProtoV018: 18,
ProtoV019: 19,
ProtoAlpha: 20,
ProtoV020: 20,
ProtoAlpha: 21,
}

Deployments = map[ChainIdHash]ProtocolHistory{
Expand All @@ -98,38 +103,33 @@ var (
{PtMumbai, 0, 3268609, 3760128, 593, 5, 16384, 1024}, // v16
{PtNairobi, 0, 3760129, 5070848, 623, 5, 16384, 1024}, // v17
{Proxford, 0, 5070849, 5726208, 703, 5, 16384, 1024}, // v18
{PtParisB, 0, 5726209, -1, 743, 2, 24576, 24576}, // v19
{PtParisB, 0, 5726209, 5898240, 743, 2, 24576, 24576}, // v19
{PsParisC, 0, 5898241, -1, 750, 2, 24576, 24576}, // v19
},
Ghostnet: {
{ProtoGenesis, 0, 0, 0, 0, 3, 4096, 256}, // 0
{ProtoBootstrap, 0, 1, 1, 0, 3, 4096, 256}, // 0
{PtHangz2, 2, 2, 8191, 0, 3, 4096, 256}, // v11
{Psithaca, 0, 8192, 765952, 2, 3, 4096, 256}, // v12
{PtJakart, 0, 765953, 1191936, 187, 3, 4096, 256}, // v13
{PtKathma, 0, 1191937, 1654784, 291, 3, 4096, 256}, // v14
{PtLimaPt, 0, 1654785, 2162688, 404, 3, 4096, 256}, // v15
{PtMumbai, 0, 2162689, 2957312, 528, 3, 8192, 512}, // v16
{PtNairobi, 0, 2957313, 5316608, 625, 3, 8192, 512}, // v17
{Proxford, 0, 5316609, -1, 913, 3, 8192, 512}, // v18
// {PtParisB, 0, 5316609, -1, 913, 3, 8192, 8192}, // v19
{ProtoGenesis, 0, 0, 0, 0, 3, 4096, 256}, // 0
{ProtoBootstrap, 0, 1, 1, 0, 3, 4096, 256}, // 0
{PtHangz2, 2, 2, 8191, 0, 3, 4096, 256}, // v11
{Psithaca, 0, 8192, 765952, 2, 3, 4096, 256}, // v12
{PtJakart, 0, 765953, 1191936, 187, 3, 4096, 256}, // v13
{PtKathma, 0, 1191937, 1654784, 291, 3, 4096, 256}, // v14
{PtLimaPt, 0, 1654785, 2162688, 404, 3, 4096, 256}, // v15
{PtMumbai, 0, 2162689, 2957312, 528, 3, 8192, 512}, // v16
{PtNairobi, 0, 2957313, 5316608, 625, 3, 8192, 512}, // v17
{Proxford, 0, 5316609, 6422528, 913, 3, 8192, 512}, // v18
{PtParisB, 0, 6422529, 6729728, 1048, 2, 12288, 12288}, // v19
{PsParisC, 0, 6729729, -1, 1073, 2, 12288, 12288}, // v19
},
Nairobinet: {
{ProtoGenesis, 0, 0, 0, 0, 3, 8192, 512}, // 0
{ProtoBootstrap, 0, 1, 1, 0, 3, 8192, 512}, // 0
{PtMumbai, 2, 2, 16384, 0, 3, 8192, 512}, // v16
{PtNairobi, 0, 16385, -1, 2, 3, 8192, 512}, // v17
Parisnet: {
{ProtoGenesis, 0, 0, 0, 0, 3, 8192, 512}, // 0
{ProtoBootstrap, 0, 1, 1, 0, 3, 8192, 512}, // 0
{Proxford, 2, 2, 8192, 0, 3, 8192, 512}, // v18
{PtParisB, 0, 8193, -1, 1, 2, 12288, 12288}, // v19
},
Oxfordnet: {
ParisCnet: {
{ProtoGenesis, 0, 0, 0, 0, 3, 8192, 512}, // 0
{ProtoBootstrap, 0, 1, 1, 0, 3, 8192, 512}, // 0
{PtNairobi, 2, 2, 16384, 0, 3, 8192, 512}, // v17
{Proxford, 0, 16385, -1, 2, 3, 8192, 512}, // v18
},
Parisnet: {
{ProtoGenesis, 0, 0, 0, 0, 3, 8192, 512}, // 0
{ProtoBootstrap, 0, 1, 1, 0, 3, 8192, 512}, // 0
{Proxford, 2, 2, 16384, 0, 3, 8192, 512}, // v18
{PtParisB, 0, 16385, -1, 2, 2, 12288, 12288}, // v19
{PsParisC, 2, 2, -1, 0, 2, 128, 128}, // v19
},
}
)
Expand Down

0 comments on commit fdb15f7

Please sign in to comment.